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): def __init__(self, data):
""" """
Default ScoutSuite telemetry constructor Default ScoutSuite telemetry constructor
:param data: Data gathered via ScoutSuite ( :param data: Data gathered via ScoutSuite
""" """
super().__init__() super().__init__()
self.data = data 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 typing import Tuple
from ScoutSuite.providers.base.authentication_strategy import AuthenticationException
from common.cloud.scoutsuite_consts import CloudProviders from common.cloud.scoutsuite_consts import CloudProviders
from common.utils.exceptions import InvalidAWSKeys from common.utils.exceptions import InvalidAWSKeys
from monkey_island.cc.server_utils.encryptor import encryptor from monkey_island.cc.server_utils.encryptor import encryptor
from monkey_island.cc.services.config import ConfigService from monkey_island.cc.services.config import ConfigService
from monkey_island.cc.services.config_schema.config_value_paths import AWS_KEYS_PATH 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]: def is_cloud_authentication_setup(provider: CloudProviders) -> Tuple[bool, str]:
if provider == CloudProviders.AWS.value: if provider == CloudProviders.AWS.value:
@ -30,7 +19,7 @@ def is_cloud_authentication_setup(provider: CloudProviders) -> Tuple[bool, str]:
profile = auth_strategy.AWSAuthenticationStrategy().authenticate() profile = auth_strategy.AWSAuthenticationStrategy().authenticate()
return True, f" Profile \"{profile.session.profile_name}\" is already setup. " \ return True, f" Profile \"{profile.session.profile_name}\" is already setup. " \
f"Run Monkey on Island to start the scan." f"Run Monkey on Island to start the scan."
except Exception: except AuthenticationException:
return False, "" return False, ""

View File

@ -56,6 +56,8 @@ const getContents = (props) => {
.then(res => { .then(res => {
if (res['error_msg'] === '') { if (res['error_msg'] === '') {
setSuccessMessage('AWS keys saved!'); 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 { } else {
setErrorMessage(res['error_msg']); setErrorMessage(res['error_msg']);
} }
@ -79,11 +81,12 @@ const getContents = (props) => {
<div className={'key-creation-tutorial'}> <div className={'key-creation-tutorial'}>
<h5>Tips</h5> <h5>Tips</h5>
<p>Consider creating a new user account just for this activity. Assign only <b>ReadOnlyAccess</b> and&nbsp; <p>Consider creating a new user account just for this activity. Assign only <b>ReadOnlyAccess</b> and&nbsp;
<b>SecurityAudit</b> policies.</p> <b>SecurityAudit</b> policies.</p>
<h5>Keys for custom user</h5> <h5>Keys for custom user</h5>
<p>1. Open the IAM console at <a href={'https://console.aws.amazon.com/iam/'} <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>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 <p>3. Choose the name of the user whose access keys you want to create, and then choose the Security credentials
tab.</p> tab.</p>
@ -157,7 +160,7 @@ const getContents = (props) => {
{ {
successMessage ? successMessage ?
<div className="alert alert-success" role="alert">{successMessage}&nbsp; <div className="alert alert-success" role="alert">{successMessage}&nbsp;
Go back and&nbsp; Go back and&nbsp;
<Button variant={'link'} onClick={() => props.setComponent()} className={'link-in-success-message'}> <Button variant={'link'} onClick={() => props.setComponent()} className={'link-in-success-message'}>
run Monkey from the Island server </Button> to start AWS scan!</div> run Monkey from the Island server </Button> to start AWS scan!</div>
: :

View File

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