@bridge_gpt/mcp-server 0.2.73 → 0.2.74

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.
Files changed (90) hide show
  1. package/README.md +5 -5
  2. package/build/agent-launchers/claude-executor-adapter.js +12 -0
  3. package/build/agents.generated.js +3 -3
  4. package/build/bridge-config.js +7 -1
  5. package/build/bridge-permissions.js +3 -0
  6. package/build/command-provisioning.js +4 -3
  7. package/build/commands.generated.js +5 -5
  8. package/build/conductor/bridge-api-client.js +26 -1
  9. package/build/conductor/command-drift.js +1 -1
  10. package/build/conductor/declared-extras.js +335 -0
  11. package/build/conductor/doctor.js +2 -0
  12. package/build/conductor/driver-pass-output.js +104 -0
  13. package/build/conductor/driver-pass.js +571 -0
  14. package/build/conductor/epic-branch-ci-inspection.js +61 -16
  15. package/build/conductor/epic-implementer-cli.js +33 -0
  16. package/build/conductor/epic-server-sfcc-upload.js +1567 -0
  17. package/build/conductor/epic-server-sfcc.js +58 -80
  18. package/build/conductor/epic-server.js +57 -4
  19. package/build/conductor/gate-discovery.js +46 -6
  20. package/build/conductor/gate-settings-review.js +51 -14
  21. package/build/credential-delivery.js +280 -0
  22. package/build/credential-launch-safety.js +142 -0
  23. package/build/credential-materialization.js +91 -16
  24. package/build/credential-references-node-deps.js +29 -0
  25. package/build/credential-references.js +1394 -0
  26. package/build/credential-references.test-fixtures.js +211 -0
  27. package/build/credential-scan-conventions.js +145 -0
  28. package/build/credential-scan.js +517 -0
  29. package/build/credential-store.js +50 -0
  30. package/build/credentials-cli.js +252 -3
  31. package/build/dependency-install-declarations.js +47 -1
  32. package/build/docs.generated.js +8 -1
  33. package/build/doctor.js +41 -0
  34. package/build/drive-epic.js +297 -37
  35. package/build/epic-branch-ci-summary.js +18 -1
  36. package/build/epic-capability-statement.js +71 -3
  37. package/build/epic-ci-workflow-drift.js +52 -13
  38. package/build/epic-ci-workflow-install.js +31 -6
  39. package/build/epic-ci-workflow-v3.js +273 -0
  40. package/build/epic-ci-workflow.js +128 -7
  41. package/build/epic-implementer-bin.js +161 -70
  42. package/build/epic-launch-context.js +102 -7
  43. package/build/epic-server-record.js +30 -15
  44. package/build/executor/credential-delivery-step.js +168 -0
  45. package/build/executor/deps.js +3 -1
  46. package/build/executor/env.js +39 -1
  47. package/build/executor/epic-server-context.js +23 -7
  48. package/build/executor/guarded-fast-forward-push.js +13 -8
  49. package/build/executor/job-runner.js +159 -17
  50. package/build/executor/permissions.js +85 -3
  51. package/build/executor/prompt-spec.js +37 -3
  52. package/build/executor-launch.js +4 -2
  53. package/build/git-exclude-lock.js +187 -0
  54. package/build/index.js +398 -269
  55. package/build/install-bridge-conductor-answers.js +84 -21
  56. package/build/install-bridge-conductor-apply.js +30 -1
  57. package/build/install-bridge-conductor-assessment.js +375 -48
  58. package/build/install-bridge-conductor-compact.js +27 -2
  59. package/build/install-bridge-conductor-contracts.js +10 -1
  60. package/build/install-bridge-conductor-gate.js +124 -11
  61. package/build/install-bridge-conductor-setup.js +46 -8
  62. package/build/install-bridge-conductor.js +625 -113
  63. package/build/install-bridge.js +88 -11
  64. package/build/install-doctor.js +38 -8
  65. package/build/install-sfcc-detection.js +120 -0
  66. package/build/install-sfcc-setup.js +185 -0
  67. package/build/mcp-grant-candidates.js +108 -96
  68. package/build/mcp-invoke.js +168 -4
  69. package/build/mcp-provisioning.js +21 -4
  70. package/build/mcp-server-invocation.js +13 -0
  71. package/build/merge-workflow-install.js +9 -1
  72. package/build/pipelines.generated.js +2 -1
  73. package/build/plane/status.js +8 -2
  74. package/build/printed-remedy-commands.js +5 -0
  75. package/build/project-root.js +40 -0
  76. package/build/readme.generated.js +1 -1
  77. package/build/repository-state-paths.js +5 -2
  78. package/build/repository-toolchains.js +6 -3
  79. package/build/setup-epic.js +116 -15
  80. package/build/sfcc/credentials.js +3 -2
  81. package/build/sfcc/hostname.js +98 -2
  82. package/build/sfcc/tool-wrapper.js +6 -95
  83. package/build/start-tickets.js +193 -29
  84. package/build/test-support/executor-source-files.js +200 -0
  85. package/build/testing-config-client.js +25 -2
  86. package/build/third-party-mcp-targets.js +35 -4
  87. package/build/version.generated.js +3 -3
  88. package/build/with-credentials.js +208 -0
  89. package/build/worktree-credential-delivery.js +340 -0
  90. package/package.json +1 -1
