How pala46/cloudaudit works
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: aws_provider.py AWS provider · models.py Check model · cloudaudit.py CloudAudit CLI · s3 S3 checks
Components 23
Core flow
CLI orchestration and shared domain model
- CloudAudit CLI · Parses args and orchestrates audit runs
cloudaudit.py - Check model · Common metadata, status, and finding abstractions
lib/check/models.py
AWS provider
AWS-specific provider, adapters, and checks
- AWS provider · AWS cloud abstraction and provider orchestration
providers/aws/aws_provider.py - Azure stub · Placeholder for non-AWS provider expansion
providers/azure.py - Region map · Maps services to applicable AWS regions
providers/aws/aws_regions_by_service.json - S3 client · Normalizes S3 CLI responses for checks
providers/aws/services/s3/s3_client.py - IAM client · Normalizes IAM CLI responses for checks
providers/aws/services/iam/iam_client.py - EC2 client · Normalizes EC2 CLI responses for checks
providers/aws/services/ec2/ec2_client.py - CloudTrail client · Normalizes CloudTrail CLI responses for checks
providers/aws/services/cloudtrail/cloudtrail_client.py - RDS client · Normalizes RDS CLI responses for checks
providers/aws/services/rds/rds_client.py - S3 checks · Bucket exposure, encryption, versioning, and logging checks
providers/aws/services/s3 - IAM checks · Root, MFA, password, key hygiene, and admin posture checks
providers/aws/services/iam - EC2 checks · Public IP and security group exposure checks
providers/aws/services/ec2 - CloudTrail checks · Audit trail enablement check
providers/aws/services/cloudtrail - KMS checks · Key rotation check
providers/aws/services/kms - RDS checks · Instance encryption check
providers/aws/services/rds - Lambda checks · Public exposure check for functions
providers/aws/services/awslambda
Support assets
Compliance, output, and exception handling
- Allowlisters · Handles approved exceptions or suppressed findings
lib/allowlisters/__init__.py - JSON output · Serializes findings as JSON
output/json.py - HTML output · Renders human-readable HTML reports
output/html.py - CSV output · Exports findings as CSV
output/csv.py - CIS mapping · CIS AWS benchmark mapping
compliance/aws/cis_aws.json - Audit policy · Least-privilege audit user policy
compliance/aws/audit_user_policy.json
Connections 32
- 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