Skip to content

Commit

Permalink
solve pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
marwinbaumannsbp committed Dec 22, 2023
1 parent df89981 commit 363b2e9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions awsfindingsmanagerlib/awsfindingsmanagerlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,13 @@ def original_payload(self):


class Rule:
"""Models xx"""
"""Models a rule."""

types = ('security_control_id', 'control_id', 'resource_id', 'tag')

# check also other variables, e.g. action now needs to be SUPPRESSED. etc.

# pylint: disable=too-many-arguments
def __init__(self, type_, value, action, rules, notes):
self.type = self._validate_type(type_)
self.value = value
Expand All @@ -252,6 +253,7 @@ def _validate_type(type_):
raise InvalidRuleType(type_)
return type_


class FindingsManager:
"""Models security hub and can retrieve findings."""

Expand All @@ -274,6 +276,7 @@ def rules(self):
def rules_errors(self):
return self._rules_errors

# pylint: disable=too-many-arguments
def register_rule(self, type_, value, action, rules, notes):
self._rules.append(Rule(type_, value, action, rules, notes))

Expand All @@ -292,9 +295,6 @@ def register_rules(self, rules):
self._logger.exception(f'Rule with data {data} is invalid')
return success




def _validate_region(self, region):
if any([not region, region in self.regions]):
return region
Expand Down Expand Up @@ -369,6 +369,7 @@ def _get_aggregating_region(self):
self._logger.debug('Could not get aggregating region, either not set, or a client error')
# return aggregating_region
return 'eu-west-1'

@retry(retry_on_exceptions=botocore.exceptions.ClientError)
def _get_findings(self, query_filter):
findings = set()
Expand Down Expand Up @@ -464,7 +465,8 @@ def get_findings_by_control_id(self, control_id):
findings (list): A list of findings from security hub.
"""
query_filter = {'ProductFields': [{'Key': 'ControlId', 'Value': control_id, 'Comparison': 'EQUALS'}]} #controlid == ruleid
query_filter = {
'ProductFields': [{'Key': 'ControlId', 'Value': control_id, 'Comparison': 'EQUALS'}]} # controlid == ruleid
return self._get_findings(query_filter)

def get_findings_by_tag(self):
Expand Down

0 comments on commit 363b2e9

Please sign in to comment.