@parcha/agentrun-serve 0.1.0-beta.58 → 0.1.0-beta.59
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/CHANGELOG.md +325 -1
- package/README.md +332 -88
- package/dist/acp-package.d.ts +5 -1
- package/dist/acp-package.js +19 -2
- package/dist/adapters.d.ts +23 -2
- package/dist/adapters.js +106 -33
- package/dist/agents-store.js +1 -1
- package/dist/answer-text.d.ts +3 -0
- package/dist/answer-text.js +22 -0
- package/dist/attach-conformance.js +5 -4
- package/dist/box-paths.d.ts +3 -2
- package/dist/box-paths.js +5 -4
- package/dist/browser-computer.d.ts +3 -8
- package/dist/browser-computer.js +12 -35
- package/dist/browser-cost.js +94 -20
- package/dist/capacity.d.ts +1 -1
- package/dist/capacity.js +3 -3
- package/dist/chatgpt-plan.d.ts +5 -0
- package/dist/chatgpt-plan.js +25 -11
- package/dist/claude-login-token.d.ts +15 -11
- package/dist/claude-login-token.js +167 -107
- package/dist/claude-login.d.ts +76 -31
- package/dist/claude-login.js +426 -79
- package/dist/claude-sign-in.d.ts +3 -0
- package/dist/claude-sign-in.js +10 -1
- package/dist/cli.js +323 -292
- package/dist/composio-made.d.ts +1 -6
- package/dist/composio-made.js +1 -6
- package/dist/composio-owners.d.ts +26 -0
- package/dist/composio-owners.js +36 -0
- package/dist/composio-preset.d.ts +56 -23
- package/dist/composio-preset.js +173 -77
- package/dist/composio-triggers.d.ts +4 -4
- package/dist/composio-triggers.js +6 -7
- package/dist/compute-cost.js +11 -2
- package/dist/computer-attach.d.ts +6 -3
- package/dist/computer-attach.js +41 -29
- package/dist/computer-held-routes.d.ts +1 -1
- package/dist/computer-held-routes.js +9 -4
- package/dist/computer-keys.d.ts +11 -1
- package/dist/computer-keys.js +26 -1
- package/dist/computer-record.js +3 -1
- package/dist/computer-view.d.ts +5 -3
- package/dist/computer-view.js +10 -6
- package/dist/computer-viewer.js +36 -7
- package/dist/computers.d.ts +2 -1
- package/dist/computers.js +6 -3
- package/dist/console/THIRD-PARTY-NOTICES.txt +50 -0
- package/dist/console/assets/backend-BztxEAvb.js +166 -0
- package/dist/console/assets/index-LwNL4L9q.js +619 -0
- package/dist/console/assets/share-L84tlUDW.js +6 -0
- package/dist/console/assets/styles-CaRKlHke.js +291 -0
- package/dist/console/assets/styles-DQo8rzY-.css +1 -0
- package/dist/console/index.html +4 -3
- package/dist/console/share.html +17 -0
- package/dist/decisions.d.ts +17 -7
- package/dist/decisions.js +41 -15
- package/dist/dial-relay.js +10 -4
- package/dist/docker-daemon.js +4 -5
- package/dist/docker-host-addresses.js +29 -11
- package/dist/email/account.d.ts +6 -0
- package/dist/email/account.js +6 -0
- package/dist/email/authentication.d.ts +21 -0
- package/dist/email/authentication.js +106 -0
- package/dist/email/email-faux.d.ts +11 -2
- package/dist/email/email-faux.js +21 -5
- package/dist/email/mail.d.ts +25 -0
- package/dist/email/mail.js +58 -2
- package/dist/email/names.js +2 -2
- package/dist/email/tools.d.ts +9 -4
- package/dist/email/tools.js +95 -13
- package/dist/env-switch.d.ts +12 -2
- package/dist/env-switch.js +23 -3
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +11 -1
- package/dist/fal-price.js +33 -0
- package/dist/faux-computers.js +1 -1
- package/dist/filed-answer.d.ts +2 -2
- package/dist/filed-answer.js +2 -2
- package/dist/graph-served.d.ts +10 -5
- package/dist/graph-served.js +40 -10
- package/dist/handed-values.js +1 -2
- package/dist/harness-check.d.ts +2 -1
- package/dist/harness-check.js +45 -12
- package/dist/harness-keys.js +9 -6
- package/dist/harness-opencode/facts.js +2 -0
- package/dist/harness-recipe-entry.d.ts +9 -3
- package/dist/harness-recipe-entry.js +18 -9
- package/dist/harness-recipe.d.ts +21 -0
- package/dist/harness-recipe.js +25 -3
- package/dist/harness-table.d.ts +8 -0
- package/dist/harness-table.js +17 -6
- package/dist/helper-env.d.ts +4 -1
- package/dist/helper-env.js +4 -1
- package/dist/host-check.d.ts +2 -3
- package/dist/host-check.js +13 -7
- package/dist/hosted-search.js +1 -1
- package/dist/import.d.ts +11 -8
- package/dist/import.js +437 -186
- package/dist/key-refusal.d.ts +9 -2
- package/dist/key-refusal.js +86 -32
- package/dist/learn/audit.d.ts +8 -5
- package/dist/learn/audit.js +15 -7
- package/dist/learn/compile.d.ts +5 -2
- package/dist/learn/compile.js +45 -21
- package/dist/learn/field-check.d.ts +111 -0
- package/dist/learn/field-check.js +174 -0
- package/dist/learn/ledger.d.ts +32 -29
- package/dist/learn/ledger.js +26 -19
- package/dist/learn/promote.d.ts +79 -36
- package/dist/learn/promote.js +60 -65
- package/dist/learn/secrets.d.ts +4 -0
- package/dist/learn/secrets.js +12 -0
- package/dist/learned-nodes.d.ts +8 -5
- package/dist/learned-nodes.js +8 -5
- package/dist/learned-workflow.d.ts +2 -1
- package/dist/learned-workflow.js +13 -10
- package/dist/learning-cost.d.ts +25 -8
- package/dist/learning-cost.js +23 -8
- package/dist/learning-setting.d.ts +6 -0
- package/dist/learning-setting.js +11 -1
- package/dist/listen-first.d.ts +5 -4
- package/dist/listen-first.js +4 -5
- package/dist/live-reach.d.ts +7 -0
- package/dist/live-reach.js +7 -0
- package/dist/mcp-api-only-origins.d.ts +15 -0
- package/dist/mcp-api-only-origins.js +40 -0
- package/dist/mcp-gateway.d.ts +16 -2
- package/dist/mcp-gateway.js +41 -3
- package/dist/mcp-oauth.d.ts +1 -1
- package/dist/mcp-oauth.js +3 -2
- package/dist/mcp-probe.d.ts +3 -0
- package/dist/mcp-probe.js +3 -0
- package/dist/mcp-secret-writes.d.ts +24 -2
- package/dist/mcp-secret-writes.js +30 -2
- package/dist/mcp-servers-store.d.ts +52 -14
- package/dist/mcp-servers-store.js +165 -61
- package/dist/mcp-sources.d.ts +1 -2
- package/dist/mcp-sources.js +1 -2
- package/dist/mcp-store.d.ts +5 -5
- package/dist/mcp-store.js +3 -3
- package/dist/mcp.js +1 -1
- package/dist/model-gateway.d.ts +1 -1
- package/dist/model-gateway.js +20 -36
- package/dist/ollama-provider.d.ts +23 -9
- package/dist/ollama-provider.js +49 -20
- package/dist/openapi.js +202 -51
- package/dist/otel/genai.d.ts +83 -7
- package/dist/otel/genai.js +69 -9
- package/dist/otel/tracer.d.ts +42 -13
- package/dist/otel/tracer.js +241 -56
- package/dist/page.d.ts +7 -1
- package/dist/page.js +76 -22
- package/dist/paid-calls.d.ts +6 -4
- package/dist/paid-calls.js +15 -7
- package/dist/place-offers.d.ts +55 -34
- package/dist/place-offers.js +93 -54
- package/dist/place.d.ts +13 -14
- package/dist/place.js +56 -41
- package/dist/print.js +1 -1
- package/dist/provider.d.ts +3 -2
- package/dist/provider.js +17 -8
- package/dist/redact/match.d.ts +27 -9
- package/dist/redact/match.js +266 -57
- package/dist/run-census.d.ts +1 -1
- package/dist/run-census.js +4 -5
- package/dist/run-cut.js +4 -5
- package/dist/run-export-store.d.ts +15 -0
- package/dist/run-export-store.js +30 -0
- package/dist/run-export.d.ts +139 -0
- package/dist/run-export.js +379 -0
- package/dist/run-file-cut.d.ts +5 -0
- package/dist/run-file-cut.js +13 -0
- package/dist/run-launch.js +16 -3
- package/dist/run-model-key.d.ts +15 -6
- package/dist/run-model-key.js +30 -31
- package/dist/run-reads-over-store.js +4 -4
- package/dist/run-secrets.js +3 -5
- package/dist/run-timeline-served.js +3 -1
- package/dist/runnable.js +2 -2
- package/dist/runner/adapter-loop.d.ts +35 -18
- package/dist/runner/adapter-loop.js +94 -47
- package/dist/runner/adapter-run-spec.d.ts +14 -1
- package/dist/runner/adapter-run-spec.js +64 -28
- package/dist/runner/adapters/pi.js +4 -2
- package/dist/runner/audit.d.ts +8 -5
- package/dist/runner/audit.js +37 -17
- package/dist/runner/beside.js +5 -6
- package/dist/runner/claim-secrets.d.ts +10 -3
- package/dist/runner/claim-secrets.js +29 -13
- package/dist/runner/cli-run-spec.d.ts +18 -0
- package/dist/runner/cli-run-spec.js +81 -46
- package/dist/runner/compare-end.d.ts +2 -1
- package/dist/runner/compare-end.js +25 -10
- package/dist/runner/conformance/harness.js +2 -3
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/harness-loops.js +3 -3
- package/dist/runner/held.d.ts +5 -2
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +22 -4
- package/dist/runner/learned-first.js +20 -4
- package/dist/runner/learning-end.d.ts +2 -8
- package/dist/runner/learning-end.js +11 -19
- package/dist/runner/live-ticker.js +7 -5
- package/dist/runner/loop-contract.d.ts +0 -2
- package/dist/runner/loop.d.ts +7 -0
- package/dist/runner/loop.js +1 -0
- package/dist/runner/main.js +12 -11
- package/dist/runner/mcp-claim.js +21 -5
- package/dist/runner/meta-tools.js +3 -2
- package/dist/runner/metrics.d.ts +7 -0
- package/dist/runner/metrics.js +19 -0
- package/dist/runner/model-route.d.ts +10 -7
- package/dist/runner/model-route.js +79 -15
- package/dist/runner/native-loop.js +10 -8
- package/dist/runner/presence.d.ts +1 -4
- package/dist/runner/presence.js +6 -8
- package/dist/runner/promotion.d.ts +25 -13
- package/dist/runner/promotion.js +125 -50
- package/dist/runner/redact.d.ts +3 -1
- package/dist/runner/redact.js +5 -3
- package/dist/runner/responses-fetch.d.ts +36 -0
- package/dist/runner/responses-fetch.js +511 -0
- package/dist/runner/run-child-host.d.ts +20 -5
- package/dist/runner/run-child-host.js +179 -77
- package/dist/runner/run-child.js +11 -4
- package/dist/runner/runner-check.js +5 -1
- package/dist/runner/runner.d.ts +2 -3
- package/dist/runner/runner.js +13 -9
- package/dist/runner/sdk-loop.js +8 -8
- package/dist/runner/spec-holds.d.ts +8 -1
- package/dist/runner/spec-holds.js +9 -4
- package/dist/runner/workflow-calls.d.ts +9 -0
- package/dist/runner/workflow-calls.js +150 -0
- package/dist/runner/workflow-first.d.ts +120 -32
- package/dist/runner/workflow-first.js +218 -94
- package/dist/runner/workflow-spec.js +1 -1
- package/dist/runs-over-store.js +8 -7
- package/dist/save-once.d.ts +14 -0
- package/dist/save-once.js +31 -0
- package/dist/scrub-command.d.ts +34 -31
- package/dist/scrub-command.js +116 -147
- package/dist/sdk/runs.d.ts +6 -0
- package/dist/sdk/runs.js +89 -10
- package/dist/seal-key.js +4 -4
- package/dist/secret-cut.d.ts +3 -0
- package/dist/secret-cut.js +7 -1
- package/dist/secret-rules.d.ts +8 -1
- package/dist/secret-rules.js +482 -53
- package/dist/secrets.d.ts +51 -9
- package/dist/secrets.js +311 -21
- package/dist/server-keys.d.ts +4 -3
- package/dist/server-keys.js +4 -3
- package/dist/server-secrets-store.js +2 -4
- package/dist/server.d.ts +15 -3
- package/dist/server.js +312 -80
- package/dist/share-context.d.ts +22 -0
- package/dist/share-context.js +76 -0
- package/dist/shell-lex.d.ts +105 -0
- package/dist/shell-lex.js +646 -0
- package/dist/sign-ins-store.d.ts +5 -7
- package/dist/sign-ins-store.js +12 -16
- package/dist/sign-ins.d.ts +7 -11
- package/dist/sign-ins.js +40 -41
- package/dist/skills/agentrun-serve/SKILL.md +5 -2
- package/dist/start-switches.d.ts +6 -5
- package/dist/start-switches.js +8 -4
- package/dist/stats.d.ts +5 -1
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.js +2 -2
- package/dist/store/dialect.d.ts +4 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/mcp-record-keys.d.ts +10 -0
- package/dist/store/mcp-record-keys.js +13 -0
- package/dist/store/postgres/dialect.js +2 -0
- package/dist/store/postgres/migrations/0029_run_launch_census_settle.sql +28 -0
- package/dist/store/postgres/migrations/0030_learning_ledger_epoch.sql +40 -0
- package/dist/store/postgres/migrations/0031_learning_ledger_calls.sql +12 -0
- package/dist/store/postgres/store.js +4 -0
- package/dist/store/schema.d.ts +33 -10
- package/dist/store/schema.js +70 -16
- package/dist/store/seal.d.ts +4 -1
- package/dist/store/sqlite/run-launch.d.ts +3 -10
- package/dist/store/sqlite/run-launch.js +12 -23
- package/dist/store/sqlite/run-patch.d.ts +17 -10
- package/dist/store/sqlite/run-patch.js +50 -13
- package/dist/store/sqlite/store.d.ts +3 -0
- package/dist/store/sqlite/store.js +116 -34
- package/dist/store/store-schema.js +3 -4
- package/dist/store/store.d.ts +67 -32
- package/dist/store/store.js +14 -11
- package/dist/store-reads/analytics.d.ts +2 -1
- package/dist/store-reads/analytics.js +7 -5
- package/dist/store-reads/learning.d.ts +35 -26
- package/dist/store-reads/learning.js +120 -92
- package/dist/store-reads/stats.d.ts +2 -2
- package/dist/store-reads/stats.js +13 -7
- package/dist/store-view.js +10 -7
- package/dist/suggestions.d.ts +1 -1
- package/dist/suggestions.js +29 -13
- package/dist/template-eval.d.ts +72 -9
- package/dist/template-eval.js +358 -64
- package/dist/timeline/labels.d.ts +1 -1
- package/dist/timeline/labels.js +4 -3
- package/dist/timeline/timeline.d.ts +23 -11
- package/dist/timeline/timeline.js +115 -31
- package/dist/timeline/web-calls.d.ts +8 -6
- package/dist/timeline/web-calls.js +10 -6
- package/dist/tool-gate.d.ts +13 -1
- package/dist/tool-gate.js +43 -3
- package/dist/tool-keys-store.js +2 -4
- package/dist/tool-keys.d.ts +11 -0
- package/dist/tool-keys.js +16 -0
- package/dist/tool-plane.d.ts +50 -11
- package/dist/tool-plane.js +94 -30
- package/dist/tools.d.ts +5 -1
- package/dist/tools.js +7 -7
- package/dist/trigger-email.js +12 -6
- package/dist/triggers.d.ts +15 -34
- package/dist/triggers.js +119 -126
- package/dist/validate.d.ts +8 -1
- package/dist/validate.js +163 -23
- package/dist/web-fake.d.ts +2 -1
- package/dist/web-fake.js +8 -6
- package/dist/web-fetch.d.ts +8 -6
- package/dist/web-fetch.js +13 -11
- package/dist/web-holds.d.ts +32 -0
- package/dist/web-holds.js +86 -0
- package/dist/web-run.d.ts +32 -5
- package/dist/web-run.js +75 -28
- package/dist/web-save.js +23 -12
- package/dist/web-search.js +14 -25
- package/dist/wires.d.ts +4 -3
- package/dist/wires.js +5 -4
- package/dist/workspace/archil-claim.d.ts +12 -5
- package/dist/workspace/archil-claim.js +45 -5
- package/dist/workspace/attach.js +52 -19
- package/dist/workspace/attached-computers.d.ts +6 -2
- package/dist/workspace/attached-computers.js +5 -4
- package/dist/workspace/computer-deps.d.ts +23 -6
- package/dist/workspace/computer-deps.js +35 -17
- package/dist/workspace/computer-for-claim.d.ts +21 -4
- package/dist/workspace/computer-for-claim.js +160 -54
- package/dist/workspace/computer-intervals.d.ts +2 -0
- package/dist/workspace/computer-intervals.js +1 -1
- package/dist/workspace/computer-janitor.d.ts +48 -14
- package/dist/workspace/computer-janitor.js +153 -44
- package/dist/workspace/computer-kept.d.ts +158 -32
- package/dist/workspace/computer-kept.js +288 -63
- package/dist/workspace/computer-providers.d.ts +8 -3
- package/dist/workspace/computer-providers.js +12 -5
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/local.js +41 -1
- package/dist/workspace/mount-revoke-left.d.ts +31 -0
- package/dist/workspace/mount-revoke-left.js +72 -0
- package/dist/workspace/paired-route.js +4 -5
- package/dist/workspace/resolve-computer.d.ts +5 -2
- package/dist/workspace/resolve-computer.js +9 -3
- package/dist/workspace/run-end-computers.d.ts +11 -5
- package/dist/workspace/run-end-computers.js +153 -28
- package/dist/workspace/run-tools.d.ts +22 -3
- package/dist/workspace/run-tools.js +17 -5
- package/dist/workspace/run-workspace.d.ts +14 -1
- package/dist/workspace/run-workspace.js +34 -1
- package/dist/workspace/workspace.d.ts +6 -0
- package/package.json +12 -13
- package/skills/agentrun-serve/SKILL.md +5 -2
- package/templates/README.md +22 -6
- package/dist/console/assets/backend-CSAWUqtZ.js +0 -166
- package/dist/console/assets/index-Bwn1oTem.css +0 -1
- package/dist/console/assets/index-DPh29cyz.js +0 -747
package/dist/secret-rules.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// in its length (secret-scrub.test.mjs walks them).
|
|
12
12
|
import { heldNeedles, MIN_SECRET } from "./learn/secrets.js";
|
|
13
13
|
import { cutSpans, SECRET_SHAPES, shapeSpans } from "./redact/match.js";
|
|
14
|
+
import { argWords, commandLimit, lex, lexCount, wordFrom, wordText } from "./shell-lex.js";
|
|
14
15
|
/** Whether a cut of each kind may be put back by a preview: fixed per kind, never per rule or per cut. */
|
|
15
16
|
export const RESTORABLE = Object.freeze({ format: false, held: false, dump: false, label: true, personal: true, jev: true });
|
|
16
17
|
/** The index of the last of `places` (sorted) before `at`, or -1. */
|
|
@@ -99,6 +100,27 @@ const CONTROLS = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g;
|
|
|
99
100
|
/** A Windows path from its drive, written as typed (one backslash a separator, never `C:\\`: that is a path a JSON
|
|
100
101
|
* string holds, its backslashes escapes the next view decodes), through every character a path holds. */
|
|
101
102
|
const DRIVE_PATH = /(?<![A-Za-z0-9])[A-Za-z]:\\(?!\\)[^\s"'\x60<>|]{0,4096}/g;
|
|
103
|
+
/** The same inside quotes, blanks and all, up to a closing quote on its line (`"C:\Program Files\Redis\redis-cli.exe"`:
|
|
104
|
+
* `\R` and `\r` there are separators, and a blank does not end the path). A quote left open is no path: its escapes
|
|
105
|
+
* are read as escapes, so a value never runs on through a kept `\n`. */
|
|
106
|
+
const QUOTED_DRIVE_PATH = /(?<=["'])[A-Za-z]:\\(?!\\)[^"'\n]{0,4096}(?=["'])/g;
|
|
107
|
+
/** A relative Windows path (`.\redis-cli.exe`, `..\bin\npm.cmd`), as written: its backslashes are separators too. */
|
|
108
|
+
const DOT_PATH = /(?<![^\s"'=(])\.{1,2}\\(?!\\)[^\s"'\x60<>|]{0,4096}/g;
|
|
109
|
+
/** The spans of `text` that are Windows paths (DRIVE_PATH, QUOTED_DRIVE_PATH, DOT_PATH), merged and sorted. */
|
|
110
|
+
function windowsPaths(text) {
|
|
111
|
+
const spans = [DRIVE_PATH, QUOTED_DRIVE_PATH, DOT_PATH]
|
|
112
|
+
.flatMap((re) => [...text.matchAll(re)].map((m) => [m.index, m.index + m[0].length]))
|
|
113
|
+
.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
|
114
|
+
const out = [];
|
|
115
|
+
for (const span of spans) {
|
|
116
|
+
const last = out[out.length - 1];
|
|
117
|
+
if (last && span[0] <= last[1])
|
|
118
|
+
last[1] = Math.max(last[1], span[1]);
|
|
119
|
+
else
|
|
120
|
+
out.push(span);
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
102
124
|
const DECODED = { '"': '"', "\\": "\\", "/": "/", b: "\b", f: "\f", n: "\n", r: "\r", t: "\t" };
|
|
103
125
|
/** `text` decoded once as a JSON string's body: each escape read as the character it stands for (no exception: a
|
|
104
126
|
* backslash in a Windows path is a JSON escape here like any other, and the raw view reads the path as written). An
|
|
@@ -154,10 +176,11 @@ function decodeOnce(text) {
|
|
|
154
176
|
/** `text` as the rules read it: each of `delimiters` blanked (the quotes the text it was decoded from held as written:
|
|
155
177
|
* that text's JSON strings' delimiters, which would otherwise close a quoted value that was never one), each escape in
|
|
156
178
|
* it blanked (a blank for each of its characters, so offsets hold), but one
|
|
157
|
-
* that stands whole inside a Windows path (`C:\Users\nina
|
|
158
|
-
* written: the next view decodes it), and each control character a
|
|
179
|
+
* that stands whole inside a Windows path (`C:\Users\nina`, `"C:\Program Files\Redis\redis-cli.exe"`, `.\npm.cmd`:
|
|
180
|
+
* there a backslash is the path's separator, read as written: the next view decodes it), and each control character a
|
|
181
|
+
* blank. So no value starts on an escape's letter
|
|
159
182
|
* (`\tgit@...` reads a blank and `git@...`) and none runs through one. */
|
|
160
|
-
function blanked(text, escapes, delimiters = []) {
|
|
183
|
+
function blanked(text, escapes, delimiters = [], paths = true) {
|
|
161
184
|
let plain = text.replace(CONTROLS, " ");
|
|
162
185
|
if (delimiters.length) {
|
|
163
186
|
const chars = plain.split("");
|
|
@@ -167,7 +190,7 @@ function blanked(text, escapes, delimiters = []) {
|
|
|
167
190
|
}
|
|
168
191
|
if (!escapes.length)
|
|
169
192
|
return { text: plain, escapes: [] };
|
|
170
|
-
const drives =
|
|
193
|
+
const drives = paths ? windowsPaths(text) : [];
|
|
171
194
|
const parts = [];
|
|
172
195
|
const cut = [];
|
|
173
196
|
let from = 0;
|
|
@@ -199,7 +222,9 @@ function quotesOf(source) {
|
|
|
199
222
|
}
|
|
200
223
|
return out;
|
|
201
224
|
}
|
|
202
|
-
/** `text`'s views: the raw text, then each JSON decoding of it up to VIEW_DEPTH times, while a decoding changes it.
|
|
225
|
+
/** `text`'s views: the raw text, then each JSON decoding of it up to VIEW_DEPTH times, while a decoding changes it. At a
|
|
226
|
+
* level where a Windows path kept an escape as written, a second view of that level, every escape blanked, follows
|
|
227
|
+
* it (the beside view below). */
|
|
203
228
|
export function viewsOf(text) {
|
|
204
229
|
const views = [];
|
|
205
230
|
let source = text;
|
|
@@ -213,6 +238,13 @@ export function viewsOf(text) {
|
|
|
213
238
|
const quotes = quotesOf(source).filter((quote) => !inherited.has(quote));
|
|
214
239
|
const strings = pairQuotes(source, quotes).map(([open, close]) => [quotes[open], quotes[close]]);
|
|
215
240
|
views.push({ text: read.text, source, depth, escapes: read.escapes, at, delimiters, decodedStrings, strings });
|
|
241
|
+
// A Windows path is a guess from the text: where one kept an escape as written, the same level read the way main's
|
|
242
|
+
// scrubber reads it, every escape blanked, stands beside it. The rules read both and the cuts are their union, so
|
|
243
|
+
// a path read never leaves a value the blanked reading cuts (`{"t":"Q:\tmysql --password\nCopper9lumen9"}`).
|
|
244
|
+
if (read.escapes.length < next.escapes.length) {
|
|
245
|
+
const plain = blanked(source, next.escapes, delimiters, false);
|
|
246
|
+
views.push({ text: plain.text, source, depth, escapes: plain.escapes, at, delimiters, decodedStrings, strings });
|
|
247
|
+
}
|
|
216
248
|
if (!next.escapes.length || depth === VIEW_DEPTH)
|
|
217
249
|
break;
|
|
218
250
|
const outer = at;
|
|
@@ -508,9 +540,193 @@ function placesOf(text, form) {
|
|
|
508
540
|
out.push({ start: at, end: at + form.length });
|
|
509
541
|
return out;
|
|
510
542
|
}
|
|
511
|
-
/** How far a command is read past its name
|
|
512
|
-
|
|
543
|
+
/** How far a command is read past its name, at least (shell-lex.ts commandLimit: at most three times): SHELL_LINE_MAX, and
|
|
544
|
+
* CURL_MAX for curl's continuation lines. */
|
|
545
|
+
export const SHELL_LINE_MAX = 1024;
|
|
513
546
|
const CURL_MAX = 4096;
|
|
547
|
+
/** How deep a command inside a substitution of the same command is read on its own (`curl -H "$(curl -u a:pw …)"`). */
|
|
548
|
+
const SUBSTITUTION_DEPTH = 4;
|
|
549
|
+
/** A program's name as the shell reads it, for the lexer's readers: after a word boundary (a path before it too,
|
|
550
|
+
* `/usr/bin/curl`, `C:\tools\curl.exe`), a Windows extension maybe after it (`.exe`, `.cmd`, `.bat`, `.ps1`, in any
|
|
551
|
+
* case), and no word character or `-` glued on (`curl-user` names no curl); or the same quoted whole (`"curl"`,
|
|
552
|
+
* `'curl'`, `$'curl'`), with a path before it that may hold blanks inside the quotes
|
|
553
|
+
* (`"C:\Program Files\Docker\docker.exe"`, at most 256 characters on its line), the match taking the closing quote so
|
|
554
|
+
* the read starts past it. With an extension the name is read in any case too (`Docker.exe`, `MYSQL.EXE`): Windows
|
|
555
|
+
* names files without case; a bare name keeps its case (`Docker login` in prose names no command). A subcommand
|
|
556
|
+
* (`login`, `set`) is no name: the reader takes it from the command's words (subcommandAt). `names` is plain names
|
|
557
|
+
* joined by `|` (letters and `-`), so each letter maps to its two cases as written. */
|
|
558
|
+
const shellName = (names) => {
|
|
559
|
+
const extension = String.raw `\.(?:[eE][xX][eE]|[cC][mM][dD]|[bB][aA][tT]|[pP][sS]1)`;
|
|
560
|
+
const anyCase = [...names].map((c) => (c >= "a" && c <= "z" ? `[${c}${c.toUpperCase()}]` : c)).join("");
|
|
561
|
+
const name = String.raw `(?:(?:${names})(?:${extension})?|(?:${anyCase})${extension})`;
|
|
562
|
+
const path = (quote) => String.raw `(?:[^${quote}\n]{0,256}[/\\])?`;
|
|
563
|
+
return String.raw `(?:\b${name}(?![\w-])|"${path('"')}${name}"|'${path("'")}${name}')`;
|
|
564
|
+
};
|
|
565
|
+
/** The operators that end a command: `;`, `&`, `&&`, `||`, `|`, `|&` (a line's end always does, shell-lex.ts). */
|
|
566
|
+
const shellEnds = (op) => op === ";" || op === "&" || op === "&&" || op === "||" || op === "|" || op === "|&";
|
|
567
|
+
/** curl reads on over a lone `&` (ruling XXIV: an unquoted URL's `?a=1&b=2`). */
|
|
568
|
+
const curlEnds = (op) => op !== "&" && shellEnds(op);
|
|
569
|
+
/** What commandWords may spend reading commands named inside an earlier command's read, in the characters its lex
|
|
570
|
+
* calls read (Lexed.reads), as a share of the text's length: at most half a read a character more. */
|
|
571
|
+
const REREAD_SHARE = 0.5;
|
|
572
|
+
/** Where a subcommand's words end in a program's arguments (`login`; `set`, `config set`), or -1. Options before it
|
|
573
|
+
* are passed over (`docker --config ~/.docker login`, `docker -D login`): a word starting with `-` and the word after
|
|
574
|
+
* one without `=` (its value, when it takes one). Any other word first is another subcommand (`docker run … login`).
|
|
575
|
+
* A path's later words are looked up (nextWord): the first such word after the one before, whatever stands between
|
|
576
|
+
* (`npm config --global set`, `npm config get set //r/:_authToken tok`: the second is an over-cut, kept), so a
|
|
577
|
+
* password behind any number of options in the command's read is cut (secret-scrub CVII) and a read stays linear in
|
|
578
|
+
* its words however many `config` it holds (CVI). Where a word could be an option's value or the subcommand, it is
|
|
579
|
+
* read as the subcommand: a list of which options take a value would leak past every option it lacks. A word's
|
|
580
|
+
* blanks at its ends are no part of it here (`docker\ login`: bash names no such program, the text still holds a
|
|
581
|
+
* login's password). */
|
|
582
|
+
const subcommandAt = (paths) => (text, words) => {
|
|
583
|
+
const at = (i) => wordText(text, words[i]).trim();
|
|
584
|
+
const nextOf = new Map();
|
|
585
|
+
/** The first word at or after words[j] that is `name`, or -1: an index built in one pass over the read's words the
|
|
586
|
+
* first time `name` is looked up, so each later look-up is one step. */
|
|
587
|
+
const nextWord = (name, j) => {
|
|
588
|
+
let next = nextOf.get(name);
|
|
589
|
+
if (next === undefined) {
|
|
590
|
+
next = new Int32Array(words.length);
|
|
591
|
+
for (let k = words.length - 1, seen = -1; k >= 0; k--) {
|
|
592
|
+
lexCount.passed++;
|
|
593
|
+
if (at(k) === name)
|
|
594
|
+
seen = k;
|
|
595
|
+
next[k] = seen;
|
|
596
|
+
}
|
|
597
|
+
nextOf.set(name, next);
|
|
598
|
+
}
|
|
599
|
+
return j < words.length ? next[j] : -1;
|
|
600
|
+
};
|
|
601
|
+
/** Where `path` ends when its first word is words[i], or -1. */
|
|
602
|
+
const pathEnd = (path, i) => {
|
|
603
|
+
if (at(i) !== path[0])
|
|
604
|
+
return -1;
|
|
605
|
+
let j = i + 1;
|
|
606
|
+
for (const name of path.slice(1)) {
|
|
607
|
+
j = nextWord(name, j);
|
|
608
|
+
if (j < 0)
|
|
609
|
+
return -1;
|
|
610
|
+
j++;
|
|
611
|
+
}
|
|
612
|
+
return j;
|
|
613
|
+
};
|
|
614
|
+
let value = false;
|
|
615
|
+
for (let i = 0; i < words.length; i++) {
|
|
616
|
+
const word = at(i);
|
|
617
|
+
if (word.startsWith("-")) {
|
|
618
|
+
value = !word.includes("=");
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
for (const path of paths) {
|
|
622
|
+
const end = pathEnd(path, i);
|
|
623
|
+
if (end >= 0)
|
|
624
|
+
return end;
|
|
625
|
+
}
|
|
626
|
+
if (!value)
|
|
627
|
+
return -1;
|
|
628
|
+
value = false;
|
|
629
|
+
}
|
|
630
|
+
return -1;
|
|
631
|
+
};
|
|
632
|
+
/** The words of each command `command` names in `text`, after its name, read by shell-lex.ts to the operator `ends`
|
|
633
|
+
* takes, its line's end or `max` characters (a redirection's target dropped: argWords); then the same of each command
|
|
634
|
+
* inside its substitutions, to SUBSTITUTION_DEPTH. For curl (`own`) a word inside `$(…)` is no argument of the command
|
|
635
|
+
* around it; for the others each substitution's words are read as one more list of the command's (parity: an over-cut
|
|
636
|
+
* kept). The next command is looked for from this one's name on, so a command of the same name that an earlier read
|
|
637
|
+
* took into a quote it paired (`redis-cli -h o'neil ping; redis-cli -a pw 'x'`) is read too; one inside a substitution
|
|
638
|
+
* is read once, by the substitution's own read. Such re-reads share a budget of what their lex calls read
|
|
639
|
+
* (Lexed.reads, REREAD_SHARE of the text's length): past it the next command is looked for past the earlier read's end,
|
|
640
|
+
* as before, and the span scan (inside) still cuts there. The lexer's failed searches are kept across the text
|
|
641
|
+
* (`misses`): linear. Each list is yielded as it is read, so one command's words are held at a time, not the text's. */
|
|
642
|
+
function* commandWords(text, command, how) {
|
|
643
|
+
const misses = new Map();
|
|
644
|
+
let spare = Math.ceil(text.length * REREAD_SHARE);
|
|
645
|
+
/** The words handed out and not yet let go by the consumer: a list counts from its yield to the consumer's next
|
|
646
|
+
* call, so the most held at once is one command's (lexCount.held, a test's measure) however long the text. */
|
|
647
|
+
let held = 0;
|
|
648
|
+
const hand = (words) => {
|
|
649
|
+
held += words.length;
|
|
650
|
+
lexCount.held = Math.max(lexCount.held, held);
|
|
651
|
+
return words;
|
|
652
|
+
};
|
|
653
|
+
/** The commands named in text[from, to), read, each command's words yielded as it is read; what their lex calls read. */
|
|
654
|
+
const read = function* (from, to, depth) {
|
|
655
|
+
const region = from === 0 && to === text.length ? text : text.slice(from, to);
|
|
656
|
+
const re = new RegExp(command.source, command.flags);
|
|
657
|
+
let subs = [];
|
|
658
|
+
let readTo = from;
|
|
659
|
+
let total = 0;
|
|
660
|
+
for (let m = re.exec(region); m; m = re.exec(region)) {
|
|
661
|
+
const at = from + m.index;
|
|
662
|
+
const sub = subs.find(([start, end]) => start <= at && at < end);
|
|
663
|
+
if (sub || (at < readTo && spare <= 0)) {
|
|
664
|
+
re.lastIndex = Math.max((sub ? sub[1] : readTo) - from, m.index + 1);
|
|
665
|
+
continue;
|
|
666
|
+
}
|
|
667
|
+
const named = at + m[0].length;
|
|
668
|
+
const lexed = lex(text, named, commandLimit(named, how.max, to), how.ends, misses);
|
|
669
|
+
let reads = lexed.reads;
|
|
670
|
+
const words = argWords(text, lexed.tokens);
|
|
671
|
+
const first = how.after ? how.after(text, words) : 0;
|
|
672
|
+
if (first >= 0) {
|
|
673
|
+
yield hand(first === 0 ? words : words.slice(first));
|
|
674
|
+
if (!how.own)
|
|
675
|
+
reads += yield* substitutionWords(text, lexed.subs, depth, misses, hand);
|
|
676
|
+
}
|
|
677
|
+
if (depth < SUBSTITUTION_DEPTH)
|
|
678
|
+
for (const [start, end] of lexed.subs)
|
|
679
|
+
reads += yield* read(start, end, depth + 1);
|
|
680
|
+
if (at < readTo)
|
|
681
|
+
spare -= reads;
|
|
682
|
+
total += reads;
|
|
683
|
+
subs = lexed.subs;
|
|
684
|
+
readTo = Math.max(readTo, lexed.end);
|
|
685
|
+
re.lastIndex = Math.max(named - from, m.index + 1);
|
|
686
|
+
}
|
|
687
|
+
return total;
|
|
688
|
+
};
|
|
689
|
+
for (const words of read(0, text.length, 0)) {
|
|
690
|
+
yield words;
|
|
691
|
+
held -= words.length;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
/** Each substitution body's words (operators inside it read through), and its own substitutions' in turn, to
|
|
695
|
+
* SUBSTITUTION_DEPTH: each body one list, yielded through `hand` (commandWords' count). What the lex calls read. */
|
|
696
|
+
function* substitutionWords(text, subs, depth, misses, hand) {
|
|
697
|
+
if (depth >= SUBSTITUTION_DEPTH)
|
|
698
|
+
return 0;
|
|
699
|
+
let reads = 0;
|
|
700
|
+
for (const [start, end] of subs) {
|
|
701
|
+
const body = lex(text, start, end, never, misses);
|
|
702
|
+
yield hand(argWords(text, body.tokens));
|
|
703
|
+
reads += body.reads + (yield* substitutionWords(text, body.subs, depth + 1, misses, hand));
|
|
704
|
+
}
|
|
705
|
+
return reads;
|
|
706
|
+
}
|
|
707
|
+
const never = () => false;
|
|
708
|
+
// ---------- the span scans: the command readers before the lexer, kept beside it (union, fail closed)
|
|
709
|
+
//
|
|
710
|
+
// Each of the five command rules (mysql-password, password-flag's -p and -a, curl-user, npm set) cuts the union of its
|
|
711
|
+
// lexer read (commandWords) and this span scan: the scan reads a command to its end and runs a pattern over it. The
|
|
712
|
+
// lexer read adds cuts where it reads the shell better; it never takes one away. Once the differential corpus
|
|
713
|
+
// (test/fixtures/scrub-differential) shows the lexer's cuts cover the scan's on every row, the scan can go: this
|
|
714
|
+
// section to its end marker, the five scan* calls in the rules, and these patterns' RULE_PATTERNS entries.
|
|
715
|
+
/** The commands as the scan names them, and the flag and value each one's pattern finds inside (main's, verbatim). */
|
|
716
|
+
const MYSQL_SCAN = /\b(?:mysql|mysqldump|mysqladmin|mysqlimport|mysqlshow|mysqlcheck|mysqlsh|mariadb|mariadb-dump|mariadb-admin)(?=[ \t])/g;
|
|
717
|
+
const MYSQL_P = new RegExp(String.raw `(?<=[ \t])-p${VALUE}`, "gd");
|
|
718
|
+
const LOGIN_SCAN = /\b(?:docker|podman|nerdctl|buildah|skopeo)[ \t]{1,3}login\b/g;
|
|
719
|
+
const LOGIN_P = new RegExp(String.raw `(?<=[ \t])(-p)(?:=|[ \t]{1,3})${VALUE}`, "gd");
|
|
720
|
+
const REDIS_SCAN = /\bredis-cli\b/g;
|
|
721
|
+
const REDIS_A = new RegExp(String.raw `(?<=[ \t])(-a)[ \t]{1,3}${VALUE}`, "gd");
|
|
722
|
+
const CURL_SCAN = /\bcurl\b/g;
|
|
723
|
+
const CURL_USER = /(?<=\s)(?:-u[ \t]{0,3}|--user(?:=|[ \t]{1,3}))(?:(["'])[^\s:"']{0,256}:([^"'\n]{1,512})\1|[^\s:"']{0,256}:([^\s"']{1,512}))/gd;
|
|
724
|
+
const NPM_SET_SCAN = /\b(?:npm|pnpm|yarn)[ \t]{1,3}(?:config[ \t]{1,3})?set(?=[ \t])/g;
|
|
725
|
+
const NPM_SET_AUTH = new RegExp(String.raw `(?<![\w$.])(_authToken|_password|_auth)[ \t]{1,3}${VALUE}`, "gd");
|
|
726
|
+
const curlUser = (m) => {
|
|
727
|
+
const [start, end] = m.indices[m[2] !== undefined ? 2 : 3];
|
|
728
|
+
return { start, end, name: "user", quoted: true };
|
|
729
|
+
};
|
|
514
730
|
/** How far a substitution's closer is looked for: one that does not close within it ends the command where it opens. */
|
|
515
731
|
const SUBSTITUTION_MAX = 256;
|
|
516
732
|
/** Where a substitution opened at `at` ends, past its closer, before its line's end, `limit` and SUBSTITUTION_MAX, or
|
|
@@ -594,13 +810,12 @@ function quoteEnd(text, at, limit, curl, misses, subs) {
|
|
|
594
810
|
misses[quote] = { from: at, to: i, final, subs: found };
|
|
595
811
|
return -1;
|
|
596
812
|
}
|
|
597
|
-
/** Where a shell command whose name ends at `from` ends, and the substitutions it holds (
|
|
598
|
-
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
* ends the command where it opens. At most SHELL_LINE_MAX characters (CURL_MAX) are read. `misses` carries failed
|
|
813
|
+
/** Where a shell command whose name ends at `from` ends, and the substitutions it holds (`redis-cli -a 'Copper&lumen9'`
|
|
814
|
+
* read on over its quoted `&`): its line's end, or a shell operator outside quotes (`;`, `|`, `&`). A quoted part is
|
|
815
|
+
* read whole to its closing quote on its line. curl (ruling XXIV) runs on over a backslash's line break and a lone
|
|
816
|
+
* `&`, and ends at `&&`; a substitution (`$(…)`, a backtick pair), bare or in double quotes, is read whole and the
|
|
817
|
+
* command read on past it (its contents are no part of curl's arguments, and a `-u` after it is), and one that never
|
|
818
|
+
* closes ends the command where it opens. At most SHELL_LINE_MAX characters (CURL_MAX) are read. `misses` carries failed
|
|
604
819
|
* quote searches from one command to the next (quoteEnd), and a substitution's search is bounded and ends its command
|
|
605
820
|
* when it fails: linear in the text. */
|
|
606
821
|
function commandEnd(text, from, curl, misses) {
|
|
@@ -637,8 +852,6 @@ function commandEnd(text, from, curl, misses) {
|
|
|
637
852
|
}
|
|
638
853
|
return { end: Math.min(at, limit), subs };
|
|
639
854
|
}
|
|
640
|
-
/** How deep a command inside a substitution of the same command is read on its own (`curl -H "$(curl -u a:pw …)"`). */
|
|
641
|
-
const SUBSTITUTION_DEPTH = 4;
|
|
642
855
|
/** The hits `pattern` finds inside each command `command` names (read whole first, to commandEnd), mapped to the text.
|
|
643
856
|
* A hit starting inside one of the command's substitutions is not the command's; the substitution's contents are read
|
|
644
857
|
* as a text of their own. The next command is looked for past this one's end. */
|
|
@@ -664,6 +877,43 @@ function inside(text, command, pattern, hit, curl = false, depth = 0) {
|
|
|
664
877
|
}
|
|
665
878
|
return out;
|
|
666
879
|
}
|
|
880
|
+
/** Each rule's scan: the hits its pattern finds inside each command the scan names. */
|
|
881
|
+
const scanMysql = (text) => inside(text, MYSQL_SCAN, MYSQL_P, (m) => flagValue(valueHit(m, 1, 1, "-p")));
|
|
882
|
+
const scanLogin = (text) => inside(text, LOGIN_SCAN, LOGIN_P, (m) => flagValue(valueHit(m, 2, 1, m[1])));
|
|
883
|
+
const scanRedis = (text) => inside(text, REDIS_SCAN, REDIS_A, (m) => flagValue(valueHit(m, 2, 1, m[1])));
|
|
884
|
+
const scanCurl = (text) => inside(text, CURL_SCAN, CURL_USER, curlUser, true);
|
|
885
|
+
const scanNpm = (text) => inside(text, NPM_SET_SCAN, NPM_SET_AUTH, npmAuth);
|
|
886
|
+
/** Each command rule's scan alone, by rule id, for the tests' cost bound (secret-scrub.test.mjs XCIX). */
|
|
887
|
+
export const SPAN_SCANS = Object.freeze({
|
|
888
|
+
"mysql-password": scanMysql,
|
|
889
|
+
"password-flag": (text) => [...scanLogin(text), ...scanRedis(text)],
|
|
890
|
+
"curl-user": scanCurl,
|
|
891
|
+
"secret-assign": scanNpm,
|
|
892
|
+
});
|
|
893
|
+
// ---------- the span scans end
|
|
894
|
+
/** The value a word gives its command from its `skip`th character on (shell-lex.ts wordChars: quotes taken off,
|
|
895
|
+
* escapes read), placed where those characters are written: a hit when at least `min` characters long. */
|
|
896
|
+
function wordValue(text, word, skip, min, name) {
|
|
897
|
+
const value = wordFrom(text, word, skip);
|
|
898
|
+
return value && value.length - skip >= min ? { start: value.start, end: value.end, name } : undefined;
|
|
899
|
+
}
|
|
900
|
+
/** `flag <pw>`, with `equals` `flag=<pw>` too, and with `glued` `flag<pw>` (a registry login's `-p<pw>`: its CLI reads
|
|
901
|
+
* a short flag's value glued on), in each command's words: the password, at least `min` long. */
|
|
902
|
+
function flagWords(text, commands, flag, equals, min, glued = false) {
|
|
903
|
+
const out = [];
|
|
904
|
+
for (const words of commands) {
|
|
905
|
+
for (let i = 0; i < words.length; i++) {
|
|
906
|
+
const value = wordText(text, words[i]);
|
|
907
|
+
const hit = value === flag && i + 1 < words.length ? wordValue(text, words[i + 1], 0, min, flag)
|
|
908
|
+
: equals && value.startsWith(`${flag}=`) ? wordValue(text, words[i], flag.length + 1, min, flag)
|
|
909
|
+
: glued && value.startsWith(flag) && value.length > flag.length ? wordValue(text, words[i], flag.length, min, flag)
|
|
910
|
+
: undefined;
|
|
911
|
+
if (hit)
|
|
912
|
+
out.push(flagValue(hit));
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
return out;
|
|
916
|
+
}
|
|
667
917
|
// ---------- format: redact/match.ts SECRET_SHAPES, the PEM block whole, secretlint
|
|
668
918
|
const SHAPE_IDS = new Map([
|
|
669
919
|
["AWS access key id", "aws-access-key"],
|
|
@@ -1388,10 +1638,26 @@ function iniSection(text, from) {
|
|
|
1388
1638
|
* quoted key's `:` (`"//registry/:_authToken": "tok"`, a JSON or YAML map of npm's config). npm config list's own
|
|
1389
1639
|
* mask, `= (protected)`, is no value VALUE reads. */
|
|
1390
1640
|
const NPMRC_AUTH = new RegExp(String.raw `(?<![\w$.])(_authToken|_password|_auth)(?:[ \t]{0,3}=(?!=)|["'][ \t]{0,3}:)[ \t]{0,3}${VALUE}`, "gd");
|
|
1391
|
-
/** npm
|
|
1392
|
-
* (`npm config set //registry/:_authToken tok`), ruling LXXVI. */
|
|
1393
|
-
const
|
|
1394
|
-
|
|
1641
|
+
/** npm (pnpm, yarn), read as a command (commandWords) when it runs `config set` or `set`: there a key and its value
|
|
1642
|
+
* are two words (`npm config set //registry/:_authToken tok`), ruling LXXVI. */
|
|
1643
|
+
const NPM_COMMAND = new RegExp(shellName("npm|pnpm|yarn"), "g");
|
|
1644
|
+
/** `c` is npm's and pnpm's alias of `config` (`npm c set …`). */
|
|
1645
|
+
const NPM_SET = subcommandAt([["set"], ["config", "set"], ["c", "set"]]);
|
|
1646
|
+
/** An npm auth key ending a `set` argument (`//registry/:_authToken`); the next word is its value. */
|
|
1647
|
+
const NPM_AUTH_KEY = /(?:^|[^\w$.])(_authToken|_password|_auth)$/;
|
|
1648
|
+
/** Each `npm set` key's value, at least 3 characters: the word after the key's (ruling LXXVI). */
|
|
1649
|
+
const npmSet = (text) => {
|
|
1650
|
+
const out = [];
|
|
1651
|
+
for (const words of commandWords(text, NPM_COMMAND, { max: SHELL_LINE_MAX, ends: shellEnds, after: NPM_SET })) {
|
|
1652
|
+
for (let i = 0; i + 1 < words.length; i++) {
|
|
1653
|
+
const key = NPM_AUTH_KEY.exec(wordText(text, words[i]));
|
|
1654
|
+
const hit = key ? wordValue(text, words[i + 1], 0, 3, key[1]) : undefined;
|
|
1655
|
+
if (hit)
|
|
1656
|
+
out.push(flagValue(hit));
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
return out;
|
|
1660
|
+
};
|
|
1395
1661
|
/** An npm key's value: a slot code does not fill (ruling XII). */
|
|
1396
1662
|
const npmAuth = (m) => flagValue(valueHit(m, 2, 3, m[1]));
|
|
1397
1663
|
/** NAME=value, as a shell or .env writes it: a key-shaped name or one of PASSWORD_NAMES. An upper-case name (an
|
|
@@ -2064,18 +2330,27 @@ const dockerAuth = (text, ctx) => {
|
|
|
2064
2330
|
};
|
|
2065
2331
|
};
|
|
2066
2332
|
const SSHPASS = new RegExp(String.raw `\bsshpass[ \t]{1,3}-p[ \t]{0,3}${VALUE}`, "gd");
|
|
2067
|
-
/** A mysql-family command, read
|
|
2333
|
+
/** A mysql-family command, read as a command (commandWords); its `-p<pw>` read inside (no blank after
|
|
2068
2334
|
* `-p`: `-p word` prompts for the password and names a database, ruling D). */
|
|
2069
|
-
const MYSQL_COMMAND =
|
|
2070
|
-
const
|
|
2335
|
+
const MYSQL_COMMAND = new RegExp(shellName("mysql|mysqldump|mysqladmin|mysqlimport|mysqlshow|mysqlcheck|mysqlsh|mariadb|mariadb-dump|mariadb-admin"), "g");
|
|
2336
|
+
const mysqlPasswords = (text) => {
|
|
2337
|
+
const out = [];
|
|
2338
|
+
for (const words of commandWords(text, MYSQL_COMMAND, { max: SHELL_LINE_MAX, ends: shellEnds })) {
|
|
2339
|
+
for (const word of words) {
|
|
2340
|
+
const hit = wordText(text, word).startsWith("-p") ? wordValue(text, word, 2, 1, "-p") : undefined;
|
|
2341
|
+
if (hit)
|
|
2342
|
+
out.push(flagValue(hit));
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
return out;
|
|
2346
|
+
};
|
|
2071
2347
|
/** --password=<pw> or --password <pw>, and the same of --*-password, --passwd, --token, --api-key and kin. */
|
|
2072
2348
|
const PASSWORD_FLAG = new RegExp(String.raw `(?<![A-Za-z0-9-])(--(?:[a-z0-9]{1,20}-){0,3}(?:password|passwd|pass|token|api-key|apikey|auth-token|secret-key|access-key))(?:=|[ \t]{1,3}(?!-))${VALUE}`, "gdi");
|
|
2073
|
-
/** A registry login (`docker login -p <pw>`), redis-cli's `-a <pw>`: each command read
|
|
2074
|
-
* short password flag inside
|
|
2075
|
-
const LOGIN_COMMAND =
|
|
2076
|
-
const
|
|
2077
|
-
const REDIS_COMMAND =
|
|
2078
|
-
const REDIS_A = new RegExp(String.raw `(?<=[ \t])(-a)[ \t]{1,3}${VALUE}`, "gd");
|
|
2349
|
+
/** A registry login (`docker login -p <pw>`, `-p<pw>`), redis-cli's `-a <pw>`: each command read as one (commandWords), its
|
|
2350
|
+
* short password flag inside; a registry tool's only when it runs `login`. */
|
|
2351
|
+
const LOGIN_COMMAND = new RegExp(shellName("docker|podman|nerdctl|buildah|skopeo"), "g");
|
|
2352
|
+
const LOGIN = subcommandAt([["login"]]);
|
|
2353
|
+
const REDIS_COMMAND = new RegExp(shellName("redis-cli"), "g");
|
|
2079
2354
|
/** openssl's `-passin pass:<pw>` (and -passout, -pass, -k pass:): the password after `pass:`. */
|
|
2080
2355
|
const OPENSSL_PASS = /(?<![A-Za-z0-9-])(-(?:passin|passout|pass|k))[ \t]{1,3}(["']?)pass:([^\s"']{1,1024})\2/dg;
|
|
2081
2356
|
/** A .netrc line: `machine <host>` (or `default`), maybe `login`/`account`, then `password <pw>`. */
|
|
@@ -2085,8 +2360,10 @@ const flagValue = (hit) => (hit ? { ...hit, code: false } : undefined);
|
|
|
2085
2360
|
function passwordFlags(text) {
|
|
2086
2361
|
return [
|
|
2087
2362
|
...each(text, PASSWORD_FLAG, (m) => flagValue(valueHit(m, 2, 3, m[1]))),
|
|
2088
|
-
...
|
|
2089
|
-
...
|
|
2363
|
+
...flagWords(text, commandWords(text, LOGIN_COMMAND, { max: SHELL_LINE_MAX, ends: shellEnds, after: LOGIN }), "-p", true, 1, true),
|
|
2364
|
+
...flagWords(text, commandWords(text, REDIS_COMMAND, { max: SHELL_LINE_MAX, ends: shellEnds }), "-a", false, 1),
|
|
2365
|
+
...scanLogin(text),
|
|
2366
|
+
...scanRedis(text),
|
|
2090
2367
|
...each(text, OPENSSL_PASS, (m) => ({ start: m.indices[3][0], end: m.indices[3][1], name: m[1], quoted: true })),
|
|
2091
2368
|
...each(text, NETRC, (m) => ({ start: m.indices[2][0], end: m.indices[2][1], name: m[1], quoted: true })),
|
|
2092
2369
|
];
|
|
@@ -2136,14 +2413,52 @@ const cookieHeader = (text) => (m) => {
|
|
|
2136
2413
|
const start = m.indices[4][0];
|
|
2137
2414
|
return { start, end: start + value.length, name: m[1] };
|
|
2138
2415
|
};
|
|
2139
|
-
/** A curl command, its continuation lines included,
|
|
2140
|
-
*
|
|
2141
|
-
* password read inside. */
|
|
2142
|
-
const CURL_COMMAND =
|
|
2143
|
-
|
|
2144
|
-
const
|
|
2145
|
-
|
|
2146
|
-
|
|
2416
|
+
/** A curl command, its continuation lines included, read as one (commandWords with curlEnds: `;`, `|`, `&&`, `||`,
|
|
2417
|
+
* a line's end, none of them quoted; a lone `&` does not end it, ruling XXIV); its `-u user:pass`, `-uuser:pass`,
|
|
2418
|
+
* `--user user:pass` or `--user=user:pass` password read inside. */
|
|
2419
|
+
const CURL_COMMAND = new RegExp(shellName("curl"), "g");
|
|
2420
|
+
/** How long a curl `-u` user may be before its `:`. */
|
|
2421
|
+
const CURL_USER_MAX = 256;
|
|
2422
|
+
/** The characters that end the run a curl `-u` password is glued into. */
|
|
2423
|
+
const GLUED_STOP = /[\s"']/;
|
|
2424
|
+
const curlUsers = (text) => {
|
|
2425
|
+
const out = [];
|
|
2426
|
+
// The last glued run read, [from, to): a password inside it ends where it does, so each run is read once.
|
|
2427
|
+
let run = [0, 0];
|
|
2428
|
+
for (const words of commandWords(text, CURL_COMMAND, { max: CURL_MAX, ends: curlEnds, own: true })) {
|
|
2429
|
+
for (let i = 0; i < words.length; i++) {
|
|
2430
|
+
const flag = wordText(text, words[i]);
|
|
2431
|
+
let arg;
|
|
2432
|
+
let skip = 0;
|
|
2433
|
+
if (flag === "-u" || flag === "--user")
|
|
2434
|
+
arg = words[i + 1];
|
|
2435
|
+
else if (flag.startsWith("--user="))
|
|
2436
|
+
[arg, skip] = [words[i], 7];
|
|
2437
|
+
else if (flag.startsWith("-u") && !flag.startsWith("--"))
|
|
2438
|
+
[arg, skip] = [words[i], 2];
|
|
2439
|
+
if (!arg)
|
|
2440
|
+
continue;
|
|
2441
|
+
const colon = (arg === words[i] ? flag : wordText(text, arg)).indexOf(":", skip);
|
|
2442
|
+
// user:password, the user at most CURL_USER_MAX long (a password a substitution writes is a placeholder, XCV).
|
|
2443
|
+
const password = colon < 0 || colon - skip > CURL_USER_MAX ? undefined : wordFrom(text, arg, colon + 1);
|
|
2444
|
+
if (!password)
|
|
2445
|
+
continue;
|
|
2446
|
+
// The shell ends a word at `&`, `(`, `)`, `<`, `>`; a password written with one (`admin:Copper&9lumen9`) runs on
|
|
2447
|
+
// to the next blank or quote, as the span scan reads it (CURL_USER): the cut takes the glued run, to its end
|
|
2448
|
+
// however long (fail closed: no tail is left).
|
|
2449
|
+
let end = password.end;
|
|
2450
|
+
if (run[0] <= end && end < run[1])
|
|
2451
|
+
end = run[1];
|
|
2452
|
+
else {
|
|
2453
|
+
const from = end;
|
|
2454
|
+
while (end < text.length && !GLUED_STOP.test(text.charAt(end)))
|
|
2455
|
+
end++;
|
|
2456
|
+
run = [from, end];
|
|
2457
|
+
}
|
|
2458
|
+
out.push({ start: password.start, end, name: "user", quoted: true });
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
return out;
|
|
2147
2462
|
};
|
|
2148
2463
|
/** A line-numbered read's prefix (cat -n, a Read tool's " 12→", grep -n's `path:12:`: LINE_LEAD's numbered leads,
|
|
2149
2464
|
* ruling XXVII; a diff's `+`/`-` is not dropped, a PEM line opens with `-`), dropped before a line's shape is read. A JSON
|
|
@@ -2187,6 +2502,8 @@ function linesOf(text) {
|
|
|
2187
2502
|
return lines;
|
|
2188
2503
|
}
|
|
2189
2504
|
const blank = (line) => line.body.trim() === "";
|
|
2505
|
+
/** Where the raw line holding `offset` starts: its first character, before any JSON field opening linesOf skips. */
|
|
2506
|
+
const rawStart = (text, offset) => text.lastIndexOf("\n", offset - 1) + 1;
|
|
2190
2507
|
const block = (lines, from, to) => ({ start: lines[from].start, end: lines[to].end });
|
|
2191
2508
|
/** The lines after `at` while `fits` holds, trailing blank lines left out; undefined when none is left. */
|
|
2192
2509
|
function after(lines, at, fits) {
|
|
@@ -2230,8 +2547,10 @@ function envDumps(text) {
|
|
|
2230
2547
|
let to = at;
|
|
2231
2548
|
while (to + 1 < lines.length && to - at < count && !blank(lines[to + 1]) && notPrompt(lines[to + 1].body) && notMarker(lines[to + 1].body))
|
|
2232
2549
|
to++;
|
|
2550
|
+
// From the value line's own start, not past a JSON field's opening: a cut starting inside a string would end at
|
|
2551
|
+
// that string's quote (11-25 read, P1-1).
|
|
2233
2552
|
if (to > at)
|
|
2234
|
-
out.push(
|
|
2553
|
+
out.push({ start: rawStart(text, lines[at + 1].start), end: lines[to].end });
|
|
2235
2554
|
at = to + 1;
|
|
2236
2555
|
continue;
|
|
2237
2556
|
}
|
|
@@ -2260,14 +2579,123 @@ const readPath = (body) => READ_COMMAND.exec(body)?.[2] ?? READ_TOOL.exec(body)?
|
|
|
2260
2579
|
/** The file a command prints whole, when it is one read alone (`cat ~/.pgpass`): its output is that file's content
|
|
2261
2580
|
* (ruling LVI). */
|
|
2262
2581
|
export const commandReadPath = (command) => (command === undefined ? undefined : readPath(command));
|
|
2263
|
-
/**
|
|
2264
|
-
* `
|
|
2265
|
-
|
|
2266
|
-
|
|
2582
|
+
/** Where a command line splits into the commands it runs: `;`, `&&`, `||`, a pipe, a lone `&` (not a redirection's:
|
|
2583
|
+
* `2>&1`, `&>`), a line break, a subshell's or a substitution's `(` and `)`, a backtick. Quotes are not read: a split
|
|
2584
|
+
* inside them only makes more pieces to read, and an env word in one is read as a command (`echo "a; env"`, an over-cut
|
|
2585
|
+
* that fails closed). */
|
|
2586
|
+
const COMMAND_SPLIT = /;|&&|\|\||\||(?<![<>&])&(?![&>])|\n|\(|\)|`/;
|
|
2587
|
+
const COMMAND_BLANKS = /[ \t\r]{1,4096}/;
|
|
2588
|
+
/** A shell prompt standing as a piece's first word (`$ env`, `C:\app> set`). */
|
|
2589
|
+
const PROMPT_WORD = /^(?:[$#%>❯]|[A-Za-z]:\\[^>\n]{0,256}>)$/;
|
|
2590
|
+
/** A leading assignment (`FOO=1 printenv A`): the command follows it. */
|
|
2591
|
+
const ASSIGNMENT_WORD = /^[A-Za-z_][A-Za-z0-9_]{0,127}=/;
|
|
2592
|
+
/** A redirection (`2>&1`, `>/tmp/e`, `&>log`); one that is its operator alone takes the next word as its file. */
|
|
2593
|
+
const REDIRECT_WORD = /^(?:\d{1,2}|&)?(?:<<?|>>?)(?:&\d{0,2}-?)?/;
|
|
2594
|
+
const REDIRECT_ALONE = /^(?:\d{1,2}|&)?(?:<<?|>>?)$/;
|
|
2595
|
+
/** A variable's expansion in a word (`$APP_SEED`, `"x=${A}"`). */
|
|
2596
|
+
const VARIABLE_WORD = /\$\{?[A-Za-z_]/;
|
|
2597
|
+
/** A word's quotes at its ends (`'env'`, `env"` past a split inside quotes). */
|
|
2598
|
+
const WORD_EDGE_QUOTES = /^["']{1,8}|["']{1,8}$/g;
|
|
2599
|
+
/** A shell's flag that runs its next words as a script (`-c`, `-lc`). */
|
|
2600
|
+
const SCRIPT_FLAG = /^-[A-Za-z]{0,8}c[A-Za-z]{0,8}$/;
|
|
2601
|
+
const NUMBER_WORD = /^\d{1,12}(?:\.\d{1,6})?[smhd]?$/;
|
|
2602
|
+
/** export's or declare's flag that prints (`-p`, `-px`). */
|
|
2603
|
+
const PRINT_FLAG = /^-[A-Za-z]{0,8}p/;
|
|
2604
|
+
/** Words a command can stand behind: grouping, control flow, negation. */
|
|
2605
|
+
const LEAD_WORDS = new Set(["{", "}", "!", "if", "then", "else", "elif", "do", "while", "until"]);
|
|
2606
|
+
/** Commands that run the command after them (their flags, a flag's argument and a number between). */
|
|
2607
|
+
const WRAPPERS = new Set(["sudo", "doas", "exec", "command", "builtin", "time", "nice", "nohup", "timeout", "stdbuf", "ionice", "chrt", "unbuffer"]);
|
|
2608
|
+
const WRAPPER_ARG_FLAGS = new Set(["-u", "-g", "-n", "-p", "-c", "-s", "-k", "-C", "-o", "-e", "-i"]);
|
|
2609
|
+
const ENV_ARG_FLAGS = new Set(["-u", "--unset", "-C", "--chdir"]);
|
|
2610
|
+
const SHELLS = new Set(["sh", "bash", "zsh", "dash", "ksh", "fish"]);
|
|
2611
|
+
const commandName = (word) => {
|
|
2612
|
+
const bare = word.replace(WORD_EDGE_QUOTES, "");
|
|
2613
|
+
return bare.slice(bare.lastIndexOf("/") + 1);
|
|
2614
|
+
};
|
|
2615
|
+
/** Whether one command of a line prints the environment or a variable's value: env or printenv (env's own options and
|
|
2616
|
+
* assignments aside, no command after it), set or export with no argument, export or declare -p, compgen -v, an echo
|
|
2617
|
+
* or printf of a variable, or a shell's `-c` script that does. Read past a prompt, grouping and control-flow words,
|
|
2618
|
+
* wrappers (`sudo -E`, `nice -n 5`, `exec`, a path), leading assignments and redirections. An echo of any variable
|
|
2619
|
+
* counts, a secret name or not (`cd x && echo $PWD && npm test` cuts the test's output too: an over-cut, fails
|
|
2620
|
+
* closed). */
|
|
2621
|
+
function pieceDumps(piece, depth) {
|
|
2622
|
+
const words = piece.split(COMMAND_BLANKS).filter(Boolean);
|
|
2623
|
+
let at = 0;
|
|
2624
|
+
while (at < words.length) {
|
|
2625
|
+
const word = words[at];
|
|
2626
|
+
if (PROMPT_WORD.test(word) || LEAD_WORDS.has(word) || ASSIGNMENT_WORD.test(word)) {
|
|
2627
|
+
at++;
|
|
2628
|
+
continue;
|
|
2629
|
+
}
|
|
2630
|
+
if (!WRAPPERS.has(commandName(word)))
|
|
2631
|
+
break;
|
|
2632
|
+
at++;
|
|
2633
|
+
while (at < words.length && (words[at].startsWith("-") || NUMBER_WORD.test(words[at])))
|
|
2634
|
+
at += WRAPPER_ARG_FLAGS.has(words[at]) ? 2 : 1;
|
|
2635
|
+
}
|
|
2636
|
+
if (at >= words.length)
|
|
2637
|
+
return false;
|
|
2638
|
+
const name = commandName(words[at]);
|
|
2639
|
+
const args = [];
|
|
2640
|
+
for (let i = at + 1; i < words.length; i++) {
|
|
2641
|
+
if (REDIRECT_ALONE.test(words[i]))
|
|
2642
|
+
i++;
|
|
2643
|
+
else if (!REDIRECT_WORD.test(words[i]))
|
|
2644
|
+
args.push(words[i]);
|
|
2645
|
+
}
|
|
2646
|
+
const flagsOnly = args.every((arg) => arg.startsWith("-"));
|
|
2647
|
+
switch (name) {
|
|
2648
|
+
case "printenv":
|
|
2649
|
+
return true;
|
|
2650
|
+
case "env":
|
|
2651
|
+
for (let i = 0; i < args.length; i++) {
|
|
2652
|
+
if (ENV_ARG_FLAGS.has(args[i]))
|
|
2653
|
+
i++;
|
|
2654
|
+
else if (!args[i].startsWith("-") && !ASSIGNMENT_WORD.test(args[i]))
|
|
2655
|
+
return false;
|
|
2656
|
+
}
|
|
2657
|
+
return true;
|
|
2658
|
+
case "set":
|
|
2659
|
+
return args.length === 0;
|
|
2660
|
+
case "export":
|
|
2661
|
+
case "declare":
|
|
2662
|
+
case "typeset":
|
|
2663
|
+
return flagsOnly || args.some((arg) => PRINT_FLAG.test(arg));
|
|
2664
|
+
case "compgen":
|
|
2665
|
+
return args.includes("-v");
|
|
2666
|
+
case "echo":
|
|
2667
|
+
case "printf":
|
|
2668
|
+
return args.some((arg) => VARIABLE_WORD.test(arg));
|
|
2669
|
+
default: {
|
|
2670
|
+
if (!SHELLS.has(name) || depth >= 2)
|
|
2671
|
+
return false;
|
|
2672
|
+
const flag = args.findIndex((arg) => SCRIPT_FLAG.test(arg));
|
|
2673
|
+
return flag >= 0 && printsEnvironment(args.slice(flag + 1).join(" ").replace(WORD_EDGE_QUOTES, ""), depth + 1);
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
/** Whether a call's command line prints the environment or a variable's value, any one of its commands (`env`,
|
|
2678
|
+
* `cd app && env | sort`, `printenv A; printenv A B`, `(env)`, `bash -c 'env'`). A line longer than is read is read so
|
|
2679
|
+
* too: what lies past the read can't be told (fails closed). */
|
|
2680
|
+
function printsEnvironment(command, depth = 0) {
|
|
2681
|
+
if (command.length > COMMAND_MAX)
|
|
2682
|
+
return true;
|
|
2683
|
+
return command.split(COMMAND_SPLIT).some((piece) => pieceDumps(piece, depth));
|
|
2684
|
+
}
|
|
2685
|
+
/** All of a call's output as one dump, from its first character that is not a blank to its last (11-25 read): its
|
|
2686
|
+
* lines can't be told apart by command, a value can span lines, and a first line that opens like a JSON field or a
|
|
2687
|
+
* quote is no head to start after. A one-line summary is cut whole, its head with it. Already a dump's cut: no cut. */
|
|
2688
|
+
function wholeDump(text) {
|
|
2689
|
+
if (DUMP_MARKER_LINE.test(text))
|
|
2267
2690
|
return [];
|
|
2268
|
-
const
|
|
2269
|
-
|
|
2691
|
+
const end = text.trimEnd().length;
|
|
2692
|
+
const start = text.length - text.trimStart().length;
|
|
2693
|
+
return end > start ? [{ start, end }] : [];
|
|
2270
2694
|
}
|
|
2695
|
+
/** A command's output, given apart from its command (ruling LVI): all of it is a dump when the command prints the
|
|
2696
|
+
* environment or a variable's value, alone on its line or among others. An approval outcome's head line is cut with
|
|
2697
|
+
* it (ruled so: never split on run-view's words). */
|
|
2698
|
+
const commandDumps = (text, given) => (given !== undefined && given.trim() !== "" && printsEnvironment(given) ? wholeDump(text) : []);
|
|
2271
2699
|
const PATH_SEPARATOR = /[\\/]/;
|
|
2272
2700
|
const ENV_FILE_NAME = /^(?:\.env(?:rc)?|\.env\.[A-Za-z0-9_.-]{1,64}|[A-Za-z0-9_.-]{1,64}\.env)$/;
|
|
2273
2701
|
const ENV_TEMPLATE = /\.(?:example|sample|template|tmpl|dist|defaults?|schema)$/i;
|
|
@@ -2515,10 +2943,10 @@ export const SCRUB_RULES = Object.freeze([
|
|
|
2515
2943
|
// naming their file (ssh-keyscan's public host keys) are not cut (ruling G).
|
|
2516
2944
|
rule("ssh-file", "dump", (text, ctx) => [...wholeText(text, ctx, sshFilePath), ...fileReads(text, sshFilePath, sshLine)]),
|
|
2517
2945
|
rule("sshpass", "label", (text) => each(text, SSHPASS, (m) => flagValue(valueHit(m, 1, 1, "sshpass -p")))),
|
|
2518
|
-
rule("mysql-password", "label", (text) =>
|
|
2946
|
+
rule("mysql-password", "label", (text) => [...mysqlPasswords(text), ...scanMysql(text)]),
|
|
2519
2947
|
rule("password-flag", "label", passwordFlags),
|
|
2520
2948
|
rule("auth-header", "label", (text) => [...each(text, AUTH_HEADER, authHeader(text)), ...each(text, COOKIE_HEADER, cookieHeader(text))]),
|
|
2521
|
-
rule("curl-user", "label", (text) =>
|
|
2949
|
+
rule("curl-user", "label", (text) => [...curlUsers(text), ...scanCurl(text)]),
|
|
2522
2950
|
// The generic label comes after the labels a command or a header names, so where both read one value (a header
|
|
2523
2951
|
// in a string, ruling XXXIX), the cut is named for the narrower label.
|
|
2524
2952
|
rule("secret-assign", "label", (text, ctx) => {
|
|
@@ -2531,7 +2959,8 @@ export const SCRUB_RULES = Object.freeze([
|
|
|
2531
2959
|
...each(text, ENV_FLAG, envFlag),
|
|
2532
2960
|
...helmSetLists(text),
|
|
2533
2961
|
...each(text, NPMRC_AUTH, npmAuth),
|
|
2534
|
-
...
|
|
2962
|
+
...npmSet(text),
|
|
2963
|
+
...scanNpm(text),
|
|
2535
2964
|
];
|
|
2536
2965
|
}),
|
|
2537
2966
|
rule("k8s-secret", "label", (text) => [
|
|
@@ -2551,11 +2980,11 @@ export const SCRUB_RULES = Object.freeze([
|
|
|
2551
2980
|
/** Every module-level pattern the rules read, by name: secret-scrub.test.mjs walks each (redact/match.ts SECRET_SHAPES are scanners, linear by construction)
|
|
2552
2981
|
* and fails on an unbounded quantifier outside its allowlist, and fails on a module-level pattern missing here. */
|
|
2553
2982
|
export const RULE_PATTERNS = Object.freeze({
|
|
2554
|
-
ESCAPE, CONTROLS, DRIVE_PATH, NOT_DIGIT, NOT_HEX, NOT_ALNUM, NOT_BASE64, PLACEHOLDER, ELLIPSIS, TYPE_WORD, GENERIC, PASCAL_TYPE, METAVAR, NAME_PARTS, LEADING_DASHES,
|
|
2983
|
+
ESCAPE, CONTROLS, DRIVE_PATH, QUOTED_DRIVE_PATH, DOT_PATH, NOT_DIGIT, NOT_HEX, NOT_ALNUM, NOT_BASE64, PLACEHOLDER, ELLIPSIS, TYPE_WORD, GENERIC, PASCAL_TYPE, METAVAR, NAME_PARTS, LEADING_DASHES,
|
|
2555
2984
|
CODE_CALL, IDENT_CHAIN, MEMBER_CHAIN, CODE_CASE, CAMEL_OR_SNAKE, CALL_AFTER, LITERAL_START, YAML_NODE, ELIDED_AFTER, REFERENCE, ELIDED, TRAILING_PUNCTUATION, SENTENCE_END, BARE_START, EDGE_BLANK, EDGE_TOKEN_PUNCT, SLUG_OFF, SLUG_ENDS, PEM_END, PEM_BEGIN, PEM_OFF, PEM_TAIL, PEM_BODY_LINE, PEM_LAST_LINE, PEM_END_LINE, LEAD_TOKEN, DIGIT_START, BASE64_CHAR, BACKSLASH_RUN, BARE_STOP, URL_USERINFO, NAME_KEY_OFF, IDENTIFIER, ENDS_ENTRY, ENTRY_END_AFTER, TYPE_SUFFIX, TYPE_AFTER, LOCAL_LEAD, LOCAL_END, NESTED_ESCAPE, COOKIE_SPLIT, LINT_URL, CAMEL_HUMP, NAME_SEPARATORS, DIGITS_ONLY,
|
|
2556
|
-
UPPER_NAME, LEAD_AT_START, LINE_PREFIX, LINE_REST, CODE_KEYWORD, CODE_EXPRESSION, OPENERS, CLOSERS, INI_HEADER, INI_LINE, NPMRC_AUTH,
|
|
2557
|
-
REDIS_COMMAND, REDIS_A, OPENSSL_PASS, NETRC, AUTH_HEADER, TOKEN_RUN, CODE_KEY_BEFORE, URL_SAFE_RUN, BASE64_RUN_BEFORE, BASE64_RUN_AFTER, LETTER_OR_DIGIT, ENV_NAME_RUN, BASE64_CHARS, COOKIE_HEADER, COOKIE_PAIR, CURL_COMMAND, CURL_USER, NUMBERED, JSON_FIELD_OPEN, PROMPT_LINE,
|
|
2558
|
-
ENV_LINE, ENV_COMMAND, PRINTENV_NAMES, ECHO_VARIABLE, NAME_RUN, READ_COMMAND, READ_TOOL, PATH_SEPARATOR, ENV_FILE_NAME, ENV_TEMPLATE, SSH_FILE,
|
|
2985
|
+
UPPER_NAME, LEAD_AT_START, LINE_PREFIX, LINE_REST, CODE_KEYWORD, CODE_EXPRESSION, OPENERS, CLOSERS, INI_HEADER, INI_LINE, NPMRC_AUTH, NPM_COMMAND, NPM_SET_SCAN, NPM_SET_AUTH, NPM_AUTH_KEY, ESCAPED_QUOTE_BEFORE, ESCAPED_QUOTE_AFTER, DOTTED_KEY_BEFORE, CODE_END, MEMBER_OBJECT_BEFORE, CODE_ROOT_BEFORE, STATEMENT_END_AFTER, REFERENCE_START, ENV_ASSIGN, HF_TOKEN, DIGITALOCEAN_TOKEN, PYPI_TOKEN, SENDGRID_KEY, ASSIGN, ASSIGN_SPACED, ASSIGN_COLON, SSHPASS, MYSQL_COMMAND, PASSWORD_FLAG, LOGIN_COMMAND,
|
|
2986
|
+
REDIS_COMMAND, LOGIN_SCAN, LOGIN_P, REDIS_SCAN, REDIS_A, MYSQL_SCAN, MYSQL_P, OPENSSL_PASS, NETRC, AUTH_HEADER, TOKEN_RUN, CODE_KEY_BEFORE, URL_SAFE_RUN, BASE64_RUN_BEFORE, BASE64_RUN_AFTER, LETTER_OR_DIGIT, ENV_NAME_RUN, BASE64_CHARS, COOKIE_HEADER, COOKIE_PAIR, CURL_COMMAND, CURL_SCAN, CURL_USER, GLUED_STOP, NUMBERED, JSON_FIELD_OPEN, PROMPT_LINE,
|
|
2987
|
+
ENV_LINE, ENV_COMMAND, PRINTENV_NAMES, ECHO_VARIABLE, COMMAND_SPLIT, COMMAND_BLANKS, PROMPT_WORD, ASSIGNMENT_WORD, REDIRECT_WORD, REDIRECT_ALONE, VARIABLE_WORD, WORD_EDGE_QUOTES, SCRIPT_FLAG, NUMBER_WORD, PRINT_FLAG, NAME_RUN, READ_COMMAND, READ_TOOL, PATH_SEPARATOR, ENV_FILE_NAME, ENV_TEMPLATE, SSH_FILE,
|
|
2559
2988
|
CREDENTIAL_FILE, FILE_VARIABLE, ENV_FILE_LINE, KEY_LINE, SSH_CONFIG, COMMENT_LINE, PEM_LINE, BASE64_LINE, PEM_HEADER_LINE, HOME_UNIX, HOME_WINDOWS, SEGMENT_AFTER,
|
|
2560
2989
|
TRAILING_SLASHES, HOME_USER, CLAUDE_SLUG, CLAUDE_PROJECTS_BEFORE, SLUG_OFF_CHARS, SLUG_USER, BOT_TRAILER, DUMP_MARKER_LINE, EMAIL, EXAMPLE_DOMAIN, NO_REPLY_LOCAL, NO_REPLY_DOMAIN, FORGE_NO_REPLY, USER_ONLY_BEFORE, PORT_PASSWORD, HOST_SHAPED, IPV4, VERSION_BEFORE, PRE_RELEASE_AFTER,
|
|
2561
2990
|
BUILD_AFTER, RANGE_AFTER, IPV6, IPV6_GROUPS, ENV_PREFIX_BEFORE, ENV_PREFIX_AFTER, ENV_PREFIX_CHAIN, ENV_PREFIX_STATEMENT, ENV_FLAG, HELM_LIST_FLAG, HELM_SET, HELM_NAME, RESOURCE_NAME, SECRET_OBJECT_NAME, CONNECTION_PASSWORD, ADO_PAIR, CONNECTION_KEY_PAIR, BLANKS, LIBPQ_PAIR_AFTER, FORMAT_FIELD, PWD_PATH, QUERY_VALUE_STOP, QUERY_PASSWORD, ARGUMENT_TAIL, NEXT_ASSIGNMENT, ASSIGNMENT_BEFORE,
|