* chore(#604): rename get-shit-done/ runtime directory to gsd-core/ Renames the installed runtime directory `get-shit-done/` to `gsd-core/` so the on-disk name matches the package (`@opengsd/gsd-core`), repo, and binary (`gsd-tools`). The npm package name and binary are unchanged; npx/npm consumers are unaffected. Mechanical (bulk, ~90% of the diff): - `git mv get-shit-done gsd-core` - Swept path/identifier references across the repo via `perl -pe 's/get-shit-done(?!-\w)/gsd-core/g'`. The negative lookahead preserves the five legitimate slug variants that are NOT the directory: get-shit-done-{OLD,cc,classic,cli,redux} (old package/repo names). - Build/manifest wiring: package.json (bin, files, coverage globs), tsconfig.build.json (outDir), ~86 .gitignore build-output entries, stryker.config.mjs, scan-ignore files, install.js path strings. - Frozen (not rewritten): CHANGELOG.md history; translated docs (README.<locale>.md and docs/{ja-JP,ko-KR,pt-BR,zh-CN}/). New logic (review here): - src/installer-migrations/003-rename-get-shit-done-to-gsd-core.cts: a proper ADR-0008 installer migration. On upgrade it walks the legacy `~/.claude/get-shit-done/` tree, classifies each file via the prior install manifest, and emits remove-managed / backup-and-remove for managed files while PRESERVING unknown user-added files. Symlink-safe (skips a symlinked root and symlinked entries; bounds-checks every path under configDir). The framework rolls back on install failure. Emptied dirs may remain (framework has no recursive dir-removal primitive) — documented. - scripts/lint-legacy-dir-name.cjs: CI regression guard forbidding the bare `get-shit-done` directory token (split token to avoid self-match; case- insensitive; `(?!-\w)` lookahead allows the slug variants; allowlists CHANGELOG, translated docs, and `gsd-allow-legacy-name` marker lines). Wired into the lint-tests CI job. - Restored scripts/lint-package-identity-drift.cjs detection regexes (the mechanical sweep had wrongly rewritten the old-name patterns it exists to detect) and marked them as intentional legacy references. - TDD tests for the migration and the guard; do.md slash-command guard regex tightened so a `/gsd-core/bin` path segment is not mistaken for a command; changeset + docs/installer-migrations.md row added. Breaking: the installed runtime path moves `~/.claude/get-shit-done/` -> `~/.claude/gsd-core/`. Migration 003 removes the stale legacy dir's managed files (preserving user files) on upgrade. Users with custom hooks/configs hardcoding the old path must update them. Closes #604 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): unsweep pending changesets + allowlist injection-example docs CI fixes for the rename PR: - Do not sweep pending .changeset/*.md (ephemeral release-note fragments, like CHANGELOG); reverted those body edits so 5 pre-existing malformed fragments (missing type/pr) no longer enter the PR diff and trip docs-lint. Allowlisted .changeset/ in the legacy-name guard accordingly. - Allowlisted TEST-EXAMPLES.md and docs/explanation/security-model.md in prompt-injection-scan.sh: they contain intentional injection examples / security-model prose; the path-reference rewrites are kept. CodeQL alerts on this PR are pre-existing (alert lines unchanged by this PR; none in the new migration/guard) and are out of scope for the rename. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): resolve CodeQL alerts surfaced on this PR The rename diff touched files carrying pre-existing CodeQL findings; per the no-pre-existing-dismissal rule, fixing every surfaced alert rather than waving them off. All behavior-preserving: - scripts/ci-test-scope.cjs: build the config-path match from string .includes() instead of a RegExp over an arg-derived value (js/regex-injection). - src/profile-output.cts: escape backslashes before pipe-escaping desc/safeName so the table-cell escape is complete (js/incomplete-sanitization). - tests/{bug-2643,bug-2808,docs-parity-live-registry}: two-pass HTML-comment strip so a bare/unclosed `<!--` cannot survive (js/incomplete-multi-character-sanitization). - tests/inline-plan-threshold: drop the no-op `\s`->`\s` identity replace, keep the meaningful POSIX-class conversion (js/identity-replacement). Verified: build:lib green; the touched test files + ci-test-scope + profile-output suites pass; lint:legacy-name clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): correctly resolve remaining CodeQL alerts (regex-injection + sanitization) The prior commit's fixes for two alerts were ineffective: - ci-test-scope.cjs js/regex-injection: the alert is the CLI-arg-derived `file` reaching static regex `.test(file)` calls (not the config rule). Removed ALL regex over file/t — startsWith/includes/=== string checks + an isWindowsHint helper — so there is no regex sink for the tainted value. - js/incomplete-multi-character-sanitization (3 test files): a single `.replace(/<!--...-->/g,'')` can let `<!--` re-form. Replaced with a fixpoint loop (replace until stable) plus a final bare-opener strip. Verified: no regex over file/t remains; ci-test-scope + the 3 test suites pass; lint:legacy-name clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): make ci-test-scope + comment-strippers regex-free to clear CodeQL CodeQL flags the regex PATTERNS syntactically (regex-injection on the --files arg split; incomplete-multi-character-sanitization on the <!--...--> replace), so loop fixes do not satisfy it. Made these paths regex-free: - ci-test-scope.cjs splitFiles: char-by-char separator tokenizer (no /[,\\s]+/). - 3 test files: indexOf/slice HTML-comment stripper (no .replace(/<!--/)). Behavior preserved; ci-test-scope + the 3 suites pass; guard clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): unblock security base64 scan on the large rename diff The security job hit its 10m timeout: base64-scan.sh choked on the binary test fixture tests/feat-3594-parser-property-style.test.cjs (embedded NUL/ non-UTF8 bytes -> thousands of bogus blobs + "ignored null byte" warnings), and the ~800-file rename diff is slow to scan regardless. - scripts/base64-scan.sh: skip binary-by-content files (grep -Iq .) — they can't carry base64-obfuscated *text* and feeding NUL bytes through the per-line scanner is pathologically slow. collect_files already filtered binary *extensions*; this catches binary *content* in text extensions. - .github/workflows/security-scan.yml: raise the security job timeout 10m->30m to accommodate very large diffs (the scan itself is unchanged). Verified locally: scan skips the fixture, 0 "ignored null byte" warnings, 0 findings, exit 0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): sweep get-shit-done refs introduced by merging next The branch was updated with next (#614/#384/#618 etc.), which reference the get-shit-done/ dir (still named that on next). Swept the stale references in the merged files to gsd-core so the rename stays consistent and lint:legacy-name passes: - commands/gsd/discuss-phase.md (runtime-launcher shim paths) - src/core.cts (getAgentsDir layout comments) - tests/bug-384-agents-runtime-aware.test.cjs (require path to runtime lib) Verified: guard 0 violations; build green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): exclude gsd-core/ path segments from bug-3683 command cross-ref invariant The #614 runtime-launcher shim added to discuss-phase.md references `${_GSD_RUNTIME_ROOT}/gsd-core/bin/...`. bug-3683's REF_PATTERN excluded path-y refs only via lookbehind, but `}` precedes `/gsd-core/` in the shim, so it mis-read the directory path as a dangling `/gsd-core` command ref (same class as the #604 bug-2954 fix). Added a trailing `(?![\w-]*\/)` so `/gsd-<x>/...` path segments are not treated as slash-command references. Verified locally on BOTH platforms before pushing: - mac (node 26) full suite: 0 failures - gsd-test-runner (linux, node22 image) full suite: 0 failures - bug-3683 + bug-2954 pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): lazily resolve findProjectRoot in gsd-tools (harden flaky CI) CI intermittently failed state.test's gsd-tools subprocess with "findProjectRoot is not a function" (flip-flopping across legs; not reproducible on mac full suite, gsd-test linux full suite, test:unit, or state.test x8). findProjectRoot is a re-export from core.cjs (sourced from project-root.cjs); binding it via destructure at module-load can be undefined under a load-ordering edge. Resolve it lazily at call time via a small wrapper so the lookup happens after core.cjs is fully initialized. Verified green on BOTH platforms before pushing: - mac (node 26) full suite: 0 failures - gsd-test-runner (linux, node22) full suite: 0 failures - state.test.cjs: 106/106; gsd-tools loads cleanly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(#604): allowlist verification-patterns.md placeholder examples in secret scan The rename git-mv'd references/verification-patterns.md into gsd-core/, pulling it into the secret-scan diff. It documents stub/placeholder RED-FLAG env-var examples (illustrative Stripe test-key / database-URL / API-key placeholders) — not real credentials. Added it to .secretscanignore with the strict annotation, mirroring the existing gsd-core/workflows/plan-phase.md exception. Verified locally: secret-scan-lint --strict OK; secret-scan --diff origin/next exits 0 with 0 findings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
398 lines
18 KiB
JavaScript
398 lines
18 KiB
JavaScript
'use strict';
|
|
|
|
// allow-test-rule: source-text-is-the-product
|
|
// Reads .md/.json/.yml product files whose deployed text IS what the
|
|
// runtime loads — testing text content tests the deployed contract.
|
|
|
|
/**
|
|
* #2529 — /gsd-settings-integrations: configure third-party search and review integrations.
|
|
*
|
|
* Covers:
|
|
* - Artifacts exist (command, workflow, skill stub) with correct frontmatter
|
|
* - Workflow references the four search API key fields
|
|
* - Workflow exposes review.models.{claude,codex,gemini,opencode} routing
|
|
* - Workflow exposes agent_skills.<agent-type> injection input
|
|
* - Masking convention (****last4) is documented in the workflow and the displayed
|
|
* confirmation pattern does not echo plaintext
|
|
* - config-set round-trips all integration keys through VALID_CONFIG_KEYS + dynamic patterns
|
|
* - Config merge preserves unrelated keys
|
|
* - /gsd:settings confirmation output mentions /gsd:settings-integrations
|
|
* - Negative: invalid agent-type name (path traversal / special char) is rejected
|
|
* - Negative: malformed review.models key is rejected
|
|
* - Logging: plaintext API keys do not appear in any file written under .planning/
|
|
* by the config-set flow other than config.json itself
|
|
*/
|
|
|
|
const { describe, test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const { createTempProject, cleanup, runGsdTools } = require('./helpers.cjs');
|
|
const {
|
|
VALID_CONFIG_KEYS,
|
|
isValidConfigKey,
|
|
} = require('../gsd-core/bin/lib/config-schema.cjs');
|
|
|
|
const REPO_ROOT = path.join(__dirname, '..');
|
|
// #2790: settings-integrations.md was consolidated into config.md as the --integrations flag.
|
|
const COMMAND_PATH = path.join(REPO_ROOT, 'commands', 'gsd', 'config.md');
|
|
const WORKFLOW_PATH = path.join(REPO_ROOT, 'gsd-core', 'workflows', 'settings-integrations.md');
|
|
const SKILL_PATH = path.join(REPO_ROOT, '.claude', 'skills', 'gsd-settings-integrations.md');
|
|
const SETTINGS_WORKFLOW_PATH = path.join(REPO_ROOT, 'gsd-core', 'workflows', 'settings.md');
|
|
|
|
function readIfExists(p) {
|
|
try { return fs.readFileSync(p, 'utf-8'); } catch { return null; }
|
|
}
|
|
|
|
// ─── Artifacts ───────────────────────────────────────────────────────────────
|
|
|
|
describe('#2529 artifacts', () => {
|
|
test('consolidated config.md command exists (#2790: settings-integrations absorbed)', () => {
|
|
// #2790: settings-integrations.md was absorbed into config.md as the --integrations flag.
|
|
assert.ok(fs.existsSync(COMMAND_PATH), `missing ${COMMAND_PATH}`);
|
|
});
|
|
|
|
test('config.md frontmatter declares name gsd:config and routes to --integrations', () => {
|
|
const src = fs.readFileSync(COMMAND_PATH, 'utf-8');
|
|
// #2790: consolidated command uses gsd:config name
|
|
assert.match(src, /name:\s*gsd:config/);
|
|
assert.match(src, /description:\s*.+/);
|
|
assert.match(src, /allowed-tools:/);
|
|
assert.match(src, /AskUserQuestion/);
|
|
});
|
|
|
|
test('workflow exists at gsd-core/workflows/settings-integrations.md', () => {
|
|
assert.ok(fs.existsSync(WORKFLOW_PATH), `missing ${WORKFLOW_PATH}`);
|
|
});
|
|
|
|
test('skill stub or canonical command surface ships (#2790: via config.md --integrations)', () => {
|
|
// #2790: The command surface is now config.md + settings-integrations.md workflow.
|
|
const hasStub = fs.existsSync(SKILL_PATH);
|
|
const hasCanonical =
|
|
fs.existsSync(COMMAND_PATH) && fs.existsSync(WORKFLOW_PATH);
|
|
assert.ok(
|
|
hasStub || hasCanonical,
|
|
`neither ${SKILL_PATH} nor the canonical command/workflow pair exists`
|
|
);
|
|
});
|
|
|
|
test('config.md routes --integrations to the settings-integrations workflow', () => {
|
|
const src = fs.readFileSync(COMMAND_PATH, 'utf-8');
|
|
assert.ok(
|
|
src.includes('workflows/settings-integrations.md') || src.includes('--integrations'),
|
|
'config.md must reference settings-integrations workflow or --integrations flag'
|
|
);
|
|
});
|
|
});
|
|
|
|
// ─── Content: search API keys ────────────────────────────────────────────────
|
|
|
|
describe('#2529 workflow — search integrations', () => {
|
|
test('workflow references all four search fields', () => {
|
|
const src = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
|
|
for (const key of ['brave_search', 'firecrawl', 'exa_search', 'search_gitignored']) {
|
|
assert.ok(src.includes(key), `workflow must reference ${key}`);
|
|
}
|
|
});
|
|
});
|
|
|
|
// ─── Content: review.models routing ──────────────────────────────────────────
|
|
|
|
describe('#2529 workflow — review.models routing', () => {
|
|
test('workflow references all four reviewer CLIs', () => {
|
|
const src = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
|
|
for (const cli of ['claude', 'codex', 'gemini', 'opencode']) {
|
|
assert.ok(
|
|
src.includes(`review.models.${cli}`),
|
|
`workflow must reference review.models.${cli}`
|
|
);
|
|
}
|
|
});
|
|
|
|
test('review.models.<cli> matches the dynamic pattern validator', () => {
|
|
for (const cli of ['claude', 'codex', 'gemini', 'opencode']) {
|
|
assert.ok(
|
|
isValidConfigKey(`review.models.${cli}`),
|
|
`review.models.${cli} must pass isValidConfigKey`
|
|
);
|
|
}
|
|
});
|
|
});
|
|
|
|
// ─── Content: agent_skills.<agent-type> injection ────────────────────────────
|
|
|
|
describe('#2529 workflow — agent_skills injection', () => {
|
|
test('workflow references agent_skills.<agent-type> injection concept', () => {
|
|
const src = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
|
|
assert.ok(src.includes('agent_skills'), 'workflow must reference agent_skills');
|
|
assert.ok(
|
|
/agent_skills\.<[^>]+>|agent_skills\.\w+/.test(src),
|
|
'workflow must reference agent_skills.<agent-type> or concrete agent_skills.<slug>'
|
|
);
|
|
});
|
|
|
|
test('agent_skills.<valid-slug> passes validator', () => {
|
|
assert.ok(isValidConfigKey('agent_skills.gsd-executor'));
|
|
assert.ok(isValidConfigKey('agent_skills.gsd-planner'));
|
|
assert.ok(isValidConfigKey('agent_skills.my_custom_agent'));
|
|
});
|
|
});
|
|
|
|
// ─── Content: masking ────────────────────────────────────────────────────────
|
|
|
|
describe('#2529 workflow — API key masking', () => {
|
|
test('workflow documents the **** masking convention', () => {
|
|
const src = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
|
|
// Must reference the **** mask pattern
|
|
assert.ok(src.includes('****'), 'workflow must document the **** mask pattern');
|
|
// Must explicitly state that plaintext is not displayed
|
|
assert.ok(
|
|
/never\s+(echo|display|log|show)[^.]*plaintext|plaintext[^.]*never\s+(echo|display|log|shown)|plaintext[^.]*not\s+(echoed|displayed|logged|shown)|not\s+(echoed|displayed|logged|shown)[^.]*plaintext/i.test(src),
|
|
'workflow must explicitly forbid displaying plaintext API keys'
|
|
);
|
|
});
|
|
|
|
test('workflow shows masked-value confirmation pattern, not raw secrets', () => {
|
|
const src = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
|
|
// The confirmation table in the workflow must describe the masked display
|
|
assert.ok(
|
|
/\*\*\*\*\w{0,4}|\*\*\*\* *already set|\*\*\*\*<last.?4>/i.test(src),
|
|
'workflow must describe a masked confirmation pattern (e.g. ****last4 or **** already set)'
|
|
);
|
|
});
|
|
|
|
test('workflow includes a Leave / Replace / Clear flow for already-set keys', () => {
|
|
const src = fs.readFileSync(WORKFLOW_PATH, 'utf-8');
|
|
assert.ok(/Leave/i.test(src) && /Replace/i.test(src) && /Clear/i.test(src),
|
|
'workflow must offer Leave / Replace / Clear when a key is already set');
|
|
});
|
|
});
|
|
|
|
// ─── config-set round-trip ───────────────────────────────────────────────────
|
|
|
|
describe('#2529 config-set round-trip', () => {
|
|
test('brave_search, firecrawl, exa_search, search_gitignored are valid keys', () => {
|
|
for (const k of ['brave_search', 'firecrawl', 'exa_search', 'search_gitignored']) {
|
|
assert.ok(VALID_CONFIG_KEYS.has(k), `${k} must be in VALID_CONFIG_KEYS`);
|
|
}
|
|
});
|
|
|
|
test('config-set writes brave_search, firecrawl, exa_search values to config.json', (t) => {
|
|
const tmp = createTempProject();
|
|
t.after(() => cleanup(tmp));
|
|
runGsdTools(['config-ensure-section'], tmp);
|
|
|
|
const r1 = runGsdTools(['config-set', 'brave_search', 'BSKY-111111112222'], tmp);
|
|
assert.ok(r1.success, `brave_search set failed: ${r1.error}`);
|
|
const r2 = runGsdTools(['config-set', 'firecrawl', 'fc-aaaaaaaabbbbcccc'], tmp);
|
|
assert.ok(r2.success, `firecrawl set failed: ${r2.error}`);
|
|
const r3 = runGsdTools(['config-set', 'exa_search', 'ex-000011112222dddd'], tmp);
|
|
assert.ok(r3.success, `exa_search set failed: ${r3.error}`);
|
|
const r4 = runGsdTools(['config-set', 'search_gitignored', 'true'], tmp);
|
|
assert.ok(r4.success, `search_gitignored set failed: ${r4.error}`);
|
|
|
|
const cfg = JSON.parse(fs.readFileSync(path.join(tmp, '.planning', 'config.json'), 'utf-8'));
|
|
assert.strictEqual(cfg.brave_search, 'BSKY-111111112222');
|
|
assert.strictEqual(cfg.firecrawl, 'fc-aaaaaaaabbbbcccc');
|
|
assert.strictEqual(cfg.exa_search, 'ex-000011112222dddd');
|
|
assert.ok(
|
|
cfg.search_gitignored === true || cfg.search_gitignored === 'true',
|
|
`search_gitignored round-trip mismatch: got ${JSON.stringify(cfg.search_gitignored)}`
|
|
);
|
|
});
|
|
|
|
test('config-set round-trips review.models.<cli>', (t) => {
|
|
const tmp = createTempProject();
|
|
t.after(() => cleanup(tmp));
|
|
runGsdTools(['config-ensure-section'], tmp);
|
|
|
|
const r = runGsdTools(
|
|
['config-set', 'review.models.codex', 'codex exec --model gpt-5'],
|
|
tmp
|
|
);
|
|
assert.ok(r.success, `review.models.codex set failed: ${r.error}`);
|
|
const cfg = JSON.parse(fs.readFileSync(path.join(tmp, '.planning', 'config.json'), 'utf-8'));
|
|
assert.strictEqual(cfg.review?.models?.codex, 'codex exec --model gpt-5');
|
|
});
|
|
|
|
test('config-set round-trips agent_skills.<agent-type>', (t) => {
|
|
const tmp = createTempProject();
|
|
t.after(() => cleanup(tmp));
|
|
runGsdTools(['config-ensure-section'], tmp);
|
|
|
|
const r = runGsdTools(
|
|
['config-set', 'agent_skills.gsd-executor', 'skill-a,skill-b'],
|
|
tmp
|
|
);
|
|
assert.ok(r.success, `agent_skills.gsd-executor set failed: ${r.error}`);
|
|
const cfg = JSON.parse(fs.readFileSync(path.join(tmp, '.planning', 'config.json'), 'utf-8'));
|
|
// Accept either array or string — validator accepts both shapes today.
|
|
const v = cfg.agent_skills?.['gsd-executor'];
|
|
assert.ok(v === 'skill-a,skill-b' || (Array.isArray(v) && v.join(',') === 'skill-a,skill-b'),
|
|
`expected agent_skills.gsd-executor to contain both skills, got ${JSON.stringify(v)}`);
|
|
});
|
|
});
|
|
|
|
// ─── Config merge preserves unrelated keys ───────────────────────────────────
|
|
|
|
describe('#2529 config merge safety', () => {
|
|
test('setting brave_search preserves unrelated workflow.research key', (t) => {
|
|
const tmp = createTempProject();
|
|
t.after(() => cleanup(tmp));
|
|
runGsdTools(['config-ensure-section'], tmp);
|
|
runGsdTools(['config-set', 'workflow.research', 'false'], tmp);
|
|
|
|
const r = runGsdTools(['config-set', 'brave_search', 'BSKY-preserve-me-9999'], tmp);
|
|
assert.ok(r.success, `set failed: ${r.error}`);
|
|
|
|
const cfg = JSON.parse(fs.readFileSync(path.join(tmp, '.planning', 'config.json'), 'utf-8'));
|
|
assert.strictEqual(cfg.workflow?.research, false, 'unrelated workflow.research must be preserved');
|
|
assert.strictEqual(cfg.brave_search, 'BSKY-preserve-me-9999');
|
|
});
|
|
|
|
test('setting agent_skills.gsd-executor preserves unrelated review.models.codex', (t) => {
|
|
const tmp = createTempProject();
|
|
t.after(() => cleanup(tmp));
|
|
runGsdTools(['config-ensure-section'], tmp);
|
|
runGsdTools(['config-set', 'review.models.codex', 'codex exec'], tmp);
|
|
|
|
const r = runGsdTools(['config-set', 'agent_skills.gsd-planner', 'a,b'], tmp);
|
|
assert.ok(r.success, `set failed: ${r.error}`);
|
|
|
|
const cfg = JSON.parse(fs.readFileSync(path.join(tmp, '.planning', 'config.json'), 'utf-8'));
|
|
assert.strictEqual(cfg.review?.models?.codex, 'codex exec', 'unrelated review.models.codex must be preserved');
|
|
assert.ok(cfg.agent_skills?.['gsd-planner'], 'agent_skills.gsd-planner must be set');
|
|
});
|
|
});
|
|
|
|
// ─── /gsd-settings mentions /gsd-settings-integrations ──────────────────────
|
|
|
|
describe('#2529 /gsd-settings mentions new command', () => {
|
|
test('settings workflow mentions canonical /gsd-config --integrations', () => {
|
|
const src = fs.readFileSync(SETTINGS_WORKFLOW_PATH, 'utf-8');
|
|
assert.ok(
|
|
src.includes('/gsd:config --integrations'),
|
|
'settings.md must mention /gsd:config --integrations'
|
|
);
|
|
assert.ok(
|
|
!src.includes('/gsd-settings-integrations'),
|
|
'settings.md must not mention the legacy /gsd-settings-integrations variant'
|
|
);
|
|
});
|
|
});
|
|
|
|
// ─── Negative scenarios ──────────────────────────────────────────────────────
|
|
|
|
describe('#2529 negative — invalid inputs rejected', () => {
|
|
test('invalid agent-type with path separators is rejected by validator', () => {
|
|
assert.ok(!isValidConfigKey('agent_skills.../etc/passwd'),
|
|
'agent_skills.../etc/passwd must be rejected');
|
|
assert.ok(!isValidConfigKey('agent_skills./evil'),
|
|
'agent_skills./evil must be rejected');
|
|
assert.ok(!isValidConfigKey('agent_skills.a b c'),
|
|
'agent_skills with spaces must be rejected');
|
|
assert.ok(!isValidConfigKey('agent_skills.$(whoami)'),
|
|
'agent_skills with shell metacharacters must be rejected');
|
|
});
|
|
|
|
test('config-set rejects agent_skills with path traversal', (t) => {
|
|
const tmp = createTempProject();
|
|
t.after(() => cleanup(tmp));
|
|
runGsdTools(['config-ensure-section'], tmp);
|
|
|
|
const r = runGsdTools(['config-set', 'agent_skills.../etc/passwd', 'x'], tmp);
|
|
assert.ok(!r.success, 'config-set must reject path-traversal agent-type slug');
|
|
});
|
|
|
|
test('malformed review.models entry (empty cli) is rejected', () => {
|
|
assert.ok(!isValidConfigKey('review.models.'),
|
|
'review.models. (empty) must be rejected');
|
|
assert.ok(!isValidConfigKey('review.models'),
|
|
'review.models (no cli) must be rejected');
|
|
assert.ok(!isValidConfigKey('review.models.claude/../../x'),
|
|
'review.models with path separators must be rejected');
|
|
});
|
|
});
|
|
|
|
// ─── Security: plaintext never leaks to disk outside config.json ─────────────
|
|
|
|
describe('#2529 security — plaintext containment', () => {
|
|
test('after setting brave_search, plaintext appears only in config.json', (t) => {
|
|
const tmp = createTempProject();
|
|
t.after(() => cleanup(tmp));
|
|
runGsdTools(['config-ensure-section'], tmp);
|
|
|
|
// Build sentinel via concat so secret-scanners do not flag the literal.
|
|
const marker = ['MASKCHECK', '9f3a7b2c'].join('-');
|
|
const r = runGsdTools(['config-set', 'brave_search', marker], tmp);
|
|
assert.ok(r.success, `set failed: ${r.error}`);
|
|
|
|
const planning = path.join(tmp, '.planning');
|
|
const hits = [];
|
|
function walk(dir) {
|
|
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
const full = path.join(dir, entry.name);
|
|
if (entry.isDirectory()) { walk(full); continue; }
|
|
if (!entry.isFile()) continue;
|
|
let buf;
|
|
try { buf = fs.readFileSync(full, 'utf-8'); } catch { continue; }
|
|
if (buf.includes(marker)) hits.push(full);
|
|
}
|
|
}
|
|
walk(planning);
|
|
|
|
assert.deepStrictEqual(
|
|
hits.map(h => path.basename(h)).sort(),
|
|
['config.json'],
|
|
`plaintext marker leaked outside config.json: found in ${hits.join(', ')}`
|
|
);
|
|
});
|
|
|
|
test('config-set does not echo plaintext secret on stdout/stderr', (t) => {
|
|
const tmp = createTempProject();
|
|
t.after(() => cleanup(tmp));
|
|
runGsdTools(['config-ensure-section'], tmp);
|
|
|
|
const marker = ['ECHOCHECK', '77aa33bb'].join('-');
|
|
const r = runGsdTools(['config-set', 'brave_search', marker], tmp);
|
|
assert.ok(r.success, `set failed: ${r.error}`);
|
|
const combined = `${r.output || ''}\n${r.error || ''}`;
|
|
assert.ok(
|
|
!combined.includes(marker),
|
|
`config-set output must not echo the plaintext marker. Got:\n${combined}`
|
|
);
|
|
});
|
|
|
|
test('config-get masks secrets and never echoes plaintext for brave_search/firecrawl/exa_search', (t) => {
|
|
const tmp = createTempProject();
|
|
t.after(() => cleanup(tmp));
|
|
runGsdTools(['config-ensure-section'], tmp);
|
|
|
|
const cases = [
|
|
{ key: 'brave_search', marker: ['GETMASK', 'brave', 'aaaa1111'].join('-') },
|
|
{ key: 'firecrawl', marker: ['GETMASK', 'fc', 'bbbb2222'].join('-') },
|
|
{ key: 'exa_search', marker: ['GETMASK', 'ex', 'cccc3333'].join('-') },
|
|
];
|
|
|
|
for (const { key, marker } of cases) {
|
|
const set = runGsdTools(['config-set', key, marker], tmp);
|
|
assert.ok(set.success, `${key} set failed: ${set.error}`);
|
|
|
|
const get = runGsdTools(['config-get', key], tmp);
|
|
assert.ok(get.success, `${key} get failed: ${get.error}`);
|
|
const combined = `${get.output || ''}\n${get.error || ''}`;
|
|
assert.ok(
|
|
!combined.includes(marker),
|
|
`config-get must not echo plaintext for ${key}. Got:\n${combined}`
|
|
);
|
|
// Must contain the masked tail (last 4 of marker)
|
|
const expectedMask = '****' + marker.slice(-4);
|
|
assert.ok(
|
|
combined.includes(expectedMask),
|
|
`config-get must show masked form (${expectedMask}) for ${key}. Got:\n${combined}`
|
|
);
|
|
}
|
|
});
|
|
});
|