Minor readability improvements: typehints and comments where needed

This commit is contained in:
VakarisZ 2021-01-28 12:15:01 +02:00
parent 7aef86744e
commit 255bfe9444
6 changed files with 16 additions and 10 deletions

View File

@ -10,6 +10,8 @@ def _add_scoutsuite_to_python_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()
import common.cloud.scoutsuite.ScoutSuite.api_run as scoutsuite_api

View File

@ -1,6 +1,7 @@
import logging
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.utils.exceptions import ScoutSuiteScanError
from infection_monkey.config import WormConfiguration
@ -26,5 +27,5 @@ def run_scoutsuite(cloud_type: str):
aws_session_token=WormConfiguration.aws_session_token)
def send_results(results):
def send_results(results: AWSProvider):
ScoutSuiteTelem(results).send()

View File

@ -1,11 +1,12 @@
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 infection_monkey.telemetry.base_telem import BaseTelem
class ScoutSuiteTelem(BaseTelem):
def __init__(self, data):
def __init__(self, data: AWSProvider):
"""
Default ScoutSuite telemetry constructor
:param data: Data gathered via ScoutSuite

View File

@ -1,4 +1,5 @@
from abc import ABC, abstractmethod
from typing import List
from common.common_consts import zero_trust_consts
from .rule_names.cloudformation_rules import CloudformationRules
@ -21,12 +22,12 @@ from .rule_names.vpc_rules import VPCRules
class ScoutSuiteFinding(ABC):
@property
@abstractmethod
def rules(self):
def rules(self) -> List[str]:
pass
@property
@abstractmethod
def test(self):
def test(self) -> str:
pass

View File

@ -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 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) {
let resourcePath = this.fillTemplatePath(itemPath, templatePath);

View File

@ -40,11 +40,11 @@ export default class ScoutSuiteRuleButton extends Component {
}
function RuleCountBadge(props) {
const maxRuleCountToShow = 9;
const textForMoreThanMaxRuleCount = maxRuleCountToShow + '+';
const MAX_RULE_COUNT_TO_SHOW = 9;
const TEXT_FOR_LARGE_RULE_COUNT = MAX_RULE_COUNT_TO_SHOW + '+';
const ruleCountText = props.count > maxRuleCountToShow ?
textForMoreThanMaxRuleCount : props.count;
const ruleCountText = props.count > MAX_RULE_COUNT_TO_SHOW ?
TEXT_FOR_LARGE_RULE_COUNT : props.count;
return <Badge variant={'monkey-info-light'}>{ruleCountText}</Badge>;
}