# aaarya2117/iam-trace architecture

> Architecture diagram of the GitHub repository aaarya2117/iam-trace, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aaarya2117/iam-trace
- Repository: https://github.com/aaarya2117/iam-trace

## Overview

IAM-Trace scans live AWS IAM data or offline JSON, normalizes it, evaluates effective permissions, detects escalation techniques, and emits findings, reports, and escalation graphs. The principal flow is visible in the CLI and README; the README also documents group inheritance, deny precedence, wildcard/resource matching, condition review, and nine detection rules. Relationships involving unsampled implementations are limited to documented or indexed dependencies; dashed edges mark optional live-AWS acquisition.

Main entry points: [`iam_trace/cli/main.py`](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/cli/main.py) (Scan CLI), [`iam_trace/rules/base.py`](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/rules/base.py) (Rule engine), [`iam_trace/rules/service_chains.py`](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/rules/service_chains.py) (Service chain rules), [`iam_trace/ingestion/aws.py`](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/ingestion/aws.py) (AWS collector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Data ingestion"]
  node_aws_ingest["AWS collector<br/>[aws.py]"]
  node_json_parser["JSON parser<br/>[parser.py]"]
  node_iam_models["IAM data model<br/>[models.py]"]
end

subgraph group_analysis["Policy analysis"]
  node_policy_eval["Policy evaluator<br/>[engine.py]"]
  node_pattern_match["Policy matcher<br/>[matcher.py]"]
end

subgraph group_detection["Escalation detection"]
  node_rule_engine["Rule engine<br/>[base.py]"]
  node_rule_registry["Rule registry<br/>[registry.py]"]
  node_iam_rules["IAM management rules<br/>[iam_management.py]"]
  node_chain_rules["Service chain rules<br/>[service_chains.py]"]
  node_findings["Escalation findings<br/>[models.py]"]
end

subgraph group_outputs["Findings and outputs"]
  node_graph_builder["Graph builder<br/>[builder.py]"]
  node_graph_renderer["Graph renderer<br/>[renderer.py]"]
  node_report_generator["Report generator<br/>[generator.py]"]
end

node_operator(("Operator"))
node_offline_json["Offline JSON"]
node_aws_iam[("AWS IAM")]
node_cli["Scan CLI<br/>[main.py]"]

node_operator -->|"starts scan"| node_cli
node_offline_json -->|"supplies input"| node_cli
node_cli -.->|"requests live scan"| node_aws_ingest
node_aws_ingest -.->|"reads IAM data"| node_aws_iam
node_cli -->|"parses offline data"| node_json_parser
node_aws_ingest -->|"parses responses"| node_json_parser
node_json_parser -->|"creates normalized data"| node_iam_models
node_aws_ingest -->|"uses data models"| node_iam_models
node_cli -->|"gets default engine"| node_rule_registry
node_rule_registry -->|"configures"| node_rule_engine
node_rule_registry -->|"registers rules"| node_iam_rules
node_rule_registry -->|"registers rules"| node_chain_rules
node_rule_engine -->|"creates evaluator"| node_policy_eval
node_rule_engine -.->|"dispatches checks"| node_iam_rules
node_rule_engine -.->|"dispatches checks"| node_chain_rules
node_iam_rules -->|"checks permissions"| node_policy_eval
node_chain_rules -->|"checks permissions"| node_policy_eval
node_chain_rules -->|"matches actions"| node_pattern_match
node_policy_eval -->|"matches statements"| node_pattern_match
node_cli -->|"evaluates account"| node_rule_engine
node_iam_rules -->|"creates findings"| node_findings
node_chain_rules -->|"creates findings"| node_findings
node_cli -->|"writes reports"| node_report_generator
node_cli -->|"builds escalation graph"| node_graph_builder
node_cli -->|"exports visualizations"| node_graph_renderer
node_graph_builder -->|"reads findings"| node_iam_models
node_graph_renderer -.->|"renders graph data"| node_graph_builder

click node_cli "https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/cli/main.py"
click node_aws_ingest "https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/ingestion/aws.py"
click node_json_parser "https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/ingestion/parser.py"
click node_iam_models "https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/ingestion/models.py"
click node_rule_engine "https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/rules/base.py"
click node_rule_registry "https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/rules/registry.py"
click node_iam_rules "https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/rules/iam_management.py"
click node_chain_rules "https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/rules/service_chains.py"
click node_policy_eval "https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/evaluation/engine.py"
click node_pattern_match "https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/evaluation/matcher.py"
click node_findings "https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/ingestion/models.py"
click node_graph_builder "https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/graph/builder.py"
click node_graph_renderer "https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/graph/renderer.py"
click node_report_generator "https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/report/generator.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_aws_ingest,node_json_parser,node_iam_models toneBlue
class node_policy_eval,node_pattern_match,node_aws_iam toneAmber
class node_rule_engine,node_rule_registry,node_iam_rules,node_chain_rules,node_findings toneMint
class node_graph_builder,node_graph_renderer,node_report_generator toneRose
class node_operator,node_offline_json toneIndigo
class node_cli toneTeal
```

## Components

### Data ingestion

- [AWS collector](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/ingestion/aws.py): `iam_trace/ingestion/aws.py`
- [JSON parser](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/ingestion/parser.py): `iam_trace/ingestion/parser.py`
- [IAM data model](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/ingestion/models.py): `iam_trace/ingestion/models.py`

### Policy analysis

- [Policy evaluator](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/evaluation/engine.py): `iam_trace/evaluation/engine.py`
- [Policy matcher](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/evaluation/matcher.py): `iam_trace/evaluation/matcher.py`

### Escalation detection

- [Rule engine](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/rules/base.py): `iam_trace/rules/base.py`
- [Rule registry](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/rules/registry.py): `iam_trace/rules/registry.py`
- [IAM management rules](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/rules/iam_management.py): `iam_trace/rules/iam_management.py`
- [Service chain rules](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/rules/service_chains.py): `iam_trace/rules/service_chains.py`
- [Escalation findings](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/ingestion/models.py): `iam_trace/ingestion/models.py`

### Findings and outputs

- [Graph builder](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/graph/builder.py): `iam_trace/graph/builder.py`
- [Graph renderer](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/graph/renderer.py): `iam_trace/graph/renderer.py`
- [Report generator](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/report/generator.py): `iam_trace/report/generator.py`

### Other components

- **Operator**
- **Offline JSON**
- **AWS IAM**
- [Scan CLI](https://github.com/aaarya2117/iam-trace/blob/main/iam_trace/cli/main.py): `iam_trace/cli/main.py`

## Connections

- Operator → Scan CLI: starts scan (evidence: `README.md`)
- Offline JSON → Scan CLI: supplies input (evidence: `README.md`)
- Scan CLI → AWS collector: requests live scan (evidence: `README.md`)
- AWS collector → AWS IAM: reads IAM data (evidence: `README.md`)
- Scan CLI → JSON parser: parses offline data (evidence: `iam_trace/cli/main.py`)
- AWS collector → JSON parser: parses responses (evidence: `iam_trace/ingestion/aws.py`)
- JSON parser → IAM data model: creates normalized data (evidence: `iam_trace/ingestion/parser.py`)
- AWS collector → IAM data model: uses data models (evidence: `iam_trace/ingestion/aws.py`)
- Scan CLI → Rule registry: gets default engine (evidence: `iam_trace/cli/main.py`)
- Rule registry → Rule engine: configures (evidence: `iam_trace/rules/registry.py`)
- Rule registry → IAM management rules: registers rules (evidence: `iam_trace/rules/registry.py`)
- Rule registry → Service chain rules: registers rules (evidence: `iam_trace/rules/registry.py`)
- Rule engine → Policy evaluator: creates evaluator (evidence: `iam_trace/rules/base.py`)
- Rule engine → IAM management rules: dispatches checks (evidence: `iam_trace/rules/iam_management.py`)
- Rule engine → Service chain rules: dispatches checks (evidence: `iam_trace/rules/service_chains.py`)
- IAM management rules → Policy evaluator: checks permissions (evidence: `iam_trace/rules/iam_management.py`)
- Service chain rules → Policy evaluator: checks permissions (evidence: `iam_trace/rules/service_chains.py`)
- Service chain rules → Policy matcher: matches actions (evidence: `iam_trace/rules/service_chains.py`)
- Policy evaluator → Policy matcher: matches statements (evidence: `iam_trace/evaluation/engine.py`)
- Scan CLI → Rule engine: evaluates account (evidence: `README.md`)
- IAM management rules → Escalation findings: creates findings (evidence: `iam_trace/rules/iam_management.py`)
- Service chain rules → Escalation findings: creates findings (evidence: `iam_trace/rules/service_chains.py`)
- Scan CLI → Report generator: writes reports (evidence: `iam_trace/cli/main.py`)
- Scan CLI → Graph builder: builds escalation graph (evidence: `iam_trace/cli/main.py`)
- Scan CLI → Graph renderer: exports visualizations (evidence: `iam_trace/cli/main.py`)
- Graph builder → IAM data model: reads findings (evidence: `iam_trace/graph/builder.py`)
- Graph renderer → Graph builder: renders graph data