@@ -15,21 +15,43 @@
15
15
  * the executor host's interactive `claude login`, or, headlessly, through an
16
16
  * operator-exported `CLAUDE_CODE_OAUTH_TOKEN` that Bridge only forwards and
17
17
  * never stores — there is nothing left for this CLI to onboard.
18
- * `migrate-agent-config` is the only supported subcommand.
18
+ * `migrate-agent-config` and `references` are the supported subcommands.
19
+ *
20
+ * `references list [--json]` and `references apply --file <proposal.json>
21
+ * --expect-digest <digest>` (BAPI-1646) record and show the per-repository
22
+ * worker credential REFERENCES (names and source locations, never values). They
23
+ * deliver nothing to workers.
24
+ *
25
+ * `references scan --json` (BAPI-1648) inventories credential candidates for the
26
+ * `/install-bridge` review and prints exactly one JSON document of names,
27
+ * locations, key mappings, and launch fingerprints. Discovery does not open an
28
+ * ignored or untracked credential candidate, with ONE exception: an ignored or
29
+ * untracked root `dw.json` gets a bounded check whose only outputs are a closed
30
+ * host class (sfcc_sandbox, not_sandbox, unknown) and the names of the mapped
31
+ * selectors that are present. The status step may resolve sources the owner has
32
+ * already approved. It writes nothing and starts no MCP server.
19
33
  *
20
34
  * This subcommand owns the WRITE path so the `doctor` subcommand can remain
21
35
  * strictly read-only. Secret values are NEVER printed anywhere: the migration
22
36
  * references only candidate `filePath`/`serverName`.
23
37
  */
24
- import { readFile, mkdir, writeFile, rename, chmod, unlink, open } from "fs/promises";
38
+ import { readFile, mkdir, writeFile, rename, chmod, unlink, open, lstat } from "fs/promises";
25
39
  import os from "os";
26
40
  import readline from "readline";
27
41
  import { migrateAgentConfigCredentialToStore, } from "./agent-config-credential-migration.js";
42
+ import { listRepositoryCredentialTargetNames, } from "./credential-store.js";
43
+ import { scanCredentialReferences } from "./credential-scan.js";
44
+ import { knownBridgeUrlMatcher } from "./mcp-grant-candidates.js";
45
+ import { DEFAULT_BRIDGE_BASE_URL } from "./init.js";
46
+ import { execFile } from "child_process";
47
+ import { applyCredentialReferences, credentialReferenceListJson, formatApplyStatusLines, formatCredentialReferenceList, readCredentialReferenceRecord, statusOnly, } from "./credential-references.js";
48
+ import { createNodeCredentialReferenceApplyDeps, createNodeCredentialReferenceDeps, } from "./credential-references-node-deps.js";
28
49
  import { MCP_PACKAGE_NAME } from "./mcp-identity.js";
