forked from p15670423/monkey
Minor readability improvements: typehints and comments where needed
This commit is contained in:
parent
7aef86744e
commit
255bfe9444
|
@ -10,6 +10,8 @@ def _add_scoutsuite_to_python_path():
|
||||||
sys.path.append(scoutsuite_path)
|
sys.path.append(scoutsuite_path)
|
||||||
|
|
||||||
|
|
||||||
|
# Add ScoutSuite to python path because this way
|
||||||
|
# we don't need to change any imports in ScoutSuite code
|
||||||
_add_scoutsuite_to_python_path()
|
_add_scoutsuite_to_python_path()
|
||||||
|
|
||||||
import common.cloud.scoutsuite.ScoutSuite.api_run as scoutsuite_api
|
import common.cloud.scoutsuite.ScoutSuite.api_run as scoutsuite_api
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import infection_monkey.system_info.collectors.scoutsuite_collector.scoutsuite_api as scoutsuite_api
|
import infection_monkey.system_info.collectors.scoutsuite_collector.scoutsuite_api as scoutsuite_api
|
||||||
|
from common.cloud.scoutsuite.ScoutSuite.providers.aws.provider import AWSProvider
|
||||||
from common.cloud.scoutsuite_consts import CloudProviders
|
from common.cloud.scoutsuite_consts import CloudProviders
|
||||||
from common.utils.exceptions import ScoutSuiteScanError
|
from common.utils.exceptions import ScoutSuiteScanError
|
||||||
from infection_monkey.config import WormConfiguration
|
from infection_monkey.config import WormConfiguration
|
||||||
|
@ -26,5 +27,5 @@ def run_scoutsuite(cloud_type: str):
|
||||||
aws_session_token=WormConfiguration.aws_session_token)
|
aws_session_token=WormConfiguration.aws_session_token)
|
||||||
|
|
||||||
|
|
||||||
def send_results(results):
|
def send_results(results: AWSProvider):
|
||||||
ScoutSuiteTelem(results).send()
|
ScoutSuiteTelem(results).send()
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
from common.cloud.scoutsuite.ScoutSuite.output.result_encoder import ScoutJsonEncoder
|
from common.cloud.scoutsuite.ScoutSuite.output.result_encoder import ScoutJsonEncoder
|
||||||
|
from common.cloud.scoutsuite.ScoutSuite.providers.aws.provider import AWSProvider
|
||||||
from common.common_consts.telem_categories import TelemCategoryEnum
|
from common.common_consts.telem_categories import TelemCategoryEnum
|
||||||
from infection_monkey.telemetry.base_telem import BaseTelem
|
from infection_monkey.telemetry.base_telem import BaseTelem
|
||||||
|
|
||||||
|
|
||||||
class ScoutSuiteTelem(BaseTelem):
|
class ScoutSuiteTelem(BaseTelem):
|
||||||
|
|
||||||
def __init__(self, data):
|
def __init__(self, data: AWSProvider):
|
||||||
"""
|
"""
|
||||||
Default ScoutSuite telemetry constructor
|
Default ScoutSuite telemetry constructor
|
||||||
:param data: Data gathered via ScoutSuite
|
:param data: Data gathered via ScoutSuite
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
from typing import List
|
||||||
|
|
||||||
from common.common_consts import zero_trust_consts
|
from common.common_consts import zero_trust_consts
|
||||||
from .rule_names.cloudformation_rules import CloudformationRules
|
from .rule_names.cloudformation_rules import CloudformationRules
|
||||||
|
@ -21,12 +22,12 @@ from .rule_names.vpc_rules import VPCRules
|
||||||
class ScoutSuiteFinding(ABC):
|
class ScoutSuiteFinding(ABC):
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def rules(self):
|
def rules(self) -> List[str]:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def test(self):
|
def test(self) -> str:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,11 @@ export default class ScoutSuiteDataParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Gets value of cloud resource based on path of specific checked field and more abstract template path,
|
||||||
|
* which describes the scope of resource values.
|
||||||
* @param itemPath contains path to a specific value e.g. s3.buckets.da1e7081077ce92.secure_transport_enabled
|
* @param itemPath contains path to a specific value e.g. s3.buckets.da1e7081077ce92.secure_transport_enabled
|
||||||
* @param templatePath contains a template path for resource we would want to display e.g. s3.buckets.id
|
* @param templatePath contains a template path for resource we would want to display e.g. s3.buckets.id
|
||||||
* @returns {*[]|*}
|
* @returns {*[]|*} resource value e.g. {'bucket_id': 123, 'bucket_max_size': '123GB'}
|
||||||
*/
|
*/
|
||||||
getResourceValue(itemPath, templatePath) {
|
getResourceValue(itemPath, templatePath) {
|
||||||
let resourcePath = this.fillTemplatePath(itemPath, templatePath);
|
let resourcePath = this.fillTemplatePath(itemPath, templatePath);
|
||||||
|
|
|
@ -40,11 +40,11 @@ export default class ScoutSuiteRuleButton extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
function RuleCountBadge(props) {
|
function RuleCountBadge(props) {
|
||||||
const maxRuleCountToShow = 9;
|
const MAX_RULE_COUNT_TO_SHOW = 9;
|
||||||
const textForMoreThanMaxRuleCount = maxRuleCountToShow + '+';
|
const TEXT_FOR_LARGE_RULE_COUNT = MAX_RULE_COUNT_TO_SHOW + '+';
|
||||||
|
|
||||||
const ruleCountText = props.count > maxRuleCountToShow ?
|
const ruleCountText = props.count > MAX_RULE_COUNT_TO_SHOW ?
|
||||||
textForMoreThanMaxRuleCount : props.count;
|
TEXT_FOR_LARGE_RULE_COUNT : props.count;
|
||||||
return <Badge variant={'monkey-info-light'}>{ruleCountText}</Badge>;
|
return <Badge variant={'monkey-info-light'}>{ruleCountText}</Badge>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue