# pala46/cloudaudit architecture

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

- Interactive diagram: https://gitdiagram.com/pala46/cloudaudit
- Repository: https://github.com/pala46/cloudaudit

## Overview

1. **What this repo is**
   CloudAudit is a Python CLI security-audit framework for AWS, designed to run with **no Python dependencies** and rely on the **AWS CLI** for API access. The architecture is intentionally lightweight so it can run in constrained environments like CloudShell.

2. **Top-level control flow**
   `cloudaudit.py` is the entry point. It parses arguments such as provider, service, check, and output format, then orchestrates the audit run: select provider → discover checks → execute checks → collect findings → format results.

3. **Provider boundary**
   `providers/` is the cloud abstraction layer. The repository shows an AWS implementation in `providers/aws/aws_provider.py`, plus an `providers/azure.py` placeholder indicating the design is meant to expand beyond AWS. In practice, the current functional surface is AWS-first.

4. **AWS implementation structure**
   AWS-specific logic is split by service under `providers/aws/services/`. Each service directory owns its checks and any service adapter code needed to query AWS CLI output. The repo includes implementations for S3, IAM, EC2, CloudTrail, KMS, RDS, and Lambda.

5. **Service client adapters**
   Files like `s3_client.py`, `iam_client.py`, `ec2_client.py`, `cloudtrail_client.py`, and `rds_client.py` act as normalized access layers for each AWS service. These are the boundary between the audit checks and AWS CLI responses, so checks can work with service-specific data structures without reimplementing API plumbing.

6. **Check packaging model**
   Each check lives in its own package directory, for example `providers/aws/services/s3/s3_bucket_public_access/`. This keeps checks isolated and makes them easy to enumerate, run individually, or map to compliance controls. The package structure mirrors Prowler-style check organization, which the README calls out as a migration-friendly design choice.

7. **Shared check model**
   `lib/check/models.py` contains the common check/report abstractions used across the repo. This is the domain model layer that standardizes metadata, severity, status, and finding output regardless of which AWS service produced the result.

8. **Compliance mapping layer**
   `compliance/aws/` contains benchmark and policy artifacts, including `cis_aws.json` and `audit_user_policy.json`. This layer links technical checks to compliance frameworks and also provides the least-privilege IAM policy needed for the audit user.

9. **Output formatting boundary**
   `output/json.py`, `output/html.py`, and `output/csv.py` convert the collected findings into report formats. This is a clean terminal stage in the pipeline: the audit engine produces structured results first, and output modules only serialize/present them.

10. **Scope and inventory of implemented checks**
   The repository currently includes checks for public S3 exposure, encryption, versioning, logging, IAM MFA/password/admin posture, EC2 public exposure/security groups, CloudTrail enablement, KMS rotation, RDS encryption, and Lambda public exposure. This gives the architecture a clear service-by-service audit map rather than a generic rules engine.

11. **Security and permissions boundary**
   The intended runtime model is a dedicated read-only audit IAM user configured in the target account. The repo includes `compliance/aws/audit_user_policy.json` to support that boundary, which is important because the audit tool depends on read access to multiple AWS services but should not require write privileges.

12. **Auxiliary/organizational pieces**
   `checks/` and `checks/aws/` appear to be compatibility or scaffolding directories, while `lib/allowlisters/` suggests a mechanism for suppressing known exceptions or approved findings. `providers/aws/aws_regions_by_service.json` indicates region/service applicability is part of the provider logic, which matters for checks that must enumerate resources across regions.

13. **How to diagram it**
   A good architecture diagram should show: **CLI entry point** at the top, branching into an **AWS provider layer**, then into **service adapters and per-check modules**, with outputs flowing into **JSON/HTML/CSV renderers**. Compliance assets and IAM policy files sit as supporting inputs, not as runtime execution nodes.

