13 Guard Duty Dedup Findings By Severity And Archive
Query
// REVIEW ONLY - AWS Security Operations Workbook Visual Query
// Tab: GuardDuty | Panel: dedup-findings-by-severity-and-archive | Visualization: barchart | Mode: All
// Security Question: How many unique active vs. archived GuardDuty findings exist across threat categories?
// Drill-Through: Focus triage on Active High/Medium findings in Panel 4.2 below.
// Empty/No-Data Contract: No AWSGuardDuty findings in window (check Tab 2 Data Health to confirm AWSGuardDuty ingestion).
let Start = {TimeRange:start};
let End = {TimeRange:end};
let OrgFilter = base64_decode_tostring("{Organization:base64}");
let AccountFilter = base64_decode_tostring("{AwsAccount:base64}");
let RegionFilter = base64_decode_tostring("{AwsRegion:base64}");
let EnvFilter = base64_decode_tostring("{Environment:base64}");
let WorkloadFilter = base64_decode_tostring("{Workload:base64}");
let SeverityFilter = base64_decode_tostring("{Severity:base64}");
let SourceFilter = base64_decode_tostring("{SourceTable:base64}");
let SummaryPref = base64_decode_tostring("{SummaryMode:base64}");
let SelectedPrincipalFilter = base64_decode_tostring("{SelectedPrincipal:base64}");
let SelectedIpFilter = base64_decode_tostring("{SelectedIp:base64}");
union isfuzzy=true
(datatable(TimeGenerated:datetime, Id:string, AccountId:string, Region:string, ServiceDetails:dynamic, Severity:real, ActivityType:string)[]),
(AWSGuardDuty | where TimeGenerated between (Start .. End)
| project TimeGenerated, Id, AccountId, Region, ServiceDetails=todynamic(ServiceDetails), Severity=todouble(Severity), ActivityType)
| where (AccountFilter == "*" or AccountId == AccountFilter) and (RegionFilter == "*" or Region == RegionFilter)
| summarize arg_max(TimeGenerated, *) by Id
| extend ArchiveState = iff(tobool(ServiceDetails.archived) == true, "Archived", "Active"),
SeverityBand = case(Severity >= 7.0, "High", Severity >= 4.0, "Medium", "Low"),
ThreatPurpose = tostring(split(ActivityType, ":")[0])
| where SeverityFilter == "*" or SeverityBand =~ SeverityFilter
| summarize UniqueFindings=count() by ThreatPurpose, strcat(ArchiveState, ":", SeverityBand)
| order by UniqueFindings desc
| take 5000Explanation
This query is designed to analyze AWS GuardDuty findings, focusing on the number of unique findings that are either active or archived, categorized by threat severity and purpose. Here's a simplified breakdown:
-
Time Range and Filters: The query uses a specified time range and applies filters based on organization, account, region, environment, workload, severity, source, principal, and IP address. These filters are decoded from base64 strings.
-
Data Union: It combines data from a predefined empty table and the AWSGuardDuty table, focusing on records within the specified time range.
-
Filtering and Projection: It filters the data based on account and region, then selects relevant columns such as time generated, ID, account ID, region, service details, severity, and activity type.
-
Deduplication: The query removes duplicate findings by keeping the most recent entry for each unique finding ID.
-
Classification: Each finding is classified as either "Active" or "Archived" based on its archived status. The severity is categorized into "High," "Medium," or "Low" bands.
-
Threat Purpose: The query extracts the threat purpose from the activity type.
-
Counting Unique Findings: It counts the number of unique findings for each combination of threat purpose, archive state, and severity band.
-
Ordering and Limiting Results: The results are ordered by the number of unique findings in descending order, and the query returns up to 5,000 results.
The overall goal is to provide a visual summary (in a bar chart) of how many unique GuardDuty findings exist, categorized by their threat purpose, severity, and whether they are active or archived. This helps in focusing triage efforts on active high and medium severity findings.