* feat(#3415): ship local/no-unbounded-quantifier, burn down ReDoS class Phase 4 of epic #3212 (ADR-3212 §5/§7, the final phase). New rule flags an unbounded */+/{n,} quantifier over a broad character class ([\s\S], dotAll ., or a 1-2-unit negated class like [^\n]/[^)\n] — the exact #2128-fixed shape) applied to a regex whose match target is data-flow-traced to readFileSync content. eslint-rules/lib/readfilesync-trace.cjs extracts the data-flow tracer shared with no-crlf-fragile-split (Phase 2) rather than a second copy — no-crlf-fragile-split refactored onto it with zero behavior change, parity-tested. Real triage, not 798 mechanical edits: the ADR's census (2026-08-08) screened every unbounded quantifier in the tree unscoped. Correctly scoped to readFileSync-derived content (matching Phase 2's own G2/G3 scoping), the rule found 162 real hits across two detection waves — the second wave (93) surfaced only after a genuine off-by-one bug in this rule's own first draft was caught while writing its RuleTester tests and fixed (the bug silently missed every directly-quantified [\s\S]* with no gap before the quantifier — exactly the class this rule exists to catch). 3 hits landed in production src/ (commands.cts, milestone.cts, roadmap.cts) and were each empirically timed against adversarial input (matching #2128's own measured-not-assumed precedent) — all confirmed linear-time/benign, left unbounded with a measured-evidence comment rather than mechanically bounded. The remaining 159 are test-file fixture parsing (test-author-controlled, fixed-size content, not adversarial input) — each suppressed with a specific, non-generic reason. Zero functional behavior changed anywhere in this diff. tests/no-pending-3212-markers.test.cjs locks the epic's own closing invariant (ADR §7: "assert zero pending #3212 markers remain") — ground truth confirmed trivially true today (no phase left any such marker behind), now regression-locked going forward. Design: .gsd/phase/chore-3415-prohibition-with-teeth/40-design.md Test matrix: .gsd/phase/chore-3415-prohibition-with-teeth/50-test-matrix.md Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(#3415): correct rule category mislabel, add CI test-scope entry An orthogonal Standards-axis review found eslint-rules/no-unbounded-quantifier.cjs mistakenly carried meta.docs.category: 'Portability', copied from a sibling rule without realizing what that implied: docs/contributing/cross-platform- portability-rules.md governs an ADR-1703 rule family under a hard "zero escape hatches" contract (tests/portability-rule-disable-ban.test.cjs's PROTECTED_RULES bans eslint-disable for those rules entirely). This rule is not part of that family — it's ADR-3212 (ReDoS/CWE-1333), a different epic — and its eslint-disable-next-line suppressions (159 of them, added earlier this same phase after empirical benign-verification) are an intentional, correct design, not a bypass. Corrected to category: 'Best Practices', matching the actual precedent (no-adhoc-regex-escape.cjs, Phase 1 of the same epic, which is also correctly outside PROTECTED_RULES), and the rule's own docstring now states this explicitly so a future reader doesn't have to re-derive it. Also registers a new scripts/ci-test-scope.cjs bucket so editing this rule or the shared eslint-rules/lib/readfilesync-trace.cjs helper re-runs their own test suites under targeted CI selection — was previously unregistered and invisible to that fast-path (this PR's own gsd-test checkpoint runs the full suite regardless, so this only affects future narrowly-scoped PRs). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(#3415): bound no-unbounded-quantifier's own scanner (CWE-1333, ironic) Security review found the rule meant to catch algorithmic-complexity bugs had one of its own: hasUnboundedBroadQuantifier's negated-class inner scan walked from each `[^` occurrence to the next `]` (or EOF) with no bound, while the outer loop only ever advanced by one character — O(n²) total work on a pattern with many unclosed `[^` runs. Runs unconditionally inside checkPattern on any `new RegExp('literal string')` argument in any linted file, before the (cheap) readFileSync data-flow gate — so a single crafted string literal, no valid regex syntax required, could make `npm run lint` / CI hang. Empirically confirmed both the bug and the fix: pre-fix, n=4000/8000/ 16000/32000 chars took 30.8/115.6/463.8/1874.3ms (~4x work per 2x n, quadratic); extrapolated, the 300000-char repro from the finding would run ~165s. Post-fix (bail the inner scan once units exceeds the rule's own 1-2-unit scope, rather than continuing to hunt for a closing `]`), the same 300000-char input runs in 8.7ms via the real rule module, independently reconfirmed at 18ms via a fresh Linter.verify() call. New regression row in tests/no-unbounded-quantifier.rule.test.cjs asserts the RuleTester run on a 50000-char adversarial pattern completes and returns a defined result — no wall-clock assertion (CLAUDE.md Clock Seams / local/no-elapsed-assertion). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(#3415): triage 3 new sites, re-raise ceiling after upstream batch next merged 12 more PRs during this PR's review. Two consequences: - tests/edit-phase.test.cjs (fix #3262, unrelated) added 3 new content.match(/<tag>([\s\S]*?)<\/tag>/) reads of this repo's own workflow .md content — the same Class A pattern as the ~159 sites already triaged elsewhere in this PR. Suppressed with the same established reason. - lint-allow-test-rule-refs' ratchet ceiling needed re-raising again (301 -> 303) for the same reason as the two prior bumps: organic growth from unrelated, already-reviewed PRs landing concurrently, not a defect in this branch's own diff. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: sim <sim@local> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
396 lines
18 KiB
JavaScript
396 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');
|
|
|
|
// ─── 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(
|
|
// eslint-disable-next-line local/no-unbounded-quantifier -- parses maintainer-authored workflow markdown, bounded prose, not adversarial input
|
|
/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(
|
|
// eslint-disable-next-line local/no-unbounded-quantifier -- parses maintainer-authored workflow markdown, bounded prose, not adversarial input
|
|
/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}`
|
|
);
|
|
}
|
|
});
|
|
});
|