sample-aiml-security-assessment

AGENTS.md

Repository-wide instructions for coding agents working on this AWS AI/ML security assessment framework. It deploys assessment Lambdas with SAM and Step Functions, writes findings CSVs, and renders single- and multi-account HTML reports. The current check inventory, counts, and check IDs are in docs/SECURITY_CHECKS.md.

Start with the task guide

Toolchain and tests

Use the repository .venv/bin/ executables for Python, pip, pytest, Ruff, and cfn-lint. Do not install Python packages globally or rely on a shell activation. Use git and the system-installed sam normally. Setup, environment variables, SAM commands, and the full test commands are in the developer guide’s Running Checks Locally section.

Run everything under tests/ in one pytest session. Test modules load each assessment package’s app.py under a distinct name with importlib.util.spec_from_file_location; a bare import app can resolve to a different package’s module. Run responsible_ai_grc_tests/ in a separate session and generate_consolidated_report/test_generate_report.py from its own directory. Keep assessment_history/ at 100% line and branch coverage.

Use the guide’s whole-repository .venv/bin/ruff check . and .venv/bin/ruff format --check . commands before delivery. Run the relevant pytest sessions, cfn-lint for changed templates, and SAM validation/build when deployment wiring changes. Generate and inspect both report modes when a check, lens, standard, or report UI changes.

Execution and artifact contracts

Check and status contracts

Before delivering assessment changes

  1. Verify the boto3 client, operation, paginator, request/response shape, and the exact evidence behind each outcome. Test successful empty responses where the API permits them.
  2. Audit per-Lambda assessment IAM in both SAM templates and S3 permissions for every artifact reader and writer. Keep assessment-service read actions out of top-level deployment roles.
  3. Test compliant, non-compliant or advisory, no-resource, denied, unsupported-region, and unexpected-error paths with SDK-shaped responses. Cover later pages, list failures, per-resource failures, and two-region behavior where relevant. Assert the exact fallback Check_ID and visible partial results.
  4. Check source-to-lens mappings, AG numbering, AISF derivation and source coverage, CSV schema, selection flags, Step Functions success/skip/catch paths, and missing selected artifacts. Render synthetic single- and multi-account reports and inspect scope, counts, navigation, and filters.
  5. Use only synthetic account IDs, organization IDs, ARNs, and resource identifiers in tests, examples, fixtures, snapshots, and sample reports. Established example account IDs are 123456789012, 111122223333, 444455556666, and 777788889999. Anonymized sample reports additionally use the repeated-digit placeholders from ANONYMIZED_ACCOUNT_IDS in sample-reports/scripts/capture_screenshots.py; keep that list’s order stable, since an ID’s position decides which discovered ID maps to it.
  6. For a catalog change, review AGENTS.md, README.md, docs/DEVELOPER_GUIDE.md, docs/SECURITY_CHECKS.md, the applicable check catalogs, docs/TROUBLESHOOTING.md, CHANGELOG.md, and affected scope, severity, sample-report, and diagram documentation. Update check counts, headings, table-of-contents links, deep links, remediation, and report examples where they drift.
  7. For releasable behavior, dependency, buildspec.yml, consolidator, assessment runtime, or deployment-template changes, add one user-facing CHANGELOG.md Unreleased entry. When deployable files change, include Deployment impact with the exact single-account, CodeBuild, member-role StackSet, and/or central infrastructure actions in the required order. Follow docs/UPGRADING.md.
  8. When responsible_ai_grc_assessments/app.py or its check catalog changes, run .venv/bin/python generate_provenance.py --check; if stale, regenerate provenance.json with generate_provenance.py and commit it. When assessment-history matching changes, run its coverage gate. Anonymize new sample reports, including the changes sample, with sample-reports/scripts/capture_screenshots.py --anonymize-only as described in docs/DEVELOPER_GUIDE.md.