Minor scoutsuite code refactorings

This commit is contained in:
VakarisZ 2021-01-14 16:05:52 +02:00
parent 22194c566a
commit de69d167ba
5 changed files with 24 additions and 19 deletions

View File

@ -8,7 +8,7 @@ class ScoutSuiteTelem(BaseTelem):
def __init__(self, data):
"""
Default ScoutSuite telemetry constructor
:param data: Data gathered via ScoutSuite (
:param data: Data gathered via ScoutSuite
"""
super().__init__()
self.data = data

View File

@ -0,0 +1,13 @@
import pkgutil
import sys
from pathlib import PurePath
_scoutsuite_api_package = pkgutil.get_loader('common.cloud.scoutsuite.ScoutSuite.__main__')
def _add_scoutsuite_to_python_path():
scoutsuite_path = PurePath(_scoutsuite_api_package.path).parent.parent.__str__()
sys.path.append(scoutsuite_path)
_add_scoutsuite_to_python_path()

View File

@ -1,24 +1,13 @@
import pkgutil
import sys
from pathlib import PurePath
from typing import Tuple
from ScoutSuite.providers.base.authentication_strategy import AuthenticationException
from common.cloud.scoutsuite_consts import CloudProviders
from common.utils.exceptions import InvalidAWSKeys
from monkey_island.cc.server_utils.encryptor import encryptor
from monkey_island.cc.services.config import ConfigService
from monkey_island.cc.services.config_schema.config_value_paths import AWS_KEYS_PATH
_scoutsuite_api_package = pkgutil.get_loader('common.cloud.scoutsuite.ScoutSuite.__main__')
def _add_scoutsuite_to_python_path():
scoutsuite_path = PurePath(_scoutsuite_api_package.path).parent.parent.__str__()
sys.path.append(scoutsuite_path)
_add_scoutsuite_to_python_path()
def is_cloud_authentication_setup(provider: CloudProviders) -> Tuple[bool, str]:
if provider == CloudProviders.AWS.value:
@ -30,7 +19,7 @@ def is_cloud_authentication_setup(provider: CloudProviders) -> Tuple[bool, str]:
profile = auth_strategy.AWSAuthenticationStrategy().authenticate()
return True, f" Profile \"{profile.session.profile_name}\" is already setup. " \
f"Run Monkey on Island to start the scan."
except Exception:
except AuthenticationException:
return False, ""

View File

@ -56,6 +56,8 @@ const getContents = (props) => {
.then(res => {
if (res['error_msg'] === '') {
setSuccessMessage('AWS keys saved!');
} else if (res['message'] === 'Internal Server Error') {
setErrorMessage('Something went wrong, double check keys and contact support if problem persists.');
} else {
setErrorMessage(res['error_msg']);
}
@ -83,7 +85,8 @@ const getContents = (props) => {
<h5>Keys for custom user</h5>
<p>1. Open the IAM console at <a href={'https://console.aws.amazon.com/iam/'}
target={'_blank'} rel="noopener noreferrer">https://console.aws.amazon.com/iam/</a>.</p>
target={'_blank'}
rel="noopener noreferrer">https://console.aws.amazon.com/iam/</a>.</p>
<p>2. In the navigation pane, choose Users.</p>
<p>3. Choose the name of the user whose access keys you want to create, and then choose the Security credentials
tab.</p>

View File

@ -29,5 +29,5 @@ const ImageModal = (props) => {
export default ImageModal;
ImageModal.propTypes = {
image: PropTypes.element
image: PropTypes.string
}