50
+ import { resolveRequiredStartTicketsRepoName, } from "./start-tickets-repo.js";
29
51
  /** The only agent-config sources the migration knows how to scan. */
30
52
  const ALLOWED_SOURCES = [".mcp.json", ".cursor/mcp.json"];
31
53
  /** Every subcommand this CLI accepts, in help order. */
32
- const SUBCOMMANDS = ["migrate-agent-config"];
54
+ const SUBCOMMANDS = ["migrate-agent-config", "references"];
33
55
  /** User-facing usage text for the `credentials` subcommand. */
34
56
  export function getCredentialsUsage() {
35
57
  return [
@@ -47,6 +69,38 @@ export function getCredentialsUsage() {
47
69
  " Without --write-credentials this is a dry preview: it scans and reports what",
48
70
  " it WOULD migrate but writes nothing.",
49
71
  "",
72
+ ` npx -y ${MCP_PACKAGE_NAME} credentials references list [--json]`,
73
+ ` npx -y ${MCP_PACKAGE_NAME} credentials references apply \\`,
74
+ " --file <proposal.json> --expect-digest <digest>",
75
+ ` npx -y ${MCP_PACKAGE_NAME} credentials references scan --json`,
76
+ "",
77
+ "references list",
78
+ " Shows the worker credential references recorded for this repository: each",
79
+ " entry's name, level, source location, key names, consumers, and whether its",
80
+ " source is present, missing, or unreadable. With --json it also prints the",
81
+ " record state and record_digest (the SHA-256 of the record file, or 'absent').",
82
+ "",
83
+ "references apply",
84
+ " Replaces the WHOLE list with the proposal's list. The proposal holds names and",
85
+ " paths only, never values. --expect-digest must equal the current record_digest",
86
+ " ('absent' when there is no record), so a record changed since you listed it is",
87
+ " never overwritten. Afterwards it prints each entry's status; a missing source is",
88
+ " a warning, not a failure.",
89
+ "",
90
+ "references scan",
91
+ " Prints one JSON document of credential candidates: file names and locations,",
92
+ " template key names, MCP server names and key names, launch fingerprints, and",
93
+ " the current record with its status. Discovery stays names-only and does not",
94
+ " open an ignored or untracked credential file, except one bounded check of an",
95
+ " ignored or untracked root dw.json. That check prints only a host class",
96
+ " (sfcc_sandbox, not_sandbox, or unknown) and the names of the selectors",
97
+ " present; never a host, a value, or an error. Separately, the status step may",
98
+ " read sources you already approved. It uses the same repository selection as",
99
+ " list, writes nothing, and never prints a value.",
100
+ "",
101
+ " These commands only record and show references. They do not deliver credentials",
102
+ " to workers.",
103
+ "",
50
104
  "Flags:",
51
105
  " --write-credentials Consent to write the discovered key into the store",
52
106
  " --no-write-credentials Dry preview only (default)",
@@ -55,6 +109,70 @@ export function getCredentialsUsage() {
55
109
  " -h, --help Show this help",
56
110
  ].join("\n");
57
111
  }
112
+ const REFERENCES_VERBS_TEXT = "Expected one of: list, apply, scan.";
113
+ const EXPECT_DIGEST_RE = /^(absent|[0-9a-f]{64})$/;
114
+ function referencesError(message) {
115
+ return { status: "error", message };
116
+ }
117
+ /**
118
+ * Parse the nested `references` verbs strictly. Every diagnostic is fixed text:
119
+ * submitted argument contents are never echoed.
120
+ */
121
+ function parseReferencesArgs(rest) {
122
+ const verb = rest[0];
123
+ if (verb === undefined)
124
+ return referencesError(`Missing references verb. ${REFERENCES_VERBS_TEXT}`);
125
+ const args = rest.slice(1);
126
+ if (verb === "list") {
127
+ let json = false;
128
+ for (const arg of args) {
129
+ if (arg !== "--json")
130
+ return referencesError("references list accepts only --json.");
131
+ if (json)
132
+ return referencesError("--json was given more than once.");
133
+ json = true;
134
+ }
135
+ return { status: "ok", subcommand: "references", verb: "list", json };
136
+ }
137
+ if (verb === "scan") {
138
+ if (args.length !== 1 || args[0] !== "--json")
139
+ return referencesError("references scan accepts only --json, which is required.");
140
+ return { status: "ok", subcommand: "references", verb: "scan", json: true };
141
+ }
142
+ if (verb === "apply") {
143
+ let file;
144
+ let expectDigest;
145
+ for (let i = 0; i < args.length; i += 2) {
146
+ const flag = args[i];
147
+ if (flag !== "--file" && flag !== "--expect-digest") {
148
+ return referencesError("references apply accepts only --file <proposal.json> and --expect-digest <digest>.");
149
+ }
150
+ const value = args[i + 1];
151
+ if (value === undefined || value.startsWith("--") || value.length === 0) {
152
+ return referencesError("A references option is missing its value.");
153
+ }
154
+ if (flag === "--file") {
155
+ if (file !== undefined)
156
+ return referencesError("--file was given more than once.");
157
+ file = value;
158
+ }
159
+ else {
160
+ if (expectDigest !== undefined)
161
+ return referencesError("--expect-digest was given more than once.");
162
+ expectDigest = value;
163
+ }
164
+ }
165
+ if (file === undefined)
166
+ return referencesError("references apply requires --file <proposal.json>.");
167
+ if (expectDigest === undefined)
168
+ return referencesError("references apply requires --expect-digest <digest>.");
169
+ if (!EXPECT_DIGEST_RE.test(expectDigest)) {
170
+ return referencesError("--expect-digest must be 'absent' or a lower-case 64-character hex digest.");
171
+ }
172
+ return { status: "ok", subcommand: "references", verb: "apply", file, expectDigest };
173
+ }
174
+ return referencesError(`Unknown references verb. ${REFERENCES_VERBS_TEXT}`);
175
+ }
58
176
  /**
59
177
  * Parse argv strictly. Supports the `migrate-agent-config` subcommand,
60
178
  * `--write-credentials` / `--no-write-credentials` (last one wins; default
@@ -65,6 +183,8 @@ export function parseCredentialsArgs(argv) {
65
183
  if (argv.includes("-h") || argv.includes("--help")) {
66
184
  return { status: "help" };
67
185
  }
186
+ if (argv[0] === "references")
187
+ return parseReferencesArgs(argv.slice(1));
68
188
  const positionals = [];
69
189
  let writeCredentials = false;
70
190
  const sources = [];
@@ -173,6 +293,132 @@ export function createDefaultCredentialsDeps(writeCredentials) {
173
293
  errorLog: (m) => console.error(m),
174
294
  };
175
295
  }
296
+ export function createDefaultReferenceCliDeps(log, errorLog) {
297
+ const env = process.env;
298
+ const referenceDeps = createNodeCredentialReferenceDeps(env);
299
+ const applyDeps = createNodeCredentialReferenceApplyDeps(env);
300
+ return {
301
+ log,
302
+ errorLog,
303
+ env,
304
+ cwd: process.cwd(),
305
+ readFile: (p) => readFile(p, "utf-8"),
306
+ resolveRepo: resolveRequiredStartTicketsRepoName,
307
+ referenceDeps,
308
+ applyDeps,
309
+ inspect: async (repoName) => {
310
+ const read = await readCredentialReferenceRecord(repoName, referenceDeps);
311
+ const status = await statusOnly(repoName, referenceDeps);
312
+ return { status, record: read.state === "ok" ? read.record : null };
313
+ },
314
+ apply: (input) => applyCredentialReferences({ ...input, deps: applyDeps }),
315
+ scan: (repoName) => runCredentialScan(repoName, env, referenceDeps),
316
+ };
317
+ }
318
+ const GIT_OUTPUT_LIMIT = 64 * 1024 * 1024;
319
+ /** Production scan wiring: real Git, real reads, the shared reference reader. */
320
+ function runCredentialScan(repoName, env, referenceDeps) {
321
+ const bridgeUrls = [DEFAULT_BRIDGE_BASE_URL, env.BAPI_BASE_URL].filter((u) => typeof u === "string" && u.trim().length > 0);
322
+ const matchers = bridgeUrls.map((u) => knownBridgeUrlMatcher(u));
323
+ return scanCredentialReferences({
324
+ repoName,
325
+ checkout: process.cwd(),
326
+ homedir: referenceDeps.homedir,
327
+ platform: referenceDeps.platform,
328
+ readFile: referenceDeps.readFile,
329
+ lstat,
330
+ runGit: (file, args, options) => new Promise((resolve) => {
331
+ execFile(file, args, { cwd: options?.cwd, maxBuffer: GIT_OUTPUT_LIMIT, encoding: "utf8" }, (error, stdout, stderr) => {
332
+ const code = error ? (typeof error.code === "number" ? (error.code) : 128) : 0;
333
+ resolve({ stdout: String(stdout ?? ""), stderr: String(stderr ?? ""), exitCode: code });
334
+ });
335
+ }),
336
+ listStoreTargets: (repo) => listRepositoryCredentialTargetNames(repo, {
337
+ env: referenceDeps.env,
338
+ homedir: referenceDeps.homedir,
339
+ platform: referenceDeps.platform,
340
+ readFile: referenceDeps.readFile,
341
+ stat: referenceDeps.stat,
342
+ }),
343
+ readRecord: (repo) => readCredentialReferenceRecord(repo, referenceDeps),
344
+ statusOnly: (repo) => statusOnly(repo, referenceDeps),
345
+ isKnownBridgeUrl: (value) => matchers.some((m) => m(value)),
346
+ });
347
+ }
348
+ const REFERENCES_FAILED_TEXT = "Error: the credential references command failed; nothing was written.";
349
+ async function runReferencesCli(parsed, deps) {
350
+ try {
351
+ let repoName;
352
+ try {
353
+ const resolved = await deps.resolveRepo({ env: deps.env, cwd: deps.cwd, readFile: deps.readFile });
354
+ if (!resolved.ok)
355
+ throw new Error("repo");
356
+ repoName = resolved.repoName;
357
+ }
358
+ catch {
359
+ deps.errorLog("Error: could not resolve the repository name (set BAPI_REPO_NAME or add a valid .bridge/config).");
360
+ return 1;
361
+ }
362
+ if (parsed.verb === "scan") {
363
+ let result;
364
+ try {
365
+ result = await deps.scan(repoName);
366
+ }
367
+ catch {
368
+ deps.errorLog("Error: the credential scan failed; nothing was written.");
369
+ return 1;
370
+ }
371
+ // Exactly one JSON document on stdout; source problems are inside it.
372
+ deps.log(JSON.stringify(result, null, 2));
373
+ return 0;
374
+ }
375
+ if (parsed.verb === "list") {
376
+ const { status, record } = await deps.inspect(repoName);
377
+ if (parsed.json) {
378
+ deps.log(JSON.stringify(credentialReferenceListJson(repoName, status, record), null, 2));
379
+ }
380
+ else {
381
+ deps.log(formatCredentialReferenceList(repoName, status, record));
382
+ }
383
+ return 0;
384
+ }
385
+ let proposalText;
386
+ try {
387
+ proposalText = await deps.readFile(parsed.file);
388
+ }
389
+ catch {
390
+ deps.errorLog("Error: the proposal file could not be read; nothing was written.");
391
+ return 1;
392
+ }
393
+ const result = await deps.apply({ repoName, proposalText, expectDigest: parsed.expectDigest });
394
+ if (!result.ok) {
395
+ deps.errorLog(`Error: ${result.message}.`);
396
+ for (const refusal of result.refusals ?? [])
397
+ deps.errorLog(` - ${refusal.entry}: ${refusal.reason}`);
398
+ if (result.kind === "stale_digest") {
399
+ if (result.changes) {
400
+ const { added, removed, changed } = result.changes;
401
+ deps.errorLog(` would add: ${added.length > 0 ? added.join(", ") : "none"}`);
402
+ deps.errorLog(` would remove: ${removed.length > 0 ? removed.join(", ") : "none"}`);
403
+ deps.errorLog(` would change: ${changed.length > 0 ? changed.join(", ") : "none"}`);
404
+ }
405
+ else {
406
+ deps.errorLog(" entry comparison unavailable: the current record cannot be compared.");
407
+ }
408
+ deps.errorLog("List the record again with 'references list --json' and use its record_digest.");
409
+ }
410
+ return 1;
411
+ }
412
+ deps.log(`Recorded ${result.record.credentials.length} credential reference(s) for ${repoName}.`);
413
+ for (const line of formatApplyStatusLines(result.status))
414
+ deps.log(line);
415
+ return 0;
416
+ }
417
+ catch {
418
+ deps.errorLog(REFERENCES_FAILED_TEXT);
419
+ return 1;
420
+ }
421
+ }
176
422
  /**
177
423
  * CLI entry for the `credentials` subcommand. Returns a process exit code. Help
178
424
  * returns 0; parser errors return 1. For `migrate-agent-config`, the only
@@ -199,6 +445,9 @@ export async function runCredentialsCli(argv, overrides) {
199
445
  errorLog(getCredentialsUsage());
200
446
  return 1;
201
447
  }
448
+ if (parsed.subcommand === "references") {
449
+ return runReferencesCli(parsed, { ...createDefaultReferenceCliDeps(log, errorLog), ...overrides?.references });
450
+ }
202
451
  // Build deps: defaults seeded with the parsed consent flag, then any overrides.
203
452
  const baseDeps = createDefaultCredentialsDeps(parsed.writeCredentials);
204
453
  const deps = { ...baseDeps, ...overrides };
@@ -16,7 +16,8 @@
16
16
  *
17
17
  * Nothing here logs, and nothing returned for a refusal carries an argv item. A
18
18
  * `cwd` is returned beside a refusal only after it passed the path rules, so it
19
- * is safe to print.
19
+ * is safe to print. BAPI-1677 adds one shared safety rule to both postures: an entry
20
+ * carrying a credential shape, an environment reference, or `${{` is invalid.
20
21
  *
21
22
  * Identity: two entries are duplicates when they share the canonical
22
23
  * `(cwd, sorted lockfiles)` pair. A JavaScript and a Python toolchain at the same
@@ -34,6 +35,45 @@ const ENTRY_KEYS = new Set(["cwd", "argv", "lockfiles"]);
34
35
  /** Absolute-looking, backslash, colon, and every control or line-separator character. */
35
36
  const FORBIDDEN_PATH_CHARS = /[:\\\x00-\x1f\x7f-\x9f\u2028\u2029]/;
36
37
  const FORBIDDEN_ARG_CHARS = /[\u0000\r\n]/;
38
+ /**
39
+ * BAPI-1677 — the one refusal for an install entry that carries a secret or an
40
+ * expression. Fixed text: it never includes any part of the submitted entry.
41
+ */
42
+ export const DEPENDENCY_INSTALL_UNSAFE_MESSAGE = "An install command must not carry a credential, a token, an environment reference, or a GitHub Actions expression.";
43
+ /** `scheme://user@` or `scheme://user:password@`, anywhere inside one argument. */
44
+ const URL_USERINFO_RE = /[A-Za-z][A-Za-z0-9+.-]*:\/\/[^/\s?#]*@/;
45
+ /**
46
+ * The established credential shapes (`TOKEN_SHAPED_RE` in the answers parser and
47
+ * `conductor/redaction.ts`), matched anywhere so `--option=value` is covered.
48
+ * Deliberate false positives: a run of 40 or more identifier characters and an
49
+ * `sk-` word read as tokens even when they are not. There is no bypass; a person
50
+ * with such an argument moves it into a file the install command reads.
51
+ */
52
+ const TOKEN_SHAPED_ARG_RE = /\bgh[pousr]_[A-Za-z0-9]{6,}|\bgithub_pat_|[A-Za-z0-9_-]{40,}|eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+|\b(?:AKIA|ASIA)[0-9A-Z]{16}\b|\bsk-(?:ant-|proj-)?[A-Za-z0-9_-]{6,}/;
53
+ /** `$NAME`, `${NAME}` (any `${` form, including `${{`), and `%NAME%`. */
54
+ const ENVIRONMENT_REFERENCE_RE = /\$\{|\$[A-Za-z_]|%[A-Za-z_][A-Za-z0-9_]*%/;
55
+ /** The opener GitHub Actions evaluates inside a `run:` or `working-directory:` value. */
56
+ const ACTIONS_EXPRESSION_OPENER = "${{";
57
+ /** True when one argument carries URL userinfo, a token shape, or an environment reference. */
58
+ export function isUnsafeDependencyInstallArg(arg) {
59
+ return URL_USERINFO_RE.test(arg) || TOKEN_SHAPED_ARG_RE.test(arg) || ENVIRONMENT_REFERENCE_RE.test(arg);
60
+ }
61
+ /**
62
+ * BAPI-1677 — the stateless safety check over an entry's known fields. It looks only
63
+ * at the strings present, so it can run before or after the shape rules, and it
64
+ * returns a boolean so no caller can echo what matched.
65
+ */
66
+ export function isUnsafeDependencyInstallEntry(raw) {
67
+ if (typeof raw !== "object" || raw === null)
68
+ return false;
69
+ const { cwd, argv, lockfiles } = raw;
70
+ const strings = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
71
+ if (typeof cwd === "string" && cwd.includes(ACTIONS_EXPRESSION_OPENER))
72
+ return true;
73
+ if (strings(lockfiles).some((file) => file.includes(ACTIONS_EXPRESSION_OPENER)))
74
+ return true;
75
+ return strings(argv).some(isUnsafeDependencyInstallArg);
76
+ }
37
77
  /**
38
78
  * True when `value` is a safe repository-relative path: not absolute, no `..`,
39
79
  * no `.` segment, no empty segment, no backslash, colon, or control character.
@@ -66,6 +106,9 @@ export function checkDependencyInstallEntry(raw) {
66
106
  const { cwd, argv, lockfiles } = item;
67
107
  if (typeof cwd !== "string")
68
108
  return { ok: false, reason: "dependency_install_invalid_entry" };
109
+ // An unsafe path is refused before the path rules, so it is never returned as printable.
110
+ if (cwd.includes(ACTIONS_EXPRESSION_OPENER))
111
+ return { ok: false, reason: "dependency_install_invalid_entry" };
69
112
  if (!isSafeRepoRelativePath(cwd, { allowRoot: true })) {
70
113
  return { ok: false, reason: "dependency_install_invalid_path" };
71
114
  }
@@ -94,6 +137,9 @@ export function checkDependencyInstallEntry(raw) {
94
137
  return { ok: false, reason: "dependency_install_duplicate", cwd };
95
138
  seenLockfiles.add(file);
96
139
  }
140
+ if (isUnsafeDependencyInstallEntry({ cwd, argv, lockfiles })) {
141
+ return { ok: false, reason: "dependency_install_invalid_entry", cwd };
142
+ }
97
143
  return { ok: true, entry: { cwd, argv: [...argv], lockfiles: [...lockfiles] } };
98
144
  }
99
145
  /**