Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion review-enrichment/src/analyzers/iac-misconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const MAX_FINDINGS = 25;
const MAX_LINE_CHARS = 2000;

const CONFIG_PATH_RE =
/(?:^|\/)(?:docker-compose[^/]*\.ya?ml|compose[^/]*\.ya?ml|values(?:\.[^/]+)?\.ya?ml|\.env(?:\.[^/]+)?|.*\.(?:tf|ya?ml|json|toml|ini|conf|env)|Dockerfile(?:\.[^/]+)?|nginx[^/]*\.conf)$/i;
/(?:^|\/)(?:docker-compose[^/]*\.ya?ml|compose[^/]*\.ya?ml|values(?:\.[^/]+)?\.ya?ml|\.env(?:\.[^/]+)?|.*\.(?:tf|tfvars|hcl|ya?ml|json|toml|ini|conf|env)|Dockerfile(?:\.[^/]+)?|nginx[^/]*\.conf)$/i;

const CORS_ORIGIN_RE =
/\b(?:access-control-allow-origin|allow_origin|cors_origin|origin)\b[\s"'=:,\[\]-]*\*/i;
Expand Down
10 changes: 10 additions & 0 deletions review-enrichment/test/iac-misconfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ import {
scanPatchForIacMisconfig,
} from "../dist/analyzers/iac-misconfig.js";

test("isRelevantConfigPath recognizes Terraform .tfvars and HCL files (siblings of .tf)", () => {
// `.tf` was already scanned; `.tfvars` and `.hcl` end after `tf`, so the extension
// group missed them and scanIacMisconfig skipped these canonical IaC files entirely.
assert.ok(isRelevantConfigPath("infra/terraform.tfvars"));
assert.ok(isRelevantConfigPath("env/prod.auto.tfvars"));
assert.ok(isRelevantConfigPath("packer/build.pkr.hcl"));
assert.ok(isRelevantConfigPath("infra/main.tf")); // the pre-existing sibling still matches
assert.equal(isRelevantConfigPath("src/app.ts"), false); // a non-config source file does not
});

test("scanPatchForIacMisconfig flags hostNetwork and compose host network mode", () => {
const k8s = scanPatchForIacMisconfig(
"deploy/k8s/app.yaml",
Expand Down
Loading