agentleFS
mejbaurbaharmejbaurbahar/software-tester-skills/skills/iac-container-security-testing/SKILL.md

iac-container-security-testing

Skill1 starsChanged 53 days agoMITView on GitHub

Use when testing Infrastructure-as-Code and container configuration — Terraform/CloudFormation/Helm/Kubernetes scanning (Checkov, tfsec, KICS, kube-linter), policy-as-code (OPA/Conftest/Kyverno), Dockerfile lint (hadolint), image scanning (Trivy), CIS benchmarks, and drift detection.

The file

Files
SKILL.md

IaC & Container Configuration Testing

Misconfiguration is a leading cause of cloud incidents. Shift it left: test infrastructure definitions like code, before they are applied.

Pipeline: lint → scan → policy → plan-test → runtime

terraform fmt -check && terraform validate && tflint
checkov -d . --framework terraform,kubernetes,dockerfile,helm
trivy config --severity HIGH,CRITICAL .
terraform plan -out tf.plan && terraform show -json tf.plan > plan.json
conftest test plan.json -p policy/                     # OPA/Rego on the plan
helm template chart | kubeconform -strict -            # schema validation
kube-linter lint k8s/ ; kubescape scan framework nsa k8s/
hadolint Dockerfile
trivy image --severity HIGH,CRITICAL --ignore-unfixed --exit-code 1 myapp:1.2.3

Checklist by layer

LayerVerify
Cloud IAMNo wildcard actions/principals, root protected with MFA, roles over users, short-lived credentials
NetworkNo world-open admin/DB ports, data in private subnets, restricted egress, TLS everywhere
Storage & DBEncryption at rest, public access blocked, versioning, backups (disaster-recovery-backup-testing), access logging
SecretsNot in Terraform variables/state/env in plain text; secret manager in use; state backend encrypted and locked
LoggingAudit logs enabled, immutable, alerting on IAM/root changes
KubernetesNon-root, readOnlyRootFilesystem, allowPrivilegeEscalation: false, drop capabilities, no privileged/hostPath/hostNetwork, resource limits, default-deny NetworkPolicy, Pod Security restricted, least-privilege RBAC
ImagesMinimal/distroless base, pinned digest, non-root USER, no secrets in layers, multi-stage build, SBOM + signature (supply-chain-dependency-testing)
DockerfileNo latest, COPY over ADD, HEALTHCHECK, no sudo/ssh

Policy-as-code example (Rego)

package terraform.s3
deny[msg] {
  r := input.resource_changes[_]
  r.type == "aws_s3_bucket_public_access_block"
  r.change.after.block_public_acls == false
  msg := sprintf("%s must block public ACLs", [r.address])
}

Enforce the same rules at admission with Kyverno or Gatekeeper (require-non-root, disallow-latest-tag, require-resource-limits). Test the policies too: opa test policy/ -v, kyverno test ..

Test infrastructure behaviour, not just config

Terratest, terraform test or Pulumi tests: create ephemeral infra, assert outputs and reachability, destroy. Add drift detection (terraform plan -detailed-exitcode nightly) and idempotency (second apply = no changes).

Triage

Suppress only with an inline reason, owner and expiry (#checkov:skip=CKV_AWS_18:reason). Prioritise internet-exposed, data-bearing, privileged resources.

Related

cloud-infrastructure-testing, supply-chain-dependency-testing, security-hardening, compliance-testing, configuration-feature-flag-testing

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.