Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aws][feat] Take only active findings for GuardDuty and Inspector2 services #2299

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion plugins/aws/fix_plugin_aws/resource/guardduty.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,9 @@ def add_finding(
"FindingIds",
expected_errors=["BadRequestException"],
DetectorId=detector_id,
FindingCriteria={"Criterion": {"accountId": {"Eq": [builder.account.id]}}},
FindingCriteria={
"Criterion": {"accountId": {"Eq": [builder.account.id]}, "service.archived": {"Eq": ["false"]}},
},
): detector_id
for detector_id in detector_ids
}
Expand Down
5 changes: 4 additions & 1 deletion plugins/aws/fix_plugin_aws/resource/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ def add_finding(
action="list-findings",
result_name="findings",
expected_errors=["AccessDeniedException"],
filterCriteria={"awsAccountId": [{"comparison": "EQUALS", "value": f"{builder.account.id}"}]},
filterCriteria={
"awsAccountId": [{"comparison": "EQUALS", "value": f"{builder.account.id}"}],
"findingStatus": [{"comparison": "EQUALS", "value": "ACTIVE"}],
},
):
if finding := AwsInspectorFinding.from_api(item, builder):
for fr in finding.finding_resources or []:
Expand Down
2 changes: 1 addition & 1 deletion plugins/aws/fix_plugin_aws/resource/ssm.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class AwsSSMResourceCompliance(AwsResource, PhantomBaseResource):
compliance_details: Optional[Dict[str, str]] = field(default=None, metadata={"description": "A Key:Value tag combination for the compliance item."}) # fmt: skip

def parse_finding(self) -> Finding:
title = self.title or ""
title = self.title or (self.compliance_details or {}).get("DocumentName") or ""
severity = SEVERITY_MAPPING.get(self.severity or "", Severity.medium)
details = self.compliance_details
if self.execution_summary:
Expand Down
Loading