@node9/policy-engine 2.38.0 → 2.39.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 CHANGED
@@ -393,7 +393,8 @@ interface ResolvedCheck {
393
393
  * The value in force for one check, read from today's config shape, and
394
394
  * where it came from. A locked check always answers its floor. A pack row is
395
395
  * `off` unless its pack is applied. Anything the config does not set is the
396
- * catalog default.
396
+ * default of the level `settings.mode` names (levels.ts), which for most
397
+ * checks is the catalog default.
397
398
  */
398
399
  declare function resolveCheck(settings: CatalogSettings, id: string): ResolvedCheck | undefined;
399
400
  /** Every check resolved, in catalog order. */
@@ -1217,6 +1218,15 @@ declare function checksFromLegacyPolicy(policy: LegacyPolicyKnobs, mode?: string
1217
1218
  * legacy shape cannot carry the value.
1218
1219
  */
1219
1220
  declare function checkToLegacyPolicy(policy: Obj, id: string, v: Verdict): boolean;
1221
+ /**
1222
+ * The knob-governed checks a legacy policy block STATES: it sets the field
1223
+ * that picks the check's value. Presence, not value, decides, so a level
1224
+ * (levels.ts) leaves the check alone. A field that turns a check on without
1225
+ * choosing between its on values (`dlp.enabled: true` for the weak-credential
1226
+ * row, `untrustedContent.enabled: true`) does not pin it: older `node9 init`
1227
+ * runs wrote those into every config file.
1228
+ */
1229
+ declare function knobStatedChecks(policy: LegacyPolicyKnobs): Set<string>;
1220
1230
  /**
1221
1231
  * Checks whose detector reads the resolved checks map: every value the
1222
1232
  * catalog row offers works. Pack rows (`packs.*`) qualify too.
@@ -1239,6 +1249,37 @@ declare function configurableValues(id: string): readonly Verdict[];
1239
1249
  /** The ids a config file or a workspace can state today. */
1240
1250
  declare const CONFIGURABLE_CHECK_IDS: readonly string[];
1241
1251
 
1252
+ declare const LEVELS: readonly ["audit", "soft", "standard", "strict", "block-all"];
1253
+ type Level = (typeof LEVELS)[number];
1254
+ /** Every value `settings.mode` accepts: the five levels plus `observe`, the
1255
+ * older name of Audit that the dashboard still stores. */
1256
+ declare const MODE_VALUES: readonly ["observe", "audit", "soft", "standard", "strict", "block-all"];
1257
+ type ModeValue = (typeof MODE_VALUES)[number];
1258
+ declare function isModeValue(v: unknown): v is ModeValue;
1259
+ /** The level a mode names. `observe` is Audit; anything unknown or unset is
1260
+ * Standard, the default of every install. */
1261
+ declare function levelOf(mode: string | undefined): Level;
1262
+ /** Audit: nothing is stopped; every check records what it would have done. */
1263
+ declare function isRecordOnly(mode: string | undefined): boolean;
1264
+ /** Strict and Block all ask about every inline code call, not only the
1265
+ * dangerous ones the inline judge finds. */
1266
+ declare function reviewsEveryInline(mode: string | undefined): boolean;
1267
+ /** Block all: ask before any call no check recognised (the catch-all,
1268
+ * `commands.unknown`) and about a binary of unknown origin. This is what
1269
+ * `strict` meant before the levels. */
1270
+ declare function isBlockAll(mode: string | undefined): boolean;
1271
+ /** The value a level gives a check nobody stated, or undefined when the
1272
+ * level keeps the catalog default. */
1273
+ declare function levelCheckValue(mode: string | undefined, id: string): Verdict | undefined;
1274
+ /** Every check a level changes, with its value. */
1275
+ declare function levelChecks(mode: string | undefined): Readonly<Record<string, Verdict>>;
1276
+ /** The package registry signals (`loading.malicious-package` tuning), which
1277
+ * allow only review or off. Soft turns both off; the others keep review. */
1278
+ declare function levelPackageSignals(mode: string | undefined): {
1279
+ newPackage: 'review' | 'off';
1280
+ installScript: 'review' | 'off';
1281
+ } | undefined;
1282
+
1242
1283
  interface PipeChainAnalysis {
1243
1284
  isPipeline: boolean;
1244
1285
  hasSensitiveSource: boolean;
@@ -2333,5 +2374,5 @@ declare function scanArgumentSecrets(args: unknown): DlpMatch | null;
2333
2374
  /** Engine version stamped on audit entries for future drift detection. */
2334
2375
  declare const ENGINE_VERSION = "1.4.0";
2335
2376
 
2336
- export { ACTION_CHECKS, ACTION_TEMPLATES, AGENT_INSTRUCTION_DIRS, AGENT_INSTRUCTION_FILES, APP_SERVER_GLOB, APP_SHIELD_NAMES, APP_SHIELD_SPECS, ARGUMENT_SCAN_LIMITS, 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, LONG_OUTPUT_THRESHOLD_BYTES, LOOP_MAX_RECORDS, LOOP_THRESHOLD_FOR_WASTE, MAP_GOVERNED, MAX_BLAST_PATH, MAX_DESTINATIONS, NET_BINARIES, PATTERN_VERB_NAMES, PRIVILEGE_ESCALATION_RE, REALTIME_PII_PATTERNS, REPLACED_SHIELDS, SCAN_SIGNAL_WEIGHTS, SENSITIVE_PATH_RE, SENSITIVE_PATH_REGEXES, SSRF_MAX_HOST, STARTUP_NAMES, SYSTEM_AUTH_DIRS, SYSTEM_AUTH_FILES, TUNING_FIELDS, VERDICTS, analyzeFsOperation, 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, destinationDomain, destinationKind, destinationValue, detectArgsPii, detectDangerousEval, detectDangerousShellExec, detectInlineExec, detectPii, entryDisplay, evaluateEgress, evaluateLoopWindow, evaluatePolicy, evaluateProtectedFileAccess, evaluateSmartConditions, extractAllSshHosts, extractArgDestinations, extractCanonicalFindings, extractContentDestinations, extractNetworkTargets, extractPackageInstalls, extractPositionalArgs, extractSessionLevelFindings, extractShellDestTokens, extractShellDestinations, extractToolDestinations, fileAccessView, fileOperandFlagsOf, fileToolOperation, foldHomoglyphs, getCheck, getCompiledRegex, getNestedValue, gitRepoPath, hashDestination, hostMatches, incompleteFileVerdict, inlineExecDescription, inlineExecReason, inlineExecReview, inspectArgumentSecrets, inspectionEntry, inspectionLayers, isAgentInstructionPath, isBashTool, isDestructiveToolName, isHashedEntry, isIgnoredTool, isInside, isKnobGoverned, isLegacySystemPath, isLockedCheck, isLoopbackHost, isMaskedKind, isPasswordHashPath, isPrivateHost, isProtectedHomePath, isShellShapedTool, isShieldVerdict, isStrictGatedTier, isVerdict, maskDestination, maskPersonalData, maskPersonalValue, matchCanary, matchCanaryArgs, matchSensitivePath, matchesPattern, matchesTrustedEntry, matchesTrustedList, mcpServerFromToolName, narrativeRuleLabel, normalizeCommandForPolicy, normalizeDestination, normalizeFilePath, normalizeForScan, normalizeIpLiteral, normalizePyPiName, normalizeRecipient, normalizeTrustedEntry, parseAllSshHostsFromCommand, parseDestHost, patternShapeOf, positionedArgs, previewArgs, redactText, resolveAllChecks, resolveCheck, resolveCheckMap, resolvePinned, resolveShellInput, ruleServerMatches, safeMessage, sampleCopyCommand, scanArgs, scanArgumentSecrets, scanInjection, 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 };
2337
- export type { ActionTemplateName, ApprovalRow, ArgumentInspectionResult, AuditEntryForClassify, BlastEnvFinding, BlastFinding, BlastResult, BlastSummary, CanaryHit, CanaryValue, CanaryView, CanonicalAgent, CanonicalFinding, CanonicalFindingType, CanonicalSourceType, CatalogSettings, CheckDef, CheckGroup, CheckSource, CheckText, Destination, DestinationKind, DlpMatch, EgressPolicy, EgressVerdict, ExtractContext, FileAccess, FileAccessContext, FsOpVerdict, InjectionConfidence, InjectionContext, InjectionMatch, InlineExecReview, InspectionInput, InspectionLayers, LegacyPolicyKnobs, LoopWindowEvaluation, PackageEcosystem, PackageInstallRequest, PiiPattern, PipeChainAnalysis, PolicyConfig, PolicyContext, PolicyHostHooks, PolicyVerdict, PositionedArg, ProtectedFileVerdict, ProvenanceLookup, ProvenanceTrust, 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 };
2377
+ export { ACTION_CHECKS, ACTION_TEMPLATES, AGENT_INSTRUCTION_DIRS, AGENT_INSTRUCTION_FILES, APP_SERVER_GLOB, APP_SHIELD_NAMES, APP_SHIELD_SPECS, ARGUMENT_SCAN_LIMITS, 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, PRIVILEGE_ESCALATION_RE, REALTIME_PII_PATTERNS, REPLACED_SHIELDS, SCAN_SIGNAL_WEIGHTS, SENSITIVE_PATH_RE, SENSITIVE_PATH_REGEXES, SSRF_MAX_HOST, STARTUP_NAMES, SYSTEM_AUTH_DIRS, SYSTEM_AUTH_FILES, TUNING_FIELDS, VERDICTS, analyzeFsOperation, 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, destinationDomain, destinationKind, destinationValue, detectArgsPii, detectDangerousEval, detectDangerousShellExec, detectInlineExec, detectPii, entryDisplay, evaluateEgress, evaluateLoopWindow, evaluatePolicy, evaluateProtectedFileAccess, evaluateSmartConditions, extractAllSshHosts, extractArgDestinations, extractCanonicalFindings, extractContentDestinations, extractNetworkTargets, extractPackageInstalls, extractPositionalArgs, extractSessionLevelFindings, extractShellDestTokens, extractShellDestinations, extractToolDestinations, fileAccessView, fileOperandFlagsOf, fileToolOperation, foldHomoglyphs, getCheck, getCompiledRegex, getNestedValue, gitRepoPath, hashDestination, hostMatches, incompleteFileVerdict, inlineExecDescription, inlineExecReason, inlineExecReview, inspectArgumentSecrets, inspectionEntry, inspectionLayers, isAgentInstructionPath, isBashTool, isBlockAll, isDestructiveToolName, isHashedEntry, isIgnoredTool, isInside, isKnobGoverned, isLegacySystemPath, isLockedCheck, isLoopbackHost, isMaskedKind, isModeValue, isPasswordHashPath, isPrivateHost, isProtectedHomePath, 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, parseAllSshHostsFromCommand, parseDestHost, patternShapeOf, positionedArgs, previewArgs, redactText, resolveAllChecks, resolveCheck, resolveCheckMap, resolvePinned, resolveShellInput, reviewsEveryInline, ruleServerMatches, safeMessage, sampleCopyCommand, scanArgs, scanArgumentSecrets, scanInjection, 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 };
2378
+ export type { ActionTemplateName, ApprovalRow, ArgumentInspectionResult, AuditEntryForClassify, BlastEnvFinding, BlastFinding, BlastResult, BlastSummary, CanaryHit, CanaryValue, CanaryView, CanonicalAgent, CanonicalFinding, CanonicalFindingType, CanonicalSourceType, CatalogSettings, CheckDef, CheckGroup, CheckSource, CheckText, Destination, DestinationKind, DlpMatch, EgressPolicy, EgressVerdict, ExtractContext, FileAccess, FileAccessContext, FsOpVerdict, InjectionConfidence, InjectionContext, InjectionMatch, InlineExecReview, InspectionInput, InspectionLayers, LegacyPolicyKnobs, Level, LoopWindowEvaluation, ModeValue, PackageEcosystem, PackageInstallRequest, PiiPattern, PipeChainAnalysis, PolicyConfig, PolicyContext, PolicyHostHooks, PolicyVerdict, PositionedArg, ProtectedFileVerdict, ProvenanceLookup, ProvenanceTrust, 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
@@ -393,7 +393,8 @@ interface ResolvedCheck {
393
393
  * The value in force for one check, read from today's config shape, and
394
394
  * where it came from. A locked check always answers its floor. A pack row is
395
395
  * `off` unless its pack is applied. Anything the config does not set is the
396
- * catalog default.
396
+ * default of the level `settings.mode` names (levels.ts), which for most
397
+ * checks is the catalog default.
397
398
  */
398
399
  declare function resolveCheck(settings: CatalogSettings, id: string): ResolvedCheck | undefined;
399
400
  /** Every check resolved, in catalog order. */
@@ -1217,6 +1218,15 @@ declare function checksFromLegacyPolicy(policy: LegacyPolicyKnobs, mode?: string
1217
1218
  * legacy shape cannot carry the value.
1218
1219
  */
1219
1220
  declare function checkToLegacyPolicy(policy: Obj, id: string, v: Verdict): boolean;
1221
+ /**
1222
+ * The knob-governed checks a legacy policy block STATES: it sets the field
1223
+ * that picks the check's value. Presence, not value, decides, so a level
1224
+ * (levels.ts) leaves the check alone. A field that turns a check on without
1225
+ * choosing between its on values (`dlp.enabled: true` for the weak-credential
1226
+ * row, `untrustedContent.enabled: true`) does not pin it: older `node9 init`
1227
+ * runs wrote those into every config file.
1228
+ */
1229
+ declare function knobStatedChecks(policy: LegacyPolicyKnobs): Set<string>;
1220
1230
  /**
1221
1231
  * Checks whose detector reads the resolved checks map: every value the
1222
1232
  * catalog row offers works. Pack rows (`packs.*`) qualify too.
@@ -1239,6 +1249,37 @@ declare function configurableValues(id: string): readonly Verdict[];
1239
1249
  /** The ids a config file or a workspace can state today. */
1240
1250
  declare const CONFIGURABLE_CHECK_IDS: readonly string[];
1241
1251
 
1252
+ declare const LEVELS: readonly ["audit", "soft", "standard", "strict", "block-all"];
1253
+ type Level = (typeof LEVELS)[number];
1254
+ /** Every value `settings.mode` accepts: the five levels plus `observe`, the
1255
+ * older name of Audit that the dashboard still stores. */
1256
+ declare const MODE_VALUES: readonly ["observe", "audit", "soft", "standard", "strict", "block-all"];
1257
+ type ModeValue = (typeof MODE_VALUES)[number];
1258
+ declare function isModeValue(v: unknown): v is ModeValue;
1259
+ /** The level a mode names. `observe` is Audit; anything unknown or unset is
1260
+ * Standard, the default of every install. */
1261
+ declare function levelOf(mode: string | undefined): Level;
1262
+ /** Audit: nothing is stopped; every check records what it would have done. */
1263
+ declare function isRecordOnly(mode: string | undefined): boolean;
1264
+ /** Strict and Block all ask about every inline code call, not only the
1265
+ * dangerous ones the inline judge finds. */
1266
+ declare function reviewsEveryInline(mode: string | undefined): boolean;
1267
+ /** Block all: ask before any call no check recognised (the catch-all,
1268
+ * `commands.unknown`) and about a binary of unknown origin. This is what
1269
+ * `strict` meant before the levels. */
1270
+ declare function isBlockAll(mode: string | undefined): boolean;
1271
+ /** The value a level gives a check nobody stated, or undefined when the
1272
+ * level keeps the catalog default. */
1273
+ declare function levelCheckValue(mode: string | undefined, id: string): Verdict | undefined;
1274
+ /** Every check a level changes, with its value. */
1275
+ declare function levelChecks(mode: string | undefined): Readonly<Record<string, Verdict>>;
1276
+ /** The package registry signals (`loading.malicious-package` tuning), which
1277
+ * allow only review or off. Soft turns both off; the others keep review. */
1278
+ declare function levelPackageSignals(mode: string | undefined): {
1279
+ newPackage: 'review' | 'off';
1280
+ installScript: 'review' | 'off';
1281
+ } | undefined;
1282
+
1242
1283
  interface PipeChainAnalysis {
1243
1284
  isPipeline: boolean;
1244
1285
  hasSensitiveSource: boolean;
@@ -2333,5 +2374,5 @@ declare function scanArgumentSecrets(args: unknown): DlpMatch | null;
2333
2374
  /** Engine version stamped on audit entries for future drift detection. */
2334
2375
  declare const ENGINE_VERSION = "1.4.0";
2335
2376
 
2336
- export { ACTION_CHECKS, ACTION_TEMPLATES, AGENT_INSTRUCTION_DIRS, AGENT_INSTRUCTION_FILES, APP_SERVER_GLOB, APP_SHIELD_NAMES, APP_SHIELD_SPECS, ARGUMENT_SCAN_LIMITS, 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, LONG_OUTPUT_THRESHOLD_BYTES, LOOP_MAX_RECORDS, LOOP_THRESHOLD_FOR_WASTE, MAP_GOVERNED, MAX_BLAST_PATH, MAX_DESTINATIONS, NET_BINARIES, PATTERN_VERB_NAMES, PRIVILEGE_ESCALATION_RE, REALTIME_PII_PATTERNS, REPLACED_SHIELDS, SCAN_SIGNAL_WEIGHTS, SENSITIVE_PATH_RE, SENSITIVE_PATH_REGEXES, SSRF_MAX_HOST, STARTUP_NAMES, SYSTEM_AUTH_DIRS, SYSTEM_AUTH_FILES, TUNING_FIELDS, VERDICTS, analyzeFsOperation, 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, destinationDomain, destinationKind, destinationValue, detectArgsPii, detectDangerousEval, detectDangerousShellExec, detectInlineExec, detectPii, entryDisplay, evaluateEgress, evaluateLoopWindow, evaluatePolicy, evaluateProtectedFileAccess, evaluateSmartConditions, extractAllSshHosts, extractArgDestinations, extractCanonicalFindings, extractContentDestinations, extractNetworkTargets, extractPackageInstalls, extractPositionalArgs, extractSessionLevelFindings, extractShellDestTokens, extractShellDestinations, extractToolDestinations, fileAccessView, fileOperandFlagsOf, fileToolOperation, foldHomoglyphs, getCheck, getCompiledRegex, getNestedValue, gitRepoPath, hashDestination, hostMatches, incompleteFileVerdict, inlineExecDescription, inlineExecReason, inlineExecReview, inspectArgumentSecrets, inspectionEntry, inspectionLayers, isAgentInstructionPath, isBashTool, isDestructiveToolName, isHashedEntry, isIgnoredTool, isInside, isKnobGoverned, isLegacySystemPath, isLockedCheck, isLoopbackHost, isMaskedKind, isPasswordHashPath, isPrivateHost, isProtectedHomePath, isShellShapedTool, isShieldVerdict, isStrictGatedTier, isVerdict, maskDestination, maskPersonalData, maskPersonalValue, matchCanary, matchCanaryArgs, matchSensitivePath, matchesPattern, matchesTrustedEntry, matchesTrustedList, mcpServerFromToolName, narrativeRuleLabel, normalizeCommandForPolicy, normalizeDestination, normalizeFilePath, normalizeForScan, normalizeIpLiteral, normalizePyPiName, normalizeRecipient, normalizeTrustedEntry, parseAllSshHostsFromCommand, parseDestHost, patternShapeOf, positionedArgs, previewArgs, redactText, resolveAllChecks, resolveCheck, resolveCheckMap, resolvePinned, resolveShellInput, ruleServerMatches, safeMessage, sampleCopyCommand, scanArgs, scanArgumentSecrets, scanInjection, 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 };
2337
- export type { ActionTemplateName, ApprovalRow, ArgumentInspectionResult, AuditEntryForClassify, BlastEnvFinding, BlastFinding, BlastResult, BlastSummary, CanaryHit, CanaryValue, CanaryView, CanonicalAgent, CanonicalFinding, CanonicalFindingType, CanonicalSourceType, CatalogSettings, CheckDef, CheckGroup, CheckSource, CheckText, Destination, DestinationKind, DlpMatch, EgressPolicy, EgressVerdict, ExtractContext, FileAccess, FileAccessContext, FsOpVerdict, InjectionConfidence, InjectionContext, InjectionMatch, InlineExecReview, InspectionInput, InspectionLayers, LegacyPolicyKnobs, LoopWindowEvaluation, PackageEcosystem, PackageInstallRequest, PiiPattern, PipeChainAnalysis, PolicyConfig, PolicyContext, PolicyHostHooks, PolicyVerdict, PositionedArg, ProtectedFileVerdict, ProvenanceLookup, ProvenanceTrust, 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 };
2377
+ export { ACTION_CHECKS, ACTION_TEMPLATES, AGENT_INSTRUCTION_DIRS, AGENT_INSTRUCTION_FILES, APP_SERVER_GLOB, APP_SHIELD_NAMES, APP_SHIELD_SPECS, ARGUMENT_SCAN_LIMITS, 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, PRIVILEGE_ESCALATION_RE, REALTIME_PII_PATTERNS, REPLACED_SHIELDS, SCAN_SIGNAL_WEIGHTS, SENSITIVE_PATH_RE, SENSITIVE_PATH_REGEXES, SSRF_MAX_HOST, STARTUP_NAMES, SYSTEM_AUTH_DIRS, SYSTEM_AUTH_FILES, TUNING_FIELDS, VERDICTS, analyzeFsOperation, 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, destinationDomain, destinationKind, destinationValue, detectArgsPii, detectDangerousEval, detectDangerousShellExec, detectInlineExec, detectPii, entryDisplay, evaluateEgress, evaluateLoopWindow, evaluatePolicy, evaluateProtectedFileAccess, evaluateSmartConditions, extractAllSshHosts, extractArgDestinations, extractCanonicalFindings, extractContentDestinations, extractNetworkTargets, extractPackageInstalls, extractPositionalArgs, extractSessionLevelFindings, extractShellDestTokens, extractShellDestinations, extractToolDestinations, fileAccessView, fileOperandFlagsOf, fileToolOperation, foldHomoglyphs, getCheck, getCompiledRegex, getNestedValue, gitRepoPath, hashDestination, hostMatches, incompleteFileVerdict, inlineExecDescription, inlineExecReason, inlineExecReview, inspectArgumentSecrets, inspectionEntry, inspectionLayers, isAgentInstructionPath, isBashTool, isBlockAll, isDestructiveToolName, isHashedEntry, isIgnoredTool, isInside, isKnobGoverned, isLegacySystemPath, isLockedCheck, isLoopbackHost, isMaskedKind, isModeValue, isPasswordHashPath, isPrivateHost, isProtectedHomePath, 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, parseAllSshHostsFromCommand, parseDestHost, patternShapeOf, positionedArgs, previewArgs, redactText, resolveAllChecks, resolveCheck, resolveCheckMap, resolvePinned, resolveShellInput, reviewsEveryInline, ruleServerMatches, safeMessage, sampleCopyCommand, scanArgs, scanArgumentSecrets, scanInjection, 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 };
2378
+ export type { ActionTemplateName, ApprovalRow, ArgumentInspectionResult, AuditEntryForClassify, BlastEnvFinding, BlastFinding, BlastResult, BlastSummary, CanaryHit, CanaryValue, CanaryView, CanonicalAgent, CanonicalFinding, CanonicalFindingType, CanonicalSourceType, CatalogSettings, CheckDef, CheckGroup, CheckSource, CheckText, Destination, DestinationKind, DlpMatch, EgressPolicy, EgressVerdict, ExtractContext, FileAccess, FileAccessContext, FsOpVerdict, InjectionConfidence, InjectionContext, InjectionMatch, InlineExecReview, InspectionInput, InspectionLayers, LegacyPolicyKnobs, Level, LoopWindowEvaluation, ModeValue, PackageEcosystem, PackageInstallRequest, PiiPattern, PipeChainAnalysis, PolicyConfig, PolicyContext, PolicyHostHooks, PolicyVerdict, PositionedArg, ProtectedFileVerdict, ProvenanceLookup, ProvenanceTrust, 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
@@ -65,12 +65,14 @@ __export(src_exports, {
65
65
  FS_READ_TOOLS: () => FS_READ_TOOLS,
66
66
  GENERAL_ACTION_RULES: () => GENERAL_ACTION_RULES,
67
67
  KNOB_GOVERNED: () => KNOB_GOVERNED,
68
+ LEVELS: () => LEVELS,
68
69
  LONG_OUTPUT_THRESHOLD_BYTES: () => LONG_OUTPUT_THRESHOLD_BYTES,
69
70
  LOOP_MAX_RECORDS: () => LOOP_MAX_RECORDS,
70
71
  LOOP_THRESHOLD_FOR_WASTE: () => LOOP_THRESHOLD_FOR_WASTE,
71
72
  MAP_GOVERNED: () => MAP_GOVERNED,
72
73
  MAX_BLAST_PATH: () => MAX_BLAST_PATH,
73
74
  MAX_DESTINATIONS: () => MAX_DESTINATIONS,
75
+ MODE_VALUES: () => MODE_VALUES,
74
76
  NET_BINARIES: () => NET_BINARIES,
75
77
  PATTERN_VERB_NAMES: () => PATTERN_VERB_NAMES,
76
78
  PRIVILEGE_ESCALATION_RE: () => PRIVILEGE_ESCALATION_RE,
@@ -155,6 +157,7 @@ __export(src_exports, {
155
157
  inspectionLayers: () => inspectionLayers,
156
158
  isAgentInstructionPath: () => isAgentInstructionPath,
157
159
  isBashTool: () => isBashTool,
160
+ isBlockAll: () => isBlockAll,
158
161
  isDestructiveToolName: () => isDestructiveToolName,
159
162
  isHashedEntry: () => isHashedEntry,
160
163
  isIgnoredTool: () => isIgnoredTool,
@@ -164,13 +167,20 @@ __export(src_exports, {
164
167
  isLockedCheck: () => isLockedCheck,
165
168
  isLoopbackHost: () => isLoopbackHost,
166
169
  isMaskedKind: () => isMaskedKind,
170
+ isModeValue: () => isModeValue,
167
171
  isPasswordHashPath: () => isPasswordHashPath,
168
172
  isPrivateHost: () => isPrivateHost,
169
173
  isProtectedHomePath: () => isProtectedHomePath,
174
+ isRecordOnly: () => isRecordOnly,
170
175
  isShellShapedTool: () => isShellShapedTool,
171
176
  isShieldVerdict: () => isShieldVerdict,
172
177
  isStrictGatedTier: () => isStrictGatedTier,
173
178
  isVerdict: () => isVerdict,
179
+ knobStatedChecks: () => knobStatedChecks,
180
+ levelCheckValue: () => levelCheckValue,
181
+ levelChecks: () => levelChecks,
182
+ levelOf: () => levelOf,
183
+ levelPackageSignals: () => levelPackageSignals,
174
184
  maskDestination: () => maskDestination,
175
185
  maskPersonalData: () => maskPersonalData,
176
186
  maskPersonalValue: () => maskPersonalValue,
@@ -201,6 +211,7 @@ __export(src_exports, {
201
211
  resolveCheckMap: () => resolveCheckMap,
202
212
  resolvePinned: () => resolvePinned,
203
213
  resolveShellInput: () => resolveShellInput,
214
+ reviewsEveryInline: () => reviewsEveryInline,
204
215
  ruleServerMatches: () => ruleServerMatches,
205
216
  safeMessage: () => safeMessage,
206
217
  sampleCopyCommand: () => sampleCopyCommand,
@@ -2464,6 +2475,80 @@ var CHECK_TEXT = {
2464
2475
  }
2465
2476
  };
2466
2477
 
2478
+ // src/levels.ts
2479
+ var LEVELS = ["audit", "soft", "standard", "strict", "block-all"];
2480
+ var MODE_VALUES = ["observe", ...LEVELS];
2481
+ function isModeValue(v) {
2482
+ return typeof v === "string" && MODE_VALUES.includes(v);
2483
+ }
2484
+ function levelOf(mode) {
2485
+ if (mode === "observe") return "audit";
2486
+ return LEVELS.includes(mode ?? "") ? mode : "standard";
2487
+ }
2488
+ function isRecordOnly(mode) {
2489
+ return levelOf(mode) === "audit";
2490
+ }
2491
+ function reviewsEveryInline(mode) {
2492
+ const level = levelOf(mode);
2493
+ return level === "strict" || level === "block-all";
2494
+ }
2495
+ function isBlockAll(mode) {
2496
+ return levelOf(mode) === "block-all";
2497
+ }
2498
+ var SOFT = {
2499
+ "commands.inline-exec": "log",
2500
+ "commands.eval-dynamic": "log",
2501
+ "commands.rm": "log",
2502
+ "commands.chmod": "log",
2503
+ "commands.sudo": "log",
2504
+ "commands.git-destructive": "log",
2505
+ "commands.sql-ddl": "log",
2506
+ "commands.sql-no-where": "log",
2507
+ "commands.temp-binary": "log",
2508
+ "commands.disk-destroy": "log",
2509
+ "commands.dangerous-word": "log",
2510
+ "files.system-dirs": "log",
2511
+ "files.shell-startup": "log",
2512
+ "files.password-hashes": "log",
2513
+ "data.pipe-chain": "log",
2514
+ "behavior.untrusted-content": "log"
2515
+ };
2516
+ var STRICT = {
2517
+ "commands.sql-ddl": "block",
2518
+ "commands.disk-destroy": "block",
2519
+ "commands.node9-disarm": "block",
2520
+ "files.system-dirs": "block",
2521
+ "files.shell-startup": "block",
2522
+ "files.password-hashes": "block",
2523
+ "data.secrets-weak": "block",
2524
+ "data.pipe-chain": "block",
2525
+ "network.unknown-host": "review",
2526
+ "network.internal-addresses": "block",
2527
+ "behavior.prompt-injection": "log",
2528
+ "loading.skill-tamper": "block"
2529
+ };
2530
+ var BLOCK_ALL = {
2531
+ ...STRICT,
2532
+ "commands.unknown": "review",
2533
+ "commands.temp-binary": "block"
2534
+ };
2535
+ var LEVEL_CHECKS = {
2536
+ audit: {},
2537
+ soft: SOFT,
2538
+ standard: {},
2539
+ strict: STRICT,
2540
+ "block-all": BLOCK_ALL
2541
+ };
2542
+ function levelCheckValue(mode, id) {
2543
+ return LEVEL_CHECKS[levelOf(mode)][id];
2544
+ }
2545
+ function levelChecks(mode) {
2546
+ return LEVEL_CHECKS[levelOf(mode)];
2547
+ }
2548
+ function levelPackageSignals(mode) {
2549
+ return levelOf(mode) === "soft" ? { newPackage: "off", installScript: "off" } : void 0;
2550
+ }
2551
+
2467
2552
  // src/catalog.ts
2468
2553
  var VERDICTS = ["off", "log", "review", "block"];
2469
2554
  var CHECK_VERDICT_RANK = { off: 0, log: 1, review: 2, block: 3 };
@@ -3070,7 +3155,7 @@ var LEGACY_READERS = {
3070
3155
  "commands.rm": (s) => knob(s.commandChecks?.rmAdvisory),
3071
3156
  "commands.chmod": (s) => knob(s.commandChecks?.chmod),
3072
3157
  "commands.sql-ddl": (s) => knob(s.commandChecks?.sqlDdl),
3073
- "commands.unknown": (s) => s.mode === void 0 ? void 0 : s.mode === "strict" ? "review" : "off",
3158
+ "commands.unknown": (s) => s.mode === void 0 ? void 0 : isBlockAll(s.mode) ? "review" : "off",
3074
3159
  "data.secrets": (s) => enabledOr(s.dlp?.enabled, "block"),
3075
3160
  "data.secrets-weak": (s) => {
3076
3161
  if (s.dlp?.enabled === false) return "off";
@@ -3109,19 +3194,21 @@ function resolveCheck(settings, id) {
3109
3194
  if (!def) return void 0;
3110
3195
  if (isLockedCheck(def)) return { id, value: "block", source: "locked" };
3111
3196
  const floor = def.floor ? CHECK_VERDICT_RANK[def.floor] : 0;
3197
+ const levelDefault = levelCheckValue(settings.mode, id) ?? def.defaultValue;
3198
+ const sourceOf = (value2) => value2 === levelDefault ? "default" : "configured";
3112
3199
  const explicit = settings.checks?.[id];
3113
3200
  if (isVerdict(explicit)) {
3114
3201
  const value2 = CHECK_VERDICT_RANK[explicit] < floor ? def.floor : explicit;
3115
- return { id, value: value2, source: value2 === def.defaultValue ? "default" : "configured" };
3202
+ return { id, value: value2, source: sourceOf(value2) };
3116
3203
  }
3117
3204
  if (def.pack) {
3118
3205
  const on = settings.appliedShields?.includes(def.pack) ?? false;
3119
3206
  return { id, value: on ? def.defaultValue : "off", source: "default" };
3120
3207
  }
3121
3208
  const read = LEGACY_READERS[id]?.(settings);
3122
- if (read === void 0) return { id, value: def.defaultValue, source: "default" };
3209
+ if (read === void 0) return { id, value: levelDefault, source: "default" };
3123
3210
  const value = CHECK_VERDICT_RANK[read] < floor ? def.floor : read;
3124
- return { id, value, source: value === def.defaultValue ? "default" : "configured" };
3211
+ return { id, value, source: sourceOf(value) };
3125
3212
  }
3126
3213
  function resolveAllChecks(settings) {
3127
3214
  return CHECKS.map((c) => resolveCheck(settings, c.id));
@@ -12916,7 +13003,7 @@ function checksFromLegacyPolicy(policy, mode) {
12916
13003
  if (uc?.enabled === false) out["behavior.untrusted-content"] = "off";
12917
13004
  else if (uc?.enabled === true)
12918
13005
  out["behavior.untrusted-content"] = uc.afterExposure === "log-only" ? "log" : "review";
12919
- if (mode === "strict") out["commands.unknown"] = "review";
13006
+ if (isBlockAll(mode)) out["commands.unknown"] = "review";
12920
13007
  return out;
12921
13008
  }
12922
13009
  function checkToLegacyPolicy(policy, id, v) {
@@ -13008,6 +13095,25 @@ function checkToLegacyPolicy(policy, id, v) {
13008
13095
  return false;
13009
13096
  }
13010
13097
  }
13098
+ function knobStatedChecks(policy) {
13099
+ const out = /* @__PURE__ */ new Set();
13100
+ const has = (o, key) => !!o && typeof o === "object" && o[key] !== void 0;
13101
+ const { dlp, egress, loopDetection, injectionScan, skillPinning, packageCheck } = policy;
13102
+ const uc = policy.untrustedContent;
13103
+ if (has(dlp, "enabled")) out.add("data.secrets");
13104
+ if (has(dlp, "reviewAction") || dlp?.enabled === false) out.add("data.secrets-weak");
13105
+ if (has(dlp, "pii")) out.add("data.pii");
13106
+ if (has(egress, "enabled") || has(egress, "mode")) out.add("network.unknown-host");
13107
+ if (has(egress, "ssrfStrict")) out.add("network.internal-addresses");
13108
+ if (has(loopDetection, "enabled")) out.add("behavior.loops");
13109
+ if (has(injectionScan, "enabled")) out.add("behavior.prompt-injection");
13110
+ if (has(skillPinning, "enabled") || has(skillPinning, "mode")) out.add("loading.skill-tamper");
13111
+ if (has(packageCheck, "enabled") || has(packageCheck, "onMalicious"))
13112
+ out.add("loading.malicious-package");
13113
+ if (uc && typeof uc === "object" && (uc.enabled === false || has(uc, "afterExposure")))
13114
+ out.add("behavior.untrusted-content");
13115
+ return out;
13116
+ }
13011
13117
  var MAP_GOVERNED = /* @__PURE__ */ new Set([
13012
13118
  "files.shell-startup",
13013
13119
  "files.password-hashes",
@@ -14074,7 +14180,7 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
14074
14180
  if (v?.logged) noteLogged(v);
14075
14181
  else if (v) candidates.push(v);
14076
14182
  };
14077
- const inline = config.settings.mode === "strict" ? detectInlineExec(shellCommand) ? void 0 : null : inlineExecReview(shellCommand);
14183
+ const inline = reviewsEveryInline(config.settings.mode) ? detectInlineExec(shellCommand) ? void 0 : null : inlineExecReview(shellCommand);
14078
14184
  if (inline !== null) {
14079
14185
  consider("commands.inline-exec", {
14080
14186
  decision: "review",
@@ -14134,21 +14240,17 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
14134
14240
  if (firstToken && firstToken.startsWith("/") && checkProvenance) {
14135
14241
  const prov = checkProvenance(firstToken, cwd);
14136
14242
  if (prov.trustLevel === "suspect") {
14137
- const value = cv("commands.temp-binary");
14138
- const v = applyCheckValue(
14139
- value === "review" && config.settings.mode === "strict" ? "block" : value,
14140
- {
14141
- decision: "review",
14142
- blockedByLabel: "Node9: Suspect Binary",
14143
- reason: `Binary "${firstToken}" resolved to ${prov.resolvedPath} \u2014 ${prov.reason}`,
14144
- tier: 3,
14145
- checkId: "commands.temp-binary"
14146
- }
14147
- );
14243
+ const v = applyCheckValue(cv("commands.temp-binary"), {
14244
+ decision: "review",
14245
+ blockedByLabel: "Node9: Suspect Binary",
14246
+ reason: `Binary "${firstToken}" resolved to ${prov.resolvedPath} \u2014 ${prov.reason}`,
14247
+ tier: 3,
14248
+ checkId: "commands.temp-binary"
14249
+ });
14148
14250
  if (v?.logged) noteLogged(v);
14149
14251
  else if (v) return v;
14150
14252
  }
14151
- if (prov.trustLevel === "unknown" && config.settings.mode === "strict") {
14253
+ if (prov.trustLevel === "unknown" && isBlockAll(config.settings.mode)) {
14152
14254
  return {
14153
14255
  decision: "review",
14154
14256
  blockedByLabel: "Node9: Unknown Binary (strict mode)",
@@ -14239,7 +14341,7 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
14239
14341
  if (v?.logged) noteLogged(v);
14240
14342
  else if (v) return v;
14241
14343
  }
14242
- if (config.settings.mode === "strict") {
14344
+ if (isBlockAll(config.settings.mode)) {
14243
14345
  if (activeEnvironment?.requireApproval === false) return allowed();
14244
14346
  return {
14245
14347
  decision: "review",
@@ -16241,12 +16343,14 @@ var ENGINE_VERSION = "1.4.0";
16241
16343
  FS_READ_TOOLS,
16242
16344
  GENERAL_ACTION_RULES,
16243
16345
  KNOB_GOVERNED,
16346
+ LEVELS,
16244
16347
  LONG_OUTPUT_THRESHOLD_BYTES,
16245
16348
  LOOP_MAX_RECORDS,
16246
16349
  LOOP_THRESHOLD_FOR_WASTE,
16247
16350
  MAP_GOVERNED,
16248
16351
  MAX_BLAST_PATH,
16249
16352
  MAX_DESTINATIONS,
16353
+ MODE_VALUES,
16250
16354
  NET_BINARIES,
16251
16355
  PATTERN_VERB_NAMES,
16252
16356
  PRIVILEGE_ESCALATION_RE,
@@ -16331,6 +16435,7 @@ var ENGINE_VERSION = "1.4.0";
16331
16435
  inspectionLayers,
16332
16436
  isAgentInstructionPath,
16333
16437
  isBashTool,
16438
+ isBlockAll,
16334
16439
  isDestructiveToolName,
16335
16440
  isHashedEntry,
16336
16441
  isIgnoredTool,
@@ -16340,13 +16445,20 @@ var ENGINE_VERSION = "1.4.0";
16340
16445
  isLockedCheck,
16341
16446
  isLoopbackHost,
16342
16447
  isMaskedKind,
16448
+ isModeValue,
16343
16449
  isPasswordHashPath,
16344
16450
  isPrivateHost,
16345
16451
  isProtectedHomePath,
16452
+ isRecordOnly,
16346
16453
  isShellShapedTool,
16347
16454
  isShieldVerdict,
16348
16455
  isStrictGatedTier,
16349
16456
  isVerdict,
16457
+ knobStatedChecks,
16458
+ levelCheckValue,
16459
+ levelChecks,
16460
+ levelOf,
16461
+ levelPackageSignals,
16350
16462
  maskDestination,
16351
16463
  maskPersonalData,
16352
16464
  maskPersonalValue,
@@ -16377,6 +16489,7 @@ var ENGINE_VERSION = "1.4.0";
16377
16489
  resolveCheckMap,
16378
16490
  resolvePinned,
16379
16491
  resolveShellInput,
16492
+ reviewsEveryInline,
16380
16493
  ruleServerMatches,
16381
16494
  safeMessage,
16382
16495
  sampleCopyCommand,
package/dist/index.mjs CHANGED
@@ -2225,6 +2225,80 @@ var CHECK_TEXT = {
2225
2225
  }
2226
2226
  };
2227
2227
 
2228
+ // src/levels.ts
2229
+ var LEVELS = ["audit", "soft", "standard", "strict", "block-all"];
2230
+ var MODE_VALUES = ["observe", ...LEVELS];
2231
+ function isModeValue(v) {
2232
+ return typeof v === "string" && MODE_VALUES.includes(v);
2233
+ }
2234
+ function levelOf(mode) {
2235
+ if (mode === "observe") return "audit";
2236
+ return LEVELS.includes(mode ?? "") ? mode : "standard";
2237
+ }
2238
+ function isRecordOnly(mode) {
2239
+ return levelOf(mode) === "audit";
2240
+ }
2241
+ function reviewsEveryInline(mode) {
2242
+ const level = levelOf(mode);
2243
+ return level === "strict" || level === "block-all";
2244
+ }
2245
+ function isBlockAll(mode) {
2246
+ return levelOf(mode) === "block-all";
2247
+ }
2248
+ var SOFT = {
2249
+ "commands.inline-exec": "log",
2250
+ "commands.eval-dynamic": "log",
2251
+ "commands.rm": "log",
2252
+ "commands.chmod": "log",
2253
+ "commands.sudo": "log",
2254
+ "commands.git-destructive": "log",
2255
+ "commands.sql-ddl": "log",
2256
+ "commands.sql-no-where": "log",
2257
+ "commands.temp-binary": "log",
2258
+ "commands.disk-destroy": "log",
2259
+ "commands.dangerous-word": "log",
2260
+ "files.system-dirs": "log",
2261
+ "files.shell-startup": "log",
2262
+ "files.password-hashes": "log",
2263
+ "data.pipe-chain": "log",
2264
+ "behavior.untrusted-content": "log"
2265
+ };
2266
+ var STRICT = {
2267
+ "commands.sql-ddl": "block",
2268
+ "commands.disk-destroy": "block",
2269
+ "commands.node9-disarm": "block",
2270
+ "files.system-dirs": "block",
2271
+ "files.shell-startup": "block",
2272
+ "files.password-hashes": "block",
2273
+ "data.secrets-weak": "block",
2274
+ "data.pipe-chain": "block",
2275
+ "network.unknown-host": "review",
2276
+ "network.internal-addresses": "block",
2277
+ "behavior.prompt-injection": "log",
2278
+ "loading.skill-tamper": "block"
2279
+ };
2280
+ var BLOCK_ALL = {
2281
+ ...STRICT,
2282
+ "commands.unknown": "review",
2283
+ "commands.temp-binary": "block"
2284
+ };
2285
+ var LEVEL_CHECKS = {
2286
+ audit: {},
2287
+ soft: SOFT,
2288
+ standard: {},
2289
+ strict: STRICT,
2290
+ "block-all": BLOCK_ALL
2291
+ };
2292
+ function levelCheckValue(mode, id) {
2293
+ return LEVEL_CHECKS[levelOf(mode)][id];
2294
+ }
2295
+ function levelChecks(mode) {
2296
+ return LEVEL_CHECKS[levelOf(mode)];
2297
+ }
2298
+ function levelPackageSignals(mode) {
2299
+ return levelOf(mode) === "soft" ? { newPackage: "off", installScript: "off" } : void 0;
2300
+ }
2301
+
2228
2302
  // src/catalog.ts
2229
2303
  var VERDICTS = ["off", "log", "review", "block"];
2230
2304
  var CHECK_VERDICT_RANK = { off: 0, log: 1, review: 2, block: 3 };
@@ -2831,7 +2905,7 @@ var LEGACY_READERS = {
2831
2905
  "commands.rm": (s) => knob(s.commandChecks?.rmAdvisory),
2832
2906
  "commands.chmod": (s) => knob(s.commandChecks?.chmod),
2833
2907
  "commands.sql-ddl": (s) => knob(s.commandChecks?.sqlDdl),
2834
- "commands.unknown": (s) => s.mode === void 0 ? void 0 : s.mode === "strict" ? "review" : "off",
2908
+ "commands.unknown": (s) => s.mode === void 0 ? void 0 : isBlockAll(s.mode) ? "review" : "off",
2835
2909
  "data.secrets": (s) => enabledOr(s.dlp?.enabled, "block"),
2836
2910
  "data.secrets-weak": (s) => {
2837
2911
  if (s.dlp?.enabled === false) return "off";
@@ -2870,19 +2944,21 @@ function resolveCheck(settings, id) {
2870
2944
  if (!def) return void 0;
2871
2945
  if (isLockedCheck(def)) return { id, value: "block", source: "locked" };
2872
2946
  const floor = def.floor ? CHECK_VERDICT_RANK[def.floor] : 0;
2947
+ const levelDefault = levelCheckValue(settings.mode, id) ?? def.defaultValue;
2948
+ const sourceOf = (value2) => value2 === levelDefault ? "default" : "configured";
2873
2949
  const explicit = settings.checks?.[id];
2874
2950
  if (isVerdict(explicit)) {
2875
2951
  const value2 = CHECK_VERDICT_RANK[explicit] < floor ? def.floor : explicit;
2876
- return { id, value: value2, source: value2 === def.defaultValue ? "default" : "configured" };
2952
+ return { id, value: value2, source: sourceOf(value2) };
2877
2953
  }
2878
2954
  if (def.pack) {
2879
2955
  const on = settings.appliedShields?.includes(def.pack) ?? false;
2880
2956
  return { id, value: on ? def.defaultValue : "off", source: "default" };
2881
2957
  }
2882
2958
  const read = LEGACY_READERS[id]?.(settings);
2883
- if (read === void 0) return { id, value: def.defaultValue, source: "default" };
2959
+ if (read === void 0) return { id, value: levelDefault, source: "default" };
2884
2960
  const value = CHECK_VERDICT_RANK[read] < floor ? def.floor : read;
2885
- return { id, value, source: value === def.defaultValue ? "default" : "configured" };
2961
+ return { id, value, source: sourceOf(value) };
2886
2962
  }
2887
2963
  function resolveAllChecks(settings) {
2888
2964
  return CHECKS.map((c) => resolveCheck(settings, c.id));
@@ -12677,7 +12753,7 @@ function checksFromLegacyPolicy(policy, mode) {
12677
12753
  if (uc?.enabled === false) out["behavior.untrusted-content"] = "off";
12678
12754
  else if (uc?.enabled === true)
12679
12755
  out["behavior.untrusted-content"] = uc.afterExposure === "log-only" ? "log" : "review";
12680
- if (mode === "strict") out["commands.unknown"] = "review";
12756
+ if (isBlockAll(mode)) out["commands.unknown"] = "review";
12681
12757
  return out;
12682
12758
  }
12683
12759
  function checkToLegacyPolicy(policy, id, v) {
@@ -12769,6 +12845,25 @@ function checkToLegacyPolicy(policy, id, v) {
12769
12845
  return false;
12770
12846
  }
12771
12847
  }
12848
+ function knobStatedChecks(policy) {
12849
+ const out = /* @__PURE__ */ new Set();
12850
+ const has = (o, key) => !!o && typeof o === "object" && o[key] !== void 0;
12851
+ const { dlp, egress, loopDetection, injectionScan, skillPinning, packageCheck } = policy;
12852
+ const uc = policy.untrustedContent;
12853
+ if (has(dlp, "enabled")) out.add("data.secrets");
12854
+ if (has(dlp, "reviewAction") || dlp?.enabled === false) out.add("data.secrets-weak");
12855
+ if (has(dlp, "pii")) out.add("data.pii");
12856
+ if (has(egress, "enabled") || has(egress, "mode")) out.add("network.unknown-host");
12857
+ if (has(egress, "ssrfStrict")) out.add("network.internal-addresses");
12858
+ if (has(loopDetection, "enabled")) out.add("behavior.loops");
12859
+ if (has(injectionScan, "enabled")) out.add("behavior.prompt-injection");
12860
+ if (has(skillPinning, "enabled") || has(skillPinning, "mode")) out.add("loading.skill-tamper");
12861
+ if (has(packageCheck, "enabled") || has(packageCheck, "onMalicious"))
12862
+ out.add("loading.malicious-package");
12863
+ if (uc && typeof uc === "object" && (uc.enabled === false || has(uc, "afterExposure")))
12864
+ out.add("behavior.untrusted-content");
12865
+ return out;
12866
+ }
12772
12867
  var MAP_GOVERNED = /* @__PURE__ */ new Set([
12773
12868
  "files.shell-startup",
12774
12869
  "files.password-hashes",
@@ -13835,7 +13930,7 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
13835
13930
  if (v?.logged) noteLogged(v);
13836
13931
  else if (v) candidates.push(v);
13837
13932
  };
13838
- const inline = config.settings.mode === "strict" ? detectInlineExec(shellCommand) ? void 0 : null : inlineExecReview(shellCommand);
13933
+ const inline = reviewsEveryInline(config.settings.mode) ? detectInlineExec(shellCommand) ? void 0 : null : inlineExecReview(shellCommand);
13839
13934
  if (inline !== null) {
13840
13935
  consider("commands.inline-exec", {
13841
13936
  decision: "review",
@@ -13895,21 +13990,17 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
13895
13990
  if (firstToken && firstToken.startsWith("/") && checkProvenance) {
13896
13991
  const prov = checkProvenance(firstToken, cwd);
13897
13992
  if (prov.trustLevel === "suspect") {
13898
- const value = cv("commands.temp-binary");
13899
- const v = applyCheckValue(
13900
- value === "review" && config.settings.mode === "strict" ? "block" : value,
13901
- {
13902
- decision: "review",
13903
- blockedByLabel: "Node9: Suspect Binary",
13904
- reason: `Binary "${firstToken}" resolved to ${prov.resolvedPath} \u2014 ${prov.reason}`,
13905
- tier: 3,
13906
- checkId: "commands.temp-binary"
13907
- }
13908
- );
13993
+ const v = applyCheckValue(cv("commands.temp-binary"), {
13994
+ decision: "review",
13995
+ blockedByLabel: "Node9: Suspect Binary",
13996
+ reason: `Binary "${firstToken}" resolved to ${prov.resolvedPath} \u2014 ${prov.reason}`,
13997
+ tier: 3,
13998
+ checkId: "commands.temp-binary"
13999
+ });
13909
14000
  if (v?.logged) noteLogged(v);
13910
14001
  else if (v) return v;
13911
14002
  }
13912
- if (prov.trustLevel === "unknown" && config.settings.mode === "strict") {
14003
+ if (prov.trustLevel === "unknown" && isBlockAll(config.settings.mode)) {
13913
14004
  return {
13914
14005
  decision: "review",
13915
14006
  blockedByLabel: "Node9: Unknown Binary (strict mode)",
@@ -14000,7 +14091,7 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
14000
14091
  if (v?.logged) noteLogged(v);
14001
14092
  else if (v) return v;
14002
14093
  }
14003
- if (config.settings.mode === "strict") {
14094
+ if (isBlockAll(config.settings.mode)) {
14004
14095
  if (activeEnvironment?.requireApproval === false) return allowed();
14005
14096
  return {
14006
14097
  decision: "review",
@@ -16001,12 +16092,14 @@ export {
16001
16092
  FS_READ_TOOLS,
16002
16093
  GENERAL_ACTION_RULES,
16003
16094
  KNOB_GOVERNED,
16095
+ LEVELS,
16004
16096
  LONG_OUTPUT_THRESHOLD_BYTES,
16005
16097
  LOOP_MAX_RECORDS,
16006
16098
  LOOP_THRESHOLD_FOR_WASTE,
16007
16099
  MAP_GOVERNED,
16008
16100
  MAX_BLAST_PATH,
16009
16101
  MAX_DESTINATIONS,
16102
+ MODE_VALUES,
16010
16103
  NET_BINARIES,
16011
16104
  PATTERN_VERB_NAMES,
16012
16105
  PRIVILEGE_ESCALATION_RE,
@@ -16091,6 +16184,7 @@ export {
16091
16184
  inspectionLayers,
16092
16185
  isAgentInstructionPath,
16093
16186
  isBashTool,
16187
+ isBlockAll,
16094
16188
  isDestructiveToolName,
16095
16189
  isHashedEntry,
16096
16190
  isIgnoredTool,
@@ -16100,13 +16194,20 @@ export {
16100
16194
  isLockedCheck,
16101
16195
  isLoopbackHost,
16102
16196
  isMaskedKind,
16197
+ isModeValue,
16103
16198
  isPasswordHashPath,
16104
16199
  isPrivateHost,
16105
16200
  isProtectedHomePath,
16201
+ isRecordOnly,
16106
16202
  isShellShapedTool,
16107
16203
  isShieldVerdict,
16108
16204
  isStrictGatedTier,
16109
16205
  isVerdict,
16206
+ knobStatedChecks,
16207
+ levelCheckValue,
16208
+ levelChecks,
16209
+ levelOf,
16210
+ levelPackageSignals,
16110
16211
  maskDestination,
16111
16212
  maskPersonalData,
16112
16213
  maskPersonalValue,
@@ -16137,6 +16238,7 @@ export {
16137
16238
  resolveCheckMap,
16138
16239
  resolvePinned,
16139
16240
  resolveShellInput,
16241
+ reviewsEveryInline,
16140
16242
  ruleServerMatches,
16141
16243
  safeMessage,
16142
16244
  sampleCopyCommand,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node9/policy-engine",
3
- "version": "2.38.0",
3
+ "version": "2.39.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",