@intentius/chant 0.54.0 → 0.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/audit/discover.d.ts
CHANGED
|
@@ -63,6 +63,15 @@ export declare function ciLexiconForPath(path: string): AuditLexicon | undefined
|
|
|
63
63
|
/**
|
|
64
64
|
* Whether a path is worth reading/fetching at all. Bounds the local walk and,
|
|
65
65
|
* crucially, the remote fetch (so we never pull a whole repo's contents).
|
|
66
|
+
*
|
|
67
|
+
* nginx configs (#1979) ride along the way `wrangler.toml` does: the NGX
|
|
68
|
+
* scanner (`./nginx.ts`) reads them directly, no lexicon plugin — but a
|
|
69
|
+
* scanner can only see what this filter admits, so its own path detector is
|
|
70
|
+
* part of the candidate set. (Found the hard way: the checks shipped wired
|
|
71
|
+
* into the CLI while no `.conf` ever survived collection, so they were
|
|
72
|
+
* unreachable on both the local and hosted paths.) Content confirmation —
|
|
73
|
+
* a `conf.d/` file that isn't nginx — happens at parse time in the scanner,
|
|
74
|
+
* never here.
|
|
66
75
|
*/
|
|
67
76
|
export declare function isCandidatePath(path: string): boolean;
|
|
68
77
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../src/audit/discover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../src/audit/discover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,QAAQ,C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,EAAE,YAAY,EAAE,GAAG,UAAU,EAAE,CAEvF;AAED,4GAA4G;AAC5G,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,CAiB1D"}
|
package/package.json
CHANGED
package/src/audit/discover.ts
CHANGED
|
@@ -33,6 +33,7 @@ import { basename, join, relative } from "path";
|
|
|
33
33
|
import { parseYAML } from "../yaml";
|
|
34
34
|
import type { LexiconPlugin } from "../lexicon";
|
|
35
35
|
import type { AuditInput, AuditLexicon } from "./core";
|
|
36
|
+
import { isNginxConfigPath } from "./nginx";
|
|
36
37
|
|
|
37
38
|
/** Lexicons the auditor knows how to detect and run checks for. */
|
|
38
39
|
export const AUDIT_LEXICONS = ["github", "gitlab", "forgejo", "k8s", "docker", "aws", "azure", "gcp", "helm", "fountain"] as const;
|
|
@@ -267,6 +268,15 @@ export function ciLexiconForPath(path: string): AuditLexicon | undefined {
|
|
|
267
268
|
/**
|
|
268
269
|
* Whether a path is worth reading/fetching at all. Bounds the local walk and,
|
|
269
270
|
* crucially, the remote fetch (so we never pull a whole repo's contents).
|
|
271
|
+
*
|
|
272
|
+
* nginx configs (#1979) ride along the way `wrangler.toml` does: the NGX
|
|
273
|
+
* scanner (`./nginx.ts`) reads them directly, no lexicon plugin — but a
|
|
274
|
+
* scanner can only see what this filter admits, so its own path detector is
|
|
275
|
+
* part of the candidate set. (Found the hard way: the checks shipped wired
|
|
276
|
+
* into the CLI while no `.conf` ever survived collection, so they were
|
|
277
|
+
* unreachable on both the local and hosted paths.) Content confirmation —
|
|
278
|
+
* a `conf.d/` file that isn't nginx — happens at parse time in the scanner,
|
|
279
|
+
* never here.
|
|
270
280
|
*/
|
|
271
281
|
export function isCandidatePath(path: string): boolean {
|
|
272
282
|
const name = basename(path);
|
|
@@ -275,6 +285,7 @@ export function isCandidatePath(path: string): boolean {
|
|
|
275
285
|
if (name === "Chart.yaml") return true;
|
|
276
286
|
if (isSecretBearingName(name)) return true;
|
|
277
287
|
if (isWranglerConfigName(name)) return true;
|
|
288
|
+
if (isNginxConfigPath(path)) return true;
|
|
278
289
|
return /\.(ya?ml|json|template)$/i.test(name);
|
|
279
290
|
}
|
|
280
291
|
|
|
@@ -614,3 +614,38 @@ describe("Wrangler config audit (#446)", () => {
|
|
|
614
614
|
rmSync(dir, { recursive: true, force: true });
|
|
615
615
|
});
|
|
616
616
|
});
|
|
617
|
+
|
|
618
|
+
describe("nginx config audit (#1979)", () => {
|
|
619
|
+
function tmpRepo(): string {
|
|
620
|
+
const dir = join(tmpdir(), `chant-audit-nginx-${process.pid}-${Math.random().toString(36).slice(2)}`);
|
|
621
|
+
mkdirSync(dir, { recursive: true });
|
|
622
|
+
return dir;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
test("audits an nginx config end to end, even when no lexicon is installed", async () => {
|
|
626
|
+
// The whole-path proof the family shipped without: an nginx file must
|
|
627
|
+
// survive candidate COLLECTION (isCandidatePath) before the NGX scanner
|
|
628
|
+
// can ever see it — a scanner-level unit test cannot catch a filter that
|
|
629
|
+
// drops the file first.
|
|
630
|
+
const dir = tmpRepo();
|
|
631
|
+
mkdirSync(join(dir, "nginx"), { recursive: true });
|
|
632
|
+
writeFileSync(
|
|
633
|
+
join(dir, "nginx", "default.conf"),
|
|
634
|
+
"server {\n listen 80;\n location /files {\n autoindex on;\n }\n}\n",
|
|
635
|
+
);
|
|
636
|
+
const result = await auditCommand({ path: dir, plugins: [], format: "json" });
|
|
637
|
+
expect(result.status).toBe("no-lexicons"); // no lexicon installed — still not a clean miss
|
|
638
|
+
expect(result.findings.map((f) => f.checkId)).toContain("NGX003");
|
|
639
|
+
rmSync(dir, { recursive: true, force: true });
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
test("a systemd-style conf.d drop-in is collected but contributes nothing (content-confirmed)", async () => {
|
|
643
|
+
const dir = tmpRepo();
|
|
644
|
+
mkdirSync(join(dir, "conf.d"), { recursive: true });
|
|
645
|
+
writeFileSync(join(dir, "conf.d", "override.conf"), "[Service]\nRestart=always\n");
|
|
646
|
+
const result = await auditCommand({ path: dir, plugins: [] });
|
|
647
|
+
expect(result.success).toBe(true);
|
|
648
|
+
expect(result.findings.map((f) => f.checkId)).not.toEqual(expect.arrayContaining([expect.stringMatching(/^NGX/)]));
|
|
649
|
+
rmSync(dir, { recursive: true, force: true });
|
|
650
|
+
});
|
|
651
|
+
});
|