@owasp-aghast/aghast 0.8.4 → 0.9.0-rc.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/build-config.d.ts.map +1 -1
- package/dist/build-config.js +101 -2
- package/dist/build-config.js.map +1 -1
- package/dist/check-library.d.ts +25 -0
- package/dist/check-library.d.ts.map +1 -1
- package/dist/check-library.js +165 -0
- package/dist/check-library.js.map +1 -1
- package/dist/ci-metadata.d.ts +42 -0
- package/dist/ci-metadata.d.ts.map +1 -0
- package/dist/ci-metadata.js +131 -0
- package/dist/ci-metadata.js.map +1 -0
- package/dist/cli.js +4 -1
- package/dist/cli.js.map +1 -1
- package/dist/concurrency.d.ts +18 -0
- package/dist/concurrency.d.ts.map +1 -0
- package/dist/concurrency.js +39 -0
- package/dist/concurrency.js.map +1 -0
- package/dist/cost-tracker.d.ts +45 -0
- package/dist/cost-tracker.d.ts.map +1 -0
- package/dist/cost-tracker.js +56 -0
- package/dist/cost-tracker.js.map +1 -0
- package/dist/discoveries/glob-discovery.d.ts +21 -0
- package/dist/discoveries/glob-discovery.d.ts.map +1 -0
- package/dist/discoveries/glob-discovery.js +215 -0
- package/dist/discoveries/glob-discovery.js.map +1 -0
- package/dist/discoveries/script-discovery.d.ts +117 -0
- package/dist/discoveries/script-discovery.d.ts.map +1 -0
- package/dist/discoveries/script-discovery.js +593 -0
- package/dist/discoveries/script-discovery.js.map +1 -0
- package/dist/docs-url.d.ts +14 -0
- package/dist/docs-url.d.ts.map +1 -0
- package/dist/docs-url.js +17 -0
- package/dist/docs-url.js.map +1 -0
- package/dist/error-codes.d.ts +12 -1
- package/dist/error-codes.d.ts.map +1 -1
- package/dist/error-codes.js +16 -2
- package/dist/error-codes.js.map +1 -1
- package/dist/formatters/csv-formatter.d.ts +12 -1
- package/dist/formatters/csv-formatter.d.ts.map +1 -1
- package/dist/formatters/csv-formatter.js +64 -2
- package/dist/formatters/csv-formatter.js.map +1 -1
- package/dist/formatters/html-formatter.d.ts.map +1 -1
- package/dist/formatters/html-formatter.js +43 -3
- package/dist/formatters/html-formatter.js.map +1 -1
- package/dist/formatters/index.d.ts.map +1 -1
- package/dist/formatters/index.js +2 -0
- package/dist/formatters/index.js.map +1 -1
- package/dist/formatters/markdown-formatter.d.ts +61 -0
- package/dist/formatters/markdown-formatter.d.ts.map +1 -0
- package/dist/formatters/markdown-formatter.js +557 -0
- package/dist/formatters/markdown-formatter.js.map +1 -0
- package/dist/formatters/sarif-formatter.d.ts +7 -0
- package/dist/formatters/sarif-formatter.d.ts.map +1 -1
- package/dist/formatters/sarif-formatter.js +80 -0
- package/dist/formatters/sarif-formatter.js.map +1 -1
- package/dist/formatters/types.d.ts +24 -0
- package/dist/formatters/types.d.ts.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +342 -9
- package/dist/index.js.map +1 -1
- package/dist/issue-file-writer.d.ts +21 -0
- package/dist/issue-file-writer.d.ts.map +1 -0
- package/dist/issue-file-writer.js +307 -0
- package/dist/issue-file-writer.js.map +1 -0
- package/dist/judge.d.ts +62 -0
- package/dist/judge.d.ts.map +1 -0
- package/dist/judge.js +305 -0
- package/dist/judge.js.map +1 -0
- package/dist/mock-agent-provider.d.ts +3 -0
- package/dist/mock-agent-provider.d.ts.map +1 -1
- package/dist/mock-agent-provider.js +13 -0
- package/dist/mock-agent-provider.js.map +1 -1
- package/dist/new-check.d.ts.map +1 -1
- package/dist/new-check.js +322 -13
- package/dist/new-check.js.map +1 -1
- package/dist/opencode-provider.d.ts.map +1 -1
- package/dist/opencode-provider.js +33 -0
- package/dist/opencode-provider.js.map +1 -1
- package/dist/repo-scan.d.ts +80 -0
- package/dist/repo-scan.d.ts.map +1 -0
- package/dist/repo-scan.js +250 -0
- package/dist/repo-scan.js.map +1 -0
- package/dist/result-handlers/pr-comment-handler.d.ts +136 -0
- package/dist/result-handlers/pr-comment-handler.d.ts.map +1 -0
- package/dist/result-handlers/pr-comment-handler.js +381 -0
- package/dist/result-handlers/pr-comment-handler.js.map +1 -0
- package/dist/retry.d.ts +128 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +261 -0
- package/dist/retry.js.map +1 -0
- package/dist/runtime-config.d.ts.map +1 -1
- package/dist/runtime-config.js +62 -0
- package/dist/runtime-config.js.map +1 -1
- package/dist/scan-runner.d.ts +31 -22
- package/dist/scan-runner.d.ts.map +1 -1
- package/dist/scan-runner.js +145 -100
- package/dist/scan-runner.js.map +1 -1
- package/dist/semgrep-runner.js +6 -4
- package/dist/semgrep-runner.js.map +1 -1
- package/dist/stats.d.ts.map +1 -1
- package/dist/stats.js +4 -1
- package/dist/stats.js.map +1 -1
- package/dist/types.d.ts +149 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Script-based target discovery.
|
|
3
|
+
*
|
|
4
|
+
* Runs a user-provided script (`node` or `bash`) in the target repository
|
|
5
|
+
* and parses its stdout to produce discovery targets. Useful when target
|
|
6
|
+
* discovery is too custom for Semgrep / SARIF / OpenAnt — e.g. parsing an
|
|
7
|
+
* OpenAPI spec, querying a build manifest, walking a database schema, etc.
|
|
8
|
+
*
|
|
9
|
+
* ─── Trust model ─────────────────────────────────────────────────────────────
|
|
10
|
+
*
|
|
11
|
+
* Scripts run with the full privileges of the aghast process. They are not
|
|
12
|
+
* sandboxed. Treat any script referenced by a check definition as trusted
|
|
13
|
+
* code — only enable script-discovery checks whose script you (or your team)
|
|
14
|
+
* have read and audited.
|
|
15
|
+
*
|
|
16
|
+
* Defensive measures applied here:
|
|
17
|
+
* - Script path must resolve INSIDE the configured check folder or repo
|
|
18
|
+
* (no `..` escape, no absolute paths to /etc/shadow, etc.).
|
|
19
|
+
* - Symlink-aware: both the script path and `cwd` are realpath'd and
|
|
20
|
+
* re-checked against the repo root, so a symlink inside the check folder
|
|
21
|
+
* pointing outside the repo cannot be used to execute external code.
|
|
22
|
+
* - Spawned with `shell: false` and array args — no shell interpolation, no
|
|
23
|
+
* command injection from check-definition fields.
|
|
24
|
+
* - Spawned with a curated environment: only a small allow-list of neutral
|
|
25
|
+
* env vars (PATH, HOME, locale, temp dirs, Windows essentials) is forwarded.
|
|
26
|
+
* As defence-in-depth, any var matching a known-secret pattern (`*_KEY`,
|
|
27
|
+
* `*_TOKEN`, `*_SECRET`, `*_PASSWORD`, or `ANTHROPIC_*` / `OPENAI_*` /
|
|
28
|
+
* `GITHUB_*` / `AGHAST_*` / `AWS_*` / `GCP_*` / `AZURE_*` prefixes) is
|
|
29
|
+
* also explicitly dropped. Allow-list matching is case-insensitive so
|
|
30
|
+
* the Windows-style `Path` / `SystemRoot` casing works the same as POSIX
|
|
31
|
+
* `PATH`.
|
|
32
|
+
* - cwd, when supplied, must resolve (and realpath) inside the repo root.
|
|
33
|
+
* - Hard timeout (default 30s, configurable per check).
|
|
34
|
+
* - Stdout is bounded (8 MiB) to prevent memory exhaustion from runaway scripts.
|
|
35
|
+
* - Both the line-format and JSON-format output paths cap the number of
|
|
36
|
+
* parsed targets (MAX_LINE_TARGETS / MAX_JSON_TARGETS) to bound memory
|
|
37
|
+
* even if a script floods within the stdout cap.
|
|
38
|
+
* - Output is parsed as data (lines / JSON) — never `eval`-ed.
|
|
39
|
+
* - File paths returned by the script are validated to be relative & inside
|
|
40
|
+
* the repo (no `..` escape, no absolute paths) before they are forwarded
|
|
41
|
+
* to the AI prompt or snippet extractor.
|
|
42
|
+
* - On `bash` scripts, Windows is unsupported (no system bash) and a clear
|
|
43
|
+
* error is raised rather than silently falling back.
|
|
44
|
+
*/
|
|
45
|
+
import type { TargetDiscovery } from '../discovery.js';
|
|
46
|
+
/**
|
|
47
|
+
* Build a curated environment for the spawned discovery script.
|
|
48
|
+
*
|
|
49
|
+
* Discovery scripts need to walk the repo, possibly run small helper tools,
|
|
50
|
+
* but they never need API credentials. We start from a minimal allow-list of
|
|
51
|
+
* "neutral" env vars (PATH/locale/temp dirs) and then ALSO drop any var whose
|
|
52
|
+
* name matches a known-secret pattern even if it slipped through. Both layers
|
|
53
|
+
* are defence-in-depth.
|
|
54
|
+
*
|
|
55
|
+
* Exported for testing.
|
|
56
|
+
*/
|
|
57
|
+
export declare function buildScriptEnv(parent?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
58
|
+
interface ScriptTargetInput {
|
|
59
|
+
file: string;
|
|
60
|
+
startLine?: number;
|
|
61
|
+
endLine?: number;
|
|
62
|
+
message?: string;
|
|
63
|
+
snippet?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* True when `candidateAbs` lives inside `rootAbs`. Both must be absolute.
|
|
67
|
+
*
|
|
68
|
+
* Two ways to be outside, and both matter:
|
|
69
|
+
* - a `..` prefix, the ordinary case;
|
|
70
|
+
* - an absolute result, which is what `relative()` returns on Windows when
|
|
71
|
+
* the two paths are on different drives (`C:\repo` vs `D:\checks`).
|
|
72
|
+
*
|
|
73
|
+
* Exported so the rule can be unit-tested against Windows-style paths on any
|
|
74
|
+
* platform. It exists as a single function because it previously did not: two
|
|
75
|
+
* call sites implemented the rule separately, one omitted the absolute-path
|
|
76
|
+
* case, and cross-drive layouts were rejected as a result.
|
|
77
|
+
*
|
|
78
|
+
* Pass a `pathApi` of `path.win32` or `path.posix` to test either flavour.
|
|
79
|
+
*/
|
|
80
|
+
export declare function isInsideRoot(rootAbs: string, candidateAbs: string, pathApi?: {
|
|
81
|
+
relative: (a: string, b: string) => string;
|
|
82
|
+
isAbsolute: (p: string) => boolean;
|
|
83
|
+
}): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Parse stdout into a list of discovery target inputs.
|
|
86
|
+
* - `lines`: one file path per non-empty, non-comment line.
|
|
87
|
+
* - `json-array`: a JSON array of strings (file paths) or objects.
|
|
88
|
+
* - `json-object`: an object with a `targets` array of strings or objects.
|
|
89
|
+
*
|
|
90
|
+
* Both `lines` and JSON formats cap parsed targets at MAX_LINE_TARGETS /
|
|
91
|
+
* MAX_JSON_TARGETS (100k each); the rest are dropped with a warning log.
|
|
92
|
+
*
|
|
93
|
+
* Output is treated as DATA: never eval'd, never interpolated into commands.
|
|
94
|
+
*/
|
|
95
|
+
export declare function parseScriptOutput(raw: string, format: 'lines' | 'json-array' | 'json-object'): ScriptTargetInput[];
|
|
96
|
+
interface RunScriptResult {
|
|
97
|
+
stdout: string;
|
|
98
|
+
exitCode: number | null;
|
|
99
|
+
signal: NodeJS.Signals | null;
|
|
100
|
+
stderr: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Execute the script as a child process and capture stdout.
|
|
104
|
+
* - Uses `spawn` with `shell: false`: never invoke a shell, never interpolate.
|
|
105
|
+
* - Passes a curated env (no API keys / tokens) — see `buildScriptEnv`.
|
|
106
|
+
* - Bounds stdout/stderr buffers and kills the process on timeout.
|
|
107
|
+
*/
|
|
108
|
+
export declare function runScript(opts: {
|
|
109
|
+
command: string;
|
|
110
|
+
args: string[];
|
|
111
|
+
cwd: string;
|
|
112
|
+
timeoutMs: number;
|
|
113
|
+
env?: NodeJS.ProcessEnv;
|
|
114
|
+
}): Promise<RunScriptResult>;
|
|
115
|
+
export declare const scriptDiscovery: TargetDiscovery;
|
|
116
|
+
export {};
|
|
117
|
+
//# sourceMappingURL=script-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-discovery.d.ts","sourceRoot":"","sources":["../../src/discoveries/script-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAsC,MAAM,iBAAiB,CAAC;AAoB3F;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAAC,UAAU,CA8DzF;AAED,UAAU,iBAAiB;IACzB,IAAI,EA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