Main entry points: [`providers/aws/aws_provider.py`](https://github.com/pala46/cloudaudit/blob/master/providers/aws/aws_provider.py) (AWS provider), [`lib/check/models.py`](https://github.com/pala46/cloudaudit/blob/master/lib/check/models.py) (Check model), [`cloudaudit.py`](https://github.com/pala46/cloudaudit/blob/master/cloudaudit.py) (CloudAudit CLI), [`providers/aws/services/s3`](https://github.com/pala46/cloudaudit/tree/master/providers/aws/services/s3) (S3 checks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core flow"]
  node_cloudaudit_py["CloudAudit CLI<br/>entrypoint<br/>[cloudaudit.py]"]
  node_check_models["Check model<br/>domain model<br/>[models.py]"]
end

subgraph group_aws["AWS provider"]
  node_aws_provider["AWS provider<br/>[aws_provider.py]"]
  node_azure_provider["Azure stub<br/>provider stub<br/>[azure.py]"]
  node_aws_regions["Region map<br/>scope data"]
  node_s3_client["S3 client<br/>service adapter<br/>[s3_client.py]"]
  node_iam_client["IAM client<br/>service adapter<br/>[iam_client.py]"]
  node_ec2_client["EC2 client<br/>service adapter<br/>[ec2_client.py]"]
  node_cloudtrail_client["CloudTrail client<br/>service adapter"]
  node_rds_client["RDS client<br/>service adapter<br/>[rds_client.py]"]
  node_s3_checks{{"S3 checks<br/>check package"}}
  node_iam_checks{{"IAM checks<br/>check package"}}
  node_ec2_checks{{"EC2 checks<br/>check package"}}
  node_cloudtrail_checks{{"CloudTrail checks<br/>check package"}}
  node_kms_checks{{"KMS checks<br/>check package"}}
  node_rds_checks{{"RDS checks<br/>check package"}}
  node_lambda_checks{{"Lambda checks<br/>check package"}}
end

subgraph group_support["Support assets"]
  node_allowlisters["Allowlisters<br/>suppression layer<br/>[__init__.py]"]
  node_json_output["JSON output<br/>renderer<br/>[json.py]"]
  node_html_output["HTML output<br/>renderer<br/>[html.py]"]
  node_csv_output["CSV output<br/>renderer<br/>[csv.py]"]
  node_cis_policy["CIS mapping<br/>compliance asset<br/>[cis_aws.json]"]
  node_audit_policy["Audit policy<br/>iam policy"]
end

node_cloudaudit_py -->|"selects provider"| node_aws_provider
node_cloudaudit_py -->|"uses model"| node_check_models
node_cloudaudit_py -->|"formats"| node_json_output
node_cloudaudit_py -->|"formats"| node_html_output
node_cloudaudit_py -->|"formats"| node_csv_output
node_cloudaudit_py -->|"applies exceptions"| node_allowlisters
node_aws_provider -->|"uses scope"| node_aws_regions
node_aws_provider -->|"runs"| node_s3_checks
node_aws_provider -->|"runs"| node_iam_checks
node_aws_provider -->|"runs"| node_ec2_checks
node_aws_provider -->|"runs"| node_cloudtrail_checks
node_aws_provider -->|"runs"| node_kms_checks
node_aws_provider -->|"runs"| node_rds_checks
node_aws_provider -->|"runs"| node_lambda_checks
node_s3_checks -->|"reads"| node_s3_client
node_iam_checks -->|"reads"| node_iam_client
node_ec2_checks -->|"reads"| node_ec2_client
node_cloudtrail_checks -->|"reads"| node_cloudtrail_client
node_rds_checks -->|"reads"| node_rds_client
node_s3_checks -->|"emits"| node_check_models
node_iam_checks -->|"emits"| node_check_models
node_ec2_checks -->|"emits"| node_check_models
node_cloudtrail_checks -->|"emits"| node_check_models
node_kms_checks -->|"emits"| node_check_models
node_rds_checks -->|"emits"| node_check_models
node_lambda_checks -->|"emits"| node_check_models
node_json_output -->|"serializes"| node_check_models
node_html_output -->|"serializes"| node_check_models
node_csv_output -->|"serializes"| node_check_models
node_cis_policy -->|"maps"| node_check_models
node_audit_policy -->|"authorizes"| node_aws_provider
node_azure_provider -.->|"future boundary"| node_aws_provider

click node_cloudaudit_py "https://github.com/pala46/cloudaudit/blob/master/cloudaudit.py"
click node_check_models "https://github.com/pala46/cloudaudit/blob/master/lib/check/models.py"
click node_allowlisters "https://github.com/pala46/cloudaudit/blob/master/lib/allowlisters/__init__.py"
click node_aws_provider "https://github.com/pala46/cloudaudit/blob/master/providers/aws/aws_provider.py"
click node_azure_provider "https://github.com/pala46/cloudaudit/blob/master/providers/azure.py"
click node_aws_regions "https://github.com/pala46/cloudaudit/blob/master/providers/aws/aws_regions_by_service.json"
click node_s3_client "https://github.com/pala46/cloudaudit/blob/master/providers/aws/services/s3/s3_client.py"
click node_iam_client "https://github.com/pala46/cloudaudit/blob/master/providers/aws/services/iam/iam_client.py"
click node_ec2_client "https://github.com/pala46/cloudaudit/blob/master/providers/aws/services/ec2/ec2_client.py"
click node_cloudtrail_client "https://github.com/pala46/cloudaudit/blob/master/providers/aws/services/cloudtrail/cloudtrail_client.py"
click node_rds_client "https://github.com/pala46/cloudaudit/blob/master/providers/aws/services/rds/rds_client.py"
click node_s3_checks "https://github.com/pala46/cloudaudit/tree/master/providers/aws/services/s3"
click node_iam_checks "https://github.com/pala46/cloudaudit/tree/master/providers/aws/services/iam"
click node_ec2_checks "https://github.com/pala46/cloudaudit/tree/master/providers/aws/services/ec2"
click node_cloudtrail_checks "https://github.com/pala46/cloudaudit/tree/master/providers/aws/services/cloudtrail"
click node_kms_checks "https://github.com/pala46/cloudaudit/tree/master/providers/aws/services/kms"
click node_rds_checks "https://github.com/pala46/cloudaudit/tree/master/providers/aws/services/rds"
click node_lambda_checks "https://github.com/pala46/cloudaudit/tree/master/providers/aws/services/awslambda"
click node_json_output "https://github.com/pala46/cloudaudit/blob/master/output/json.py"
click node_html_output "https://github.com/pala46/cloudaudit/blob/master/output/html.py"
click node_csv_output "https://github.com/pala46/cloudaudit/blob/master/output/csv.py"
click node_cis_policy "https://github.com/pala46/cloudaudit/blob/master/compliance/aws/cis_aws.json"
click node_audit_policy "https://github.com/pala46/cloudaudit/blob/master/compliance/aws/audit_user_policy.json"

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_cloudaudit_py,node_check_models toneBlue
class node_aws_provider,node_azure_provider,node_aws_regions,node_s3_client,node_iam_client,node_ec2_client,node_cloudtrail_client,node_rds_client,node_s3_checks,node_iam_checks,node_ec2_checks,node_cloudtrail_checks,node_kms_checks,node_rds_checks,node_lambda_checks toneAmber
class node_allowlisters,node_json_output,node_html_output,node_csv_output,node_cis_policy,node_audit_policy toneMint
```

## Components

### Core flow

CLI orchestration and shared domain model

- [CloudAudit CLI](https://github.com/pala46/cloudaudit/blob/master/cloudaudit.py): entrypoint · Parses args and orchestrates audit runs · `cloudaudit.py`
- [Check model](https://github.com/pala46/cloudaudit/blob/master/lib/check/models.py): domain model · Common metadata, status, and finding abstractions · `lib/check/models.py`

### AWS provider

AWS-specific provider, adapters, and checks

- [AWS provider](https://github.com/pala46/cloudaudit/blob/master/providers/aws/aws_provider.py): provider · AWS cloud abstraction and provider orchestration · `providers/aws/aws_provider.py`
- [Azure stub](https://github.com/pala46/cloudaudit/blob/master/providers/azure.py): provider stub · Placeholder for non-AWS provider expansion · `providers/azure.py`
- [Region map](https://github.com/pala46/cloudaudit/blob/master/providers/aws/aws_regions_by_service.json): scope data · Maps services to applicable AWS regions · `providers/aws/aws_regions_by_service.json`
- [S3 client](https://github.com/pala46/cloudaudit/blob/master/providers/aws/services/s3/s3_client.py): service adapter · Normalizes S3 CLI responses for checks · `providers/aws/services/s3/s3_client.py`
- [IAM client](https://github.com/pala46/cloudaudit/blob/master/providers/aws/services/iam/iam_client.py): service adapter · Normalizes IAM CLI responses for checks · `providers/aws/services/iam/iam_client.py`
- [EC2 client](https://github.com/pala46/cloudaudit/blob/master/providers/aws/services/ec2/ec2_client.py): service adapter · Normalizes EC2 CLI responses for checks · `providers/aws/services/ec2/ec2_client.py`
- [CloudTrail client](https://github.com/pala46/cloudaudit/blob/master/providers/aws/services/cloudtrail/cloudtrail_client.py): service adapter · Normalizes CloudTrail CLI responses for checks · `providers/aws/services/cloudtrail/cloudtrail_client.py`
- [RDS client](https://github.com/pala46/cloudaudit/blob/master/providers/aws/services/rds/rds_client.py): service adapter · Normalizes RDS CLI responses for checks · `providers/aws/services/rds/rds_client.py`
- [S3 checks](https://github.com/pala46/cloudaudit/tree/master/providers/aws/services/s3): check package · Bucket exposure, encryption, versioning, and logging checks · `providers/aws/services/s3`
- [IAM checks](https://github.com/pala46/cloudaudit/tree/master/providers/aws/services/iam): check package · Root, MFA, password, key hygiene, and admin posture checks · `providers/aws/services/iam`
- [EC2 checks](https://github.com/pala46/cloudaudit/tree/master/providers/aws/services/ec2): check package · Public IP and security group exposure checks · `providers/aws/services/ec2`
- [CloudTrail checks](https://github.com/pala46/cloudaudit/tree/master/providers/aws/services/cloudtrail): check package · Audit trail enablement check · `providers/aws/services/cloudtrail`
- [KMS checks](https://github.com/pala46/cloudaudit/tree/master/providers/aws/services/kms): check package · Key rotation check · `providers/aws/services/kms`
- [RDS checks](https://github.com/pala46/cloudaudit/tree/master/providers/aws/services/rds): check package · Instance encryption check · `providers/aws/services/rds`
- [Lambda checks](https://github.com/pala46/cloudaudit/tree/master/providers/aws/services/awslambda): check package · Public exposure check for functions · `providers/aws/services/awslambda`

### Support assets

Compliance, output, and exception handling

- [Allowlisters](https://github.com/pala46/cloudaudit/blob/master/lib/allowlisters/__init__.py): suppression layer · Handles approved exceptions or suppressed findings · `lib/allowlisters/__init__.py`
- [JSON output](https://github.com/pala46/cloudaudit/blob/master/output/json.py): renderer · Serializes findings as JSON · `output/json.py`
- [HTML output](https://github.com/pala46/cloudaudit/blob/master/output/html.py): renderer · Renders human-readable HTML reports · `output/html.py`
- [CSV output](https://github.com/pala46/cloudaudit/blob/master/output/csv.py): renderer · Exports findings as CSV · `output/csv.py`
- [CIS mapping](https://github.com/pala46/cloudaudit/blob/master/compliance/aws/cis_aws.json): compliance asset · CIS AWS benchmark mapping · `compliance/aws/cis_aws.json`
- [Audit policy](https://github.com/pala46/cloudaudit/blob/master/compliance/aws/audit_user_policy.json): iam policy · Least-privilege audit user policy · `compliance/aws/audit_user_policy.json`

## Connections

- CloudAudit CLI → AWS provider: selects provider · CLI hands execution to the AWS provider for audit orchestration
- CloudAudit CLI → Check model: uses model · CLI consumes shared check and finding abstractions
- CloudAudit CLI → JSON output: formats · CLI can emit JSON reports
- CloudAudit CLI → HTML output: formats · CLI can emit HTML reports
- CloudAudit CLI → CSV output: formats · CLI can emit CSV reports
- CloudAudit CLI → Allowlisters: applies exceptions · Approved findings can be suppressed or filtered
- AWS provider → Region map: uses scope · Provider uses region applicability to enumerate checks and resources
- AWS provider → S3 checks: runs · Provider dispatches S3 checks
- AWS provider → IAM checks: runs · Provider dispatches IAM checks
- AWS provider → EC2 checks: runs · Provider dispatches EC2 checks
- AWS provider → CloudTrail checks: runs · Provider dispatches CloudTrail checks
- AWS provider → KMS checks: runs · Provider dispatches KMS checks
- AWS provider → RDS checks: runs · Provider dispatches RDS checks
- AWS provider → Lambda checks: runs · Provider dispatches Lambda checks
- S3 checks → S3 client: reads · S3 checks query normalized S3 data
- IAM checks → IAM client: reads · IAM checks query normalized IAM data
- EC2 checks → EC2 client: reads · EC2 checks query normalized EC2 data
- CloudTrail checks → CloudTrail client: reads · CloudTrail checks query normalized CloudTrail data
- RDS checks → RDS client: reads · RDS checks query normalized RDS data
- S3 checks → Check model: emits · S3 checks produce standardized findings
- IAM checks → Check model: emits · IAM checks produce standardized findings
- EC2 checks → Check model: emits · EC2 checks produce standardized findings
- CloudTrail checks → Check model: emits · CloudTrail checks produce standardized findings
- KMS checks → Check model: emits · KMS checks produce standardized findings
- RDS checks → Check model: emits · RDS checks produce standardized findings
- Lambda checks → Check model: emits · Lambda checks produce standardized findings
- JSON output → Check model: serializes · JSON renderer serializes common finding structures
- HTML output → Check model: serializes · HTML renderer serializes common finding structures
- CSV output → Check model: serializes · CSV renderer serializes common finding structures
- CIS mapping → Check model: maps · Compliance benchmark maps checks to control language
- Audit policy → AWS provider: authorizes · Policy supports the read-only audit runtime boundary
- Azure stub → AWS provider: future boundary · Placeholder for expanding beyond AWS-first implementation
