Conversation
Adds scripts/cloud_security_assessment.py (Checkov, cfn_nag, cfn-lint plus a Government-oriented custom rule pack normalized to one schema with NIST SP 800-53 Rev. 5, CIS AWS v3.0 and DoD Cloud SRG traceability), the report generator scripts/cloud_security_report.py, and the generated artifacts under security-assessment/ (findings.json, XLSX tracker, narrative report, README). No CloudFormation templates are changed. Co-Authored-By: Erik Rozi <erik.rozi@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
Original prompt from Devin Bot
|
…et-wide TLS deny check, CloudFront TLS policy defaults, per-hit finding IDs, coverage-aware report text, template-revision provenance, --fail-on-incomplete Co-Authored-By: Erik Rozi <erik.rozi@cognition.ai>
…lint batches on invocation errors, content-based finding identity, Checkov/cfn_nag parse-failure coverage, generated-twin compare gating, coverage-aware executive summary; regenerate artifacts Co-Authored-By: Erik Rozi <erik.rozi@cognition.ai>
…les as coverage gaps, check CloudFront ordered CacheBehaviors, read EKS ClusterLogging list form, type-preserving generated-twin comparison, source-aware Terraform coverage; regenerate artifacts Co-Authored-By: Erik Rozi <erik.rozi@cognition.ai>
…on, standalone IAM policy types, report scope and provenance wording, CLI path help Co-Authored-By: Erik Rozi <erik.rozi@cognition.ai>
Co-Authored-By: Erik Rozi <erik.rozi@cognition.ai>
… gaps, keep distinct scanner violations, tolerate baseline schema changes, add tests - S3 BucketEncryption, LoggingConfiguration, Kinesis StreamEncryption, Firehose encryption and Lambda VpcConfig blocks now count as a control only when they carry the required sub-keys in every Fn::If branch - external scanner hits on one resource are deduplicated by (source, check, template, resource, discriminator); cfn-lint uses the property path as discriminator, cfn_nag/checkov the line and message when repeated - baseline carry-forward rebuilds findings field by field, fills defaults, skips and reports rows missing a required field, and records findings schema_version in metadata - JSON evidence lookups are bounded to the current resource - report systemic shares count unique resources and derive denominators from each rule's applies_to - scripts/tests/test_cloud_security_assessment.py: focused regression tests (pytest) - regenerated findings.json, tracker workbook and report from this revision Co-Authored-By: Erik Rozi <erik.rozi@cognition.ai>
Task prompt
Summary
Adds a reusable Cloud Security Assessment runner and commits the generated CDRL A008-style artifacts for the CloudFormation baseline at commit
a0f43bc6. No CloudFormation templates are changed in this PR.scripts/cloud_security_assessment.py— discovers every CloudFormation template (160; 138 generated JSON twins are compared with their YAML source and only drift is reported) and any Terraform (.tf) files (none exist in this revision; the prompt'sEC2/terraform/module is absent onmain, so that part of the method is recorded as not applicable). Runs Checkov 3.3.17, cfn_nag 0.8.10 and cfn-lint 1.56.3 (per-template so an unparseable template cannot abort the scan; cfn-lint followsscripts/lint-single.shconventions — macro examples and Rain fragments excluded,!Rain::templates packaged first), plus a 55-rule Government-oriented rule pack (CSA-ENC-*,CSA-TLS-*,CSA-NET-*,CSA-LOG-*,CSA-IAM-*,CSA-SEC-*,CSA-CFG-*,CSA-BKP-*, …). Every hit is normalized into oneFindingschema withfile:lineevidence, a snippet, CAT I/II/III severity with justification, deterministic finding ID, risk score/rank, NIST SP 800-53 Rev. 5 controls, CIS AWS v3.0 ID where one exists, DoD Cloud Computing SRG area and tool IDs. Tool-only (heuristic) findings are capped at CAT II; corroborating Checkov/cfn_nag hits are merged into the custom finding rather than duplicated. Writesfindings.json, the XLSX tracker (Findings,Summary,Control-Coverage,POAM-Draft,Method) and a console summary.--baselinecarries forward findings that disappear asRemediated in PRonly when every scanner that produced them ran again on that template (otherwise the prior disposition is kept with aNot re-evaluatednote) and adds before/after counts (used by PR 2).--fail-on-incompleteexits 2 for CI when a scanner was skipped, failed or left templates unprocessed.scripts/cloud_security_report.py— renderssecurity-assessment/Cloud-Security-Assessment-Report.mdfromfindings.json(every number in the report is derived from the data).security-assessment/—findings.json,Cloud-Security-Findings-Tracker.xlsx,Cloud-Security-Assessment-Report.md,README.md.Result at baseline: 1,192 findings / 1,174 open — CAT I 9, CAT II 371, CAT III 794 (18 recommended for risk acceptance: intentional public-website buckets and CloudFront origins). 149 of 160 templates have at least one open finding. Every finding has
file:lineevidence and at least one NIST control; all 1,192 finding IDs are unique.Scanner coverage recorded in the artifacts: checkov did not process 7 template(s); cfn_nag did not process 12 template(s); cfn-lint did not process 2 template(s) (Checkov/cfn_nag parser or schema errors and the two StackSets templates whose
!Rain::Embedtarget is a build artifact not in the repository); those templates are covered by the custom rule pack and the remaining scanners and are listed in theMethodsheet. No malformed template files and no custom-rule failures were recorded. Provenance: the report states the assessment checkout SHA andtemplates_commit_sha(last commit touching any assessed template,a0f43bc6) separately, because commits on this branch add assessment files only — the artifacts are necessarily generated one commit before the commit that contains them.Review follow-up (second commit): bucket-wide
aws:SecureTransportdeny semantics forCSA-TLS-001; CloudFrontMinimumProtocolVersionmissing/parameter-default detection; per-hit stable finding IDs; coverage-gated baseline carry-forward; report text for scanner coverage, Terraform scope, systemic-pattern numerators (open findings only) and planned fixes now derived from data.Review follow-up (third commit):
BucketPolicy.Bucketgiven as a literal/!Subname is associated with the bucket whoseBucketNameis the same expression (bucket_policy_targets); a cfn-lint batch that exits with a non-result code, no JSON list, or an invocation-level error (Filename: null) marks the whole batch unprocessed instead of silently dropping it; finding IDs use a content key (CIDR/port/protocol for ingress,Sidor a digest of Effect/Action/Resource for IAM statements) so IDs do not shift when sibling hits are added or removed; Checkovsummary.parsing_errors > 0and cfn_nagFATALpseudo-violations mark the template unprocessed for that tool; a generated JSON twin counts as assessed only when both it and its source parse (generated_json_not_comparedotherwise); the executive-summary coverage sentence is built from tool status/unparsed/excluded lists.Review follow-up (fourth commit): a custom rule that raises on a parsed template is recorded in
metadata.custom_rule_failures, fails--fail-on-incomplete, and blocks the baseline carry-forward from marking that rule's findings on that template as remediated;CSA-TLS-005inspects orderedCacheBehaviorsas well asDefaultCacheBehavior;CSA-LOG-006readsLogging.ClusterLoggingin its CloudFormation list form; generated-twin drift comparison keeps scalar types and null/empty distinctions (onlyFn::GetAZsnull vs""is treated as equivalent) while identity digests keep their text canonicalisation so finding IDs are unchanged; discovery distinguishes well-formed non-template files (skipped) from malformed JSON/YAML (metadata.malformed_files, a coverage gap that fails--fail-on-incomplete) and parses multi-document YAML without error;coverage_gapchecks the custom-rule parsed set only for custom-sourced findings and matches Terraform findings against Checkov's per-directory unprocessed list, so a Terraform finding that disappears is marked remediated when Checkov processed its module. This PR description is rendered fromfindings.jsonand the workbook by a generator, so its counts cannot drift from the committed artifacts.Review follow-up (fifth commit): configuration blocks count as a control only when they carry the required sub-keys in every
Fn::Ifbranch —s3_sse_defaultsforCSA-ENC-001/CSA-ENC-002(an emptyBucketEncryption, a rule list withoutServerSideEncryptionByDefaultor a default withoutSSEAlgorithmis reported as no encryption) andblock_gapfor S3LoggingConfiguration, KinesisStreamEncryption, FirehoseDeliveryStreamEncryptionConfigurationInputand LambdaVpcConfig; JSONprop_linesearches stop at the next resource so a later resource's property is never cited as evidence for an earlier one; external scanner hits are deduplicated by (source, check, template, resource, discriminator) — cfn-lint uses the property path below the resource, cfn_nag/Checkov useline:messageonly when one check fires more than once on one resource — so distinct violations stay distinct and a lone violation keeps its plain ID; baseline carry-forward rebuilds rows field by field (finding_from_dict: unknown keys ignored, defaulted fields filled, rows missing a required field skipped and reported) andmetadata.schema_versionis written and checked; report systemic shares count unique(template, resource)pairs and derive denominators from each rule'sapplies_totypes, failing if a numerator ever exceeds its denominator.scripts/tests/test_cloud_security_assessment.py(pytest, 21 tests) covers parsing and evidence bounds, the S3 and block-gap rules, scanner normalization and merging, stable IDs, baseline schema tolerance, report shares and the committed artifact invariants.Workbook check (openpyxl, data rows):
Findings1192,Summary68,Control-Coverage30,POAM-Draft380,Method23.Top findings
Solutions/CloudFormationEndpointSignals/cfn-endpoint-creationpolicy.yaml:242BastionSGSolutions/CloudFormationEndpointSignals/cfn-endpoint-waitcondition.yaml:264BastionSGSolutions/EC2DomainJoin/EC2-Domain-Join.yaml:170InstanceSecurityGroupEFS/efs_with_automount_to_ec2.yaml:313InstanceSecurityGroupECS/EC2LaunchType/clusters/private-vpc.yaml:455PublicLoadBalancerSGECS/EC2LaunchType/clusters/public-vpc.yaml:323PublicLoadBalancerSGECS/FargateLaunchType/clusters/private-vpc.yaml:293PublicLoadBalancerSGECS/FargateLaunchType/clusters/public-vpc.yaml:159PublicLoadBalancerSGNeptuneDB/Neptune.yaml:311NeptuneDBClusterCloudFormation/MacrosExamples/Count/test.yaml:16BucketToCopyAOnly 9 CAT I findings exist at baseline; rank 10 is the highest-ranked CAT II. The full top 20 with evidence is in the report; all 1,192 rows are in the tracker.
Traceability
n/a.CKV_AWS_*, cfn_nagW*/F*and cfn-lintE*IDs are mapped to the same control sets through a rule-ID map in the runner; unmapped tool checks are recorded with their tool ID and a generic CM-6 mapping, at CAT II or CAT III.How to regenerate
See
security-assessment/README.mdfor options (--baseline,--dispositions,--skip-*,--include-generated-json,--fail-on-incomplete).Link to Devin session: https://app.devin.ai/sessions/8d1eec8831044481a04ed15d422c6da2
Open in Devin Desktop: https://app.devin.ai/desktop/session/8d1eec8831044481a04ed15d422c6da2?variant=devin
Requested by: @erikrozi