From c357ee410e1ea6f03fdf0673c6e159daebf23a8c Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Thu, 3 Feb 2022 14:30:07 +0530 Subject: [PATCH] UI: Remove Scoutsuite option from Run Monkey page --- .../pages/RunMonkeyPage/RunOptions.js | 10 +- .../AWSConfiguration/AWSCLISetup.js | 63 ------ .../AWSConfiguration/AWSKeySetup.js | 179 ------------------ .../AWSConfiguration/AWSSetupOptions.js | 40 ---- .../scoutsuite-setup/CloudOptions.js | 65 ------- .../scoutsuite-setup/ProvidersEnum.js | 9 - 6 files changed, 1 insertion(+), 365 deletions(-) delete mode 100644 monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/AWSConfiguration/AWSCLISetup.js delete mode 100644 monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/AWSConfiguration/AWSKeySetup.js delete mode 100644 monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/AWSConfiguration/AWSSetupOptions.js delete mode 100644 monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/CloudOptions.js delete mode 100644 monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/ProvidersEnum.js diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js index 1cc2aed7b..080a85df4 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js @@ -8,7 +8,6 @@ import {cloneDeep} from 'lodash'; import {faCloud, faExpandArrowsAlt} from '@fortawesome/free-solid-svg-icons'; import RunOnIslandButton from './RunOnIslandButton'; import AWSRunButton from './RunOnAWS/AWSRunButton'; -import CloudOptions from './scoutsuite-setup/CloudOptions'; const CONFIG_URL = '/api/configuration/island'; @@ -56,6 +55,7 @@ function RunOptions(props) { return InlineSelection(defaultContents, newProps); } + // TODO: Change function name function shouldShowScoutsuite(islandMode){ return islandMode !== 'ransomware'; } @@ -74,14 +74,6 @@ function RunOptions(props) { {ips: ips, setComponent: setComponent}) }}/> {shouldShowScoutsuite(props.islandMode) && } - {shouldShowScoutsuite(props.islandMode) && { - setComponent(CloudOptions, - {ips: ips, setComponent: setComponent}) - }}/> - } ); } diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/AWSConfiguration/AWSCLISetup.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/AWSConfiguration/AWSCLISetup.js deleted file mode 100644 index 178c60d8b..000000000 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/AWSConfiguration/AWSCLISetup.js +++ /dev/null @@ -1,63 +0,0 @@ -import {Button} from 'react-bootstrap'; -import React from 'react'; -import InlineSelection from '../../../../ui-components/inline-selection/InlineSelection'; -import {COLUMN_SIZES} from '../../../../ui-components/inline-selection/utils'; -import '../../../../../styles/components/scoutsuite/AWSSetup.scss'; -import AWSSetupOptions from './AWSSetupOptions'; - - -export default function AWSCLISetup(props) { - return InlineSelection(getContents, { - ...props, - collumnSize: COLUMN_SIZES.LARGE, - onBackButtonClick: () => { - props.setComponent(AWSSetupOptions, props); - } - }) -} - - -const getContents = (props) => { - return ( -
-

AWS CLI configuration for scan

-

To assess your AWS infrastructure's security do the following:

-
    -
  1. - 1. Configure AWS CLI on Monkey Island Server (if you already have a configured CLI you can skip this step). -
      -
    1. - a. Download and - install it on the Monkey Island server (machine running this page). -
    2. -
    3. - b. Run aws configure. It's important to configure credentials as it - allows ScoutSuite to get information about your cloud configuration. The simplest way to do so is to - provide  - . -
    4. -
    -
  2. -
  3. - 2. If you change the configuration, make sure not to disable AWS system info collector. -
  4. -
  5. - 3. Go -  and run Monkey on the Island server. -
  6. -
  7. - 4. Assess results in Zero Trust report. -
  8. -
