@node9/policy-engine 2.51.0 → 2.52.0
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/index.d.mts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +243 -31
- package/dist/index.mjs +242 -31
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -958,6 +958,10 @@ interface PolicyHostHooks {
|
|
|
958
958
|
* holds a `.git` entry. Decides `git -C <dir> add .` (node9Firewall#413).
|
|
959
959
|
* Absent, or no cwd: the stage-all finding stands. */
|
|
960
960
|
isGitWorkTreeTop?: (dir: string, cwd: string) => boolean;
|
|
961
|
+
/** The running daemon's pid from ~/.node9/daemon.pid, or null. A `kill` of
|
|
962
|
+
* that number switches node9 off (commands.node9-disarm). Absent: a numeric
|
|
963
|
+
* kill is never read as the daemon. */
|
|
964
|
+
daemonPid?: () => number | null;
|
|
961
965
|
}
|
|
962
966
|
interface PolicyVerdict {
|
|
963
967
|
decision: 'allow' | 'review' | 'block';
|
|
@@ -1428,6 +1432,10 @@ declare function isRecordOnly(mode: string | undefined): boolean;
|
|
|
1428
1432
|
/** Strict and Block all ask about every inline code call, not only the
|
|
1429
1433
|
* dangerous ones the inline judge finds. */
|
|
1430
1434
|
declare function reviewsEveryInline(mode: string | undefined): boolean;
|
|
1435
|
+
/** Strict and Block all hold a send to an unknown destination while the
|
|
1436
|
+
* daemon is down, since nobody knows what the session read; Standard records
|
|
1437
|
+
* it only (node9Firewall#445 follow-up). */
|
|
1438
|
+
declare function holdsSendsWithoutDaemon(mode: string | undefined): boolean;
|
|
1431
1439
|
/** Block all: ask before any call no check recognised (the catch-all,
|
|
1432
1440
|
* `commands.unknown`) and about a binary of unknown origin. This is what
|
|
1433
1441
|
* `strict` meant before the levels. */
|
|
@@ -2426,7 +2434,7 @@ declare const LONG_OUTPUT_THRESHOLD_BYTES: number;
|
|
|
2426
2434
|
* and fails CI when the hash drifts without a version bump — forgetting
|
|
2427
2435
|
* is loud, not silent.
|
|
2428
2436
|
*/
|
|
2429
|
-
declare const CANONICAL_EXTRACTOR_VERSION = "canonical-
|
|
2437
|
+
declare const CANONICAL_EXTRACTOR_VERSION = "canonical-v38";
|
|
2430
2438
|
/**
|
|
2431
2439
|
* SHA-256 prefix of the detector-source files
|
|
2432
2440
|
* (canonical.ts + pii.ts + destructive-regex.ts).
|
|
@@ -2437,7 +2445,7 @@ declare const CANONICAL_EXTRACTOR_VERSION = "canonical-v37";
|
|
|
2437
2445
|
* files changed, this hash must change too, and you must consciously
|
|
2438
2446
|
* decide whether to bump CANONICAL_EXTRACTOR_VERSION."
|
|
2439
2447
|
*/
|
|
2440
|
-
declare const CANONICAL_EXTRACTOR_HASH = "
|
|
2448
|
+
declare const CANONICAL_EXTRACTOR_HASH = "2d3dfcccff2c2f65";
|
|
2441
2449
|
declare function extractCanonicalFindings(call: ToolCallEntry, ctx: ExtractContext): CanonicalFinding[];
|
|
2442
2450
|
declare function extractSessionLevelFindings(calls: ReadonlyArray<SessionToolCall>, ctx: SessionExtractContext): CanonicalFinding[];
|
|
2443
2451
|
/**
|
|
@@ -2549,5 +2557,5 @@ declare function scanArgumentSecrets(args: unknown): DlpMatch | null;
|
|
|
2549
2557
|
/** Engine version stamped on audit entries for future drift detection. */
|
|
2550
2558
|
declare const ENGINE_VERSION = "1.4.0";
|
|
2551
2559
|
|
|
2552
|
-
export { ACTION_CHECKS, ACTION_TEMPLATES, AGENT_INSTRUCTION_DIRS, AGENT_INSTRUCTION_FILES, APP_SERVER_GLOB, APP_SHIELD_NAMES, APP_SHIELD_SPECS, ARGUMENT_SCAN_LIMITS, ASI, ASI_IDS, AST_FS_REGEX_RULES, BASH_TOOL_NAMES, BUILTIN_DANGEROUS_WORDS, BUILTIN_SHIELDS, CANARY_MIN_LENGTH, CANONICAL_EXTRACTOR_HASH, CANONICAL_EXTRACTOR_VERSION, CHECKS, CHECK_BY_ID, CHECK_GROUPS, CHECK_TEXT, CHECK_VERDICT_RANK, COMMAND_WRAPPERS, CONFIGURABLE_CHECK_IDS, COPY_VERBS, COST_PER_LOOP_ITER_USD, DEFAULT_EGRESS_ALLOWLIST, DESTINATION_ARGS, DESTRUCTIVE_OP_RE, DLP_PATTERNS, DLP_SCAN_LIMITS, ENGINE_VERSION, FILE_TOOLS, FLAGS_WITH_VALUES, FS_READ_TOOLS, GENERAL_ACTION_RULES, KNOB_GOVERNED, LEVELS, LONG_OUTPUT_THRESHOLD_BYTES, LOOP_MAX_RECORDS, LOOP_THRESHOLD_FOR_WASTE, MAP_GOVERNED, MAX_BLAST_PATH, MAX_DESTINATIONS, MODE_VALUES, NET_BINARIES, PATTERN_VERB_NAMES, POSTURE_CATEGORY_OWASP, PRIVILEGE_ESCALATION_RE, REALTIME_PII_PATTERNS, REPLACED_SHIELDS, SCAN_REPO_RULES_WITHOUT_RISK, SCAN_SIGNAL_WEIGHTS, SENSITIVE_PATH_RE, SENSITIVE_PATH_REGEXES, SSRF_MAX_HOST, STARTUP_NAMES, SYSTEM_AUTH_DIRS, SYSTEM_AUTH_FILES, TUNING_FIELDS, VERDICTS, agentFileKind, analyzeFsOperation, analyzeGit, analyzeOutbound, analyzePipeChain, analyzeShellCommand, argumentLeavesText, catalogSettingsFromConfig, checkDangerousSql, checkIdForCheckedBy, checkIdForRule, checkToLegacyPolicy, checkValue, checksFromLegacyPolicy, classifyAuditEntry, classifyRuleSeverity, classifyScanSignal, classifyShellExposure, classifySsrf, collectFileAccesses, computeAgentDeviceScore, computeArgsHash, computeBlendedSecurityScore, computeScanScore, computeSecurityScore, configurableValues, decodeEmbeddedBase64, decodeEmbeddedHex, dedupeCanonicalFindings, derivedWrites, destinationDomain, destinationKind, destinationValue, detectArgsPii, detectDangerousEval, detectDangerousShellExec, detectInlineExec, detectPii, entryDisplay, evaluateEgress, evaluateLoopWindow, evaluatePolicy, evaluateProtectedFileAccess, evaluateSmartConditions, extractAllSshHosts, extractArgDestinations, extractCanonicalFindings, extractContentDestinations, extractNetworkTargets, extractPackageInstalls, extractPositionalArgs, extractRegistryOverrides, extractSessionLevelFindings, extractShellDestTokens, extractShellDestinations, extractToolDestinations, fileAccessView, fileOperandFlagsOf, fileToolOperation, foldHomoglyphs, getCheck, getCompiledRegex, getNestedValue, gitInvocations, gitRepoPath, hashDestination, hostMatches, incompleteFileVerdict, inlineExecDescription, inlineExecReason, inlineExecReview, inspectArgumentSecrets, inspectionEntry, inspectionLayers, isAgentInstructionPath, isAsiId, isBashTool, isBlockAll, isDestructiveToolName, isHashedEntry, isIgnoredTool, isInside, isKnobGoverned, isLegacySystemPath, isLockedCheck, isLoopbackHost, isMaskedKind, isModeValue, isPasswordHashPath, isPrivateHost, isProtectedHomePath, isPublicRegistryHost, isRecordOnly, isShellShapedTool, isShieldVerdict, isStrictGatedTier, isVerdict, knobStatedChecks, levelCheckValue, levelChecks, levelOf, levelPackageSignals, maskDestination, maskPersonalData, maskPersonalValue, matchCanary, matchCanaryArgs, matchSensitivePath, matchesPattern, matchesTrustedEntry, matchesTrustedList, mcpServerFromToolName, narrativeRuleLabel, normalizeCommandForPolicy, normalizeDestination, normalizeFilePath, normalizeForScan, normalizeIpLiteral, normalizePyPiName, normalizeRecipient, normalizeTrustedEntry, packRowOwasp, parseAllSshHostsFromCommand, parseDestHost, patternShapeOf, pipelineTexts, positionedArgs, postureCategoryOwasp, previewArgs, redactText, registryHost, resolveAllChecks, resolveCheck, resolveCheckMap, resolvePinned, resolveShellInput, reviewsEveryInline, ruleServerMatches, safeMessage, sampleCopyCommand, scanArgs, scanArgumentSecrets, scanInjection, scanInstructionWrite, scanRepoRuleOwasp, scanText, scanViews, sensitivePathMatch, shellRuleArgs, shellScriptOperands, ssrfCheckId, ssrfDestinationFloor, ssrfExemptMatches, ssrfFloor, ssrfReason, stripControlChars, stripInvisible, stripTerminalEscapes, suggestFromApprovals, summarizeBlast, summarizeScan, toScanFinding, toolMatchesRule, truncateBlastPath, trustedEntryOf, tuningFromLegacyPolicy, tuningToLegacyPolicy, unwrapCommandHead, unwrapRuleLabel, validateOverrides, validateRegex, validateShieldDefinition };
|
|
2560
|
+
export { ACTION_CHECKS, ACTION_TEMPLATES, AGENT_INSTRUCTION_DIRS, AGENT_INSTRUCTION_FILES, APP_SERVER_GLOB, APP_SHIELD_NAMES, APP_SHIELD_SPECS, ARGUMENT_SCAN_LIMITS, ASI, ASI_IDS, AST_FS_REGEX_RULES, BASH_TOOL_NAMES, BUILTIN_DANGEROUS_WORDS, BUILTIN_SHIELDS, CANARY_MIN_LENGTH, CANONICAL_EXTRACTOR_HASH, CANONICAL_EXTRACTOR_VERSION, CHECKS, CHECK_BY_ID, CHECK_GROUPS, CHECK_TEXT, CHECK_VERDICT_RANK, COMMAND_WRAPPERS, CONFIGURABLE_CHECK_IDS, COPY_VERBS, COST_PER_LOOP_ITER_USD, DEFAULT_EGRESS_ALLOWLIST, DESTINATION_ARGS, DESTRUCTIVE_OP_RE, DLP_PATTERNS, DLP_SCAN_LIMITS, ENGINE_VERSION, FILE_TOOLS, FLAGS_WITH_VALUES, FS_READ_TOOLS, GENERAL_ACTION_RULES, KNOB_GOVERNED, LEVELS, LONG_OUTPUT_THRESHOLD_BYTES, LOOP_MAX_RECORDS, LOOP_THRESHOLD_FOR_WASTE, MAP_GOVERNED, MAX_BLAST_PATH, MAX_DESTINATIONS, MODE_VALUES, NET_BINARIES, PATTERN_VERB_NAMES, POSTURE_CATEGORY_OWASP, PRIVILEGE_ESCALATION_RE, REALTIME_PII_PATTERNS, REPLACED_SHIELDS, SCAN_REPO_RULES_WITHOUT_RISK, SCAN_SIGNAL_WEIGHTS, SENSITIVE_PATH_RE, SENSITIVE_PATH_REGEXES, SSRF_MAX_HOST, STARTUP_NAMES, SYSTEM_AUTH_DIRS, SYSTEM_AUTH_FILES, TUNING_FIELDS, VERDICTS, agentFileKind, analyzeFsOperation, analyzeGit, analyzeOutbound, analyzePipeChain, analyzeShellCommand, argumentLeavesText, catalogSettingsFromConfig, checkDangerousSql, checkIdForCheckedBy, checkIdForRule, checkToLegacyPolicy, checkValue, checksFromLegacyPolicy, classifyAuditEntry, classifyRuleSeverity, classifyScanSignal, classifyShellExposure, classifySsrf, collectFileAccesses, computeAgentDeviceScore, computeArgsHash, computeBlendedSecurityScore, computeScanScore, computeSecurityScore, configurableValues, decodeEmbeddedBase64, decodeEmbeddedHex, dedupeCanonicalFindings, derivedWrites, destinationDomain, destinationKind, destinationValue, detectArgsPii, detectDangerousEval, detectDangerousShellExec, detectInlineExec, detectPii, entryDisplay, evaluateEgress, evaluateLoopWindow, evaluatePolicy, evaluateProtectedFileAccess, evaluateSmartConditions, extractAllSshHosts, extractArgDestinations, extractCanonicalFindings, extractContentDestinations, extractNetworkTargets, extractPackageInstalls, extractPositionalArgs, extractRegistryOverrides, extractSessionLevelFindings, extractShellDestTokens, extractShellDestinations, extractToolDestinations, fileAccessView, fileOperandFlagsOf, fileToolOperation, foldHomoglyphs, getCheck, getCompiledRegex, getNestedValue, gitInvocations, gitRepoPath, hashDestination, holdsSendsWithoutDaemon, hostMatches, incompleteFileVerdict, inlineExecDescription, inlineExecReason, inlineExecReview, inspectArgumentSecrets, inspectionEntry, inspectionLayers, isAgentInstructionPath, isAsiId, isBashTool, isBlockAll, isDestructiveToolName, isHashedEntry, isIgnoredTool, isInside, isKnobGoverned, isLegacySystemPath, isLockedCheck, isLoopbackHost, isMaskedKind, isModeValue, isPasswordHashPath, isPrivateHost, isProtectedHomePath, isPublicRegistryHost, isRecordOnly, isShellShapedTool, isShieldVerdict, isStrictGatedTier, isVerdict, knobStatedChecks, levelCheckValue, levelChecks, levelOf, levelPackageSignals, maskDestination, maskPersonalData, maskPersonalValue, matchCanary, matchCanaryArgs, matchSensitivePath, matchesPattern, matchesTrustedEntry, matchesTrustedList, mcpServerFromToolName, narrativeRuleLabel, normalizeCommandForPolicy, normalizeDestination, normalizeFilePath, normalizeForScan, normalizeIpLiteral, normalizePyPiName, normalizeRecipient, normalizeTrustedEntry, packRowOwasp, parseAllSshHostsFromCommand, parseDestHost, patternShapeOf, pipelineTexts, positionedArgs, postureCategoryOwasp, previewArgs, redactText, registryHost, resolveAllChecks, resolveCheck, resolveCheckMap, resolvePinned, resolveShellInput, reviewsEveryInline, ruleServerMatches, safeMessage, sampleCopyCommand, scanArgs, scanArgumentSecrets, scanInjection, scanInstructionWrite, scanRepoRuleOwasp, scanText, scanViews, sensitivePathMatch, shellRuleArgs, shellScriptOperands, ssrfCheckId, ssrfDestinationFloor, ssrfExemptMatches, ssrfFloor, ssrfReason, stripControlChars, stripInvisible, stripTerminalEscapes, suggestFromApprovals, summarizeBlast, summarizeScan, toScanFinding, toolMatchesRule, truncateBlastPath, trustedEntryOf, tuningFromLegacyPolicy, tuningToLegacyPolicy, unwrapCommandHead, unwrapRuleLabel, validateOverrides, validateRegex, validateShieldDefinition };
|
|
2553
2561
|
export type { ActionTemplateName, AgentFileKind, ApprovalRow, ArgumentInspectionResult, AsiId, AuditEntryForClassify, BlastEnvFinding, BlastFinding, BlastResult, BlastSummary, CanaryHit, CanaryValue, CanaryView, CanonicalAgent, CanonicalFinding, CanonicalFindingType, CanonicalSourceType, CatalogSettings, CheckDef, CheckGroup, CheckSource, CheckText, DerivedWrite, Destination, DestinationKind, DlpMatch, EgressPolicy, EgressVerdict, ExtractContext, FileAccess, FileAccessContext, FsOpVerdict, GitAnalysis, GitFinding, GitInvocation, InjectionConfidence, InjectionContext, InjectionMatch, InlineExecReview, InspectionInput, InspectionLayers, LegacyPolicyKnobs, Level, LoopWindowEvaluation, ModeValue, OutboundAnalysis, OutboundCheckId, OutboundFinding, PackageEcosystem, PackageInstallRequest, PiiPattern, PipeChainAnalysis, PolicyConfig, PolicyContext, PolicyHostHooks, PolicyVerdict, PositionedArg, ProtectedFileVerdict, ProvenanceLookup, ProvenanceTrust, RegistryOverride, ResolvedCheck, RiskMetadata, ScanFinding, ScanSignals, ScanSummary, ScanView, ScoreTier, SessionExtractContext, SessionToolCall, Severity, ShellCommandAnalysis, ShellDestToken, ShellDestination, ShellExposure, ShellInputResolution, ShieldDefinition, ShieldOverrides, ShieldVerdict, SmartCondition, SmartRule, SsrfFloorOptions, SsrfMatch, SsrfTier, SsrfVerdict, SuggestOptions, Suggestion, ToolCallEntry, ToolCallRecord, ToolInspection, ToolInspectionEntry, TuningField, Verdict };
|
package/dist/index.d.ts
CHANGED
|
@@ -958,6 +958,10 @@ interface PolicyHostHooks {
|
|
|
958
958
|
* holds a `.git` entry. Decides `git -C <dir> add .` (node9Firewall#413).
|
|
959
959
|
* Absent, or no cwd: the stage-all finding stands. */
|
|
960
960
|
isGitWorkTreeTop?: (dir: string, cwd: string) => boolean;
|
|
961
|
+
/** The running daemon's pid from ~/.node9/daemon.pid, or null. A `kill` of
|
|
962
|
+
* that number switches node9 off (commands.node9-disarm). Absent: a numeric
|
|
963
|
+
* kill is never read as the daemon. */
|
|
964
|
+
daemonPid?: () => number | null;
|
|
961
965
|
}
|
|
962
966
|
interface PolicyVerdict {
|
|
963
967
|
decision: 'allow' | 'review' | 'block';
|
|
@@ -1428,6 +1432,10 @@ declare function isRecordOnly(mode: string | undefined): boolean;
|
|
|
1428
1432
|
/** Strict and Block all ask about every inline code call, not only the
|
|
1429
1433
|
* dangerous ones the inline judge finds. */
|
|
1430
1434
|
declare function reviewsEveryInline(mode: string | undefined): boolean;
|
|
1435
|
+
/** Strict and Block all hold a send to an unknown destination while the
|
|
1436
|
+
* daemon is down, since nobody knows what the session read; Standard records
|
|
1437
|
+
* it only (node9Firewall#445 follow-up). */
|
|
1438
|
+
declare function holdsSendsWithoutDaemon(mode: string | undefined): boolean;
|
|
1431
1439
|
/** Block all: ask before any call no check recognised (the catch-all,
|
|
1432
1440
|
* `commands.unknown`) and about a binary of unknown origin. This is what
|
|
1433
1441
|
* `strict` meant before the levels. */
|
|
@@ -2426,7 +2434,7 @@ declare const LONG_OUTPUT_THRESHOLD_BYTES: number;
|
|
|
2426
2434
|
* and fails CI when the hash drifts without a version bump — forgetting
|
|
2427
2435
|
* is loud, not silent.
|
|
2428
2436
|
*/
|
|
2429
|
-
declare const CANONICAL_EXTRACTOR_VERSION = "canonical-
|
|
2437
|
+
declare const CANONICAL_EXTRACTOR_VERSION = "canonical-v38";
|
|
2430
2438
|
/**
|
|
2431
2439
|
* SHA-256 prefix of the detector-source files
|
|
2432
2440
|
* (canonical.ts + pii.ts + destructive-regex.ts).
|
|
@@ -2437,7 +2445,7 @@ declare const CANONICAL_EXTRACTOR_VERSION = "canonical-v37";
|
|
|
2437
2445
|
* files changed, this hash must change too, and you must consciously
|
|
2438
2446
|
* decide whether to bump CANONICAL_EXTRACTOR_VERSION."
|
|
2439
2447
|
*/
|
|
2440
|
-
declare const CANONICAL_EXTRACTOR_HASH = "
|
|
2448
|
+
declare const CANONICAL_EXTRACTOR_HASH = "2d3dfcccff2c2f65";
|
|
2441
2449
|
declare function extractCanonicalFindings(call: ToolCallEntry, ctx: ExtractContext): CanonicalFinding[];
|
|
2442
2450
|
declare function extractSessionLevelFindings(calls: ReadonlyArray<SessionToolCall>, ctx: SessionExtractContext): CanonicalFinding[];
|
|
2443
2451
|
/**
|
|
@@ -2549,5 +2557,5 @@ declare function scanArgumentSecrets(args: unknown): DlpMatch | null;
|
|
|
2549
2557
|
/** Engine version stamped on audit entries for future drift detection. */
|
|
2550
2558
|
declare const ENGINE_VERSION = "1.4.0";
|
|
2551
2559
|
|
|
2552
|
-
export { ACTION_CHECKS, ACTION_TEMPLATES, AGENT_INSTRUCTION_DIRS, AGENT_INSTRUCTION_FILES, APP_SERVER_GLOB, APP_SHIELD_NAMES, APP_SHIELD_SPECS, ARGUMENT_SCAN_LIMITS, ASI, ASI_IDS, AST_FS_REGEX_RULES, BASH_TOOL_NAMES, BUILTIN_DANGEROUS_WORDS, BUILTIN_SHIELDS, CANARY_MIN_LENGTH, CANONICAL_EXTRACTOR_HASH, CANONICAL_EXTRACTOR_VERSION, CHECKS, CHECK_BY_ID, CHECK_GROUPS, CHECK_TEXT, CHECK_VERDICT_RANK, COMMAND_WRAPPERS, CONFIGURABLE_CHECK_IDS, COPY_VERBS, COST_PER_LOOP_ITER_USD, DEFAULT_EGRESS_ALLOWLIST, DESTINATION_ARGS, DESTRUCTIVE_OP_RE, DLP_PATTERNS, DLP_SCAN_LIMITS, ENGINE_VERSION, FILE_TOOLS, FLAGS_WITH_VALUES, FS_READ_TOOLS, GENERAL_ACTION_RULES, KNOB_GOVERNED, LEVELS, LONG_OUTPUT_THRESHOLD_BYTES, LOOP_MAX_RECORDS, LOOP_THRESHOLD_FOR_WASTE, MAP_GOVERNED, MAX_BLAST_PATH, MAX_DESTINATIONS, MODE_VALUES, NET_BINARIES, PATTERN_VERB_NAMES, POSTURE_CATEGORY_OWASP, PRIVILEGE_ESCALATION_RE, REALTIME_PII_PATTERNS, REPLACED_SHIELDS, SCAN_REPO_RULES_WITHOUT_RISK, SCAN_SIGNAL_WEIGHTS, SENSITIVE_PATH_RE, SENSITIVE_PATH_REGEXES, SSRF_MAX_HOST, STARTUP_NAMES, SYSTEM_AUTH_DIRS, SYSTEM_AUTH_FILES, TUNING_FIELDS, VERDICTS, agentFileKind, analyzeFsOperation, analyzeGit, analyzeOutbound, analyzePipeChain, analyzeShellCommand, argumentLeavesText, catalogSettingsFromConfig, checkDangerousSql, checkIdForCheckedBy, checkIdForRule, checkToLegacyPolicy, checkValue, checksFromLegacyPolicy, classifyAuditEntry, classifyRuleSeverity, classifyScanSignal, classifyShellExposure, classifySsrf, collectFileAccesses, computeAgentDeviceScore, computeArgsHash, computeBlendedSecurityScore, computeScanScore, computeSecurityScore, configurableValues, decodeEmbeddedBase64, decodeEmbeddedHex, dedupeCanonicalFindings, derivedWrites, destinationDomain, destinationKind, destinationValue, detectArgsPii, detectDangerousEval, detectDangerousShellExec, detectInlineExec, detectPii, entryDisplay, evaluateEgress, evaluateLoopWindow, evaluatePolicy, evaluateProtectedFileAccess, evaluateSmartConditions, extractAllSshHosts, extractArgDestinations, extractCanonicalFindings, extractContentDestinations, extractNetworkTargets, extractPackageInstalls, extractPositionalArgs, extractRegistryOverrides, extractSessionLevelFindings, extractShellDestTokens, extractShellDestinations, extractToolDestinations, fileAccessView, fileOperandFlagsOf, fileToolOperation, foldHomoglyphs, getCheck, getCompiledRegex, getNestedValue, gitInvocations, gitRepoPath, hashDestination, hostMatches, incompleteFileVerdict, inlineExecDescription, inlineExecReason, inlineExecReview, inspectArgumentSecrets, inspectionEntry, inspectionLayers, isAgentInstructionPath, isAsiId, isBashTool, isBlockAll, isDestructiveToolName, isHashedEntry, isIgnoredTool, isInside, isKnobGoverned, isLegacySystemPath, isLockedCheck, isLoopbackHost, isMaskedKind, isModeValue, isPasswordHashPath, isPrivateHost, isProtectedHomePath, isPublicRegistryHost, isRecordOnly, isShellShapedTool, isShieldVerdict, isStrictGatedTier, isVerdict, knobStatedChecks, levelCheckValue, levelChecks, levelOf, levelPackageSignals, maskDestination, maskPersonalData, maskPersonalValue, matchCanary, matchCanaryArgs, matchSensitivePath, matchesPattern, matchesTrustedEntry, matchesTrustedList, mcpServerFromToolName, narrativeRuleLabel, normalizeCommandForPolicy, normalizeDestination, normalizeFilePath, normalizeForScan, normalizeIpLiteral, normalizePyPiName, normalizeRecipient, normalizeTrustedEntry, packRowOwasp, parseAllSshHostsFromCommand, parseDestHost, patternShapeOf, pipelineTexts, positionedArgs, postureCategoryOwasp, previewArgs, redactText, registryHost, resolveAllChecks, resolveCheck, resolveCheckMap, resolvePinned, resolveShellInput, reviewsEveryInline, ruleServerMatches, safeMessage, sampleCopyCommand, scanArgs, scanArgumentSecrets, scanInjection, scanInstructionWrite, scanRepoRuleOwasp, scanText, scanViews, sensitivePathMatch, shellRuleArgs, shellScriptOperands, ssrfCheckId, ssrfDestinationFloor, ssrfExemptMatches, ssrfFloor, ssrfReason, stripControlChars, stripInvisible, stripTerminalEscapes, suggestFromApprovals, summarizeBlast, summarizeScan, toScanFinding, toolMatchesRule, truncateBlastPath, trustedEntryOf, tuningFromLegacyPolicy, tuningToLegacyPolicy, unwrapCommandHead, unwrapRuleLabel, validateOverrides, validateRegex, validateShieldDefinition };
|
|
2560
|
+
export { ACTION_CHECKS, ACTION_TEMPLATES, AGENT_INSTRUCTION_DIRS, AGENT_INSTRUCTION_FILES, APP_SERVER_GLOB, APP_SHIELD_NAMES, APP_SHIELD_SPECS, ARGUMENT_SCAN_LIMITS, ASI, ASI_IDS, AST_FS_REGEX_RULES, BASH_TOOL_NAMES, BUILTIN_DANGEROUS_WORDS, BUILTIN_SHIELDS, CANARY_MIN_LENGTH, CANONICAL_EXTRACTOR_HASH, CANONICAL_EXTRACTOR_VERSION, CHECKS, CHECK_BY_ID, CHECK_GROUPS, CHECK_TEXT, CHECK_VERDICT_RANK, COMMAND_WRAPPERS, CONFIGURABLE_CHECK_IDS, COPY_VERBS, COST_PER_LOOP_ITER_USD, DEFAULT_EGRESS_ALLOWLIST, DESTINATION_ARGS, DESTRUCTIVE_OP_RE, DLP_PATTERNS, DLP_SCAN_LIMITS, ENGINE_VERSION, FILE_TOOLS, FLAGS_WITH_VALUES, FS_READ_TOOLS, GENERAL_ACTION_RULES, KNOB_GOVERNED, LEVELS, LONG_OUTPUT_THRESHOLD_BYTES, LOOP_MAX_RECORDS, LOOP_THRESHOLD_FOR_WASTE, MAP_GOVERNED, MAX_BLAST_PATH, MAX_DESTINATIONS, MODE_VALUES, NET_BINARIES, PATTERN_VERB_NAMES, POSTURE_CATEGORY_OWASP, PRIVILEGE_ESCALATION_RE, REALTIME_PII_PATTERNS, REPLACED_SHIELDS, SCAN_REPO_RULES_WITHOUT_RISK, SCAN_SIGNAL_WEIGHTS, SENSITIVE_PATH_RE, SENSITIVE_PATH_REGEXES, SSRF_MAX_HOST, STARTUP_NAMES, SYSTEM_AUTH_DIRS, SYSTEM_AUTH_FILES, TUNING_FIELDS, VERDICTS, agentFileKind, analyzeFsOperation, analyzeGit, analyzeOutbound, analyzePipeChain, analyzeShellCommand, argumentLeavesText, catalogSettingsFromConfig, checkDangerousSql, checkIdForCheckedBy, checkIdForRule, checkToLegacyPolicy, checkValue, checksFromLegacyPolicy, classifyAuditEntry, classifyRuleSeverity, classifyScanSignal, classifyShellExposure, classifySsrf, collectFileAccesses, computeAgentDeviceScore, computeArgsHash, computeBlendedSecurityScore, computeScanScore, computeSecurityScore, configurableValues, decodeEmbeddedBase64, decodeEmbeddedHex, dedupeCanonicalFindings, derivedWrites, destinationDomain, destinationKind, destinationValue, detectArgsPii, detectDangerousEval, detectDangerousShellExec, detectInlineExec, detectPii, entryDisplay, evaluateEgress, evaluateLoopWindow, evaluatePolicy, evaluateProtectedFileAccess, evaluateSmartConditions, extractAllSshHosts, extractArgDestinations, extractCanonicalFindings, extractContentDestinations, extractNetworkTargets, extractPackageInstalls, extractPositionalArgs, extractRegistryOverrides, extractSessionLevelFindings, extractShellDestTokens, extractShellDestinations, extractToolDestinations, fileAccessView, fileOperandFlagsOf, fileToolOperation, foldHomoglyphs, getCheck, getCompiledRegex, getNestedValue, gitInvocations, gitRepoPath, hashDestination, holdsSendsWithoutDaemon, hostMatches, incompleteFileVerdict, inlineExecDescription, inlineExecReason, inlineExecReview, inspectArgumentSecrets, inspectionEntry, inspectionLayers, isAgentInstructionPath, isAsiId, isBashTool, isBlockAll, isDestructiveToolName, isHashedEntry, isIgnoredTool, isInside, isKnobGoverned, isLegacySystemPath, isLockedCheck, isLoopbackHost, isMaskedKind, isModeValue, isPasswordHashPath, isPrivateHost, isProtectedHomePath, isPublicRegistryHost, isRecordOnly, isShellShapedTool, isShieldVerdict, isStrictGatedTier, isVerdict, knobStatedChecks, levelCheckValue, levelChecks, levelOf, levelPackageSignals, maskDestination, maskPersonalData, maskPersonalValue, matchCanary, matchCanaryArgs, matchSensitivePath, matchesPattern, matchesTrustedEntry, matchesTrustedList, mcpServerFromToolName, narrativeRuleLabel, normalizeCommandForPolicy, normalizeDestination, normalizeFilePath, normalizeForScan, normalizeIpLiteral, normalizePyPiName, normalizeRecipient, normalizeTrustedEntry, packRowOwasp, parseAllSshHostsFromCommand, parseDestHost, patternShapeOf, pipelineTexts, positionedArgs, postureCategoryOwasp, previewArgs, redactText, registryHost, resolveAllChecks, resolveCheck, resolveCheckMap, resolvePinned, resolveShellInput, reviewsEveryInline, ruleServerMatches, safeMessage, sampleCopyCommand, scanArgs, scanArgumentSecrets, scanInjection, scanInstructionWrite, scanRepoRuleOwasp, scanText, scanViews, sensitivePathMatch, shellRuleArgs, shellScriptOperands, ssrfCheckId, ssrfDestinationFloor, ssrfExemptMatches, ssrfFloor, ssrfReason, stripControlChars, stripInvisible, stripTerminalEscapes, suggestFromApprovals, summarizeBlast, summarizeScan, toScanFinding, toolMatchesRule, truncateBlastPath, trustedEntryOf, tuningFromLegacyPolicy, tuningToLegacyPolicy, unwrapCommandHead, unwrapRuleLabel, validateOverrides, validateRegex, validateShieldDefinition };
|
|
2553
2561
|
export type { ActionTemplateName, AgentFileKind, ApprovalRow, ArgumentInspectionResult, AsiId, AuditEntryForClassify, BlastEnvFinding, BlastFinding, BlastResult, BlastSummary, CanaryHit, CanaryValue, CanaryView, CanonicalAgent, CanonicalFinding, CanonicalFindingType, CanonicalSourceType, CatalogSettings, CheckDef, CheckGroup, CheckSource, CheckText, DerivedWrite, Destination, DestinationKind, DlpMatch, EgressPolicy, EgressVerdict, ExtractContext, FileAccess, FileAccessContext, FsOpVerdict, GitAnalysis, GitFinding, GitInvocation, InjectionConfidence, InjectionContext, InjectionMatch, InlineExecReview, InspectionInput, InspectionLayers, LegacyPolicyKnobs, Level, LoopWindowEvaluation, ModeValue, OutboundAnalysis, OutboundCheckId, OutboundFinding, PackageEcosystem, PackageInstallRequest, PiiPattern, PipeChainAnalysis, PolicyConfig, PolicyContext, PolicyHostHooks, PolicyVerdict, PositionedArg, ProtectedFileVerdict, ProvenanceLookup, ProvenanceTrust, RegistryOverride, ResolvedCheck, RiskMetadata, ScanFinding, ScanSignals, ScanSummary, ScanView, ScoreTier, SessionExtractContext, SessionToolCall, Severity, ShellCommandAnalysis, ShellDestToken, ShellDestination, ShellExposure, ShellInputResolution, ShieldDefinition, ShieldOverrides, ShieldVerdict, SmartCondition, SmartRule, SsrfFloorOptions, SsrfMatch, SsrfTier, SsrfVerdict, SuggestOptions, Suggestion, ToolCallEntry, ToolCallRecord, ToolInspection, ToolInspectionEntry, TuningField, Verdict };
|
package/dist/index.js
CHANGED
|
@@ -157,6 +157,7 @@ __export(src_exports, {
|
|
|
157
157
|
gitInvocations: () => gitInvocations,
|
|
158
158
|
gitRepoPath: () => gitRepoPath,
|
|
159
159
|
hashDestination: () => hashDestination,
|
|
160
|
+
holdsSendsWithoutDaemon: () => holdsSendsWithoutDaemon,
|
|
160
161
|
hostMatches: () => hostMatches,
|
|
161
162
|
incompleteFileVerdict: () => incompleteFileVerdict,
|
|
162
163
|
inlineExecDescription: () => inlineExecDescription,
|
|
@@ -2384,15 +2385,15 @@ function ssrfExemptMatches(entries, normalized) {
|
|
|
2384
2385
|
continue;
|
|
2385
2386
|
}
|
|
2386
2387
|
if (!target) continue;
|
|
2387
|
-
const
|
|
2388
|
+
const base3 = bitsOf(normalizeIpLiteral(entry.slice(0, slash)) ?? "");
|
|
2388
2389
|
const prefixText = entry.slice(slash + 1);
|
|
2389
2390
|
const prefix = /^\d+$/.test(prefixText) ? Number(prefixText) : NaN;
|
|
2390
|
-
if (!
|
|
2391
|
+
if (!base3 || !Number.isInteger(prefix) || prefix < 0 || // A v4 range never matches a v6 address, and the reverse: the widths
|
|
2391
2392
|
// differ, so `0.0.0.0/0` does not release `::1`.
|
|
2392
|
-
|
|
2393
|
+
base3.length !== target.length || prefix > base3.length) {
|
|
2393
2394
|
continue;
|
|
2394
2395
|
}
|
|
2395
|
-
if (
|
|
2396
|
+
if (base3.slice(0, prefix) === target.slice(0, prefix)) return true;
|
|
2396
2397
|
}
|
|
2397
2398
|
return false;
|
|
2398
2399
|
}
|
|
@@ -2689,7 +2690,7 @@ var CHECK_TEXT = {
|
|
|
2689
2690
|
advice: "Fixed at Review for now."
|
|
2690
2691
|
},
|
|
2691
2692
|
"commands.node9-disarm": {
|
|
2692
|
-
plain: "The agent
|
|
2693
|
+
plain: "The agent switches node9 off or weakens it: stops or kills the daemon, stops its service, uninstalls node9, changes files in ~/.node9, clears a session flag, trusts an address, pauses the gate, weakens a shield.",
|
|
2693
2694
|
example: "After reading a web page, the agent runs node9 session-exposure clear --all",
|
|
2694
2695
|
advice: "Keep Review: these are your commands to run. Block if the agent should never touch node9."
|
|
2695
2696
|
},
|
|
@@ -2742,6 +2743,10 @@ function reviewsEveryAgentFileWrite(mode) {
|
|
|
2742
2743
|
const level = levelOf(mode);
|
|
2743
2744
|
return level === "strict" || level === "block-all";
|
|
2744
2745
|
}
|
|
2746
|
+
function holdsSendsWithoutDaemon(mode) {
|
|
2747
|
+
const level = levelOf(mode);
|
|
2748
|
+
return level === "strict" || level === "block-all";
|
|
2749
|
+
}
|
|
2745
2750
|
function isBlockAll(mode) {
|
|
2746
2751
|
return levelOf(mode) === "block-all";
|
|
2747
2752
|
}
|
|
@@ -3111,7 +3116,7 @@ var PRODUCT_CHECKS = [
|
|
|
3111
3116
|
group: "commands",
|
|
3112
3117
|
owasp: "ASI10",
|
|
3113
3118
|
title: "node9 disarmed from the shell",
|
|
3114
|
-
catches: "a node9 command that clears a session flag, trusts a destination, pauses the gate or weakens a shield
|
|
3119
|
+
catches: "the agent stopping or killing the node9 daemon, stopping its service, uninstalling node9, changing files in ~/.node9, or running a node9 command that clears a session flag, trusts a destination, pauses the gate or weakens a shield",
|
|
3115
3120
|
values: ALL,
|
|
3116
3121
|
defaultValue: "review",
|
|
3117
3122
|
legacy: ["review-node9-disarm"]
|
|
@@ -7935,8 +7940,8 @@ function analyzeFsOperation(command) {
|
|
|
7935
7940
|
}
|
|
7936
7941
|
var stripDotSlash = (p) => p.replace(/^\.\//, "");
|
|
7937
7942
|
function isSensitiveCleanupName(p) {
|
|
7938
|
-
const
|
|
7939
|
-
return /^\.env(\.|$)/i.test(
|
|
7943
|
+
const base3 = p.replace(/^.*[\\/]/, "");
|
|
7944
|
+
return /^\.env(\.|$)/i.test(base3) || /(?:^|[\\/])\.(?:ssh|aws|gnupg|git)(?:[\\/]|$)/i.test(p) || /\.(?:pem|key|p12|pfx|crt)$/i.test(base3) || /^\.?(?:netrc|npmrc|pgpass|htpasswd)$/i.test(base3) || /^id_(?:rsa|dsa|ecdsa|ed25519)/i.test(base3) || /credential/i.test(p) || /secret/i.test(base3);
|
|
7940
7945
|
}
|
|
7941
7946
|
function isWaivableCleanupTarget(p) {
|
|
7942
7947
|
if (/^[/~]/.test(p) || /^\$/.test(p)) return false;
|
|
@@ -9327,6 +9332,21 @@ function hits(access, paths, directories, context) {
|
|
|
9327
9332
|
}
|
|
9328
9333
|
return false;
|
|
9329
9334
|
}
|
|
9335
|
+
function hitsNode9Dir(access, dirs, context) {
|
|
9336
|
+
const home = context.homeDirs?.[0] ?? "~";
|
|
9337
|
+
if (access.glob) {
|
|
9338
|
+
const pattern = normalizeFilePath(access.glob, access.cwd ?? context.cwd, home);
|
|
9339
|
+
const magic = pattern.search(/[*?[{]/);
|
|
9340
|
+
const literal = magic < 0 ? pattern : pattern.slice(0, pattern.lastIndexOf("/", magic));
|
|
9341
|
+
return dirs.some((d) => within(literal, d));
|
|
9342
|
+
}
|
|
9343
|
+
const candidates = access.candidates ?? [
|
|
9344
|
+
normalizeFilePath(access.path, access.cwd ?? context.cwd, home)
|
|
9345
|
+
];
|
|
9346
|
+
return candidates.some(
|
|
9347
|
+
(p) => dirs.some((d) => within(p, d)) || access.recursive === true && dirs.some((d) => within(d, p))
|
|
9348
|
+
);
|
|
9349
|
+
}
|
|
9330
9350
|
var exempt = (p) => SYSTEM_DIRS_EXEMPT.some((d) => within(p, d));
|
|
9331
9351
|
function hitsSystemDir(access, context, dirs = SYSTEM_DIRS) {
|
|
9332
9352
|
const home = context.homeDirs?.[0] ?? "~";
|
|
@@ -9369,6 +9389,7 @@ function evaluateProtectedFileAccess(accesses, context, settings) {
|
|
|
9369
9389
|
const consider = (result) => {
|
|
9370
9390
|
if (!best || RANK[result.decision] > RANK[best.decision]) best = result;
|
|
9371
9391
|
};
|
|
9392
|
+
const node9Dirs = homes.map((home) => `${home.replace(/\/$/, "")}/.node9`);
|
|
9372
9393
|
for (const access of accesses) {
|
|
9373
9394
|
const mutation = access.operation !== "read";
|
|
9374
9395
|
let kind;
|
|
@@ -9397,6 +9418,10 @@ function evaluateProtectedFileAccess(accesses, context, settings) {
|
|
|
9397
9418
|
"files.system-dirs",
|
|
9398
9419
|
"review-root-home-read",
|
|
9399
9420
|
"Reading the root account's home requires approval"
|
|
9421
|
+
] : mutation && hitsNode9Dir(access, node9Dirs, context) ? [
|
|
9422
|
+
"commands.node9-disarm",
|
|
9423
|
+
"review-node9-disarm",
|
|
9424
|
+
"Changing node9's own files requires approval"
|
|
9400
9425
|
] : null;
|
|
9401
9426
|
} catch {
|
|
9402
9427
|
consider(incompleteFileVerdict(access.operation));
|
|
@@ -12401,9 +12426,9 @@ function validateBelgianNationalNumber(raw) {
|
|
|
12401
12426
|
if (!/^\d{11}$/.test(d)) return false;
|
|
12402
12427
|
const month = Number(d.slice(2, 4)) % 20;
|
|
12403
12428
|
if (month !== 0 && !plausibleDate(String(month).padStart(2, "0"), d.slice(4, 6))) return false;
|
|
12404
|
-
const
|
|
12429
|
+
const base3 = Number(d.slice(0, 9));
|
|
12405
12430
|
const check = Number(d.slice(9, 11));
|
|
12406
|
-
return 97 -
|
|
12431
|
+
return 97 - base3 % 97 === check || 97 - (2e9 + base3) % 97 === check;
|
|
12407
12432
|
}
|
|
12408
12433
|
function validateCuit(raw) {
|
|
12409
12434
|
const d = raw.replace(/-/g, "");
|
|
@@ -14011,9 +14036,9 @@ var GitWalk = class {
|
|
|
14011
14036
|
const name = n.Name.Value;
|
|
14012
14037
|
if (n.Append) {
|
|
14013
14038
|
const prev = this.appended.has(name) ? this.appended.get(name) : resolveWordLiteral(n.Value) === null ? null : void 0;
|
|
14014
|
-
const
|
|
14039
|
+
const base3 = prev === void 0 ? recordedExpansion(name) : prev;
|
|
14015
14040
|
const piece = resolveWordLiteral(n.Value);
|
|
14016
|
-
this.appended.set(name, typeof
|
|
14041
|
+
this.appended.set(name, typeof base3 === "string" && piece !== null ? base3 + piece : null);
|
|
14017
14042
|
this.treeTopVars.delete(name);
|
|
14018
14043
|
return true;
|
|
14019
14044
|
}
|
|
@@ -15045,9 +15070,9 @@ var INSTRUCTION_NAMES = /* @__PURE__ */ new Set([
|
|
|
15045
15070
|
var SETTINGS_RE = /\/(?:\.claude\/settings(?:\.local)?\.json|\.gemini\/settings\.json|\.codex\/hooks\.json|\.cursor\/hooks\.json)$/i;
|
|
15046
15071
|
function agentFileKind(p) {
|
|
15047
15072
|
const lower2 = p.toLowerCase();
|
|
15048
|
-
const
|
|
15049
|
-
if (INSTRUCTION_NAMES.has(
|
|
15050
|
-
if (
|
|
15073
|
+
const base3 = lower2.slice(lower2.lastIndexOf("/") + 1);
|
|
15074
|
+
if (INSTRUCTION_NAMES.has(base3)) return "instructions";
|
|
15075
|
+
if (base3 === "copilot-instructions.md" && lower2.endsWith("/.github/" + base3))
|
|
15051
15076
|
return "instructions";
|
|
15052
15077
|
if (/\/\.cursor\/rules(?:\/|$)/.test(lower2)) return "instructions";
|
|
15053
15078
|
if (/\/\.claude\/projects\/[^/]+\/memory(?:\/|$)/.test(lower2)) return "memory";
|
|
@@ -15217,7 +15242,7 @@ function evaluateAgentFileWrite(args, accesses, context, settings, shell, hooks
|
|
|
15217
15242
|
skills: "agent skill",
|
|
15218
15243
|
settings: "agent settings"
|
|
15219
15244
|
};
|
|
15220
|
-
const
|
|
15245
|
+
const base3 = `${kindLabel[kind]} written: ${access.path}`;
|
|
15221
15246
|
if (!signal && !every) {
|
|
15222
15247
|
return {
|
|
15223
15248
|
decision: "allow",
|
|
@@ -15227,14 +15252,14 @@ function evaluateAgentFileWrite(args, accesses, context, settings, shell, hooks
|
|
|
15227
15252
|
path: access.path,
|
|
15228
15253
|
operation: access.operation,
|
|
15229
15254
|
kind,
|
|
15230
|
-
reason:
|
|
15255
|
+
reason: base3,
|
|
15231
15256
|
ruleDescription: "The AI writes to a file every later agent session loads as instructions.",
|
|
15232
|
-
blockedByLabel: `Node9 Files: ${
|
|
15257
|
+
blockedByLabel: `Node9 Files: ${base3}`,
|
|
15233
15258
|
tier: 2
|
|
15234
15259
|
};
|
|
15235
15260
|
}
|
|
15236
15261
|
const ruleName = signal === "content" ? "review-agent-file-content" : signal === "hooks" ? "review-agent-hooks-change" : "review-agent-file-write";
|
|
15237
|
-
const reason = signal ? `${
|
|
15262
|
+
const reason = signal ? `${base3} (${detail})` : base3;
|
|
15238
15263
|
const description = signal === "content" ? "The AI writes an instruction into a file every later agent session loads: to hide something from you, to skip approvals or the guard, or to read or send a secret. It would persist past this session; confirm it is yours." : signal === "hooks" ? "The AI changes the hooks in the agent's settings. Hooks are how node9 and your other checks run before each tool call; a change here can disarm them." : "The AI writes to a file every later agent session loads as instructions (CLAUDE.md, AGENTS.md, memory, agents, commands). Confirm the change is yours.";
|
|
15239
15264
|
return {
|
|
15240
15265
|
decision: value === "log" ? "allow" : value,
|
|
@@ -17954,6 +17979,175 @@ function scanArgumentSecrets(args) {
|
|
|
17954
17979
|
} : null;
|
|
17955
17980
|
}
|
|
17956
17981
|
|
|
17982
|
+
// src/shell/node9-disarm.ts
|
|
17983
|
+
var RULE_NAME2 = "review-node9-disarm";
|
|
17984
|
+
var DESCRIPTION = "The AI wants to stop node9, remove it, or change its own files. These are your commands to run, not the agent's: with the daemon stopped the outside-content and taint checks are off.";
|
|
17985
|
+
var DAEMON_CMDLINES = [
|
|
17986
|
+
"node /usr/lib/node_modules/@node9/proxy/dist/cli.js daemon start",
|
|
17987
|
+
"node9 daemon start"
|
|
17988
|
+
];
|
|
17989
|
+
var DAEMON_NAMES = ["node", "node9"];
|
|
17990
|
+
var KILLALL_NAMES = /* @__PURE__ */ new Set(["node", "node9", "node.exe", "node9.exe"]);
|
|
17991
|
+
var STOP_SYSTEMCTL = /* @__PURE__ */ new Set(["stop", "disable", "mask", "kill"]);
|
|
17992
|
+
var STOP_LAUNCHCTL = /* @__PURE__ */ new Set(["unload", "bootout", "remove", "stop", "kill", "disable"]);
|
|
17993
|
+
var PKILL_VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
17994
|
+
"-u",
|
|
17995
|
+
"-U",
|
|
17996
|
+
"-g",
|
|
17997
|
+
"-G",
|
|
17998
|
+
"-P",
|
|
17999
|
+
"-s",
|
|
18000
|
+
"-t",
|
|
18001
|
+
"-F",
|
|
18002
|
+
"--signal",
|
|
18003
|
+
"--euid",
|
|
18004
|
+
"--uid",
|
|
18005
|
+
"--pgroup",
|
|
18006
|
+
"--group",
|
|
18007
|
+
"--parent",
|
|
18008
|
+
"--session",
|
|
18009
|
+
"--terminal",
|
|
18010
|
+
"--pidfile",
|
|
18011
|
+
"--ns",
|
|
18012
|
+
"--nslist"
|
|
18013
|
+
]);
|
|
18014
|
+
var NAME_PRESCREEN_RE = /node9|kill|systemctl|launchctl|daemon/i;
|
|
18015
|
+
function patternSelects(pattern, targets) {
|
|
18016
|
+
const pieces = pattern.toLowerCase().split(/[\\^$.*+?()[\]{}|]+/).filter(Boolean);
|
|
18017
|
+
if (pieces.length === 0) return false;
|
|
18018
|
+
return targets.some((t) => pieces.every((p) => t.includes(p)));
|
|
18019
|
+
}
|
|
18020
|
+
function sourceText(bytes, pos, end) {
|
|
18021
|
+
if (typeof pos !== "number" || typeof end !== "number" || pos < 0 || end < pos) return "";
|
|
18022
|
+
return new TextDecoder().decode(bytes.subarray(pos, end));
|
|
18023
|
+
}
|
|
18024
|
+
var base2 = (w) => (w ?? "").split(/[\\/]/).pop()?.toLowerCase() ?? "";
|
|
18025
|
+
function nextOperand(words, from) {
|
|
18026
|
+
for (let i = from; i < words.length; i++) {
|
|
18027
|
+
const w = words[i];
|
|
18028
|
+
if (w !== null && w.startsWith("-")) continue;
|
|
18029
|
+
return i;
|
|
18030
|
+
}
|
|
18031
|
+
return -1;
|
|
18032
|
+
}
|
|
18033
|
+
function node9Command(words, h) {
|
|
18034
|
+
const head = base2(words[h]);
|
|
18035
|
+
if (head !== "node9" && head !== "node9.cmd" && words[h] !== "@node9/proxy") return null;
|
|
18036
|
+
const s = nextOperand(words, h + 1);
|
|
18037
|
+
const sub = s < 0 ? "" : (words[s] ?? "").toLowerCase();
|
|
18038
|
+
if (sub === "uninstall") return "node9 uninstall";
|
|
18039
|
+
if (sub !== "daemon") return null;
|
|
18040
|
+
const a = nextOperand(words, s + 1);
|
|
18041
|
+
const action = a < 0 ? "" : (words[a] ?? "").toLowerCase();
|
|
18042
|
+
return action === "stop" || action === "uninstall" ? `node9 daemon ${action}` : null;
|
|
18043
|
+
}
|
|
18044
|
+
var HOME_PID_FILE_RE = /(?:^|[\s"'(=`])(?:~|\$HOME|\$\{HOME\}|\/home\/[^/\s]+|\/Users\/[^/\s]+|\/root)\/\.node9\/daemon\.pid/;
|
|
18045
|
+
function killsDaemon(words, texts, h, daemonPid) {
|
|
18046
|
+
const head = base2(words[h]);
|
|
18047
|
+
const args = words.slice(h + 1);
|
|
18048
|
+
if (head === "kill") {
|
|
18049
|
+
for (let i = 0; i < args.length; i++) {
|
|
18050
|
+
const w = args[i];
|
|
18051
|
+
if (w === "-s" || w === "-n") {
|
|
18052
|
+
i++;
|
|
18053
|
+
continue;
|
|
18054
|
+
}
|
|
18055
|
+
if (w !== null && w.startsWith("-")) continue;
|
|
18056
|
+
if (w === null) {
|
|
18057
|
+
if (HOME_PID_FILE_RE.test(texts[h + 1 + i] ?? "")) return "kill of the pid in daemon.pid";
|
|
18058
|
+
continue;
|
|
18059
|
+
}
|
|
18060
|
+
if (daemonPid !== null && w === String(daemonPid)) return `kill ${w} (the node9 daemon)`;
|
|
18061
|
+
}
|
|
18062
|
+
return null;
|
|
18063
|
+
}
|
|
18064
|
+
if (head === "pkill") {
|
|
18065
|
+
let full = false;
|
|
18066
|
+
let pattern = null;
|
|
18067
|
+
for (let i = 0; i < args.length; i++) {
|
|
18068
|
+
const w = args[i];
|
|
18069
|
+
if (w === null) continue;
|
|
18070
|
+
if (PKILL_VALUE_FLAGS.has(w)) {
|
|
18071
|
+
i++;
|
|
18072
|
+
continue;
|
|
18073
|
+
}
|
|
18074
|
+
if (w === "--full") full = true;
|
|
18075
|
+
else if (/^-[a-zA-Z]+$/.test(w) && w.includes("f")) full = true;
|
|
18076
|
+
if (w.startsWith("-")) continue;
|
|
18077
|
+
pattern = w;
|
|
18078
|
+
}
|
|
18079
|
+
if (pattern === null) return null;
|
|
18080
|
+
return patternSelects(pattern, full ? DAEMON_CMDLINES : DAEMON_NAMES) ? `pkill ${full ? "-f " : ""}${pattern}` : null;
|
|
18081
|
+
}
|
|
18082
|
+
if (head === "killall") {
|
|
18083
|
+
const regex = args.some((w) => w === "-r" || w === "--regexp");
|
|
18084
|
+
for (const w of args) {
|
|
18085
|
+
if (w === null || w.startsWith("-")) continue;
|
|
18086
|
+
if (regex ? patternSelects(w, DAEMON_NAMES) : KILLALL_NAMES.has(w.toLowerCase()))
|
|
18087
|
+
return `killall ${w}`;
|
|
18088
|
+
}
|
|
18089
|
+
return null;
|
|
18090
|
+
}
|
|
18091
|
+
if (head === "taskkill" || head === "taskkill.exe") {
|
|
18092
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
18093
|
+
const flag = (args[i] ?? "").toLowerCase();
|
|
18094
|
+
const value = (args[i + 1] ?? "").toLowerCase();
|
|
18095
|
+
if ((flag === "/im" || flag === "-im") && KILLALL_NAMES.has(value))
|
|
18096
|
+
return `taskkill /IM ${value}`;
|
|
18097
|
+
if ((flag === "/pid" || flag === "-pid") && daemonPid !== null && value === String(daemonPid))
|
|
18098
|
+
return `taskkill /PID ${value} (the node9 daemon)`;
|
|
18099
|
+
}
|
|
18100
|
+
}
|
|
18101
|
+
return null;
|
|
18102
|
+
}
|
|
18103
|
+
function stopsService(words, h) {
|
|
18104
|
+
const head = base2(words[h]);
|
|
18105
|
+
const args = words.slice(h + 1).map((w) => (w ?? "").toLowerCase());
|
|
18106
|
+
if (head === "systemctl") {
|
|
18107
|
+
const action = args.find((w) => STOP_SYSTEMCTL.has(w));
|
|
18108
|
+
if (action && args.some((w) => /^node9-daemon(\.service)?$/.test(w)))
|
|
18109
|
+
return `systemctl ${action} node9-daemon`;
|
|
18110
|
+
}
|
|
18111
|
+
if (head === "launchctl") {
|
|
18112
|
+
const action = args.find((w) => STOP_LAUNCHCTL.has(w));
|
|
18113
|
+
if (action && args.some((w) => w.includes("ai.node9.daemon")))
|
|
18114
|
+
return `launchctl ${action} ai.node9.daemon`;
|
|
18115
|
+
}
|
|
18116
|
+
return null;
|
|
18117
|
+
}
|
|
18118
|
+
function analyzeNode9Disarm(command, daemonPid = null, depth = 0) {
|
|
18119
|
+
if (depth > 3 || !NAME_PRESCREEN_RE.test(command.replace(/[\\'"]/g, ""))) return null;
|
|
18120
|
+
let shown = null;
|
|
18121
|
+
const bytes = new TextEncoder().encode(command);
|
|
18122
|
+
try {
|
|
18123
|
+
walkCommandScope(command, (node) => {
|
|
18124
|
+
if (shown !== null) return false;
|
|
18125
|
+
const n = node;
|
|
18126
|
+
if (!n || n.kind !== "CallExpr") return true;
|
|
18127
|
+
const words = (n.Args || []).map((a) => resolveWordLiteral(a));
|
|
18128
|
+
if (words.length === 0) return true;
|
|
18129
|
+
const texts = (n.Args || []).map((a) => sourceText(bytes, a.pos, a.end));
|
|
18130
|
+
const h = unwrapCommandHead(words);
|
|
18131
|
+
shown = node9Command(words, h) ?? killsDaemon(words, texts, h, daemonPid) ?? stopsService(words, h);
|
|
18132
|
+
if (shown === null) {
|
|
18133
|
+
const payload = literalShellPayload(words, base2(words[0]));
|
|
18134
|
+
if (payload) {
|
|
18135
|
+
const inner = analyzeNode9Disarm(payload, daemonPid, depth + 1);
|
|
18136
|
+
if (inner) shown = inner.reason.replace(/^node9 switched off by the agent: /, "");
|
|
18137
|
+
}
|
|
18138
|
+
}
|
|
18139
|
+
return true;
|
|
18140
|
+
});
|
|
18141
|
+
} catch {
|
|
18142
|
+
}
|
|
18143
|
+
if (shown === null) return null;
|
|
18144
|
+
return {
|
|
18145
|
+
ruleName: RULE_NAME2,
|
|
18146
|
+
reason: `node9 switched off by the agent: ${shown}`,
|
|
18147
|
+
description: DESCRIPTION
|
|
18148
|
+
};
|
|
18149
|
+
}
|
|
18150
|
+
|
|
17957
18151
|
// src/policy/index.ts
|
|
17958
18152
|
function catalogSettings(config) {
|
|
17959
18153
|
return catalogSettingsFromConfig(config.settings, config.policy);
|
|
@@ -18120,7 +18314,7 @@ async function evaluatePolicy(config, toolName, args, context = {}, hostHooks =
|
|
|
18120
18314
|
}
|
|
18121
18315
|
async function evaluatePolicyCore(config, toolName, args, context = {}, hooks = {}) {
|
|
18122
18316
|
const { agent, cwd, activeEnvironment } = context;
|
|
18123
|
-
const { checkProvenance, isTrustedHost, isConfiguredRegistry, isGitWorkTreeTop } = hooks;
|
|
18317
|
+
const { checkProvenance, isTrustedHost, isConfiguredRegistry, isGitWorkTreeTop, daemonPid } = hooks;
|
|
18124
18318
|
const settingsView = catalogSettings(config);
|
|
18125
18319
|
const layers = inspectionLayers(config.policy);
|
|
18126
18320
|
const cv = (id) => checkValue(settingsView, id);
|
|
@@ -18305,6 +18499,23 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
|
|
|
18305
18499
|
else if (v && !pendingAstReview) pendingAstReview = v;
|
|
18306
18500
|
}
|
|
18307
18501
|
}
|
|
18502
|
+
if (cv("commands.node9-disarm") !== "off") {
|
|
18503
|
+
const finding = analyzeNode9Disarm(bashCommand, daemonPid?.() ?? null);
|
|
18504
|
+
if (finding) {
|
|
18505
|
+
const v = applyCheckValue(cv("commands.node9-disarm"), {
|
|
18506
|
+
decision: "review",
|
|
18507
|
+
blockedByLabel: `Node9 (AST): ${finding.ruleName}`,
|
|
18508
|
+
reason: finding.reason,
|
|
18509
|
+
tier: 2,
|
|
18510
|
+
ruleName: finding.ruleName,
|
|
18511
|
+
ruleDescription: finding.description,
|
|
18512
|
+
checkId: "commands.node9-disarm"
|
|
18513
|
+
});
|
|
18514
|
+
if (v?.logged) noteLogged(v);
|
|
18515
|
+
else if (v?.decision === "block") return v;
|
|
18516
|
+
else if (v && !pendingAstReview) pendingAstReview = v;
|
|
18517
|
+
}
|
|
18518
|
+
}
|
|
18308
18519
|
}
|
|
18309
18520
|
if (config.policy.smartRules.length > 0) {
|
|
18310
18521
|
const rmCleanupWaiver = bashCommand !== null && isRmCreatedInCommandCleanup(bashCommand);
|
|
@@ -18896,8 +19107,8 @@ function hasRoutingNumber(text) {
|
|
|
18896
19107
|
return false;
|
|
18897
19108
|
}
|
|
18898
19109
|
var PII_IBAN_RE = /\b[A-Z]{2}\d{2}(?:[A-Z0-9]|[ -][A-Z0-9]){11,30}\b/;
|
|
18899
|
-
function* validCardRuns(text,
|
|
18900
|
-
const re = new RegExp(
|
|
19110
|
+
function* validCardRuns(text, base3, exemptFractions = true) {
|
|
19111
|
+
const re = new RegExp(base3.source, "g");
|
|
18901
19112
|
let m;
|
|
18902
19113
|
while ((m = re.exec(text)) !== null) {
|
|
18903
19114
|
const digits = m[0].replace(/\D/g, "");
|
|
@@ -18910,17 +19121,17 @@ function* validCardRuns(text, base2, exemptFractions = true) {
|
|
|
18910
19121
|
}
|
|
18911
19122
|
}
|
|
18912
19123
|
function hasValidCard(text) {
|
|
18913
|
-
for (const
|
|
18914
|
-
if (!validCardRuns(text,
|
|
19124
|
+
for (const base3 of CARD_PATTERNS) {
|
|
19125
|
+
if (!validCardRuns(text, base3).next().done) return true;
|
|
18915
19126
|
}
|
|
18916
19127
|
return false;
|
|
18917
19128
|
}
|
|
18918
19129
|
function replaceValidCards(text, replace, { exemptFractions = true } = {}) {
|
|
18919
19130
|
let out = text;
|
|
18920
|
-
for (const
|
|
19131
|
+
for (const base3 of CARD_PATTERNS) {
|
|
18921
19132
|
let res = "";
|
|
18922
19133
|
let last = 0;
|
|
18923
|
-
for (const run of validCardRuns(out,
|
|
19134
|
+
for (const run of validCardRuns(out, base3, exemptFractions)) {
|
|
18924
19135
|
res += out.slice(last, run.index) + replace(run.digits);
|
|
18925
19136
|
last = run.index + run.length;
|
|
18926
19137
|
}
|
|
@@ -19209,9 +19420,9 @@ function maskLeaf(value, key, depth) {
|
|
|
19209
19420
|
const used = /* @__PURE__ */ new Set();
|
|
19210
19421
|
return Object.fromEntries(
|
|
19211
19422
|
Object.entries(value).map(([k, v]) => {
|
|
19212
|
-
const
|
|
19213
|
-
let name =
|
|
19214
|
-
for (let n = 2; used.has(name); n++) name = `${
|
|
19423
|
+
const base3 = maskPersonalData(k);
|
|
19424
|
+
let name = base3;
|
|
19425
|
+
for (let n = 2; used.has(name); n++) name = `${base3}#${n}`;
|
|
19215
19426
|
used.add(name);
|
|
19216
19427
|
return [name, maskLeaf(v, k, depth + 1)];
|
|
19217
19428
|
})
|
|
@@ -20259,8 +20470,8 @@ function matchCanaryArgs(args, values) {
|
|
|
20259
20470
|
|
|
20260
20471
|
// src/scan/canonical.ts
|
|
20261
20472
|
var LONG_OUTPUT_THRESHOLD_BYTES = 100 * 1024;
|
|
20262
|
-
var CANONICAL_EXTRACTOR_VERSION = "canonical-
|
|
20263
|
-
var CANONICAL_EXTRACTOR_HASH = "
|
|
20473
|
+
var CANONICAL_EXTRACTOR_VERSION = "canonical-v38";
|
|
20474
|
+
var CANONICAL_EXTRACTOR_HASH = "2d3dfcccff2c2f65";
|
|
20264
20475
|
var DEDUPE_PREVIEW_LEN = 120;
|
|
20265
20476
|
function extractCanonicalFindings(call, ctx) {
|
|
20266
20477
|
const out = [];
|
|
@@ -20841,6 +21052,7 @@ var ENGINE_VERSION = "1.4.0";
|
|
|
20841
21052
|
gitInvocations,
|
|
20842
21053
|
gitRepoPath,
|
|
20843
21054
|
hashDestination,
|
|
21055
|
+
holdsSendsWithoutDaemon,
|
|
20844
21056
|
hostMatches,
|
|
20845
21057
|
incompleteFileVerdict,
|
|
20846
21058
|
inlineExecDescription,
|
package/dist/index.mjs
CHANGED
|
@@ -2122,15 +2122,15 @@ function ssrfExemptMatches(entries, normalized) {
|
|
|
2122
2122
|
continue;
|
|
2123
2123
|
}
|
|
2124
2124
|
if (!target) continue;
|
|
2125
|
-
const
|
|
2125
|
+
const base3 = bitsOf(normalizeIpLiteral(entry.slice(0, slash)) ?? "");
|
|
2126
2126
|
const prefixText = entry.slice(slash + 1);
|
|
2127
2127
|
const prefix = /^\d+$/.test(prefixText) ? Number(prefixText) : NaN;
|
|
2128
|
-
if (!
|
|
2128
|
+
if (!base3 || !Number.isInteger(prefix) || prefix < 0 || // A v4 range never matches a v6 address, and the reverse: the widths
|
|
2129
2129
|
// differ, so `0.0.0.0/0` does not release `::1`.
|
|
2130
|
-
|
|
2130
|
+
base3.length !== target.length || prefix > base3.length) {
|
|
2131
2131
|
continue;
|
|
2132
2132
|
}
|
|
2133
|
-
if (
|
|
2133
|
+
if (base3.slice(0, prefix) === target.slice(0, prefix)) return true;
|
|
2134
2134
|
}
|
|
2135
2135
|
return false;
|
|
2136
2136
|
}
|
|
@@ -2427,7 +2427,7 @@ var CHECK_TEXT = {
|
|
|
2427
2427
|
advice: "Fixed at Review for now."
|
|
2428
2428
|
},
|
|
2429
2429
|
"commands.node9-disarm": {
|
|
2430
|
-
plain: "The agent
|
|
2430
|
+
plain: "The agent switches node9 off or weakens it: stops or kills the daemon, stops its service, uninstalls node9, changes files in ~/.node9, clears a session flag, trusts an address, pauses the gate, weakens a shield.",
|
|
2431
2431
|
example: "After reading a web page, the agent runs node9 session-exposure clear --all",
|
|
2432
2432
|
advice: "Keep Review: these are your commands to run. Block if the agent should never touch node9."
|
|
2433
2433
|
},
|
|
@@ -2480,6 +2480,10 @@ function reviewsEveryAgentFileWrite(mode) {
|
|
|
2480
2480
|
const level = levelOf(mode);
|
|
2481
2481
|
return level === "strict" || level === "block-all";
|
|
2482
2482
|
}
|
|
2483
|
+
function holdsSendsWithoutDaemon(mode) {
|
|
2484
|
+
const level = levelOf(mode);
|
|
2485
|
+
return level === "strict" || level === "block-all";
|
|
2486
|
+
}
|
|
2483
2487
|
function isBlockAll(mode) {
|
|
2484
2488
|
return levelOf(mode) === "block-all";
|
|
2485
2489
|
}
|
|
@@ -2849,7 +2853,7 @@ var PRODUCT_CHECKS = [
|
|
|
2849
2853
|
group: "commands",
|
|
2850
2854
|
owasp: "ASI10",
|
|
2851
2855
|
title: "node9 disarmed from the shell",
|
|
2852
|
-
catches: "a node9 command that clears a session flag, trusts a destination, pauses the gate or weakens a shield
|
|
2856
|
+
catches: "the agent stopping or killing the node9 daemon, stopping its service, uninstalling node9, changing files in ~/.node9, or running a node9 command that clears a session flag, trusts a destination, pauses the gate or weakens a shield",
|
|
2853
2857
|
values: ALL,
|
|
2854
2858
|
defaultValue: "review",
|
|
2855
2859
|
legacy: ["review-node9-disarm"]
|
|
@@ -7673,8 +7677,8 @@ function analyzeFsOperation(command) {
|
|
|
7673
7677
|
}
|
|
7674
7678
|
var stripDotSlash = (p) => p.replace(/^\.\//, "");
|
|
7675
7679
|
function isSensitiveCleanupName(p) {
|
|
7676
|
-
const
|
|
7677
|
-
return /^\.env(\.|$)/i.test(
|
|
7680
|
+
const base3 = p.replace(/^.*[\\/]/, "");
|
|
7681
|
+
return /^\.env(\.|$)/i.test(base3) || /(?:^|[\\/])\.(?:ssh|aws|gnupg|git)(?:[\\/]|$)/i.test(p) || /\.(?:pem|key|p12|pfx|crt)$/i.test(base3) || /^\.?(?:netrc|npmrc|pgpass|htpasswd)$/i.test(base3) || /^id_(?:rsa|dsa|ecdsa|ed25519)/i.test(base3) || /credential/i.test(p) || /secret/i.test(base3);
|
|
7678
7682
|
}
|
|
7679
7683
|
function isWaivableCleanupTarget(p) {
|
|
7680
7684
|
if (/^[/~]/.test(p) || /^\$/.test(p)) return false;
|
|
@@ -9065,6 +9069,21 @@ function hits(access, paths, directories, context) {
|
|
|
9065
9069
|
}
|
|
9066
9070
|
return false;
|
|
9067
9071
|
}
|
|
9072
|
+
function hitsNode9Dir(access, dirs, context) {
|
|
9073
|
+
const home = context.homeDirs?.[0] ?? "~";
|
|
9074
|
+
if (access.glob) {
|
|
9075
|
+
const pattern = normalizeFilePath(access.glob, access.cwd ?? context.cwd, home);
|
|
9076
|
+
const magic = pattern.search(/[*?[{]/);
|
|
9077
|
+
const literal = magic < 0 ? pattern : pattern.slice(0, pattern.lastIndexOf("/", magic));
|
|
9078
|
+
return dirs.some((d) => within(literal, d));
|
|
9079
|
+
}
|
|
9080
|
+
const candidates = access.candidates ?? [
|
|
9081
|
+
normalizeFilePath(access.path, access.cwd ?? context.cwd, home)
|
|
9082
|
+
];
|
|
9083
|
+
return candidates.some(
|
|
9084
|
+
(p) => dirs.some((d) => within(p, d)) || access.recursive === true && dirs.some((d) => within(d, p))
|
|
9085
|
+
);
|
|
9086
|
+
}
|
|
9068
9087
|
var exempt = (p) => SYSTEM_DIRS_EXEMPT.some((d) => within(p, d));
|
|
9069
9088
|
function hitsSystemDir(access, context, dirs = SYSTEM_DIRS) {
|
|
9070
9089
|
const home = context.homeDirs?.[0] ?? "~";
|
|
@@ -9107,6 +9126,7 @@ function evaluateProtectedFileAccess(accesses, context, settings) {
|
|
|
9107
9126
|
const consider = (result) => {
|
|
9108
9127
|
if (!best || RANK[result.decision] > RANK[best.decision]) best = result;
|
|
9109
9128
|
};
|
|
9129
|
+
const node9Dirs = homes.map((home) => `${home.replace(/\/$/, "")}/.node9`);
|
|
9110
9130
|
for (const access of accesses) {
|
|
9111
9131
|
const mutation = access.operation !== "read";
|
|
9112
9132
|
let kind;
|
|
@@ -9135,6 +9155,10 @@ function evaluateProtectedFileAccess(accesses, context, settings) {
|
|
|
9135
9155
|
"files.system-dirs",
|
|
9136
9156
|
"review-root-home-read",
|
|
9137
9157
|
"Reading the root account's home requires approval"
|
|
9158
|
+
] : mutation && hitsNode9Dir(access, node9Dirs, context) ? [
|
|
9159
|
+
"commands.node9-disarm",
|
|
9160
|
+
"review-node9-disarm",
|
|
9161
|
+
"Changing node9's own files requires approval"
|
|
9138
9162
|
] : null;
|
|
9139
9163
|
} catch {
|
|
9140
9164
|
consider(incompleteFileVerdict(access.operation));
|
|
@@ -12139,9 +12163,9 @@ function validateBelgianNationalNumber(raw) {
|
|
|
12139
12163
|
if (!/^\d{11}$/.test(d)) return false;
|
|
12140
12164
|
const month = Number(d.slice(2, 4)) % 20;
|
|
12141
12165
|
if (month !== 0 && !plausibleDate(String(month).padStart(2, "0"), d.slice(4, 6))) return false;
|
|
12142
|
-
const
|
|
12166
|
+
const base3 = Number(d.slice(0, 9));
|
|
12143
12167
|
const check = Number(d.slice(9, 11));
|
|
12144
|
-
return 97 -
|
|
12168
|
+
return 97 - base3 % 97 === check || 97 - (2e9 + base3) % 97 === check;
|
|
12145
12169
|
}
|
|
12146
12170
|
function validateCuit(raw) {
|
|
12147
12171
|
const d = raw.replace(/-/g, "");
|
|
@@ -13749,9 +13773,9 @@ var GitWalk = class {
|
|
|
13749
13773
|
const name = n.Name.Value;
|
|
13750
13774
|
if (n.Append) {
|
|
13751
13775
|
const prev = this.appended.has(name) ? this.appended.get(name) : resolveWordLiteral(n.Value) === null ? null : void 0;
|
|
13752
|
-
const
|
|
13776
|
+
const base3 = prev === void 0 ? recordedExpansion(name) : prev;
|
|
13753
13777
|
const piece = resolveWordLiteral(n.Value);
|
|
13754
|
-
this.appended.set(name, typeof
|
|
13778
|
+
this.appended.set(name, typeof base3 === "string" && piece !== null ? base3 + piece : null);
|
|
13755
13779
|
this.treeTopVars.delete(name);
|
|
13756
13780
|
return true;
|
|
13757
13781
|
}
|
|
@@ -14783,9 +14807,9 @@ var INSTRUCTION_NAMES = /* @__PURE__ */ new Set([
|
|
|
14783
14807
|
var SETTINGS_RE = /\/(?:\.claude\/settings(?:\.local)?\.json|\.gemini\/settings\.json|\.codex\/hooks\.json|\.cursor\/hooks\.json)$/i;
|
|
14784
14808
|
function agentFileKind(p) {
|
|
14785
14809
|
const lower2 = p.toLowerCase();
|
|
14786
|
-
const
|
|
14787
|
-
if (INSTRUCTION_NAMES.has(
|
|
14788
|
-
if (
|
|
14810
|
+
const base3 = lower2.slice(lower2.lastIndexOf("/") + 1);
|
|
14811
|
+
if (INSTRUCTION_NAMES.has(base3)) return "instructions";
|
|
14812
|
+
if (base3 === "copilot-instructions.md" && lower2.endsWith("/.github/" + base3))
|
|
14789
14813
|
return "instructions";
|
|
14790
14814
|
if (/\/\.cursor\/rules(?:\/|$)/.test(lower2)) return "instructions";
|
|
14791
14815
|
if (/\/\.claude\/projects\/[^/]+\/memory(?:\/|$)/.test(lower2)) return "memory";
|
|
@@ -14955,7 +14979,7 @@ function evaluateAgentFileWrite(args, accesses, context, settings, shell, hooks
|
|
|
14955
14979
|
skills: "agent skill",
|
|
14956
14980
|
settings: "agent settings"
|
|
14957
14981
|
};
|
|
14958
|
-
const
|
|
14982
|
+
const base3 = `${kindLabel[kind]} written: ${access.path}`;
|
|
14959
14983
|
if (!signal && !every) {
|
|
14960
14984
|
return {
|
|
14961
14985
|
decision: "allow",
|
|
@@ -14965,14 +14989,14 @@ function evaluateAgentFileWrite(args, accesses, context, settings, shell, hooks
|
|
|
14965
14989
|
path: access.path,
|
|
14966
14990
|
operation: access.operation,
|
|
14967
14991
|
kind,
|
|
14968
|
-
reason:
|
|
14992
|
+
reason: base3,
|
|
14969
14993
|
ruleDescription: "The AI writes to a file every later agent session loads as instructions.",
|
|
14970
|
-
blockedByLabel: `Node9 Files: ${
|
|
14994
|
+
blockedByLabel: `Node9 Files: ${base3}`,
|
|
14971
14995
|
tier: 2
|
|
14972
14996
|
};
|
|
14973
14997
|
}
|
|
14974
14998
|
const ruleName = signal === "content" ? "review-agent-file-content" : signal === "hooks" ? "review-agent-hooks-change" : "review-agent-file-write";
|
|
14975
|
-
const reason = signal ? `${
|
|
14999
|
+
const reason = signal ? `${base3} (${detail})` : base3;
|
|
14976
15000
|
const description = signal === "content" ? "The AI writes an instruction into a file every later agent session loads: to hide something from you, to skip approvals or the guard, or to read or send a secret. It would persist past this session; confirm it is yours." : signal === "hooks" ? "The AI changes the hooks in the agent's settings. Hooks are how node9 and your other checks run before each tool call; a change here can disarm them." : "The AI writes to a file every later agent session loads as instructions (CLAUDE.md, AGENTS.md, memory, agents, commands). Confirm the change is yours.";
|
|
14977
15001
|
return {
|
|
14978
15002
|
decision: value === "log" ? "allow" : value,
|
|
@@ -17692,6 +17716,175 @@ function scanArgumentSecrets(args) {
|
|
|
17692
17716
|
} : null;
|
|
17693
17717
|
}
|
|
17694
17718
|
|
|
17719
|
+
// src/shell/node9-disarm.ts
|
|
17720
|
+
var RULE_NAME2 = "review-node9-disarm";
|
|
17721
|
+
var DESCRIPTION = "The AI wants to stop node9, remove it, or change its own files. These are your commands to run, not the agent's: with the daemon stopped the outside-content and taint checks are off.";
|
|
17722
|
+
var DAEMON_CMDLINES = [
|
|
17723
|
+
"node /usr/lib/node_modules/@node9/proxy/dist/cli.js daemon start",
|
|
17724
|
+
"node9 daemon start"
|
|
17725
|
+
];
|
|
17726
|
+
var DAEMON_NAMES = ["node", "node9"];
|
|
17727
|
+
var KILLALL_NAMES = /* @__PURE__ */ new Set(["node", "node9", "node.exe", "node9.exe"]);
|
|
17728
|
+
var STOP_SYSTEMCTL = /* @__PURE__ */ new Set(["stop", "disable", "mask", "kill"]);
|
|
17729
|
+
var STOP_LAUNCHCTL = /* @__PURE__ */ new Set(["unload", "bootout", "remove", "stop", "kill", "disable"]);
|
|
17730
|
+
var PKILL_VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
17731
|
+
"-u",
|
|
17732
|
+
"-U",
|
|
17733
|
+
"-g",
|
|
17734
|
+
"-G",
|
|
17735
|
+
"-P",
|
|
17736
|
+
"-s",
|
|
17737
|
+
"-t",
|
|
17738
|
+
"-F",
|
|
17739
|
+
"--signal",
|
|
17740
|
+
"--euid",
|
|
17741
|
+
"--uid",
|
|
17742
|
+
"--pgroup",
|
|
17743
|
+
"--group",
|
|
17744
|
+
"--parent",
|
|
17745
|
+
"--session",
|
|
17746
|
+
"--terminal",
|
|
17747
|
+
"--pidfile",
|
|
17748
|
+
"--ns",
|
|
17749
|
+
"--nslist"
|
|
17750
|
+
]);
|
|
17751
|
+
var NAME_PRESCREEN_RE = /node9|kill|systemctl|launchctl|daemon/i;
|
|
17752
|
+
function patternSelects(pattern, targets) {
|
|
17753
|
+
const pieces = pattern.toLowerCase().split(/[\\^$.*+?()[\]{}|]+/).filter(Boolean);
|
|
17754
|
+
if (pieces.length === 0) return false;
|
|
17755
|
+
return targets.some((t) => pieces.every((p) => t.includes(p)));
|
|
17756
|
+
}
|
|
17757
|
+
function sourceText(bytes, pos, end) {
|
|
17758
|
+
if (typeof pos !== "number" || typeof end !== "number" || pos < 0 || end < pos) return "";
|
|
17759
|
+
return new TextDecoder().decode(bytes.subarray(pos, end));
|
|
17760
|
+
}
|
|
17761
|
+
var base2 = (w) => (w ?? "").split(/[\\/]/).pop()?.toLowerCase() ?? "";
|
|
17762
|
+
function nextOperand(words, from) {
|
|
17763
|
+
for (let i = from; i < words.length; i++) {
|
|
17764
|
+
const w = words[i];
|
|
17765
|
+
if (w !== null && w.startsWith("-")) continue;
|
|
17766
|
+
return i;
|
|
17767
|
+
}
|
|
17768
|
+
return -1;
|
|
17769
|
+
}
|
|
17770
|
+
function node9Command(words, h) {
|
|
17771
|
+
const head = base2(words[h]);
|
|
17772
|
+
if (head !== "node9" && head !== "node9.cmd" && words[h] !== "@node9/proxy") return null;
|
|
17773
|
+
const s = nextOperand(words, h + 1);
|
|
17774
|
+
const sub = s < 0 ? "" : (words[s] ?? "").toLowerCase();
|
|
17775
|
+
if (sub === "uninstall") return "node9 uninstall";
|
|
17776
|
+
if (sub !== "daemon") return null;
|
|
17777
|
+
const a = nextOperand(words, s + 1);
|
|
17778
|
+
const action = a < 0 ? "" : (words[a] ?? "").toLowerCase();
|
|
17779
|
+
return action === "stop" || action === "uninstall" ? `node9 daemon ${action}` : null;
|
|
17780
|
+
}
|
|
17781
|
+
var HOME_PID_FILE_RE = /(?:^|[\s"'(=`])(?:~|\$HOME|\$\{HOME\}|\/home\/[^/\s]+|\/Users\/[^/\s]+|\/root)\/\.node9\/daemon\.pid/;
|
|
17782
|
+
function killsDaemon(words, texts, h, daemonPid) {
|
|
17783
|
+
const head = base2(words[h]);
|
|
17784
|
+
const args = words.slice(h + 1);
|
|
17785
|
+
if (head === "kill") {
|
|
17786
|
+
for (let i = 0; i < args.length; i++) {
|
|
17787
|
+
const w = args[i];
|
|
17788
|
+
if (w === "-s" || w === "-n") {
|
|
17789
|
+
i++;
|
|
17790
|
+
continue;
|
|
17791
|
+
}
|
|
17792
|
+
if (w !== null && w.startsWith("-")) continue;
|
|
17793
|
+
if (w === null) {
|
|
17794
|
+
if (HOME_PID_FILE_RE.test(texts[h + 1 + i] ?? "")) return "kill of the pid in daemon.pid";
|
|
17795
|
+
continue;
|
|
17796
|
+
}
|
|
17797
|
+
if (daemonPid !== null && w === String(daemonPid)) return `kill ${w} (the node9 daemon)`;
|
|
17798
|
+
}
|
|
17799
|
+
return null;
|
|
17800
|
+
}
|
|
17801
|
+
if (head === "pkill") {
|
|
17802
|
+
let full = false;
|
|
17803
|
+
let pattern = null;
|
|
17804
|
+
for (let i = 0; i < args.length; i++) {
|
|
17805
|
+
const w = args[i];
|
|
17806
|
+
if (w === null) continue;
|
|
17807
|
+
if (PKILL_VALUE_FLAGS.has(w)) {
|
|
17808
|
+
i++;
|
|
17809
|
+
continue;
|
|
17810
|
+
}
|
|
17811
|
+
if (w === "--full") full = true;
|
|
17812
|
+
else if (/^-[a-zA-Z]+$/.test(w) && w.includes("f")) full = true;
|
|
17813
|
+
if (w.startsWith("-")) continue;
|
|
17814
|
+
pattern = w;
|
|
17815
|
+
}
|
|
17816
|
+
if (pattern === null) return null;
|
|
17817
|
+
return patternSelects(pattern, full ? DAEMON_CMDLINES : DAEMON_NAMES) ? `pkill ${full ? "-f " : ""}${pattern}` : null;
|
|
17818
|
+
}
|
|
17819
|
+
if (head === "killall") {
|
|
17820
|
+
const regex = args.some((w) => w === "-r" || w === "--regexp");
|
|
17821
|
+
for (const w of args) {
|
|
17822
|
+
if (w === null || w.startsWith("-")) continue;
|
|
17823
|
+
if (regex ? patternSelects(w, DAEMON_NAMES) : KILLALL_NAMES.has(w.toLowerCase()))
|
|
17824
|
+
return `killall ${w}`;
|
|
17825
|
+
}
|
|
17826
|
+
return null;
|
|
17827
|
+
}
|
|
17828
|
+
if (head === "taskkill" || head === "taskkill.exe") {
|
|
17829
|
+
for (let i = 0; i < args.length - 1; i++) {
|
|
17830
|
+
const flag = (args[i] ?? "").toLowerCase();
|
|
17831
|
+
const value = (args[i + 1] ?? "").toLowerCase();
|
|
17832
|
+
if ((flag === "/im" || flag === "-im") && KILLALL_NAMES.has(value))
|
|
17833
|
+
return `taskkill /IM ${value}`;
|
|
17834
|
+
if ((flag === "/pid" || flag === "-pid") && daemonPid !== null && value === String(daemonPid))
|
|
17835
|
+
return `taskkill /PID ${value} (the node9 daemon)`;
|
|
17836
|
+
}
|
|
17837
|
+
}
|
|
17838
|
+
return null;
|
|
17839
|
+
}
|
|
17840
|
+
function stopsService(words, h) {
|
|
17841
|
+
const head = base2(words[h]);
|
|
17842
|
+
const args = words.slice(h + 1).map((w) => (w ?? "").toLowerCase());
|
|
17843
|
+
if (head === "systemctl") {
|
|
17844
|
+
const action = args.find((w) => STOP_SYSTEMCTL.has(w));
|
|
17845
|
+
if (action && args.some((w) => /^node9-daemon(\.service)?$/.test(w)))
|
|
17846
|
+
return `systemctl ${action} node9-daemon`;
|
|
17847
|
+
}
|
|
17848
|
+
if (head === "launchctl") {
|
|
17849
|
+
const action = args.find((w) => STOP_LAUNCHCTL.has(w));
|
|
17850
|
+
if (action && args.some((w) => w.includes("ai.node9.daemon")))
|
|
17851
|
+
return `launchctl ${action} ai.node9.daemon`;
|
|
17852
|
+
}
|
|
17853
|
+
return null;
|
|
17854
|
+
}
|
|
17855
|
+
function analyzeNode9Disarm(command, daemonPid = null, depth = 0) {
|
|
17856
|
+
if (depth > 3 || !NAME_PRESCREEN_RE.test(command.replace(/[\\'"]/g, ""))) return null;
|
|
17857
|
+
let shown = null;
|
|
17858
|
+
const bytes = new TextEncoder().encode(command);
|
|
17859
|
+
try {
|
|
17860
|
+
walkCommandScope(command, (node) => {
|
|
17861
|
+
if (shown !== null) return false;
|
|
17862
|
+
const n = node;
|
|
17863
|
+
if (!n || n.kind !== "CallExpr") return true;
|
|
17864
|
+
const words = (n.Args || []).map((a) => resolveWordLiteral(a));
|
|
17865
|
+
if (words.length === 0) return true;
|
|
17866
|
+
const texts = (n.Args || []).map((a) => sourceText(bytes, a.pos, a.end));
|
|
17867
|
+
const h = unwrapCommandHead(words);
|
|
17868
|
+
shown = node9Command(words, h) ?? killsDaemon(words, texts, h, daemonPid) ?? stopsService(words, h);
|
|
17869
|
+
if (shown === null) {
|
|
17870
|
+
const payload = literalShellPayload(words, base2(words[0]));
|
|
17871
|
+
if (payload) {
|
|
17872
|
+
const inner = analyzeNode9Disarm(payload, daemonPid, depth + 1);
|
|
17873
|
+
if (inner) shown = inner.reason.replace(/^node9 switched off by the agent: /, "");
|
|
17874
|
+
}
|
|
17875
|
+
}
|
|
17876
|
+
return true;
|
|
17877
|
+
});
|
|
17878
|
+
} catch {
|
|
17879
|
+
}
|
|
17880
|
+
if (shown === null) return null;
|
|
17881
|
+
return {
|
|
17882
|
+
ruleName: RULE_NAME2,
|
|
17883
|
+
reason: `node9 switched off by the agent: ${shown}`,
|
|
17884
|
+
description: DESCRIPTION
|
|
17885
|
+
};
|
|
17886
|
+
}
|
|
17887
|
+
|
|
17695
17888
|
// src/policy/index.ts
|
|
17696
17889
|
function catalogSettings(config) {
|
|
17697
17890
|
return catalogSettingsFromConfig(config.settings, config.policy);
|
|
@@ -17858,7 +18051,7 @@ async function evaluatePolicy(config, toolName, args, context = {}, hostHooks =
|
|
|
17858
18051
|
}
|
|
17859
18052
|
async function evaluatePolicyCore(config, toolName, args, context = {}, hooks = {}) {
|
|
17860
18053
|
const { agent, cwd, activeEnvironment } = context;
|
|
17861
|
-
const { checkProvenance, isTrustedHost, isConfiguredRegistry, isGitWorkTreeTop } = hooks;
|
|
18054
|
+
const { checkProvenance, isTrustedHost, isConfiguredRegistry, isGitWorkTreeTop, daemonPid } = hooks;
|
|
17862
18055
|
const settingsView = catalogSettings(config);
|
|
17863
18056
|
const layers = inspectionLayers(config.policy);
|
|
17864
18057
|
const cv = (id) => checkValue(settingsView, id);
|
|
@@ -18043,6 +18236,23 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
|
|
|
18043
18236
|
else if (v && !pendingAstReview) pendingAstReview = v;
|
|
18044
18237
|
}
|
|
18045
18238
|
}
|
|
18239
|
+
if (cv("commands.node9-disarm") !== "off") {
|
|
18240
|
+
const finding = analyzeNode9Disarm(bashCommand, daemonPid?.() ?? null);
|
|
18241
|
+
if (finding) {
|
|
18242
|
+
const v = applyCheckValue(cv("commands.node9-disarm"), {
|
|
18243
|
+
decision: "review",
|
|
18244
|
+
blockedByLabel: `Node9 (AST): ${finding.ruleName}`,
|
|
18245
|
+
reason: finding.reason,
|
|
18246
|
+
tier: 2,
|
|
18247
|
+
ruleName: finding.ruleName,
|
|
18248
|
+
ruleDescription: finding.description,
|
|
18249
|
+
checkId: "commands.node9-disarm"
|
|
18250
|
+
});
|
|
18251
|
+
if (v?.logged) noteLogged(v);
|
|
18252
|
+
else if (v?.decision === "block") return v;
|
|
18253
|
+
else if (v && !pendingAstReview) pendingAstReview = v;
|
|
18254
|
+
}
|
|
18255
|
+
}
|
|
18046
18256
|
}
|
|
18047
18257
|
if (config.policy.smartRules.length > 0) {
|
|
18048
18258
|
const rmCleanupWaiver = bashCommand !== null && isRmCreatedInCommandCleanup(bashCommand);
|
|
@@ -18634,8 +18844,8 @@ function hasRoutingNumber(text) {
|
|
|
18634
18844
|
return false;
|
|
18635
18845
|
}
|
|
18636
18846
|
var PII_IBAN_RE = /\b[A-Z]{2}\d{2}(?:[A-Z0-9]|[ -][A-Z0-9]){11,30}\b/;
|
|
18637
|
-
function* validCardRuns(text,
|
|
18638
|
-
const re = new RegExp(
|
|
18847
|
+
function* validCardRuns(text, base3, exemptFractions = true) {
|
|
18848
|
+
const re = new RegExp(base3.source, "g");
|
|
18639
18849
|
let m;
|
|
18640
18850
|
while ((m = re.exec(text)) !== null) {
|
|
18641
18851
|
const digits = m[0].replace(/\D/g, "");
|
|
@@ -18648,17 +18858,17 @@ function* validCardRuns(text, base2, exemptFractions = true) {
|
|
|
18648
18858
|
}
|
|
18649
18859
|
}
|
|
18650
18860
|
function hasValidCard(text) {
|
|
18651
|
-
for (const
|
|
18652
|
-
if (!validCardRuns(text,
|
|
18861
|
+
for (const base3 of CARD_PATTERNS) {
|
|
18862
|
+
if (!validCardRuns(text, base3).next().done) return true;
|
|
18653
18863
|
}
|
|
18654
18864
|
return false;
|
|
18655
18865
|
}
|
|
18656
18866
|
function replaceValidCards(text, replace, { exemptFractions = true } = {}) {
|
|
18657
18867
|
let out = text;
|
|
18658
|
-
for (const
|
|
18868
|
+
for (const base3 of CARD_PATTERNS) {
|
|
18659
18869
|
let res = "";
|
|
18660
18870
|
let last = 0;
|
|
18661
|
-
for (const run of validCardRuns(out,
|
|
18871
|
+
for (const run of validCardRuns(out, base3, exemptFractions)) {
|
|
18662
18872
|
res += out.slice(last, run.index) + replace(run.digits);
|
|
18663
18873
|
last = run.index + run.length;
|
|
18664
18874
|
}
|
|
@@ -18947,9 +19157,9 @@ function maskLeaf(value, key, depth) {
|
|
|
18947
19157
|
const used = /* @__PURE__ */ new Set();
|
|
18948
19158
|
return Object.fromEntries(
|
|
18949
19159
|
Object.entries(value).map(([k, v]) => {
|
|
18950
|
-
const
|
|
18951
|
-
let name =
|
|
18952
|
-
for (let n = 2; used.has(name); n++) name = `${
|
|
19160
|
+
const base3 = maskPersonalData(k);
|
|
19161
|
+
let name = base3;
|
|
19162
|
+
for (let n = 2; used.has(name); n++) name = `${base3}#${n}`;
|
|
18953
19163
|
used.add(name);
|
|
18954
19164
|
return [name, maskLeaf(v, k, depth + 1)];
|
|
18955
19165
|
})
|
|
@@ -19997,8 +20207,8 @@ function matchCanaryArgs(args, values) {
|
|
|
19997
20207
|
|
|
19998
20208
|
// src/scan/canonical.ts
|
|
19999
20209
|
var LONG_OUTPUT_THRESHOLD_BYTES = 100 * 1024;
|
|
20000
|
-
var CANONICAL_EXTRACTOR_VERSION = "canonical-
|
|
20001
|
-
var CANONICAL_EXTRACTOR_HASH = "
|
|
20210
|
+
var CANONICAL_EXTRACTOR_VERSION = "canonical-v38";
|
|
20211
|
+
var CANONICAL_EXTRACTOR_HASH = "2d3dfcccff2c2f65";
|
|
20002
20212
|
var DEDUPE_PREVIEW_LEN = 120;
|
|
20003
20213
|
function extractCanonicalFindings(call, ctx) {
|
|
20004
20214
|
const out = [];
|
|
@@ -20578,6 +20788,7 @@ export {
|
|
|
20578
20788
|
gitInvocations,
|
|
20579
20789
|
gitRepoPath,
|
|
20580
20790
|
hashDestination,
|
|
20791
|
+
holdsSendsWithoutDaemon,
|
|
20581
20792
|
hostMatches,
|
|
20582
20793
|
incompleteFileVerdict,
|
|
20583
20794
|
inlineExecDescription,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node9/policy-engine",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.52.0",
|
|
4
4
|
"description": "Shared policy evaluation engine for node9 — DLP, smart rules, AST shell parsing, shields, loop detection. Pure functions, no I/O. Used by both node9-proxy and the node9 SaaS firewall.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://node9.ai",
|