fullcourtdefense-cli 1.35.10 → 1.36.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actionPolicyEngine.d.ts +24 -0
- package/dist/actionPolicyEngine.js +79 -19
- package/dist/approvalPrompt.d.ts +15 -0
- package/dist/approvalPrompt.js +157 -20
- package/dist/askDialog.d.ts +2 -0
- package/dist/askDialog.js +15 -1
- package/dist/askHeader.d.ts +81 -0
- package/dist/askHeader.js +573 -0
- package/dist/blockExplanation.d.ts +9 -0
- package/dist/blockExplanation.js +14 -0
- package/dist/callerEnv.d.ts +1 -1
- package/dist/callerEnv.js +14 -0
- package/dist/cloudGrant.d.ts +46 -0
- package/dist/cloudGrant.js +420 -0
- package/dist/cloudGrantTools.d.ts +97 -0
- package/dist/cloudGrantTools.js +1112 -0
- package/dist/commandNarrative.d.ts +8 -0
- package/dist/commandNarrative.js +222 -49
- package/dist/commands/cmdGuard.js +3 -1
- package/dist/commands/daemon.js +56 -2
- package/dist/commands/deterministicGuard.d.ts +70 -4
- package/dist/commands/deterministicGuard.js +494 -63
- package/dist/commands/discover.js +50 -16
- package/dist/commands/discoverAgentFiles.d.ts +2 -0
- package/dist/commands/discoverAgentFiles.js +1 -0
- package/dist/commands/discoverPaths.d.ts +4 -0
- package/dist/commands/discoverPaths.js +19 -1
- package/dist/commands/discoverProjectRoots.d.ts +72 -0
- package/dist/commands/discoverProjectRoots.js +327 -0
- package/dist/commands/discoverProxy.d.ts +1 -1
- package/dist/commands/discoverProxy.js +1 -1
- package/dist/commands/discoverSecrets.d.ts +44 -0
- package/dist/commands/discoverSecrets.js +158 -14
- package/dist/commands/hook.js +25 -10
- package/dist/commands/knownMcpServers.d.ts +8 -2
- package/dist/commands/knownMcpServers.js +33 -2
- package/dist/commands/mcpGateway.js +9 -7
- package/dist/commands/posixShellGuard.js +1 -1
- package/dist/commands/shellGuard.js +86 -26
- package/dist/commands/uninstallAll.d.ts +1 -7
- package/dist/commands/uninstallAll.js +6 -45
- package/dist/commands/watchdog.js +17 -3
- package/dist/config.d.ts +1 -1
- package/dist/config.js +3 -3
- package/dist/credentialGrant.d.ts +48 -0
- package/dist/credentialGrant.js +29 -18
- package/dist/credentialStore.js +1 -1
- package/dist/devConfirm.d.ts +51 -3
- package/dist/devConfirm.js +226 -33
- package/dist/distress.d.ts +2 -0
- package/dist/distress.js +2 -0
- package/dist/grantTargets.d.ts +21 -0
- package/dist/grantTargets.js +235 -0
- package/dist/localSafetySnapshot.js +2 -0
- package/dist/msiProductCode.d.ts +10 -0
- package/dist/msiProductCode.js +124 -0
- package/dist/notify.js +1 -0
- package/dist/selfTest.d.ts +1 -1
- package/dist/selfTest.js +1 -1
- package/dist/selfUpdate.d.ts +108 -0
- package/dist/selfUpdate.js +353 -18
- package/dist/shellAst.d.ts +2 -0
- package/dist/shellAst.js +7 -1
- package/dist/shellAstLoader.js +14 -1
- package/dist/telemetry.d.ts +3 -0
- package/dist/telemetry.js +1 -0
- package/dist/version.json +1 -1
- package/installer/macos/guardian/ai.fullcourtdefense.guardian.plist +19 -0
- package/installer/macos/guardian/fcd-guardian.sh +590 -0
- package/installer/macos/guardian/install-guardian.sh +32 -0
- package/installer/macos/guardian/uninstall-guardian.sh +12 -0
- package/installer/windows/README.md +88 -0
- package/installer/windows/rescue/FullCourtDefense-Rescue.ps1 +229 -0
- package/package.json +11 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ScanTruncationReason } from './discoverPaths';
|
|
1
2
|
export type SecretSeverity = 'critical' | 'high' | 'medium' | 'low' | 'info';
|
|
2
3
|
export type SecretCategory = 'env_file' | 'credential_store' | 'config' | 'shell_history' | 'ssh_key' | 'other';
|
|
3
4
|
export interface SecretFinding {
|
|
@@ -26,16 +27,59 @@ export interface SecretsScanResult {
|
|
|
26
27
|
stats?: {
|
|
27
28
|
candidateFiles: number;
|
|
28
29
|
excludedFiles: number;
|
|
30
|
+
cloudPlaceholdersSkipped?: number;
|
|
29
31
|
};
|
|
30
32
|
truncated?: {
|
|
31
33
|
candidateFiles: boolean;
|
|
32
34
|
findings: boolean;
|
|
33
35
|
};
|
|
36
|
+
/** Which limit cut the candidate file walk short; absent when it finished. */
|
|
37
|
+
truncatedReasons?: {
|
|
38
|
+
candidateFiles?: ScanTruncationReason;
|
|
39
|
+
};
|
|
34
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Whether ~/.docker/config.json holds credentials itself. `auths` entries that
|
|
43
|
+
* only name a registry are metadata when `credsStore` / `credHelpers` keep the
|
|
44
|
+
* secret in the OS store (Docker Desktop on Windows: `credsStore: desktop` =
|
|
45
|
+
* Windows Credential Manager). Counts only; never returns a value.
|
|
46
|
+
*/
|
|
47
|
+
export declare function dockerConfigCredentialFacts(content: string): {
|
|
48
|
+
inlineRegistries: number;
|
|
49
|
+
usesCredentialStore: boolean;
|
|
50
|
+
};
|
|
51
|
+
export declare function isCloudPlaceholderAttributes(attributes: number): boolean;
|
|
52
|
+
/** True for paths inside a OneDrive folder (by env root or a "OneDrive…" path segment). */
|
|
53
|
+
export declare function isCloudSyncedPath(filePath: string, env?: NodeJS.ProcessEnv): boolean;
|
|
54
|
+
export type FileAttributeProbe = (files: string[]) => Array<number | undefined> | null;
|
|
55
|
+
/**
|
|
56
|
+
* One PowerShell call reads the attributes of every candidate (no file is
|
|
57
|
+
* opened, so nothing is downloaded). Paths go in base64 on stdin so non-ASCII
|
|
58
|
+
* folder names survive the console code page; one integer per line comes back
|
|
59
|
+
* in input order. Returns null when PowerShell is unavailable or times out.
|
|
60
|
+
*/
|
|
61
|
+
export declare const probeWindowsFileAttributes: FileAttributeProbe;
|
|
62
|
+
/**
|
|
63
|
+
* Drop OneDrive online-only placeholders before any read. Only files under a
|
|
64
|
+
* OneDrive folder are probed; a failed probe keeps every file (the per-file
|
|
65
|
+
* size cap still bounds what is read).
|
|
66
|
+
*/
|
|
67
|
+
export declare function dropCloudPlaceholders(files: string[], options?: {
|
|
68
|
+
platform?: NodeJS.Platform;
|
|
69
|
+
env?: NodeJS.ProcessEnv;
|
|
70
|
+
probe?: FileAttributeProbe;
|
|
71
|
+
}): {
|
|
72
|
+
files: string[];
|
|
73
|
+
skipped: number;
|
|
74
|
+
};
|
|
35
75
|
export declare function scanSecrets(options?: {
|
|
36
76
|
cwd?: string;
|
|
37
77
|
maxEnvDepth?: number;
|
|
38
78
|
extraRoots?: string[];
|
|
39
79
|
disabledRoots?: string[];
|
|
40
80
|
configFiles?: string[];
|
|
81
|
+
/** Test seams for the OneDrive placeholder check; production uses the real platform/env/probe. */
|
|
82
|
+
platform?: NodeJS.Platform;
|
|
83
|
+
env?: NodeJS.ProcessEnv;
|
|
84
|
+
probeFileAttributes?: FileAttributeProbe;
|
|
41
85
|
}): SecretsScanResult;
|
|
@@ -33,7 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.probeWindowsFileAttributes = void 0;
|
|
37
|
+
exports.dockerConfigCredentialFacts = dockerConfigCredentialFacts;
|
|
38
|
+
exports.isCloudPlaceholderAttributes = isCloudPlaceholderAttributes;
|
|
39
|
+
exports.isCloudSyncedPath = isCloudSyncedPath;
|
|
40
|
+
exports.dropCloudPlaceholders = dropCloudPlaceholders;
|
|
36
41
|
exports.scanSecrets = scanSecrets;
|
|
42
|
+
const child_process_1 = require("child_process");
|
|
37
43
|
const crypto = __importStar(require("crypto"));
|
|
38
44
|
const fs = __importStar(require("fs"));
|
|
39
45
|
const os = __importStar(require("os"));
|
|
@@ -158,17 +164,58 @@ function looksLikePlaceholder(raw, line) {
|
|
|
158
164
|
return true;
|
|
159
165
|
return false;
|
|
160
166
|
}
|
|
167
|
+
/** Fields of a Docker `auths` entry that carry a usable credential (docker/cli configfile AuthConfig). */
|
|
168
|
+
const DOCKER_INLINE_CREDENTIAL_KEYS = new Set(['auth', 'password', 'identitytoken', 'registrytoken']);
|
|
169
|
+
/**
|
|
170
|
+
* Whether ~/.docker/config.json holds credentials itself. `auths` entries that
|
|
171
|
+
* only name a registry are metadata when `credsStore` / `credHelpers` keep the
|
|
172
|
+
* secret in the OS store (Docker Desktop on Windows: `credsStore: desktop` =
|
|
173
|
+
* Windows Credential Manager). Counts only; never returns a value.
|
|
174
|
+
*/
|
|
175
|
+
function dockerConfigCredentialFacts(content) {
|
|
176
|
+
let config;
|
|
177
|
+
try {
|
|
178
|
+
config = JSON.parse(content);
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
// Unparseable: fall back to "a credential field with a non-empty string value".
|
|
182
|
+
const inline = /"(?:auth|password|identitytoken|registrytoken)"\s*:\s*"[^"\s]+"/i.test(content);
|
|
183
|
+
return { inlineRegistries: inline ? 1 : 0, usesCredentialStore: /"(?:credsStore|credHelpers)"\s*:/.test(content) };
|
|
184
|
+
}
|
|
185
|
+
if (!config || typeof config !== 'object')
|
|
186
|
+
return { inlineRegistries: 0, usesCredentialStore: false };
|
|
187
|
+
const record = config;
|
|
188
|
+
const credsStore = typeof record.credsStore === 'string' && record.credsStore.trim() !== '';
|
|
189
|
+
const credHelpers = !!record.credHelpers && typeof record.credHelpers === 'object' && Object.keys(record.credHelpers).length > 0;
|
|
190
|
+
let inlineRegistries = 0;
|
|
191
|
+
const auths = record.auths;
|
|
192
|
+
if (auths && typeof auths === 'object' && !Array.isArray(auths)) {
|
|
193
|
+
for (const entry of Object.values(auths)) {
|
|
194
|
+
if (!entry || typeof entry !== 'object')
|
|
195
|
+
continue;
|
|
196
|
+
const hasInline = Object.entries(entry).some(([key, value]) => DOCKER_INLINE_CREDENTIAL_KEYS.has(key.toLowerCase()) && typeof value === 'string' && value.trim() !== '');
|
|
197
|
+
if (hasInline)
|
|
198
|
+
inlineRegistries += 1;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return { inlineRegistries, usesCredentialStore: credsStore || credHelpers };
|
|
202
|
+
}
|
|
161
203
|
function scanCredentialStorePosture(filePath, content, category, out, seen) {
|
|
162
204
|
const normalized = filePath.replace(/\\/g, '/').toLowerCase();
|
|
163
|
-
if (normalized.endsWith('/.docker/config.json')
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
205
|
+
if (normalized.endsWith('/.docker/config.json')) {
|
|
206
|
+
const docker = dockerConfigCredentialFacts(content);
|
|
207
|
+
if (docker.inlineRegistries > 0) {
|
|
208
|
+
pushStoreFinding(out, seen, {
|
|
209
|
+
filePath,
|
|
210
|
+
category,
|
|
211
|
+
provider: 'docker',
|
|
212
|
+
severity: 'high',
|
|
213
|
+
title: 'Docker registry credentials',
|
|
214
|
+
detail: docker.usesCredentialStore
|
|
215
|
+
? `Docker config stores credentials inline for ${docker.inlineRegistries} registr${docker.inlineRegistries === 1 ? 'y' : 'ies'} next to a credential store; the inline entries bypass it and agent tools or local malware can read them.`
|
|
216
|
+
: `Docker config stores credentials inline for ${docker.inlineRegistries} registr${docker.inlineRegistries === 1 ? 'y' : 'ies'} that agent tools or local malware can read.`,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
172
219
|
}
|
|
173
220
|
if (normalized.endsWith('/.kube/config') && /\b(?:token|client-key-data|client-certificate-data)\s*:/i.test(content)) {
|
|
174
221
|
pushStoreFinding(out, seen, {
|
|
@@ -402,10 +449,15 @@ function scanSshKeys(home, out, seen, excludedRoots = []) {
|
|
|
402
449
|
}
|
|
403
450
|
return scanned;
|
|
404
451
|
}
|
|
452
|
+
// Every root starts at depth 0 in one breadth-first queue, and a folder is
|
|
453
|
+
// walked once: a project root that also sits under the home folder is walked
|
|
454
|
+
// from its own top level (depth 0) before the home walk could reach it at
|
|
455
|
+
// depth 4+, and its files are never read twice.
|
|
405
456
|
function collectEnvFiles(roots, maxDepth, excludedRoots = []) {
|
|
406
457
|
const found = [];
|
|
407
458
|
let excluded = 0;
|
|
408
459
|
let depthLimited = false;
|
|
460
|
+
const visited = new Set();
|
|
409
461
|
const queue = roots.map(dir => ({ dir, depth: 0 }));
|
|
410
462
|
while (queue.length > 0 && found.length < MAX_ENV_FILES) {
|
|
411
463
|
const { dir, depth } = queue.shift();
|
|
@@ -413,6 +465,10 @@ function collectEnvFiles(roots, maxDepth, excludedRoots = []) {
|
|
|
413
465
|
excluded += 1;
|
|
414
466
|
continue;
|
|
415
467
|
}
|
|
468
|
+
const key = (0, discoverPaths_1.normalizedPath)(dir);
|
|
469
|
+
if (visited.has(key))
|
|
470
|
+
continue;
|
|
471
|
+
visited.add(key);
|
|
416
472
|
let entries;
|
|
417
473
|
try {
|
|
418
474
|
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
@@ -447,12 +503,14 @@ function collectEnvFiles(roots, maxDepth, excludedRoots = []) {
|
|
|
447
503
|
}
|
|
448
504
|
}
|
|
449
505
|
}
|
|
450
|
-
|
|
506
|
+
const countLimited = found.length >= MAX_ENV_FILES;
|
|
507
|
+
return { files: found, truncated: depthLimited || countLimited || queue.length > 0, depthLimited, countLimited: countLimited || queue.length > 0, excluded };
|
|
451
508
|
}
|
|
452
509
|
function collectProjectCredentialFiles(roots, maxDepth, excludedRoots = []) {
|
|
453
510
|
const found = [];
|
|
454
511
|
let excluded = 0;
|
|
455
512
|
let depthLimited = false;
|
|
513
|
+
const visited = new Set();
|
|
456
514
|
const queue = roots.map(dir => ({ dir, depth: 0 }));
|
|
457
515
|
const isCredentialFile = (filePath) => {
|
|
458
516
|
const normalized = filePath.replace(/\\/g, '/').toLowerCase();
|
|
@@ -470,6 +528,10 @@ function collectProjectCredentialFiles(roots, maxDepth, excludedRoots = []) {
|
|
|
470
528
|
excluded += 1;
|
|
471
529
|
continue;
|
|
472
530
|
}
|
|
531
|
+
const key = (0, discoverPaths_1.normalizedPath)(dir);
|
|
532
|
+
if (visited.has(key))
|
|
533
|
+
continue;
|
|
534
|
+
visited.add(key);
|
|
473
535
|
let entries;
|
|
474
536
|
try {
|
|
475
537
|
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
@@ -501,7 +563,81 @@ function collectProjectCredentialFiles(roots, maxDepth, excludedRoots = []) {
|
|
|
501
563
|
found.push(full);
|
|
502
564
|
}
|
|
503
565
|
}
|
|
504
|
-
|
|
566
|
+
const countLimited = found.length >= MAX_ENV_FILES;
|
|
567
|
+
return { files: found, truncated: depthLimited || countLimited || queue.length > 0, depthLimited, countLimited: countLimited || queue.length > 0, excluded };
|
|
568
|
+
}
|
|
569
|
+
// Windows file attributes that mark a cloud-sync placeholder (OneDrive Files
|
|
570
|
+
// On-Demand): reading such a file makes the sync client download it.
|
|
571
|
+
const FILE_ATTRIBUTE_OFFLINE = 0x1000;
|
|
572
|
+
const FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x40000;
|
|
573
|
+
const FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x400000;
|
|
574
|
+
function isCloudPlaceholderAttributes(attributes) {
|
|
575
|
+
return Number.isInteger(attributes) && attributes >= 0
|
|
576
|
+
&& (attributes & (FILE_ATTRIBUTE_OFFLINE | FILE_ATTRIBUTE_RECALL_ON_OPEN | FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS)) !== 0;
|
|
577
|
+
}
|
|
578
|
+
/** True for paths inside a OneDrive folder (by env root or a "OneDrive…" path segment). */
|
|
579
|
+
function isCloudSyncedPath(filePath, env = process.env) {
|
|
580
|
+
const roots = [env.OneDrive, env.OneDriveCommercial, env.OneDriveConsumer].filter((root) => !!root);
|
|
581
|
+
if (roots.some(root => (0, discoverPaths_1.pathIsWithin)(filePath, root)))
|
|
582
|
+
return true;
|
|
583
|
+
return filePath.split(/[\\/]/).some(segment => /^onedrive\b/i.test(segment));
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* One PowerShell call reads the attributes of every candidate (no file is
|
|
587
|
+
* opened, so nothing is downloaded). Paths go in base64 on stdin so non-ASCII
|
|
588
|
+
* folder names survive the console code page; one integer per line comes back
|
|
589
|
+
* in input order. Returns null when PowerShell is unavailable or times out.
|
|
590
|
+
*/
|
|
591
|
+
const probeWindowsFileAttributes = files => {
|
|
592
|
+
if (files.length === 0)
|
|
593
|
+
return [];
|
|
594
|
+
const script = [
|
|
595
|
+
"$ErrorActionPreference = 'SilentlyContinue'",
|
|
596
|
+
'foreach ($line in [Console]::In.ReadToEnd() -split "`n") {',
|
|
597
|
+
' $line = $line.Trim(); if (-not $line) { continue }',
|
|
598
|
+
' try { $p = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($line)); [Console]::Out.WriteLine([int][IO.File]::GetAttributes($p)) }',
|
|
599
|
+
' catch { [Console]::Out.WriteLine(-1) }',
|
|
600
|
+
'}',
|
|
601
|
+
].join('\n');
|
|
602
|
+
try {
|
|
603
|
+
const result = (0, child_process_1.spawnSync)('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', script], {
|
|
604
|
+
input: files.map(file => Buffer.from(file, 'utf8').toString('base64')).join('\n'),
|
|
605
|
+
encoding: 'utf8',
|
|
606
|
+
timeout: 15000,
|
|
607
|
+
windowsHide: true,
|
|
608
|
+
});
|
|
609
|
+
if (result.status !== 0 || typeof result.stdout !== 'string')
|
|
610
|
+
return null;
|
|
611
|
+
const values = result.stdout.split(/\r?\n/).map(line => line.trim()).filter(Boolean).map(Number);
|
|
612
|
+
if (values.length !== files.length)
|
|
613
|
+
return null;
|
|
614
|
+
return values.map(value => (Number.isInteger(value) && value >= 0 ? value : undefined));
|
|
615
|
+
}
|
|
616
|
+
catch {
|
|
617
|
+
return null;
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
exports.probeWindowsFileAttributes = probeWindowsFileAttributes;
|
|
621
|
+
/**
|
|
622
|
+
* Drop OneDrive online-only placeholders before any read. Only files under a
|
|
623
|
+
* OneDrive folder are probed; a failed probe keeps every file (the per-file
|
|
624
|
+
* size cap still bounds what is read).
|
|
625
|
+
*/
|
|
626
|
+
function dropCloudPlaceholders(files, options = {}) {
|
|
627
|
+
if ((options.platform ?? process.platform) !== 'win32')
|
|
628
|
+
return { files, skipped: 0 };
|
|
629
|
+
const env = options.env ?? process.env;
|
|
630
|
+
const synced = files.filter(file => isCloudSyncedPath(file, env));
|
|
631
|
+
if (synced.length === 0)
|
|
632
|
+
return { files, skipped: 0 };
|
|
633
|
+
const attributes = (options.probe ?? exports.probeWindowsFileAttributes)(synced);
|
|
634
|
+
if (!attributes)
|
|
635
|
+
return { files, skipped: 0 };
|
|
636
|
+
const placeholders = new Set(synced.filter((_, index) => {
|
|
637
|
+
const value = attributes[index];
|
|
638
|
+
return value !== undefined && isCloudPlaceholderAttributes(value);
|
|
639
|
+
}).map(file => (0, discoverPaths_1.normalizedPath)(file)));
|
|
640
|
+
return { files: files.filter(file => !placeholders.has((0, discoverPaths_1.normalizedPath)(file))), skipped: placeholders.size };
|
|
505
641
|
}
|
|
506
642
|
function scanSecrets(options = {}) {
|
|
507
643
|
const home = os.homedir();
|
|
@@ -550,10 +686,13 @@ function scanSecrets(options = {}) {
|
|
|
550
686
|
path.join(home, 'Documents'),
|
|
551
687
|
path.join(home, 'code'),
|
|
552
688
|
].filter(root => fs.existsSync(root) && !(0, discoverPaths_1.isExcludedPath)(root, disabledRoots)));
|
|
689
|
+
const placeholderOptions = { platform: options.platform, env: options.env, probe: options.probeFileAttributes };
|
|
553
690
|
const envCollection = collectEnvFiles(envRoots, maxDepth, disabledRoots);
|
|
554
691
|
excludedFiles += envCollection.excluded;
|
|
555
692
|
candidatesTruncated = candidatesTruncated || envCollection.truncated;
|
|
556
|
-
|
|
693
|
+
const envFiles = dropCloudPlaceholders(envCollection.files, placeholderOptions);
|
|
694
|
+
let cloudPlaceholdersSkipped = envFiles.skipped;
|
|
695
|
+
for (const envFile of envFiles.files) {
|
|
557
696
|
if (findings.length >= MAX_FINDINGS)
|
|
558
697
|
break;
|
|
559
698
|
const content = readTextFile(envFile);
|
|
@@ -565,7 +704,9 @@ function scanSecrets(options = {}) {
|
|
|
565
704
|
const credentialCollection = collectProjectCredentialFiles([cwd, ...extraRoots], maxDepth, disabledRoots);
|
|
566
705
|
excludedFiles += credentialCollection.excluded;
|
|
567
706
|
candidatesTruncated = candidatesTruncated || credentialCollection.truncated;
|
|
568
|
-
|
|
707
|
+
const credentialFiles = dropCloudPlaceholders(credentialCollection.files, placeholderOptions);
|
|
708
|
+
cloudPlaceholdersSkipped += credentialFiles.skipped;
|
|
709
|
+
for (const credentialFile of credentialFiles.files) {
|
|
569
710
|
if (findings.length >= MAX_FINDINGS)
|
|
570
711
|
break;
|
|
571
712
|
const content = readTextFile(credentialFile);
|
|
@@ -602,7 +743,10 @@ function scanSecrets(options = {}) {
|
|
|
602
743
|
scannedStores,
|
|
603
744
|
healthScore: scoreFromFindings(findings),
|
|
604
745
|
limits: { maxFileBytes: MAX_FILE_BYTES, maxEnvFiles: MAX_ENV_FILES, maxFindings: MAX_FINDINGS, maxDepth },
|
|
605
|
-
stats: { candidateFiles: scannedFiles, excludedFiles },
|
|
746
|
+
stats: { candidateFiles: scannedFiles, excludedFiles, cloudPlaceholdersSkipped },
|
|
606
747
|
truncated: { candidateFiles: candidatesTruncated, findings: findings.length >= MAX_FINDINGS },
|
|
748
|
+
truncatedReasons: {
|
|
749
|
+
candidateFiles: (0, discoverPaths_1.truncationReason)(envCollection.depthLimited || credentialCollection.depthLimited, envCollection.countLimited || credentialCollection.countLimited),
|
|
750
|
+
},
|
|
607
751
|
};
|
|
608
752
|
}
|
package/dist/commands/hook.js
CHANGED
|
@@ -851,7 +851,10 @@ function prepareDeveloperConfirmation(event, call, payload, source) {
|
|
|
851
851
|
offlineEnforced: true,
|
|
852
852
|
});
|
|
853
853
|
}
|
|
854
|
-
|
|
854
|
+
// A remote-control bridge hands the machine to an outside AI: "Allow once" is once,
|
|
855
|
+
// with no session memory. Only an explicit "Always allow" (a bridge-scoped grant) lasts.
|
|
856
|
+
const sessionMemory = source.localFinding?.remoteControl || context['toolArgs.remoteControl'] ? 'none' : source.remember;
|
|
857
|
+
const remembered = sessionMemory === 'none' ? undefined : (0, devConfirm_1.isConfirmationRemembered)({ toolName: call.toolName, operation, argsDigest: (0, devConfirm_1.actionDigest)(call.toolArgs), policyId: source.policyId, matchedRule: source.matchedRule, policyHash: memoryHash }, sessId);
|
|
855
858
|
if (remembered) {
|
|
856
859
|
(0, hookIo_1.dbg)({ phase: 'dev_confirm_remembered', event, tool: call.toolName, operation, remember: remembered.remember, where: source.where });
|
|
857
860
|
spoolCallEvent(call, {
|
|
@@ -900,10 +903,10 @@ function prepareDeveloperConfirmation(event, call, payload, source) {
|
|
|
900
903
|
policyHash: memoryHash,
|
|
901
904
|
matchedRule: source.matchedRule,
|
|
902
905
|
sessionId: sessId,
|
|
903
|
-
remember:
|
|
906
|
+
remember: sessionMemory,
|
|
904
907
|
permissionHandoff: event === 'shell',
|
|
905
908
|
});
|
|
906
|
-
(0, hookIo_1.dbg)({ phase: 'dev_confirm_ask', event, tool: call.toolName, operation, key: marker.key, remember: source.remember, where: source.where });
|
|
909
|
+
(0, hookIo_1.dbg)({ phase: 'dev_confirm_ask', event, tool: call.toolName, operation, key: marker.key, remember: source.remember, sessionMemory, where: source.where });
|
|
907
910
|
spoolCallEvent(call, {
|
|
908
911
|
decision: 'approval',
|
|
909
912
|
ruleId: source.policyId || source.localFinding?.ruleId,
|
|
@@ -911,6 +914,14 @@ function prepareDeveloperConfirmation(event, call, payload, source) {
|
|
|
911
914
|
reason: `developer confirmation requested via IDE prompt${policyLabel}${source.reason ? `: ${source.reason}` : ''}`,
|
|
912
915
|
approvalScope: 'developer',
|
|
913
916
|
offlineEnforced,
|
|
917
|
+
...(source.localFinding?.remoteControl ? {
|
|
918
|
+
category: source.localFinding.category,
|
|
919
|
+
categoryId: source.localFinding.categoryId,
|
|
920
|
+
itemId: source.localFinding.itemId,
|
|
921
|
+
evidence: source.localFinding.evidence,
|
|
922
|
+
remoteControl: source.localFinding.remoteControl,
|
|
923
|
+
severity: 'critical',
|
|
924
|
+
} : {}),
|
|
914
925
|
});
|
|
915
926
|
(0, telemetry_1.triggerFlush)(false);
|
|
916
927
|
const reason = source.reason || `${call.toolName} needs your confirmation`;
|
|
@@ -1237,11 +1248,13 @@ function explainGuardStop(kind, event, call, reason, ruleId) {
|
|
|
1237
1248
|
});
|
|
1238
1249
|
}
|
|
1239
1250
|
function spoolLocalFinding(input) {
|
|
1251
|
+
// An action that ran is never recorded as "Blocked …" (monitor showed "Blocked recursive force delete" on a warn).
|
|
1252
|
+
const recorded = input.decision === 'warn' ? input.recorded || 'warned' : undefined;
|
|
1240
1253
|
(0, telemetry_1.spoolEvent)({
|
|
1241
1254
|
decision: input.decision || 'block',
|
|
1242
1255
|
toolName: input.toolName,
|
|
1243
1256
|
operation: input.operation,
|
|
1244
|
-
reason: input.finding.reason,
|
|
1257
|
+
reason: recorded ? (0, blockExplanation_1.recordedReason)(input.finding.reason, recorded) : input.finding.reason,
|
|
1245
1258
|
ruleId: input.finding.ruleId,
|
|
1246
1259
|
category: input.finding.category,
|
|
1247
1260
|
categoryId: input.finding.categoryId,
|
|
@@ -1251,6 +1264,7 @@ function spoolLocalFinding(input) {
|
|
|
1251
1264
|
explanation: input.finding.explanation,
|
|
1252
1265
|
policyHash: input.finding.policyHash,
|
|
1253
1266
|
offlineEnforced: true,
|
|
1267
|
+
...(input.finding.remoteControl ? { remoteControl: input.finding.remoteControl, severity: 'critical' } : {}),
|
|
1254
1268
|
});
|
|
1255
1269
|
(0, telemetry_1.triggerFlush)(true);
|
|
1256
1270
|
}
|
|
@@ -1799,8 +1813,9 @@ async function hookCommandInner(args, config, io) {
|
|
|
1799
1813
|
}
|
|
1800
1814
|
// An ask carries the dialog envelope for the per-event hook process in the
|
|
1801
1815
|
// developer's session (askDialog.ts); it is removed before the IDE reads the verdict.
|
|
1816
|
+
// The same client the runtime event records as `agentClient`: the dialog names the agent the console shows.
|
|
1802
1817
|
if (ask && askEnvelope)
|
|
1803
|
-
decision = (0, askDialog_1.attachAskEnvelope)(decision, askEnvelope);
|
|
1818
|
+
decision = (0, askDialog_1.attachAskEnvelope)(decision, { ...askEnvelope, agentClient: client });
|
|
1804
1819
|
(0, hookIo_1.dbg)({ phase: 'verdict', event, format: hookFormat, blocked, decision: ask && askEnvelope ? { ...decision, [askDialog_1.ASK_ENVELOPE_FIELD]: '(envelope)' } : decision });
|
|
1805
1820
|
if (hookFormat === 'claude' && event === 'prompt' && denied) {
|
|
1806
1821
|
// Claude Desktop/Code variants do not all honor the structured
|
|
@@ -1902,8 +1917,8 @@ async function hookCommandInner(args, config, io) {
|
|
|
1902
1917
|
(0, hookIo_1.dbg)({ phase: 'local_deterministic_prompt_block', event, ruleId: localBlock.ruleId, category: localBlock.category });
|
|
1903
1918
|
if (shadow) {
|
|
1904
1919
|
// Truth-in-reporting: this prompt RAN (shadow/monitor) — 'warn', never 'block'.
|
|
1905
|
-
spoolLocalFinding({ finding: localBlock, toolName: 'prompt', operation: 'prompt', decision: 'warn' });
|
|
1906
|
-
respond(false, undefined, `[FullCourtDefense shadow]
|
|
1920
|
+
spoolLocalFinding({ finding: localBlock, toolName: 'prompt', operation: 'prompt', decision: 'warn', recorded: 'would_block' });
|
|
1921
|
+
respond(false, undefined, `[FullCourtDefense shadow] ${(0, blockExplanation_1.recordedReason)(localBlock.reason, 'would_block')}`);
|
|
1907
1922
|
return;
|
|
1908
1923
|
}
|
|
1909
1924
|
spoolLocalFinding({ finding: localBlock, toolName: 'prompt', operation: 'prompt' });
|
|
@@ -2047,8 +2062,8 @@ async function enforceActionPolicy(ctx) {
|
|
|
2047
2062
|
(0, hookIo_1.dbg)({ phase: 'local_deterministic_block', event, tool: call.toolName, ruleId: localBlock.ruleId, category: localBlock.category });
|
|
2048
2063
|
if (shadow) {
|
|
2049
2064
|
// Truth-in-reporting: this action RAN (shadow/monitor) — 'warn', never 'block'.
|
|
2050
|
-
spoolLocalFinding({ finding: localBlock, toolName: call.toolName, operation: event, decision: 'warn' });
|
|
2051
|
-
respond(false, undefined, `[FullCourtDefense shadow]
|
|
2065
|
+
spoolLocalFinding({ finding: localBlock, toolName: call.toolName, operation: event, decision: 'warn', recorded: 'would_block' });
|
|
2066
|
+
respond(false, undefined, `[FullCourtDefense shadow] ${call.toolName}: ${(0, blockExplanation_1.recordedReason)(localBlock.reason, 'would_block')}`);
|
|
2052
2067
|
return;
|
|
2053
2068
|
}
|
|
2054
2069
|
spoolLocalFinding({ finding: localBlock, toolName: call.toolName, operation: event });
|
|
@@ -2065,7 +2080,7 @@ async function enforceActionPolicy(ctx) {
|
|
|
2065
2080
|
if (localAsk) {
|
|
2066
2081
|
(0, hookIo_1.dbg)({ phase: 'local_deterministic_ask', event, tool: call.toolName, ruleId: localAsk.ruleId, humanPresent: (0, devConfirm_1.isHumanPresent)(), shadow });
|
|
2067
2082
|
if (shadow) {
|
|
2068
|
-
spoolLocalFinding({ finding: localAsk, toolName: call.toolName, operation: event, decision: 'warn' });
|
|
2083
|
+
spoolLocalFinding({ finding: localAsk, toolName: call.toolName, operation: event, decision: 'warn', recorded: 'would_ask' });
|
|
2069
2084
|
}
|
|
2070
2085
|
else if (!(0, devConfirm_1.isHumanPresent)()) {
|
|
2071
2086
|
spoolLocalFinding({ finding: localAsk, toolName: call.toolName, operation: event });
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
export interface KnownMcpServerInfo {
|
|
2
2
|
title: string;
|
|
3
3
|
description: string;
|
|
4
|
-
category: 'browser' | 'filesystem' | 'database' | 'gateway' | 'other';
|
|
4
|
+
category: 'browser' | 'filesystem' | 'database' | 'gateway' | 'remote_control' | 'remote_connector' | 'other';
|
|
5
5
|
recommendGateway: boolean;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* A server whose launch (command + args) is a catalogued remote MCP bridge —
|
|
9
|
+
* REMOTE_CONTROL_BRIDGES in deterministicGuard.ts, matched on the package and
|
|
10
|
+
* its mode argument, not the server's name.
|
|
11
|
+
*/
|
|
12
|
+
export declare function remoteMcpLaunchInfo(command?: string, args?: string[]): KnownMcpServerInfo | undefined;
|
|
13
|
+
export declare function knownMcpServerInfo(serverName: string, command?: string, args?: string[]): KnownMcpServerInfo | undefined;
|
|
8
14
|
export declare function directServerFixHint(serverName: string): string | undefined;
|
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.remoteMcpLaunchInfo = remoteMcpLaunchInfo;
|
|
3
4
|
exports.knownMcpServerInfo = knownMcpServerInfo;
|
|
4
5
|
exports.directServerFixHint = directServerFixHint;
|
|
6
|
+
const deterministicGuard_1 = require("./deterministicGuard");
|
|
7
|
+
/**
|
|
8
|
+
* A server whose launch (command + args) is a catalogued remote MCP bridge —
|
|
9
|
+
* REMOTE_CONTROL_BRIDGES in deterministicGuard.ts, matched on the package and
|
|
10
|
+
* its mode argument, not the server's name.
|
|
11
|
+
*/
|
|
12
|
+
function remoteMcpLaunchInfo(command, args) {
|
|
13
|
+
const match = (0, deterministicGuard_1.classifyRemoteMcpLaunch)(command, args || []);
|
|
14
|
+
if (!match)
|
|
15
|
+
return undefined;
|
|
16
|
+
return {
|
|
17
|
+
title: match.bridge.label,
|
|
18
|
+
description: match.bridge.card,
|
|
19
|
+
category: match.bridge.kind,
|
|
20
|
+
recommendGateway: false,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
5
23
|
const KNOWN = [
|
|
24
|
+
{
|
|
25
|
+
match: /desktop-commander/i,
|
|
26
|
+
info: {
|
|
27
|
+
title: 'Desktop Commander',
|
|
28
|
+
description: 'Terminal and file control on this machine for the local AI client (local mode — remote mode is a remote-control bridge).',
|
|
29
|
+
category: 'other',
|
|
30
|
+
recommendGateway: true,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
6
33
|
{
|
|
7
34
|
match: /playwright/i,
|
|
8
35
|
info: {
|
|
@@ -94,8 +121,12 @@ const KNOWN = [
|
|
|
94
121
|
},
|
|
95
122
|
},
|
|
96
123
|
];
|
|
97
|
-
function knownMcpServerInfo(serverName, command) {
|
|
98
|
-
const
|
|
124
|
+
function knownMcpServerInfo(serverName, command, args) {
|
|
125
|
+
const remote = remoteMcpLaunchInfo(command, args);
|
|
126
|
+
if (remote)
|
|
127
|
+
return remote;
|
|
128
|
+
const launchesDesktopCommander = (args || []).some(arg => /^(?:@wonderwhy-er\/)?desktop-commander(?:@|$)/i.test(arg));
|
|
129
|
+
const hay = `${serverName} ${command || ''}${launchesDesktopCommander ? ' desktop-commander' : ''}`;
|
|
99
130
|
for (const entry of KNOWN) {
|
|
100
131
|
if (entry.match.test(hay))
|
|
101
132
|
return entry.info;
|
|
@@ -1546,7 +1546,7 @@ class McpGatewayServer {
|
|
|
1546
1546
|
process.stderr.write(`FullCourtDefense asking the developer to confirm ${toolName}: ${ask.reason} (${origin} "${ask.itemId}", ${ask.ruleId})\n`);
|
|
1547
1547
|
const alwaysScopeLabel = (0, devConfirm_1.describeGrantScope)(grantScope);
|
|
1548
1548
|
const alwaysLimitsLabel = grantLimits ? (0, devConfirm_1.describeGrantLimits)(grantLimits) : undefined;
|
|
1549
|
-
const answer = await this.confirmWithDeveloper({ toolName, reason: ask.reason, ruleLabel: `${origin} "${ask.itemId}" (${ask.ruleId})`, evidence: ask.evidence, argsDigest: digest, allowAlways: Boolean(grantLimits), alwaysScopeLabel, alwaysLimitsLabel });
|
|
1549
|
+
const answer = await this.confirmWithDeveloper({ toolName, reason: ask.reason, ruleLabel: `${origin} "${ask.itemId}" (${ask.ruleId})`, evidence: ask.evidence, argsDigest: digest, allowAlways: Boolean(grantLimits), alwaysScopeLabel, alwaysLimitsLabel, alwaysCovers: (0, devConfirm_1.grantCoverage)(grantScope) });
|
|
1550
1550
|
if (answer.answer === 'accept') {
|
|
1551
1551
|
// Settle through the shared ledger so "remember for this session" is
|
|
1552
1552
|
// recorded exactly like an IDE approval would be.
|
|
@@ -1594,8 +1594,9 @@ class McpGatewayServer {
|
|
|
1594
1594
|
// where the scan can still yield block-action findings. Record the
|
|
1595
1595
|
// would-block and let the call through.
|
|
1596
1596
|
const would = requestOutcome.blockingFinding ? 'would block' : 'would ask you to confirm';
|
|
1597
|
-
|
|
1598
|
-
|
|
1597
|
+
const recorded = (0, blockExplanation_1.recordedReason)(localBlock.reason, requestOutcome.blockingFinding ? 'would_block' : 'would_ask');
|
|
1598
|
+
this.spoolLocalFinding({ ...localBlock, reason: `[monitor] ${recorded}` }, toolName, operation, 'warn');
|
|
1599
|
+
process.stderr.write(`FullCourtDefense (monitor) ${would} ${toolName}: ${recorded.replace(/^Would (?:block|ask): /, '')} (${origin} "${localBlock.itemId}", ${localBlock.ruleId})\n`);
|
|
1599
1600
|
}
|
|
1600
1601
|
else {
|
|
1601
1602
|
this.spoolLocalFinding(localBlock, toolName, operation);
|
|
@@ -1881,7 +1882,7 @@ class McpGatewayServer {
|
|
|
1881
1882
|
const responseOrigin = localResponseBlock.source === 'custom' ? 'org custom rule' : 'built-in Local Safety rule';
|
|
1882
1883
|
if (reportOnlyMode) {
|
|
1883
1884
|
// MONITOR CONTRACT (see request-side block above): record, never block.
|
|
1884
|
-
this.spoolLocalFinding({ ...localResponseBlock, reason: `[monitor] ${localResponseBlock.reason}` }, toolName, operation, 'warn');
|
|
1885
|
+
this.spoolLocalFinding({ ...localResponseBlock, reason: `[monitor] ${(0, blockExplanation_1.recordedReason)(localResponseBlock.reason, 'would_block')}` }, toolName, operation, 'warn');
|
|
1885
1886
|
process.stderr.write(`FullCourtDefense (monitor) would block the ${toolName} response: ${localResponseBlock.reason} (${responseOrigin} "${localResponseBlock.itemId}", ${localResponseBlock.ruleId})\n`);
|
|
1886
1887
|
}
|
|
1887
1888
|
else {
|
|
@@ -1901,7 +1902,7 @@ class McpGatewayServer {
|
|
|
1901
1902
|
if (!fullyMasked) {
|
|
1902
1903
|
const finding = responseOutcome.maskFindings[0];
|
|
1903
1904
|
if (reportOnlyMode) {
|
|
1904
|
-
this.spoolLocalFinding({ ...finding, reason: `[monitor] ${finding.reason}` }, toolName, operation, 'warn');
|
|
1905
|
+
this.spoolLocalFinding({ ...finding, reason: `[monitor] ${(0, blockExplanation_1.recordedReason)(finding.reason, 'would_block')}` }, toolName, operation, 'warn');
|
|
1905
1906
|
process.stderr.write(`FullCourtDefense (monitor) would block the ${toolName} response: mask rule "${finding.itemId}" could not rewrite this payload.\n`);
|
|
1906
1907
|
}
|
|
1907
1908
|
else {
|
|
@@ -2243,6 +2244,7 @@ class McpGatewayServer {
|
|
|
2243
2244
|
allowAlways,
|
|
2244
2245
|
alwaysScopeLabel,
|
|
2245
2246
|
alwaysLimitsLabel,
|
|
2247
|
+
alwaysCovers: (0, devConfirm_1.grantCoverage)(grantScope),
|
|
2246
2248
|
});
|
|
2247
2249
|
if (answer.answer === 'accept') {
|
|
2248
2250
|
// Policy memory limits are authoritative; a client cannot upgrade 'none'.
|
|
@@ -2320,7 +2322,7 @@ class McpGatewayServer {
|
|
|
2320
2322
|
}
|
|
2321
2323
|
async askInOsDialog(input, clientAutoAnswered) {
|
|
2322
2324
|
const evidence = input.evidence ? `\nEvidence: ${input.evidence.slice(0, 240)}` : '';
|
|
2323
|
-
const dialog = await (0, devConfirm_1.confirmNativeActionDetailed)(`Agent: ${this.gatewayConfig.agentName}\nIDE: ${this.gatewayConfig.agentClient}\nDeveloper: ${this.gatewayConfig.developerName || 'Unknown'}\nTool: ${input.toolName}\nRule: ${input.ruleLabel}\nWhy: ${input.reason}${evidence}\n\nYour answer is reported to your security dashboard as your decision.`, OS_DIALOG_TIMEOUT_MS, { allowAlways: input.allowAlways === true, alwaysScopeLabel: input.alwaysScopeLabel, alwaysLimitsLabel: input.alwaysLimitsLabel });
|
|
2325
|
+
const dialog = await (0, devConfirm_1.confirmNativeActionDetailed)(`Agent: ${this.gatewayConfig.agentName}\nIDE: ${this.gatewayConfig.agentClient}\nDeveloper: ${this.gatewayConfig.developerName || 'Unknown'}\nTool: ${input.toolName}\nRule: ${input.ruleLabel}\nWhy: ${input.reason}${evidence}\n\nYour answer is reported to your security dashboard as your decision.`, OS_DIALOG_TIMEOUT_MS, { allowAlways: input.allowAlways === true, alwaysScopeLabel: input.alwaysScopeLabel, alwaysLimitsLabel: input.alwaysLimitsLabel, alwaysCovers: input.alwaysCovers });
|
|
2324
2326
|
process.stderr.write(`FullCourtDefense: dialog for ${input.toolName} ended with "${dialog.outcome}" after ${dialog.latencyMs}ms.\n`);
|
|
2325
2327
|
const answer = dialog.outcome === 'allow' || dialog.outcome === 'allow_always' ? 'accept' : dialog.outcome === 'deny' ? 'decline' : dialog.outcome;
|
|
2326
2328
|
return { answer, remember: false, always: dialog.outcome === 'allow_always', latencyMs: dialog.latencyMs, channel: 'os_dialog', clientAutoAnswered };
|
|
@@ -3079,7 +3081,7 @@ function healCodexTomlAgentIdentities(file, dryRun) {
|
|
|
3079
3081
|
* runtime-agnostic agent identity that protect-all/auto-protect produce (`<developer>-<server>`).
|
|
3080
3082
|
* Otherwise the gateway reports a generic `<developer>-<client>` name and a dashboard policy
|
|
3081
3083
|
* targeting the MCP server (agentName contains <server>) silently never matches — the exact
|
|
3082
|
-
* bug where a block policy on `
|
|
3084
|
+
* bug where a block policy on `contoso-bank-finance` did not fire because the Claude Desktop
|
|
3083
3085
|
* entry reported `boazl-claude-desktop`. An explicit --agent-name / FCD_AGENT_NAME still wins.
|
|
3084
3086
|
*/
|
|
3085
3087
|
function applyPerServerAgentName(gatewayConfig, args, serverName) {
|
|
@@ -171,7 +171,7 @@ function buildGuardJs(nodePath, cliEntry) {
|
|
|
171
171
|
`// Execution view (aligned with the CLI's stripInertDataSegments): quoted spans containing whitespace are`,
|
|
172
172
|
`// prose (inert) unless in a code position — interpreter -c/-Command flags, remote executors (ssh/wsl/docker`,
|
|
173
173
|
`// exec), $( ) substitution, or real backtick command substitution (>=2 chars; a 1-char pair is a PS escape).`,
|
|
174
|
-
`function execView(line){if(/\\b(?:iex|invoke-expression|invoke-command)\\b|\\beval\\b|\\bxargs\\b|\\bbase64\\b[^\\n]*(?:-d\\b|--decode\\b)|frombase64string|-encodedcommand\\b|\\s-enc\\s
|
|
174
|
+
`function execView(line){if(/\\b(?:iex|invoke-expression|invoke-command)\\b|\\beval\\b|\\bxargs\\b|\\bbase64\\b[^\\n]*(?:-d\\b|--decode\\b)|frombase64string|-encodedcommand\\b|\\s-enc\\s|(?<!\\|)\\|(?!\\|)\\s*&?\\s*(?:sh|bash|zsh|dash|ksh|csh|pwsh|powershell(?:\\.exe)?|cmd(?:\\.exe)?|node|python[0-9.]*|perl|ruby)\\b|\\b(?:sh|bash|zsh|dash|ksh|csh|pwsh|powershell(?:\\.exe)?|cmd(?:\\.exe)?|node|python[0-9.]*|perl|ruby)\\s+(?:-c|\\/c|-e|-command|-scriptblock)\\b|\\b(?:ssh|wsl(?:\\.exe)?|chroot)\\b|\\b(?:docker|kubectl|podman|nerdctl)(?:\\.exe)?\\s+(?:exec|run)\\b/i.test(line))return line;const K=/\\$\\(|\`[^\`]{2,}\`/;const C=/(?:(?:^|[;&|(]|\\s)(?:-c|\\/c|-e|-command|-scriptblock|-filter)[= ]\\s*|(?:^|[;&|(]\\s*)(?:\\S*[\\\\\\/])?(?:sudo\\s+|doas\\s+)?(?:ssh|wsl(?:\\.exe)?|chroot|su|screen|tmux)(?:\\s[^;&|"']*)?\\s|(?:\\S*[\\\\\\/])?(?:docker|kubectl|podman|nerdctl)(?:\\.exe)?\\s+(?:exec|run)\\b[^;&|"']*\\s)$/i;let o=line;o=o.replace(/@'[\\s\\S]*?'@/g,' fcd_inert_data ');o=o.replace(/@"[\\s\\S]*?"@/g,m=>m.includes('$(')?m:' fcd_inert_data ');o=o.replace(/<<-?\\s*'(\\w+)'[\\s\\S]*?(?:\\n\\1\\b|$)/g,' fcd_inert_data ');o=o.replace(/<<-?\\s*"?(\\w+)"?[\\s\\S]*?(?:\\n\\1\\b|$)/g,m=>K.test(m)?m:' fcd_inert_data ');const s=o;o=s.replace(/"((?:[^"\\\\]|\\\\.)*)"|'((?:[^'\\\\]|\\\\.)*)'/g,(w,dq,sq,i)=>{const b=dq!==undefined?dq:(sq||'');if(!/\\s/.test(b))return w;if(C.test(s.slice(Math.max(0,i-80),i)))return w;if(dq!==undefined&&K.test(b))return w;return ' fcd_inert_data ';});return o;}`,
|
|
175
175
|
`// Precedence on one line: block outranks ask, ask outranks warn.`,
|
|
176
176
|
`function matchLine(line,rules){const n=line.replace(/\\s+/g,' ').trim();const x=execView(line);const xn=x.replace(/\\s+/g,' ').trim();let warnHit=null;const asks=[];for(const r of rules){try{const t=r.source==='custom'?line:x;const tn=r.source==='custom'?n:xn;if(r.re.test(tn)||r.re.test(t)){if(r.action==='block')return r;if(r.action==='ask'){asks.push(r);}else if(!warnHit)warnHit=r;}}catch{}}if(asks.length===1)return asks[0];if(asks.length>1){asks.sort((a,b)=>a.id<b.id?-1:a.id>b.id?1:0);return{...asks[0],id:'asks:'+asks.map(r=>encodeURIComponent(r.id)).join('+'),reason:asks.map(r=>r.reason).join('; ')}}return warnHit;}`,
|
|
177
177
|
`function triggerFlush(){try{if(fs.existsSync(NODE_PATH)&&fs.existsSync(CLI_ENTRY)){const c=spawn(NODE_PATH,[CLI_ENTRY,'flush-spool','--heartbeat','true'],{detached:true,stdio:'ignore'});c.unref();}}catch{}}`,
|