-
- ); -} diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/AWSConfiguration/AWSKeySetup.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/AWSConfiguration/AWSKeySetup.js deleted file mode 100644 index 04a1f490b..000000000 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/AWSConfiguration/AWSKeySetup.js +++ /dev/null @@ -1,179 +0,0 @@ -import React, {useEffect, useState} from 'react'; -import InlineSelection from '../../../../ui-components/inline-selection/InlineSelection'; -import {COLUMN_SIZES} from '../../../../ui-components/inline-selection/utils'; -import AWSSetupOptions from './AWSSetupOptions'; -import {Button, Col, Form, Row} from 'react-bootstrap'; -import AuthComponent from '../../../../AuthComponent'; -import '../../../../../styles/components/scoutsuite/AWSSetup.scss'; -import {PROVIDERS} from '../ProvidersEnum'; -import classNames from 'classnames'; -import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; -import {faChevronDown} from '@fortawesome/free-solid-svg-icons/faChevronDown'; -import {faChevronUp} from '@fortawesome/free-solid-svg-icons/faChevronUp'; -import {faQuestion} from '@fortawesome/free-solid-svg-icons'; -import Collapse from '@kunukn/react-collapse/dist/Collapse.umd'; -import keySetupForAnyUserImage from '../../../../../images/aws_keys_tutorial-any-user.png'; -import keySetupForCurrentUserImage from '../../../../../images/aws_keys_tutorial-current-user.png'; -import ImageModal from '../../../../ui-components/ImageModal'; - - -export default function AWSCLISetup(props) { - return InlineSelection(getContents, { - ...props, - collumnSize: COLUMN_SIZES.LARGE, - onBackButtonClick: () => { - props.setComponent(AWSSetupOptions, props); - } - }) -} - -const authComponent = new AuthComponent({}) - -const getContents = (props) => { - - const [accessKeyId, setAccessKeyId] = useState(''); - const [secretAccessKey, setSecretAccessKey] = useState(''); - const [sessionToken, setSessionToken] = useState(''); - const [errorMessage, setErrorMessage] = useState(''); - const [successMessage, setSuccessMessage] = useState(''); - const [docCollapseOpen, setDocCollapseOpen] = useState(false); - - function submitKeys(event) { - event.preventDefault(); - setSuccessMessage(''); - setErrorMessage(''); - authComponent.authFetch( - '/api/scoutsuite_auth/' + PROVIDERS.AWS, - { - 'method': 'POST', - 'body': JSON.stringify({ - 'accessKeyId': accessKeyId, - 'secretAccessKey': secretAccessKey, - 'sessionToken': sessionToken - }) - }) - .then(res => res.json()) - .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']); - } - }); - } - - useEffect(() => { - authComponent.authFetch('/api/aws_keys') - .then(res => res.json()) - .then(res => { - setAccessKeyId(res['access_key_id']); - setSecretAccessKey(res['secret_access_key']); - setSessionToken(res['session_token']); - }); - }, [props]); - - - // TODO separate into standalone component - function getKeyCreationDocsContent() { - return ( -
-
Tips
-

Consider creating a new user account just for this activity. Assign only ReadOnlyAccess and  - SecurityAudit policies.

- -
Keys for custom user
-

1. Open the IAM console at https://console.aws.amazon.com/iam/.

-

2. In the navigation pane, choose Users.

-

3. Choose the name of the user whose access keys you want to create, and then choose the Security credentials - tab.

-

4. In the Access keys section, choose Create Access key.

-

To view the new access key pair, choose Show. Your credentials will look something like this:

-

Access key ID: AKIAIOSFODNN7EXAMPLE

-

Secret access key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

- - - - - - -
Keys for current user
-

1. Click on your username in the upper right corner.

-

2. Click on "My security credentials".

-

3. In the Access keys section, choose Create Access key.

-

To view the new Access key pair, choose Show. Your credentials will look something like this:

-

Access key ID: AKIAIOSFODNN7EXAMPLE

-

Secret access key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

- - - - - -
); - } - - function getKeyCreationDocs() { - return ( -
- - -
); - } - - return ( -
- {getKeyCreationDocs()} -
- setAccessKeyId(evt.target.value)} - type='text' - placeholder='Access key ID' - value={accessKeyId}/> - setSecretAccessKey(evt.target.value)} - type='password' - placeholder='Secret access key' - value={secretAccessKey}/> - setSessionToken(evt.target.value)} - type='text' - placeholder='Session token (optional, only for temp. keys)' - value={sessionToken}/> - { - errorMessage ? -
{errorMessage}
- : - '' - } - { - successMessage ? -
{successMessage}  - Go back and  - to start AWS scan!
- : - '' - } - - - - - - -
- ); -} diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/AWSConfiguration/AWSSetupOptions.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/AWSConfiguration/AWSSetupOptions.js deleted file mode 100644 index a66a893d8..000000000 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/AWSConfiguration/AWSSetupOptions.js +++ /dev/null @@ -1,40 +0,0 @@ -import React from 'react'; -import InlineSelection from '../../../../ui-components/inline-selection/InlineSelection'; -import NextSelectionButton from '../../../../ui-components/inline-selection/NextSelectionButton'; -import {faKey, faTerminal} from '@fortawesome/free-solid-svg-icons'; -import AWSCLISetup from './AWSCLISetup'; -import CloudOptions from '../CloudOptions'; -import AWSKeySetup from './AWSKeySetup'; - - -const AWSSetupOptions = (props) => { - return InlineSelection(getContents, { - ...props, - onBackButtonClick: () => { - props.setComponent(CloudOptions, props); - } - }) -} - -const getContents = (props) => { - return ( - <> - { - props.setComponent(AWSKeySetup, - {setComponent: props.setComponent}) - }}/> - { - props.setComponent(AWSCLISetup, - {setComponent: props.setComponent}) - }}/> - - ) -} - -export default AWSSetupOptions; diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/CloudOptions.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/CloudOptions.js deleted file mode 100644 index bd9c83f04..000000000 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/CloudOptions.js +++ /dev/null @@ -1,65 +0,0 @@ -import React, {useEffect, useState} from 'react'; -import InlineSelection from '../../../ui-components/inline-selection/InlineSelection'; -import NextSelectionButton from '../../../ui-components/inline-selection/NextSelectionButton'; -import {faCheck, faCloud, faSync} from '@fortawesome/free-solid-svg-icons'; -import AWSSetupOptions from './AWSConfiguration/AWSSetupOptions'; -import {PROVIDERS} from './ProvidersEnum'; -import AuthComponent from '../../../AuthComponent'; - - -const CloudOptions = (props) => { - return InlineSelection(getContents, { - ...props, - onBackButtonClick: () => { - props.setComponent() - } - }) -} - -const authComponent = new AuthComponent({}) - -const getContents = (props) => { - - const [description, setDescription] = useState('Loading...'); - const [iconType, setIconType] = useState('spinning-icon'); - const [icon, setIcon] = useState(faSync); - - useEffect(() => { - authComponent.authFetch('/api/scoutsuite_auth/' + PROVIDERS.AWS) - .then(res => res.json()) - .then(res => { - if(res.is_setup){ - setDescription(getDescription(res.message)); - setIconType('icon-success'); - setIcon(faCheck); - } else { - setDescription('Setup Amazon Web Services infrastructure scan.'); - setIconType('') - setIcon(faCloud); - } - }); - }, [props]); - - function getDescription(message){ - return ( - <> - {message} Run from the Island to start the scan. Click next to change the configuration. - - ) - } - - return ( - <> - { - props.setComponent(AWSSetupOptions, - {setComponent: props.setComponent}) - }}/> - - ) -} - -export default CloudOptions; diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/ProvidersEnum.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/ProvidersEnum.js deleted file mode 100644 index 26bb87860..000000000 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/scoutsuite-setup/ProvidersEnum.js +++ /dev/null @@ -1,9 +0,0 @@ -// Should match enum in monkey/common/cloud/scoutsuite_consts.py - -export const PROVIDERS = { - AWS : 'aws', - AZURE : 'azure', - GCP : 'gcp', - ALIBABA : 'aliyun', - ORACLE : 'oci' -}