Hooks

infra hook: Detect IaC misconfiguration

Sweep Terraform, Dockerfiles, and GitHub Actions for misconfiguration, or score a single snippet, from the command line.

The infra hook flags infrastructure-as-code misconfiguration that is decidable from the file: a network open to the world, a wildcard permission, a secret in a manifest, a root container, an untrusted value in a CI shell. It reads only IaC files (.tf/.tf.json/.hcl, Dockerfile*, .github/workflows/**). It is the deterministic engine behind the infra sub-skill, in scan or check mode.

Run it

node ./.lagune/hooks/infra.mjs # scans every IaC file
node ./.lagune/hooks/infra.mjs -d infra # scans a directory
node ./.lagune/hooks/infra.mjs -f Dockerfile # scans a single file

The scan prints up to two sections. Infrastructure risks found exits non-zero and holds the decidable defects (a 0.0.0.0/0 ingress on a sensitive port, a wildcard IAM statement, a manifest secret, encrypted = false, an unpinned git module, an image that explicitly runs as root, a curl | sh, a CI script injection, permissions: write-all). Infrastructure hardening advisories does not change the exit code (a mutable base tag, a tag-pinned action). A clean run prints no infrastructure risks found.

How to read the verdict

The check mode prints the highest-severity tag it matched (for example public-ingress, iam-wildcard, root-user, curl-pipe, script-injection, write-all), an advisory tag (mutable-tag, unpinned-action), or safe. Only a finding-severity tag exits non-zero.

CLI options

OptionAliasValueDescription
--pattern-pa snippetCheck one snippet. Requires -k. Repeat for several.
--kind-kterraform | dockerfile | github-actionsThe kind the snippet is judged as.
--dir-da directoryScope a scan to a directory. Repeats and combines with -f.
--file-fa fileScope a scan to a single file. Repeats and combines with -d.

With no option it scans every IaC file in the project. -p cannot be combined with -d or -f.

tip

The hook catches the blunt, decidable cases: absent encryption, pull_request_target exposure, and the right IAM scope are judgment the infra sub-skill still covers.

Frequently Asked Questions

Terraform/HCL (.tf, .tf.json, .hcl), Dockerfiles, and GitHub Actions workflow and action YAML under .github/. It reaches those files even though the source scanners skip them.

Last updated on July 24, 2026.

Copyright © 2026-present Weslley Araújo and contributors. Lagune is under the MIT License. Please check the Security Policy.

All product names, trademarks, and registered trademarks mentioned are the property of their respective owners and are used for identification purposes only.