feat(outputs): add AWS inventory connectivity graph output format#10382
feat(outputs): add AWS inventory connectivity graph output format#10382sandiyochristan wants to merge 2 commits intoprowler-cloud:masterfrom
Conversation
Introduces `--output-formats inventory-graph` which produces two files
after a scan completes:
<output>.inventory.json – machine-readable nodes + edges graph
<output>.inventory.html – interactive D3.js force-directed graph
Why
---
Prowler's existing outputs (CSV, ASFF, OCSF) report individual check
findings but provide no cross-service topology view. Security engineers
need to understand _how_ resources are connected before they can reason
about attack paths, blast-radius, or lateral movement risk. This output
fills that gap by building a connectivity graph from the service clients
that are already loaded during a scan.
What
----
• prowler/lib/outputs/inventory/models.py
ResourceNode / ResourceEdge / ConnectivityGraph dataclasses.
• prowler/lib/outputs/inventory/graph_builder.py
Reads already-loaded service clients from sys.modules (zero extra API
calls) and delegates to per-service extractors. Services not scanned
are silently skipped.
• prowler/lib/outputs/inventory/extractors/
lambda_extractor – functions, VPC/subnet/SG edges, ESM triggers,
layers, DLQ, KMS
ec2_extractor – instances, security groups, subnet/VPC edges
vpc_extractor – VPCs, subnets, peering connections
rds_extractor – DB instances, VPC/SG/cluster/KMS edges
elbv2_extractor – ALB/NLB, SG and VPC edges
s3_extractor – buckets, replication, logging, KMS edges
iam_extractor – roles, trust-relationship edges
• prowler/lib/outputs/inventory/inventory_output.py
write_json() – serialises graph to JSON
write_html() – embeds graph data in a self-contained D3.js page with
force-directed layout, zoom/pan, tooltips, per-service
colour coding, service filter, and physics controls.
• prowler/config/config.py
Added "inventory-graph" to available_output_formats and
inventory_graph_file_suffix = ".inventory".
• prowler/__main__.py
Lazy import + call to generate_inventory_outputs() when mode ==
"inventory-graph".
How it works
------------
1. Run Prowler as normal with any set of checks.
2. Add `--output-formats inventory-graph` (combinable with csv/html/etc.).
3. After checks finish the graph builder walks sys.modules looking for
service clients that were loaded during the scan.
4. Each extractor turns the in-memory service objects into ResourceNode
and ResourceEdge objects (no extra AWS API calls).
5. JSON + HTML files are written alongside other output files.
Usage
-----
prowler aws --output-formats inventory-graph
The HTML file opens in any browser with no server needed.
|
✅ Conflict Markers Resolved All conflict markers have been successfully resolved in this pull request. |
| encryption = getattr(bucket, "encryption", None) | ||
| versioning = getattr(bucket, "versioning_enabled", None) | ||
| logging = getattr(bucket, "logging", None) | ||
| public = getattr(bucket, "public_access_block", None) |
Check notice
Code scanning / CodeQL
Unused local variable Note
| import os | ||
| from dataclasses import asdict | ||
| from datetime import datetime | ||
| from typing import Optional |
Check notice
Code scanning / CodeQL
Unused import Note
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #10382 +/- ##
==========================================
+ Coverage 56.85% 63.51% +6.66%
==========================================
Files 87 105 +18
Lines 2846 7022 +4176
==========================================
+ Hits 1618 4460 +2842
- Misses 1228 2562 +1334
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Thanks for this contribution @sandiyochristan. For now I left the One thing I'd like to highlight is that in the
It's important to leave them as is because we want to sync, having an issue first, with the community contributors before doing the implementation. This is to prevent duplications, things that may be not planned or not considered on our end, or simply to have a conversation first to define the implementation/fix. I hope you understand this. We want to always give the best support to our community. Thanks! |
Context
Prowler's existing output formats (CSV, ASFF, OCSF, HTML) surface individual check findings but provide no cross-service topology view. Security engineers need to understand how AWS resources are connected — which Lambda functions sit inside which VPC, which IAM roles can be assumed by which services, which event sources trigger which functions — before they can reason about attack paths, blast-radius, or lateral-movement risk.
This PR adds a new
--output-formats inventory-graphmode that derives a connectivity graph from the service clients already loaded during a scan, with zero extra AWS API calls, and writes two artefacts:<output>.inventory.json— machine-readable nodes + edges graph<output>.inventory.html— self-contained interactive D3.js force-directed visualizationRelated to the Prowler attack-path roadmap (cartography / Neo4j integration).
Description
New module:
prowler/lib/outputs/inventory/Edge semantic types (used for downstream filtering / attack-path analysis):
network·iam·triggers·data_flow·depends_on·replicates_to·encrypts·logs_toChanges to existing files
prowler/config/config.py"inventory-graph"toavailable_output_formats; addedinventory_graph_file_suffix = ".inventory"prowler/__main__.pymode == "inventory-graph"after the existing format handlersprowler/CHANGELOG.md## [5.21.0] 🚀 AddedKey design decisions
sys.modules__main__.pyHTML graph features
Steps to review
Code review —
prowler/lib/outputs/inventory/is self-contained; start withmodels.py→graph_builder.py→inventory_output.py, then any extractor of interest.Run locally against a real or mocked AWS account:
Open
output/<timestamp>.inventory.htmlin a browser.Smoke test (no AWS credentials needed):
Verify zero impact on existing formats — running
prowler aws --output-formats csv htmlstill works identically; the new code path is only entered whenmode == "inventory-graph".Verify CHANGELOG entry —
prowler/CHANGELOG.mdupdated under## [5.21.0] 🚀 Added.Checklist
Community Checklist
logger.error, no bareprint)prowler/CHANGELOG.md)SDK/CLI
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.