nexus-agents 2.92.2 → 2.92.4
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/{chunk-NR4NSTJH.js → chunk-27CNQPQ4.js} +21 -5
- package/dist/chunk-27CNQPQ4.js.map +1 -0
- package/dist/{chunk-F47QKVPH.js → chunk-4LEUIAYB.js} +26 -174
- package/dist/chunk-4LEUIAYB.js.map +1 -0
- package/dist/{chunk-L6JZCAFH.js → chunk-IHPYT6WU.js} +168 -4
- package/dist/chunk-IHPYT6WU.js.map +1 -0
- package/dist/{chunk-UYOHV3EG.js → chunk-JCYCITBK.js} +45 -24
- package/dist/chunk-JCYCITBK.js.map +1 -0
- package/dist/{chunk-3HVSXLPL.js → chunk-MZFWRU6E.js} +3 -3
- package/dist/{chunk-XNBPE6WG.js → chunk-VUVCSWMC.js} +2 -2
- package/dist/{chunk-G5XKEUAP.js → chunk-VYNNVUY6.js} +2 -2
- package/dist/cli.js +8 -8
- package/dist/{consensus-vote-VSRNSZ5J.js → consensus-vote-4RIUUEZQ.js} +2 -2
- package/dist/index.d.ts +171 -157
- package/dist/index.js +54 -37
- package/dist/index.js.map +1 -1
- package/dist/{issue-triage-FVZOVIRX.js → issue-triage-VB5CVE43.js} +3 -3
- package/dist/{pr-reviewer-helpers-RBUEJI6V.js → pr-reviewer-helpers-CI72F4XM.js} +3 -3
- package/dist/{setup-command-BMELLUUX.js → setup-command-E35O56BN.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-F47QKVPH.js.map +0 -1
- package/dist/chunk-L6JZCAFH.js.map +0 -1
- package/dist/chunk-NR4NSTJH.js.map +0 -1
- package/dist/chunk-UYOHV3EG.js.map +0 -1
- /package/dist/{chunk-3HVSXLPL.js.map → chunk-MZFWRU6E.js.map} +0 -0
- /package/dist/{chunk-XNBPE6WG.js.map → chunk-VUVCSWMC.js.map} +0 -0
- /package/dist/{chunk-G5XKEUAP.js.map → chunk-VYNNVUY6.js.map} +0 -0
- /package/dist/{consensus-vote-VSRNSZ5J.js.map → consensus-vote-4RIUUEZQ.js.map} +0 -0
- /package/dist/{issue-triage-FVZOVIRX.js.map → issue-triage-VB5CVE43.js.map} +0 -0
- /package/dist/{pr-reviewer-helpers-RBUEJI6V.js.map → pr-reviewer-helpers-CI72F4XM.js.map} +0 -0
- /package/dist/{setup-command-BMELLUUX.js.map → setup-command-E35O56BN.js.map} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CACHE_TIMEOUTS,
|
|
3
|
+
createLogger,
|
|
3
4
|
getTimeProvider
|
|
4
5
|
} from "./chunk-W5I6L4UT.js";
|
|
5
6
|
|
|
@@ -324,6 +325,18 @@ function buildFailClosedResult(err, originalContent, truncated, userRole, allowl
|
|
|
324
325
|
|
|
325
326
|
// src/security/reputation-model.ts
|
|
326
327
|
import { z as z2 } from "zod";
|
|
328
|
+
|
|
329
|
+
// src/security/env-mode.ts
|
|
330
|
+
var defaultLogger = createLogger({ component: "env-mode" });
|
|
331
|
+
function resolveEnvMode(raw, schema, fallback, varName, logger = defaultLogger) {
|
|
332
|
+
if (typeof raw !== "string" || raw.length === 0) return fallback;
|
|
333
|
+
const parsed = schema.safeParse(raw.toLowerCase());
|
|
334
|
+
if (parsed.success) return parsed.data;
|
|
335
|
+
logger.warn(`Invalid ${varName} value \u2014 coercing to default`, { raw, default: fallback });
|
|
336
|
+
return fallback;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// src/security/reputation-model.ts
|
|
327
340
|
var SuspiciousSignalSchema = z2.enum([
|
|
328
341
|
"new_account",
|
|
329
342
|
"no_prior_contributions",
|
|
@@ -504,10 +517,12 @@ function reconcileTrustTier(classifierTier, reputation) {
|
|
|
504
517
|
var ReputationGatingModeSchema = z2.enum(["off", "audit", "enforce"]);
|
|
505
518
|
var DEFAULT_REPUTATION_GATING_MODE = "audit";
|
|
506
519
|
function resolveReputationGatingMode(env = process.env) {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
520
|
+
return resolveEnvMode(
|
|
521
|
+
env["NEXUS_REPUTATION_GATING"],
|
|
522
|
+
ReputationGatingModeSchema,
|
|
523
|
+
DEFAULT_REPUTATION_GATING_MODE,
|
|
524
|
+
"NEXUS_REPUTATION_GATING"
|
|
525
|
+
);
|
|
511
526
|
}
|
|
512
527
|
function gateWithReputation(classifierTier, reputation, mode) {
|
|
513
528
|
const reconciledTier = mode === "off" ? classifierTier : reconcileTrustTier(classifierTier, reputation);
|
|
@@ -528,6 +543,7 @@ function buildReason(role, signals, tier) {
|
|
|
528
543
|
}
|
|
529
544
|
|
|
530
545
|
export {
|
|
546
|
+
resolveEnvMode,
|
|
531
547
|
TrustTierSchema,
|
|
532
548
|
TRUST_TIER_NUMERIC,
|
|
533
549
|
GitHubUserRoleSchema,
|
|
@@ -544,4 +560,4 @@ export {
|
|
|
544
560
|
resolveReputationGatingMode,
|
|
545
561
|
gateWithReputation
|
|
546
562
|
};
|
|
547
|
-
//# sourceMappingURL=chunk-
|
|
563
|
+
//# sourceMappingURL=chunk-27CNQPQ4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/security/trust-types.ts","../src/security/input-sanitizer.ts","../src/security/reputation-model.ts","../src/security/env-mode.ts"],"sourcesContent":["/**\n * nexus-agents/security - Trust Types\n *\n * Zod schemas and TypeScript types for the untrusted input hardening\n * framework. Defines trust tiers, sanitized input, user roles, and\n * injection detection flags.\n *\n * @module security/trust-types\n * (Source: Issue #818, #819 — Phase 1: Input Sanitization)\n */\n\nimport { z } from 'zod';\n\n// ============================================================================\n// Trust Tiers\n// ============================================================================\n\n/**\n * Trust tier classification for input sources.\n * Lower number = higher trust.\n *\n * 1 = Authoritative (repo files, CI, CLAUDE.md, allowlisted maintainers)\n * 2 = Semi-trusted (collaborator issue body, contributor PR metadata)\n * 3 = Untrusted (unknown user comments, non-collaborator issue body)\n * 4 = Hostile (injection patterns, hidden HTML, instruction-like content)\n */\nexport const TrustTierSchema = z.enum(['1', '2', '3', '4']);\nexport type TrustTier = z.infer<typeof TrustTierSchema>;\n\n/** Numeric trust tier for comparisons. Higher number = lower trust. */\nexport const TRUST_TIER_NUMERIC: Record<TrustTier, number> = {\n '1': 1,\n '2': 2,\n '3': 3,\n '4': 4,\n};\n\n// ============================================================================\n// GitHub User Roles\n// ============================================================================\n\n/**\n * GitHub user relationship to the repository.\n */\nexport const GitHubUserRoleSchema = z.enum([\n 'owner',\n 'maintainer',\n 'collaborator',\n 'contributor',\n 'member',\n 'unknown',\n]);\nexport type GitHubUserRole = z.infer<typeof GitHubUserRoleSchema>;\n\n/**\n * Default trust tier mapping for each GitHub role.\n * Can be overridden by injection pattern detection (downgrade only).\n */\nexport const ROLE_DEFAULT_TRUST: Record<GitHubUserRole, TrustTier> = {\n owner: '1',\n maintainer: '1',\n collaborator: '2',\n contributor: '2',\n member: '3',\n unknown: '3',\n};\n\n// ============================================================================\n// Injection Detection\n// ============================================================================\n\n/**\n * Categories of injection patterns detected in content.\n */\nexport const InjectionFlagSchema = z.enum([\n 'authority_claim',\n 'instruction_pattern',\n 'system_prompt_manipulation',\n 'hidden_content',\n 'urgency_manipulation',\n 'fake_conversation',\n 'base64_encoded',\n 'external_link_instruction',\n]);\nexport type InjectionFlag = z.infer<typeof InjectionFlagSchema>;\n\n/**\n * An element stripped during sanitization, preserved for audit trail.\n */\nexport const StrippedElementSchema = z.object({\n /** Type of element stripped. */\n tag: z.string().min(1),\n /** Reason for stripping. */\n reason: z.string().min(1),\n /** Start index in original content. */\n startIndex: z.number().int().nonnegative(),\n /** Length of stripped content. */\n length: z.number().int().positive(),\n});\nexport type StrippedElement = z.infer<typeof StrippedElementSchema>;\n\n// ============================================================================\n// Sanitized Input\n// ============================================================================\n\n/**\n * The result of sanitizing untrusted input.\n * Contains cleaned content, trust classification, and audit data.\n */\nexport const SanitizedInputSchema = z.object({\n /** Sanitized content with dangerous elements removed. */\n content: z.string(),\n /** Original content before sanitization (for audit). */\n originalLength: z.number().int().nonnegative(),\n /** Assigned trust tier based on user role and content analysis. */\n trustTier: TrustTierSchema,\n /** GitHub user role of the input source. */\n userRole: GitHubUserRoleSchema,\n /** Injection patterns detected in content. */\n injectionFlags: z.array(InjectionFlagSchema),\n /** Elements stripped during sanitization (audit trail). */\n strippedElements: z.array(StrippedElementSchema),\n /** Whether any dangerous content was detected and stripped. */\n wasModified: z.boolean(),\n /** Timestamp of sanitization (ISO 8601). */\n sanitizedAt: z.iso.datetime(),\n});\nexport type SanitizedInput = z.infer<typeof SanitizedInputSchema>;\n\n// ============================================================================\n// Configuration\n// ============================================================================\n\n/**\n * Configuration for the input sanitizer.\n */\nexport const SanitizerConfigSchema = z.object({\n /** GitHub usernames that are always Tier 1 (allowlisted maintainers). */\n allowlistedMaintainers: z.array(z.string().min(1)).default([]),\n /** Whether to fail open (log only) or fail closed (block). Phase 1 = open. */\n failOpen: z.boolean().default(true),\n /** Maximum input length before truncation. */\n maxInputLength: z.number().int().positive().default(50_000),\n});\nexport type SanitizerConfig = z.infer<typeof SanitizerConfigSchema>;\n","/**\n * nexus-agents/security - Input Sanitizer\n *\n * Sanitizes untrusted GitHub input by stripping dangerous HTML/XML tags,\n * detecting injection patterns, and producing a SanitizedInput result\n * with full audit trail.\n *\n * Defense layer 1 of the three-layer hardening architecture.\n * See: docs/architecture/UNTRUSTED_INPUT_HARDENING.md\n *\n * @module security/input-sanitizer\n * (Source: Issue #818, #819 — Phase 1: Input Sanitization)\n */\n\nimport type {\n InjectionFlag,\n SanitizedInput,\n SanitizerConfig,\n StrippedElement,\n TrustTier,\n GitHubUserRole,\n} from './trust-types.js';\nimport { ROLE_DEFAULT_TRUST, SanitizerConfigSchema } from './trust-types.js';\n\n// ============================================================================\n// Dangerous HTML Patterns (Trail of Bits / GitHub Copilot vectors)\n// ============================================================================\n\n/**\n * HTML tags to strip. These are known injection vectors:\n * - `<picture>` / `<source>`: Trail of Bits GitHub Copilot injection\n * - `<img>`: Can carry injection via alt text or onerror\n */\nconst DANGEROUS_HTML_PATTERN =\n /<(picture|source|img)\\b[^>]*>[\\s\\S]*?<\\/\\1>|<(picture|source|img)\\b[^>]*\\/?>/gi;\n\n// ============================================================================\n// XML-like Tags (Conversation History Injection)\n// ============================================================================\n\n/**\n * XML-like tags that mimic conversation structure or system prompts.\n */\nconst XML_INJECTION_PATTERN =\n /<\\/?(system|human|assistant|instructions|user|prompt|context|tool_use|tool_result)\\b[^>]*>/gi;\n\n// ============================================================================\n// HTML Comments with Instructions\n// ============================================================================\n\nconst HTML_COMMENT_PATTERN = /<!--[\\s\\S]*?-->/g;\n\n// ============================================================================\n// Injection Pattern Detectors\n// ============================================================================\n\ninterface PatternMatch {\n flag: InjectionFlag;\n pattern: RegExp;\n}\n\nconst INJECTION_PATTERNS: readonly PatternMatch[] = [\n {\n flag: 'authority_claim',\n pattern: /\\b(as (?:a|the) (?:maintainer|admin|owner|security lead|repo owner|developer))\\b/i,\n },\n {\n flag: 'authority_claim',\n pattern: /\\b(i(?:'m| am) the (?:repo |project )?(?:owner|maintainer|admin))\\b/i,\n },\n {\n flag: 'instruction_pattern',\n pattern: /\\b(please (?:close|merge|label|mark|apply|delete|remove|approve|reject))\\b/i,\n },\n {\n flag: 'instruction_pattern',\n pattern: /\\b(you (?:should|must|need to) (?:close|merge|label|apply|delete))\\b/i,\n },\n {\n flag: 'system_prompt_manipulation',\n pattern: /\\b(ignore (?:all )?previous (?:instructions|rules|prompts))\\b/i,\n },\n {\n flag: 'system_prompt_manipulation',\n pattern: /\\b(forget (?:your |all )?(?:instructions|rules|safety))\\b/i,\n },\n {\n flag: 'system_prompt_manipulation',\n pattern: /\\b(new (?:instructions|rules|system prompt|directives))\\b/i,\n },\n {\n flag: 'urgency_manipulation',\n pattern: /\\b(critical|emergency|urgent|must act now|immediately|time[- ]?sensitive)\\b/i,\n },\n {\n flag: 'fake_conversation',\n pattern: /<(?:assistant|human|user|system)>/i,\n },\n // base64_encoded is detected separately by `looksLikeBase64Payload` below.\n // The lookahead-based regex it replaced exhibited catastrophic backtracking\n // on long hex-only inputs (#2191) — see `looksLikeBase64Payload` for the\n // two-phase rewrite that preserves the #1811 SHA-hash false-positive guard.\n {\n flag: 'external_link_instruction',\n pattern: /(?:apply|run|execute|install)\\s+(?:this\\s+)?(?:from\\s+)?https?:\\/\\//i,\n },\n];\n\n/**\n * Two-phase base64-payload detection (#2191).\n *\n * The original `(?=[A-Za-z0-9+/]*[g-zG-Z+/=])[A-Za-z0-9+/]{40,}={0,2}` regex\n * was vulnerable to catastrophic backtracking — V8 took ~1.8s on a 50K\n * hex-only adversarial input. Splitting the check into two non-overlapping\n * phases removes the lookahead and makes the worst case linear.\n *\n * Phase 1: find a 40+ run of base64-alphabet chars (no lookahead).\n * Phase 2: confirm the matched substring contains a base64-discriminating\n * char (g-z, G-Z, +, /, =) so SHA-1 / SHA-256 hex hashes don't\n * false-positive (preserves #1811 behavior).\n *\n * Same detection coverage as the original; same false-positive resistance.\n */\nconst BASE64_RUN_GLOBAL = /[A-Za-z0-9+/]{40,}={0,2}/g;\nconst BASE64_DISCRIMINATOR = /[g-zG-Z+/=]/;\n\nfunction looksLikeBase64Payload(content: string): boolean {\n // Iterate every 40+ base64-alphabet run rather than just the first one,\n // so a long hex-only prefix doesn't mask a real base64 payload that\n // appears later in the content.\n for (const match of content.matchAll(BASE64_RUN_GLOBAL)) {\n if (BASE64_DISCRIMINATOR.test(match[0])) return true;\n }\n return false;\n}\n\n// ============================================================================\n// HTML Entity Decoding (evasion defense)\n// ============================================================================\n\n/**\n * Dangerous-tag names we will still match after entity decoding.\n * Kept in sync with DANGEROUS_HTML_PATTERN and XML_INJECTION_PATTERN above.\n */\nconst DANGEROUS_TAG_NAMES =\n 'picture|source|img|system|human|assistant|instructions|user|prompt|context|tool_use|tool_result';\n\n/**\n * Detects whether the input contains entity-encoded forms of any dangerous\n * tag (<picture, <system, <img …). Used as a cheap pre-check so\n * that benign content with legitimate entities (e.g. \"AT&T\") is passed\n * through untouched and wasModified stays false.\n */\nconst ENCODED_DANGEROUS_TAG_PATTERN = new RegExp(\n `&(?:lt|#0*60|#x0*3c);\\\\s*\\\\/?\\\\s*(?:${DANGEROUS_TAG_NAMES})\\\\b`,\n 'i'\n);\n\n/** Decodes the subset of HTML entities that can reconstruct tag syntax. */\nfunction decodeEntities(content: string): string {\n return (\n content\n // Numeric (decimal) references\n .replace(/&#(\\d+);/g, (_match, dec: string) => {\n const code = Number.parseInt(dec, 10);\n return Number.isFinite(code) ? String.fromCodePoint(code) : _match;\n })\n // Numeric (hex) references\n .replace(/&#x([0-9a-f]+);/gi, (_match, hex: string) => {\n const code = Number.parseInt(hex, 16);\n return Number.isFinite(code) ? String.fromCodePoint(code) : _match;\n })\n // Named entities most relevant to tag reconstruction\n .replace(/</gi, '<')\n .replace(/>/gi, '>')\n .replace(/"/gi, '\"')\n .replace(/'/gi, \"'\")\n // & must be decoded last so that &lt; does not resurface as <\n .replace(/&/gi, '&')\n );\n}\n\n/**\n * Runs decodeEntities only if the input contains an entity-encoded dangerous\n * tag. This keeps benign content with legitimate entities untouched.\n */\nfunction applyEntityEvasionDefense(content: string): {\n cleaned: string;\n stripped: StrippedElement[];\n} {\n if (!ENCODED_DANGEROUS_TAG_PATTERN.test(content)) {\n return { cleaned: content, stripped: [] };\n }\n const decoded = decodeEntities(content);\n return {\n cleaned: decoded,\n stripped: [\n {\n tag: '&…;',\n reason: 'HTML entity-encoded dangerous tag decoded for stripping (CWE-79)',\n startIndex: 0,\n length: content.length,\n },\n ],\n };\n}\n\n// ============================================================================\n// Core Sanitization Functions\n// ============================================================================\n\n/** Strips dangerous HTML tags and records what was removed.\n * Loops until stable to prevent reconstructed patterns after removal (#1496). */\nfunction stripDangerousHtml(content: string): {\n cleaned: string;\n stripped: StrippedElement[];\n} {\n const stripped: StrippedElement[] = [];\n let cleaned = content;\n const MAX_PASSES = 5;\n for (let pass = 0; pass < MAX_PASSES; pass++) {\n DANGEROUS_HTML_PATTERN.lastIndex = 0;\n if (!DANGEROUS_HTML_PATTERN.test(cleaned)) break;\n cleaned = cleaned.replace(DANGEROUS_HTML_PATTERN, (match, _g1, _g2, offset: number) => {\n stripped.push({\n tag: match.slice(0, 30) + (match.length > 30 ? '...' : ''),\n reason: 'Dangerous HTML tag (Trail of Bits injection vector)',\n startIndex: offset,\n length: match.length,\n });\n return '';\n });\n }\n return { cleaned, stripped };\n}\n\n/** Strips XML-like tags that mimic conversation structure.\n * Loops until stable to prevent reconstructed patterns after removal (#1496). */\nfunction stripXmlTags(content: string): {\n cleaned: string;\n stripped: StrippedElement[];\n} {\n const stripped: StrippedElement[] = [];\n let cleaned = content;\n const MAX_PASSES = 5;\n for (let pass = 0; pass < MAX_PASSES; pass++) {\n XML_INJECTION_PATTERN.lastIndex = 0;\n if (!XML_INJECTION_PATTERN.test(cleaned)) break;\n cleaned = cleaned.replace(XML_INJECTION_PATTERN, (match, _g1, offset: number) => {\n stripped.push({\n tag: match,\n reason: 'XML-like conversation injection tag',\n startIndex: offset,\n length: match.length,\n });\n return '';\n });\n }\n return { cleaned, stripped };\n}\n\n/** Strips HTML comments that may contain hidden instructions.\n * Loops until stable to prevent reconstructed comment patterns (#1496). */\nfunction stripHtmlComments(content: string): {\n cleaned: string;\n stripped: StrippedElement[];\n} {\n const stripped: StrippedElement[] = [];\n let cleaned = content;\n // Loop until stable: stripping may reveal new instruction-bearing comments\n const MAX_PASSES = 5;\n for (let pass = 0; pass < MAX_PASSES; pass++) {\n HTML_COMMENT_PATTERN.lastIndex = 0;\n const prevLength = cleaned.length;\n cleaned = cleaned.replace(HTML_COMMENT_PATTERN, (match, offset: number) => {\n const hasInstruction = /\\b(ignore|execute|close|merge|delete|apply)\\b/i.test(match);\n if (!hasInstruction) return match;\n\n stripped.push({\n tag: '<!-- ... -->',\n reason: 'HTML comment with instruction-like content',\n startIndex: offset,\n length: match.length,\n });\n return '';\n });\n if (cleaned.length === prevLength) break;\n }\n // Second pass: strip unclosed <!-- tags (incomplete comment injection)\n let searchFrom = 0;\n while (searchFrom < cleaned.length) {\n const openIdx = cleaned.indexOf('<!--', searchFrom);\n if (openIdx === -1) break;\n const closeIdx = cleaned.indexOf('-->', openIdx + 4);\n if (closeIdx === -1) {\n stripped.push({\n tag: '<!--',\n reason: 'Unclosed HTML comment (potential injection vector)',\n startIndex: openIdx,\n length: cleaned.length - openIdx,\n });\n cleaned = cleaned.slice(0, openIdx);\n break;\n }\n searchFrom = closeIdx + 3;\n }\n return { cleaned, stripped };\n}\n\n/** Detects injection patterns in content without modifying it. */\nfunction detectInjectionPatterns(content: string): InjectionFlag[] {\n const flags = new Set<InjectionFlag>();\n for (const { flag, pattern } of INJECTION_PATTERNS) {\n // Reset lastIndex for global patterns\n pattern.lastIndex = 0;\n if (pattern.test(content)) {\n flags.add(flag);\n }\n }\n if (looksLikeBase64Payload(content)) {\n flags.add('base64_encoded');\n }\n return Array.from(flags);\n}\n\n/** Lower-cases an arbitrary role literal and maps it to a known role. */\nfunction normalizeRole(userRole: string): GitHubUserRole {\n const lower = userRole.toLowerCase();\n if (lower in ROLE_DEFAULT_TRUST) return lower as GitHubUserRole;\n return 'unknown';\n}\n\n/**\n * Assigns trust tier based on user role and injection analysis.\n * Injection patterns can only DOWNGRADE trust, never upgrade.\n */\nfunction assignTrustTier(\n userRole: GitHubUserRole,\n injectionFlags: readonly InjectionFlag[],\n allowlisted: boolean\n): TrustTier {\n if (allowlisted) return '1';\n\n // Defensive lowercase — the type says GitHubUserRole, but callers\n // sometimes cast an unnormalized GitHub author_association literal\n // (e.g. 'OWNER', 'MEMBER') directly. Normalize here so the maintainer\n // exemption below matches regardless of case (CWE-178).\n const normalizedRole = normalizeRole(userRole);\n const baseTier = ROLE_DEFAULT_TRUST[normalizedRole];\n\n // Content with injection patterns is downgraded to Tier 4 (hostile)\n const hostileFlags: InjectionFlag[] = ['system_prompt_manipulation', 'fake_conversation'];\n if (injectionFlags.some((f) => hostileFlags.includes(f))) return '4';\n\n // Content with authority claims from non-maintainers is suspicious\n if (\n injectionFlags.includes('authority_claim') &&\n normalizedRole !== 'owner' &&\n normalizedRole !== 'maintainer'\n ) {\n return '4';\n }\n\n return baseTier;\n}\n\n// ============================================================================\n// Public API\n// ============================================================================\n\n/**\n * Sanitizes untrusted GitHub input through the full Layer 1 pipeline:\n * 1. HTML stripping (picture/source/img tags)\n * 2. XML tag stripping (system/human/assistant)\n * 3. HTML comment stripping (instruction-bearing comments only)\n * 4. Injection pattern detection\n * 5. Trust tier assignment\n *\n * ⚠ **Use HostileInputFirewall.process() in agent code paths.** Calling\n * sanitizeInput() directly only runs Layer 1 — it does not evaluate the\n * Rule of Two (enforced in policy-gate.ts via evaluatePolicy) and does\n * not emit audit-trail events. An agent that processes untrusted input\n * while holding both write access and secrets violates the Rule of Two;\n * the policy gate is what catches this, and it only runs inside the\n * firewall pipeline. Direct use of this function is appropriate for\n * unit tests and pure content analysis, not for agent decision paths.\n *\n * @see packages/nexus-agents/src/security/firewall/firewall-pipeline.ts\n * @see packages/nexus-agents/src/security/policy-gate.ts\n * @param content - Raw untrusted content from GitHub\n * @param userRole - GitHub user's relationship to the repository\n * @param username - GitHub username (for allowlist check)\n * @param config - Optional sanitizer configuration\n * @returns SanitizedInput with cleaned content and audit data\n */\nexport function sanitizeInput(\n content: string,\n userRole: GitHubUserRole,\n username: string,\n config?: Partial<SanitizerConfig>\n): SanitizedInput {\n const cfg = SanitizerConfigSchema.parse(config ?? {});\n const truncated = content.slice(0, cfg.maxInputLength);\n const allowlisted = cfg.allowlistedMaintainers.includes(username);\n\n try {\n // Pipeline: decode entity-encoded dangerous tags, then strip dangerous content\n const entityDecoded = applyEntityEvasionDefense(truncated);\n const html = stripDangerousHtml(entityDecoded.cleaned);\n const xml = stripXmlTags(html.cleaned);\n const comments = stripHtmlComments(xml.cleaned);\n const allStripped = [\n ...entityDecoded.stripped,\n ...html.stripped,\n ...xml.stripped,\n ...comments.stripped,\n ];\n\n // Detect injection patterns on ORIGINAL content (before stripping)\n const injectionFlags = detectInjectionPatterns(truncated);\n\n // Assign trust tier\n const trustTier = assignTrustTier(userRole, injectionFlags, allowlisted);\n\n return {\n content: comments.cleaned,\n originalLength: content.length,\n trustTier,\n userRole,\n injectionFlags,\n strippedElements: allStripped,\n wasModified: allStripped.length > 0,\n sanitizedAt: new Date().toISOString(),\n };\n } catch (err: unknown) {\n return buildFailClosedResult(err, content, truncated, userRole, allowlisted);\n }\n}\n\n/**\n * Fail-closed result returned when the sanitizer pipeline throws.\n * Returns empty content at Tier-4 (or Tier-1 for allowlisted maintainers,\n * since their bypass is not regex-dependent) so downstream consumers\n * cannot act on untrusted content we could not validate.\n * CLAUDE.md: \"Fail closed on ambiguity.\"\n */\nfunction buildFailClosedResult(\n err: unknown,\n originalContent: string,\n truncated: string,\n userRole: GitHubUserRole,\n allowlisted: boolean\n): SanitizedInput {\n const message = err instanceof Error ? err.message : String(err);\n return {\n content: '',\n originalLength: originalContent.length,\n trustTier: allowlisted ? '1' : '4',\n userRole,\n injectionFlags: [],\n strippedElements: [\n {\n tag: '(pipeline-failure)',\n reason: `Sanitizer pipeline threw; input discarded as fail-closed: ${message}`,\n startIndex: 0,\n length: truncated.length,\n },\n ],\n wasModified: true,\n sanitizedAt: new Date().toISOString(),\n };\n}\n","/**\n * nexus-agents/security - Reputation Model\n *\n * Lightweight trust model for GitHub users that assesses reputation\n * based on account age, contribution history, and behavioral signals.\n * Integrates with the trust classifier for comprehensive trust assessment.\n *\n * @module security/reputation-model\n * (Source: Issue #818, #824 — Phase 3: Reputation Model)\n */\n\nimport { z } from 'zod';\n\nimport { getTimeProvider } from '../core/index.js';\nimport { resolveEnvMode } from './env-mode.js';\nimport type { TrustTier, GitHubUserRole, InjectionFlag } from './trust-types.js';\nimport { TRUST_TIER_NUMERIC, ROLE_DEFAULT_TRUST } from './trust-types.js';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Signals that indicate a suspicious actor.\n */\nexport const SuspiciousSignalSchema = z.enum([\n 'new_account',\n 'no_prior_contributions',\n 'injection_patterns_detected',\n 'rapid_comments',\n 'mismatched_authority_claim',\n]);\nexport type SuspiciousSignal = z.infer<typeof SuspiciousSignalSchema>;\n\n/**\n * GitHub user metadata for reputation assessment.\n */\nexport interface GitHubUserMetadata {\n readonly username: string;\n /**\n * Account/activity fields are OPTIONAL (#3106). When a field is absent (the\n * caller couldn't fetch it — e.g. the firewall before Phase 3 wiring), its\n * signal is SKIPPED rather than fabricated: an unknown value must never be\n * treated as benign (the old hardcoded `365`/`0`) nor as hostile. Only the\n * `authorAssociation` + `injectionFlags` signals fire on absent activity data.\n */\n readonly accountAgeDays?: number;\n readonly priorContributions?: number;\n readonly recentCommentCount?: number;\n readonly recentCommentWindowMinutes?: number;\n readonly authorAssociation: string;\n readonly injectionFlags: readonly InjectionFlag[];\n}\n\n/**\n * Result of a reputation assessment.\n */\nexport interface ReputationAssessment {\n readonly username: string;\n readonly userRole: GitHubUserRole;\n readonly suspiciousSignals: readonly SuspiciousSignal[];\n readonly isSuspicious: boolean;\n readonly effectiveTrustTier: TrustTier;\n readonly reputationScore: number;\n readonly reason: string;\n readonly assessedAt: string;\n}\n\n// ============================================================================\n// Configuration\n// ============================================================================\n\n/** Thresholds for suspicious behavior detection. */\n/** Approximate days per year, used to normalize account age to a 0–10 scale. */\nconst DAYS_PER_YEAR_APPROX = 36.5;\n\nconst SUSPICIOUS_THRESHOLDS = {\n /** Account younger than this (days) is flagged. */\n newAccountDays: 30,\n /** Fewer contributions than this is flagged. */\n minContributions: 1,\n /** More comments than this in the window triggers rapid-comment flag. */\n rapidCommentThreshold: 5,\n /** Time window (minutes) for rapid comment detection. */\n rapidCommentWindowMinutes: 10,\n} as const;\n\n// ============================================================================\n// Reputation Cache\n// ============================================================================\n\ninterface CacheEntry {\n assessment: ReputationAssessment;\n expiresAt: number;\n}\n\n// Canonical source: config/timeouts.ts (Issue #1046)\nimport { CACHE_TIMEOUTS } from '../config/timeouts.js';\n\nconst DEFAULT_TTL_MS: number = CACHE_TIMEOUTS.reputationTtlMs;\nconst DEFAULT_MAX_SIZE = 1000;\n\n/**\n * In-memory reputation cache with TTL and max size.\n * Reduces redundant assessments for the same user within a short window.\n * Evicts oldest entries when max size is exceeded.\n */\nexport class ReputationCache {\n private readonly cache = new Map<string, CacheEntry>();\n private readonly ttlMs: number;\n private readonly maxSize: number;\n\n constructor(ttlMs = DEFAULT_TTL_MS, maxSize = DEFAULT_MAX_SIZE) {\n this.ttlMs = ttlMs;\n this.maxSize = maxSize;\n }\n\n get(username: string): ReputationAssessment | undefined {\n const entry = this.cache.get(username);\n if (entry === undefined) return undefined;\n if (getTimeProvider().now() > entry.expiresAt) {\n this.cache.delete(username);\n return undefined;\n }\n return entry.assessment;\n }\n\n set(username: string, assessment: ReputationAssessment): void {\n if (this.cache.size >= this.maxSize && !this.cache.has(username)) {\n this.evictOldest();\n }\n this.cache.set(username, {\n assessment,\n expiresAt: getTimeProvider().now() + this.ttlMs,\n });\n }\n\n /** Evict a batch of oldest entries (10% of maxSize, minimum 1). */\n private evictOldest(): void {\n const batchSize = Math.max(1, Math.floor(this.maxSize * 0.1));\n const keys = this.cache.keys();\n for (let i = 0; i < batchSize; i++) {\n const next = keys.next();\n if (next.done === true) break;\n this.cache.delete(next.value);\n }\n }\n\n clear(): void {\n this.cache.clear();\n }\n\n get size(): number {\n return this.cache.size;\n }\n}\n\n// ============================================================================\n// Suspicious Signal Detection\n// ============================================================================\n\n/** Only hostile-tier injection flags count — benign flags like\n * instruction_pattern (\"please remove\") must not trip the injection signal. */\nconst HOSTILE_INJECTION_FLAGS: readonly InjectionFlag[] = [\n 'system_prompt_manipulation',\n 'fake_conversation',\n 'authority_claim',\n 'hidden_content',\n];\n\nfunction hasHostileInjection(flags: readonly InjectionFlag[]): boolean {\n return flags.some((f) => HOSTILE_INJECTION_FLAGS.includes(f));\n}\n\n/** Rapid-comment burst — only when both count and window are known (#3106). */\nfunction isRapidCommenting(m: GitHubUserMetadata): boolean {\n return (\n m.recentCommentCount !== undefined &&\n m.recentCommentWindowMinutes !== undefined &&\n m.recentCommentCount > SUSPICIOUS_THRESHOLDS.rapidCommentThreshold &&\n m.recentCommentWindowMinutes <= SUSPICIOUS_THRESHOLDS.rapidCommentWindowMinutes\n );\n}\n\n/** Authority claim from a non-maintainer role. */\nfunction isMismatchedAuthority(m: GitHubUserMetadata): boolean {\n if (!m.injectionFlags.includes('authority_claim')) return false;\n const association = m.authorAssociation.toUpperCase();\n return association !== 'OWNER' && association !== 'MEMBER';\n}\n\n/** Detect all suspicious signals from user metadata. #3106: account/activity\n * signals are skipped when their data is absent — never fabricated. */\nfunction detectSuspiciousSignals(metadata: GitHubUserMetadata): SuspiciousSignal[] {\n const signals: SuspiciousSignal[] = [];\n const { accountAgeDays, priorContributions } = metadata;\n\n if (accountAgeDays !== undefined && accountAgeDays < SUSPICIOUS_THRESHOLDS.newAccountDays) {\n signals.push('new_account');\n }\n if (\n priorContributions !== undefined &&\n priorContributions < SUSPICIOUS_THRESHOLDS.minContributions\n ) {\n signals.push('no_prior_contributions');\n }\n if (hasHostileInjection(metadata.injectionFlags)) signals.push('injection_patterns_detected');\n if (isRapidCommenting(metadata)) signals.push('rapid_comments');\n if (isMismatchedAuthority(metadata)) signals.push('mismatched_authority_claim');\n\n return signals;\n}\n\n/** Calculate a 0-100 reputation score. */\nfunction calculateReputationScore(\n metadata: GitHubUserMetadata,\n signals: readonly SuspiciousSignal[],\n userRole: GitHubUserRole\n): number {\n let score = 50; // baseline\n\n // Role bonus\n const roleBonus: Record<GitHubUserRole, number> = {\n owner: 40,\n maintainer: 35,\n collaborator: 25,\n contributor: 15,\n member: 5,\n unknown: 0,\n };\n score += roleBonus[userRole];\n\n // Account age bonus (max +10). #3106: absent → no bonus (avoid NaN; an\n // unknown account neither earns nor loses the age bonus).\n if (metadata.accountAgeDays !== undefined) {\n score += Math.min(metadata.accountAgeDays / DAYS_PER_YEAR_APPROX, 10);\n }\n\n // Contribution bonus (max +10). #3106: absent → no bonus.\n if (metadata.priorContributions !== undefined) {\n score += Math.min(metadata.priorContributions, 10);\n }\n\n // Suspicious signal penalties\n const signalPenalty: Record<SuspiciousSignal, number> = {\n new_account: -15,\n no_prior_contributions: -10,\n injection_patterns_detected: -25,\n rapid_comments: -20,\n mismatched_authority_claim: -30,\n };\n for (const signal of signals) {\n score += signalPenalty[signal];\n }\n\n return Math.max(0, Math.min(100, Math.round(score)));\n}\n\n/** Map role string to GitHubUserRole. */\nfunction mapRole(association: string): GitHubUserRole {\n switch (association.toUpperCase()) {\n case 'OWNER':\n return 'owner';\n case 'MEMBER':\n return 'member';\n case 'COLLABORATOR':\n return 'collaborator';\n case 'CONTRIBUTOR':\n return 'contributor';\n default:\n return 'unknown';\n }\n}\n\n/** Determine effective trust tier from signals and role. */\nfunction determineEffectiveTier(\n userRole: GitHubUserRole,\n signals: readonly SuspiciousSignal[]\n): TrustTier {\n const baseTier = ROLE_DEFAULT_TRUST[userRole];\n\n // Hostile signals → Tier 4\n const hostileSignals: SuspiciousSignal[] = [\n 'injection_patterns_detected',\n 'mismatched_authority_claim',\n ];\n if (signals.some((s) => hostileSignals.includes(s))) return '4';\n\n // Multiple suspicious signals → downgrade by 1\n if (signals.length >= 2) {\n const baseNumeric = TRUST_TIER_NUMERIC[baseTier];\n const downgraded = Math.min(baseNumeric + 1, 4);\n return String(downgraded) as TrustTier;\n }\n\n return baseTier;\n}\n\n// ============================================================================\n// Public API\n// ============================================================================\n\n/**\n * Assess a GitHub user's reputation for trust classification.\n *\n * @param metadata - User metadata from GitHub API or local context.\n * @param cache - Optional cache instance for TTL-based deduplication.\n * @returns ReputationAssessment with trust tier and suspicious signals.\n */\nexport function assessReputation(\n metadata: GitHubUserMetadata,\n cache?: ReputationCache\n): ReputationAssessment {\n // Check cache first\n const cached = cache?.get(metadata.username);\n if (cached !== undefined) return cached;\n\n const userRole = mapRole(metadata.authorAssociation);\n const signals = detectSuspiciousSignals(metadata);\n const score = calculateReputationScore(metadata, signals, userRole);\n const effectiveTier = determineEffectiveTier(userRole, signals);\n\n const assessment: ReputationAssessment = {\n username: metadata.username,\n userRole,\n suspiciousSignals: signals,\n isSuspicious: signals.length > 0,\n effectiveTrustTier: effectiveTier,\n reputationScore: score,\n reason: buildReason(userRole, signals, effectiveTier),\n assessedAt: new Date().toISOString(),\n };\n\n cache?.set(metadata.username, assessment);\n return assessment;\n}\n\n/**\n * Reconcile a trust-classifier tier with a reputation assessment into the\n * effective tier to enforce (#3119 / epic #3118). Demotion-only — reputation\n * can only RAISE the tier number (more restrictive), never lower it.\n *\n * Invariants:\n * - **Allowlist/Tier-1 wins**: a classifier Tier 1 (owner/allowlisted maintainer)\n * is authoritative — reputation never demotes it.\n * - **Absent reputation → classifier tier**: no assessment (stage off / not\n * fetched) keeps the classifier/role-default tier — never fabricate a benign\n * tier, never escalate on mere absence (fetch-failure ≠ hostile signal).\n * - **Score is advisory**: only `effectiveTrustTier` participates; the 0–100\n * `reputationScore` never moves the gate.\n */\nexport function reconcileTrustTier(\n classifierTier: TrustTier,\n reputation: ReputationAssessment | undefined\n): TrustTier {\n if (classifierTier === '1') return '1';\n const repTier = reputation?.effectiveTrustTier;\n if (repTier === undefined) return classifierTier;\n return TRUST_TIER_NUMERIC[repTier] > TRUST_TIER_NUMERIC[classifierTier]\n ? repTier\n : classifierTier;\n}\n\n// ============================================================================\n// Reputation gating rollout (#3122 / epic #3118 Phase 4)\n// ============================================================================\n\n/**\n * Rollout mode for reputation-based tier gating, mirroring\n * `NEXUS_ACCESS_POLICY_MODE` (#1977): `off` (no reputation effect), `audit`\n * (compute + report the would-be demotion but enforce the classifier tier), or\n * `enforce` (apply the demotion). Default `audit` — surface telemetry without\n * blocking until the false-positive rate is known, then flip to `enforce`.\n */\nexport const ReputationGatingModeSchema = z.enum(['off', 'audit', 'enforce']);\nexport type ReputationGatingMode = z.infer<typeof ReputationGatingModeSchema>;\n\n/** Default when `NEXUS_REPUTATION_GATING` is unset/invalid — audit (telemetry, no block). */\nexport const DEFAULT_REPUTATION_GATING_MODE: ReputationGatingMode = 'audit';\n\n/**\n * Resolve the gating mode from the environment (invalid → default + warn, never\n * throws — #3130). Delegates to the shared `resolveEnvMode` so this flag and\n * `NEXUS_ACCESS_POLICY_MODE` coerce identically.\n */\nexport function resolveReputationGatingMode(\n env: NodeJS.ProcessEnv = process.env\n): ReputationGatingMode {\n return resolveEnvMode(\n env['NEXUS_REPUTATION_GATING'],\n ReputationGatingModeSchema,\n DEFAULT_REPUTATION_GATING_MODE,\n 'NEXUS_REPUTATION_GATING'\n );\n}\n\n/** Outcome of applying the gating mode to a reputation assessment. */\nexport interface ReputationGateDecision {\n /** Tier to actually enforce at the policy gate. */\n readonly enforcedTier: TrustTier;\n /** Tier reputation reconciliation computed (what `enforce` mode WOULD use). */\n readonly reconciledTier: TrustTier;\n /** True when reputation would demote but the mode (off/audit) did not enforce it. */\n readonly demotionSuppressed: boolean;\n readonly mode: ReputationGatingMode;\n}\n\n/**\n * Apply the rollout mode to a reputation assessment (#3122). `enforce` gates on\n * the reconciled (possibly demoted) tier; `audit`/`off` gate on the classifier\n * tier but report whether a demotion was suppressed (for telemetry). The\n * Tier-1/allowlist-wins and demotion-only invariants live in `reconcileTrustTier`,\n * so the allowlist remains the escape hatch in every mode.\n */\nexport function gateWithReputation(\n classifierTier: TrustTier,\n reputation: ReputationAssessment | undefined,\n mode: ReputationGatingMode\n): ReputationGateDecision {\n const reconciledTier =\n mode === 'off' ? classifierTier : reconcileTrustTier(classifierTier, reputation);\n const enforcedTier = mode === 'enforce' ? reconciledTier : classifierTier;\n return {\n enforcedTier,\n reconciledTier,\n demotionSuppressed: mode !== 'enforce' && reconciledTier !== classifierTier,\n mode,\n };\n}\n\n/** Build a human-readable reason string. */\nfunction buildReason(\n role: GitHubUserRole,\n signals: readonly SuspiciousSignal[],\n tier: TrustTier\n): string {\n if (signals.length === 0) {\n return `Role ${role} → Tier ${tier} (no suspicious signals)`;\n }\n const signalList = signals.join(', ');\n return `Role ${role} → Tier ${tier} (signals: ${signalList})`;\n}\n","/**\n * Shared resolver for `off`/`audit`/`enforce`-style security-mode env vars\n * (#3130). Both `resolveAccessPolicyMode` (ClawGuard, #1977) and\n * `resolveReputationGatingMode` (reputation gating, #3122) parse an enum env\n * var, coerce an invalid value to a safe default, and must NEVER throw — a\n * security layer must not fail-closed on a misconfiguration at startup.\n *\n * Previously the coercion was silent: a typo'd `enforce` (`enfroce`) degraded\n * to the default with no signal. This helper keeps the never-throw coercion but\n * emits a one-line `warn` so the misconfiguration is observable, and guarantees\n * both flags behave identically.\n *\n * @module security/env-mode\n */\n\nimport type { ZodType } from 'zod';\nimport { createLogger } from '../core/index.js';\nimport type { ILogger } from '../core/index.js';\n\nconst defaultLogger = createLogger({ component: 'env-mode' });\n\n/**\n * Resolve an enum-valued env var to one of its allowed values, coercing an\n * invalid/typo'd value to `fallback`. Unset or empty → `fallback` silently\n * (absence is normal, not a misconfiguration). A non-empty value that fails to\n * parse → `fallback` plus a `warn` (an explicit-but-invalid value is an operator\n * error worth surfacing). Never throws.\n *\n * @param raw The raw env value (e.g. `process.env['NEXUS_X']`).\n * @param schema Zod enum schema for the allowed values.\n * @param fallback Default returned when `raw` is absent/empty/invalid.\n * @param varName Env var name, for the warning message.\n * @param logger Injectable for testing (defaults to the module logger).\n */\nexport function resolveEnvMode<T extends string>(\n raw: string | undefined,\n schema: ZodType<T>,\n fallback: T,\n varName: string,\n logger: ILogger = defaultLogger\n): T {\n if (typeof raw !== 'string' || raw.length === 0) return fallback;\n const parsed = schema.safeParse(raw.toLowerCase());\n if (parsed.success) return parsed.data;\n logger.warn(`Invalid ${varName} value — coercing to default`, { raw, default: fallback });\n return fallback;\n}\n"],"mappings":";;;;;;;AAWA,SAAS,SAAS;AAeX,IAAM,kBAAkB,EAAE,KAAK,CAAC,KAAK,KAAK,KAAK,GAAG,CAAC;AAInD,IAAM,qBAAgD;AAAA,EAC3D,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EAC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,EACpC;AACA,QAAM,aAAa,QAAQ,KAAK,IAAI;AACpC,SAAO,QAAQ,IAAI,gBAAW,IAAI,cAAc,UAAU;AAC5D;","names":["z","z"]}
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
writeJobComplete,
|
|
43
43
|
writeJobFailed,
|
|
44
44
|
writeJobPending
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-JCYCITBK.js";
|
|
46
46
|
import {
|
|
47
47
|
REGISTRY_PATH,
|
|
48
48
|
getProjectRoot,
|
|
@@ -53,11 +53,14 @@ import {
|
|
|
53
53
|
synthesizeResearch
|
|
54
54
|
} from "./chunk-CGSVTROC.js";
|
|
55
55
|
import {
|
|
56
|
-
IssueTriage
|
|
57
|
-
|
|
56
|
+
IssueTriage,
|
|
57
|
+
createAuditTrail,
|
|
58
|
+
createGraphAuditBridge
|
|
59
|
+
} from "./chunk-IHPYT6WU.js";
|
|
58
60
|
import {
|
|
61
|
+
resolveEnvMode,
|
|
59
62
|
sanitizeInput
|
|
60
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-27CNQPQ4.js";
|
|
61
64
|
import {
|
|
62
65
|
generateSecurityPlan
|
|
63
66
|
} from "./chunk-57HMLBYN.js";
|
|
@@ -84,7 +87,7 @@ import {
|
|
|
84
87
|
DEFAULT_TASK_TTL_MS,
|
|
85
88
|
DEFAULT_TOOL_RATE_LIMITS,
|
|
86
89
|
clampTaskTtl
|
|
87
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-MZFWRU6E.js";
|
|
88
91
|
import {
|
|
89
92
|
getAvailabilityCache,
|
|
90
93
|
resolveFallback
|
|
@@ -32544,10 +32547,12 @@ var TaskAccessPolicySchema = z53.object({
|
|
|
32544
32547
|
// src/security/access-constraint-deriver/config.ts
|
|
32545
32548
|
var DEFAULT_ACCESS_POLICY_MODE = "audit";
|
|
32546
32549
|
function resolveAccessPolicyMode(env = process.env) {
|
|
32547
|
-
|
|
32548
|
-
|
|
32549
|
-
|
|
32550
|
-
|
|
32550
|
+
return resolveEnvMode(
|
|
32551
|
+
env["NEXUS_ACCESS_POLICY_MODE"],
|
|
32552
|
+
AccessPolicyModeSchema,
|
|
32553
|
+
DEFAULT_ACCESS_POLICY_MODE,
|
|
32554
|
+
"NEXUS_ACCESS_POLICY_MODE"
|
|
32555
|
+
);
|
|
32551
32556
|
}
|
|
32552
32557
|
|
|
32553
32558
|
// src/security/access-constraint-deriver/deriver.ts
|
|
@@ -39231,149 +39236,6 @@ function recordTriageOutcome(success, durationMs, errorMsg) {
|
|
|
39231
39236
|
}
|
|
39232
39237
|
}
|
|
39233
39238
|
|
|
39234
|
-
// src/security/audit-trail.ts
|
|
39235
|
-
var MAX_EVENTS = 1e4;
|
|
39236
|
-
var MAX_STRIPPED_ELEMENTS_PER_EVENT = 20;
|
|
39237
|
-
var AuditTrail = class {
|
|
39238
|
-
events = [];
|
|
39239
|
-
nextId = 1;
|
|
39240
|
-
/** Appends an event to the trail. Returns the assigned event ID. */
|
|
39241
|
-
append(event) {
|
|
39242
|
-
const id = `audit-${String(this.nextId++)}`;
|
|
39243
|
-
const fullEvent = {
|
|
39244
|
-
...event,
|
|
39245
|
-
id,
|
|
39246
|
-
timestamp: getTimeProvider().nowIso()
|
|
39247
|
-
};
|
|
39248
|
-
this.events.push(fullEvent);
|
|
39249
|
-
this.enforceLimit();
|
|
39250
|
-
return id;
|
|
39251
|
-
}
|
|
39252
|
-
/** Queries events matching the given filter. */
|
|
39253
|
-
query(filter = {}) {
|
|
39254
|
-
let results = this.events;
|
|
39255
|
-
if (filter.type !== void 0) {
|
|
39256
|
-
results = results.filter((e) => e.type === filter.type);
|
|
39257
|
-
}
|
|
39258
|
-
if (filter.since !== void 0) {
|
|
39259
|
-
results = filterSince(results, filter.since);
|
|
39260
|
-
}
|
|
39261
|
-
if (filter.until !== void 0) {
|
|
39262
|
-
results = filterUntil(results, filter.until);
|
|
39263
|
-
}
|
|
39264
|
-
if (filter.trustTier !== void 0) {
|
|
39265
|
-
results = filterByTrustTier(results, filter.trustTier);
|
|
39266
|
-
}
|
|
39267
|
-
const limit = filter.limit ?? results.length;
|
|
39268
|
-
return results.slice(-limit);
|
|
39269
|
-
}
|
|
39270
|
-
/** Returns the total number of events. */
|
|
39271
|
-
get size() {
|
|
39272
|
-
return this.events.length;
|
|
39273
|
-
}
|
|
39274
|
-
/** Clears all events. */
|
|
39275
|
-
clear() {
|
|
39276
|
-
this.events = [];
|
|
39277
|
-
}
|
|
39278
|
-
/** Enforces MAX_EVENTS bound. */
|
|
39279
|
-
enforceLimit() {
|
|
39280
|
-
if (this.events.length > MAX_EVENTS) {
|
|
39281
|
-
this.events = this.events.slice(-MAX_EVENTS);
|
|
39282
|
-
}
|
|
39283
|
-
}
|
|
39284
|
-
};
|
|
39285
|
-
function filterSince(events, since) {
|
|
39286
|
-
const sinceTime = new Date(since).getTime();
|
|
39287
|
-
return events.filter((e) => new Date(e.timestamp).getTime() >= sinceTime);
|
|
39288
|
-
}
|
|
39289
|
-
function filterUntil(events, until) {
|
|
39290
|
-
const untilTime = new Date(until).getTime();
|
|
39291
|
-
return events.filter((e) => new Date(e.timestamp).getTime() <= untilTime);
|
|
39292
|
-
}
|
|
39293
|
-
function filterByTrustTier(events, tier) {
|
|
39294
|
-
return events.filter((e) => {
|
|
39295
|
-
if (e.type === "trust_classification") return e.assignedTier === tier;
|
|
39296
|
-
if (e.type === "policy_gate") return e.inputTrustTier === tier;
|
|
39297
|
-
if (e.type === "reputation") return e.effectiveTier === tier;
|
|
39298
|
-
return true;
|
|
39299
|
-
});
|
|
39300
|
-
}
|
|
39301
|
-
function emitTrustEvent(trail, data) {
|
|
39302
|
-
return trail.append({
|
|
39303
|
-
type: "trust_classification",
|
|
39304
|
-
component: "trust-classifier",
|
|
39305
|
-
...data
|
|
39306
|
-
});
|
|
39307
|
-
}
|
|
39308
|
-
function emitPolicyEvent(trail, data) {
|
|
39309
|
-
return trail.append({
|
|
39310
|
-
type: "policy_gate",
|
|
39311
|
-
component: "policy-gate",
|
|
39312
|
-
...data
|
|
39313
|
-
});
|
|
39314
|
-
}
|
|
39315
|
-
function emitCorroborationEvent(trail, data) {
|
|
39316
|
-
return trail.append({
|
|
39317
|
-
type: "corroboration",
|
|
39318
|
-
component: "corroboration-validator",
|
|
39319
|
-
...data
|
|
39320
|
-
});
|
|
39321
|
-
}
|
|
39322
|
-
function emitReputationEvent(trail, data) {
|
|
39323
|
-
return trail.append({
|
|
39324
|
-
type: "reputation",
|
|
39325
|
-
component: "reputation-model",
|
|
39326
|
-
...data
|
|
39327
|
-
});
|
|
39328
|
-
}
|
|
39329
|
-
function emitSanitizationEvent(trail, data) {
|
|
39330
|
-
return trail.append({
|
|
39331
|
-
type: "sanitization",
|
|
39332
|
-
component: "input-sanitizer",
|
|
39333
|
-
...data
|
|
39334
|
-
});
|
|
39335
|
-
}
|
|
39336
|
-
function emitGraphExecutionEvent(trail, data) {
|
|
39337
|
-
return trail.append({
|
|
39338
|
-
type: "graph_execution",
|
|
39339
|
-
component: "graph-executor",
|
|
39340
|
-
...data
|
|
39341
|
-
});
|
|
39342
|
-
}
|
|
39343
|
-
function createGraphAuditBridge(trail) {
|
|
39344
|
-
return (event) => {
|
|
39345
|
-
const nodeId = typeof event["nodeId"] === "string" ? event["nodeId"] : void 0;
|
|
39346
|
-
const stepNumber = typeof event["stepNumber"] === "number" ? event["stepNumber"] : 0;
|
|
39347
|
-
emitGraphExecutionEvent(trail, {
|
|
39348
|
-
graphEvent: event.type,
|
|
39349
|
-
...nodeId !== void 0 ? { nodeId } : {},
|
|
39350
|
-
stepNumber,
|
|
39351
|
-
detail: formatGraphEventDetail(event)
|
|
39352
|
-
});
|
|
39353
|
-
};
|
|
39354
|
-
}
|
|
39355
|
-
function formatGraphEventDetail(event) {
|
|
39356
|
-
switch (event.type) {
|
|
39357
|
-
case "node_started":
|
|
39358
|
-
return `Node ${String(event["nodeId"])} starting`;
|
|
39359
|
-
case "node_completed":
|
|
39360
|
-
return `Node ${String(event["nodeId"])} completed in ${String(event["durationMs"])}ms`;
|
|
39361
|
-
case "node_error":
|
|
39362
|
-
return `Node ${String(event["nodeId"])} failed: ${String(event["error"])}`;
|
|
39363
|
-
case "state_updated":
|
|
39364
|
-
return `State updated: ${String(event["updatedKeys"])}`;
|
|
39365
|
-
case "step_completed":
|
|
39366
|
-
return `Step ${String(event["stepNumber"])}: ${String(event["nodesExecuted"])} nodes`;
|
|
39367
|
-
case "execution_complete":
|
|
39368
|
-
return `Complete: ${String(event["totalSteps"])} steps, ${String(event["durationMs"])}ms`;
|
|
39369
|
-
default:
|
|
39370
|
-
return event.type;
|
|
39371
|
-
}
|
|
39372
|
-
}
|
|
39373
|
-
function createAuditTrail() {
|
|
39374
|
-
return new AuditTrail();
|
|
39375
|
-
}
|
|
39376
|
-
|
|
39377
39239
|
// src/mcp/tools/run-graph-workflow.ts
|
|
39378
39240
|
import { z as z70 } from "zod";
|
|
39379
39241
|
var RunGraphWorkflowInputSchema = z70.object({
|
|
@@ -42523,7 +42385,7 @@ async function tryIssueTriage(task) {
|
|
|
42523
42385
|
try {
|
|
42524
42386
|
const issueMatch = task.match(/github\.com\/([^/]+\/[^/]+)\/issues\/(\d+)/);
|
|
42525
42387
|
if (issueMatch === null) return null;
|
|
42526
|
-
const { createIssueTriage } = await import("./issue-triage-
|
|
42388
|
+
const { createIssueTriage } = await import("./issue-triage-VB5CVE43.js");
|
|
42527
42389
|
const triage = createIssueTriage();
|
|
42528
42390
|
const owner = issueMatch[1] ?? "";
|
|
42529
42391
|
const num = issueMatch[2] ?? "";
|
|
@@ -43548,7 +43410,7 @@ ${contextBlock}`;
|
|
|
43548
43410
|
const strategy = config.votingStrategy ?? "higher_order";
|
|
43549
43411
|
await postProgress(config, "Vote", `Running consensus with ${strategy} strategy...`);
|
|
43550
43412
|
try {
|
|
43551
|
-
const { executeVoting } = await import("./consensus-vote-
|
|
43413
|
+
const { executeVoting } = await import("./consensus-vote-4RIUUEZQ.js");
|
|
43552
43414
|
const votingResult = await executeVoting(
|
|
43553
43415
|
{
|
|
43554
43416
|
proposal: plan.slice(0, 4e3),
|
|
@@ -44324,7 +44186,7 @@ ${codeContext}`;
|
|
|
44324
44186
|
const result = await stages.research(enrichedTask);
|
|
44325
44187
|
return output(PIPELINE_STATE_KEYS.RESEARCH, result, getTimeProvider().now() - start, true);
|
|
44326
44188
|
} catch (e) {
|
|
44327
|
-
return failOutput(PIPELINE_STATE_KEYS.RESEARCH,
|
|
44189
|
+
return failOutput(PIPELINE_STATE_KEYS.RESEARCH, getErrorMessage(e), getTimeProvider().now() - start);
|
|
44328
44190
|
}
|
|
44329
44191
|
}
|
|
44330
44192
|
};
|
|
@@ -44346,7 +44208,7 @@ ${priorArt}` : research;
|
|
|
44346
44208
|
const result = await stages.plan(ctx.task, enrichedResearch, feedback);
|
|
44347
44209
|
return output(PIPELINE_STATE_KEYS.PLAN, result, getTimeProvider().now() - start, true);
|
|
44348
44210
|
} catch (e) {
|
|
44349
|
-
return failOutput(PIPELINE_STATE_KEYS.PLAN,
|
|
44211
|
+
return failOutput(PIPELINE_STATE_KEYS.PLAN, getErrorMessage(e), getTimeProvider().now() - start);
|
|
44350
44212
|
}
|
|
44351
44213
|
}
|
|
44352
44214
|
};
|
|
@@ -44369,7 +44231,7 @@ function createVoteStageWrapper(stages) {
|
|
|
44369
44231
|
success: isApproved(vote)
|
|
44370
44232
|
};
|
|
44371
44233
|
} catch (e) {
|
|
44372
|
-
return failOutput(PIPELINE_STATE_KEYS.VOTE_RESULT,
|
|
44234
|
+
return failOutput(PIPELINE_STATE_KEYS.VOTE_RESULT, getErrorMessage(e), getTimeProvider().now() - start);
|
|
44373
44235
|
}
|
|
44374
44236
|
}
|
|
44375
44237
|
};
|
|
@@ -44385,7 +44247,7 @@ function createDecomposeStageWrapper(stages) {
|
|
|
44385
44247
|
const tasks = await stages.decompose(plan);
|
|
44386
44248
|
return output(PIPELINE_STATE_KEYS.TASKS, tasks, getTimeProvider().now() - start, true);
|
|
44387
44249
|
} catch (e) {
|
|
44388
|
-
return failOutput(PIPELINE_STATE_KEYS.TASKS,
|
|
44250
|
+
return failOutput(PIPELINE_STATE_KEYS.TASKS, getErrorMessage(e), getTimeProvider().now() - start);
|
|
44389
44251
|
}
|
|
44390
44252
|
}
|
|
44391
44253
|
};
|
|
@@ -44401,7 +44263,7 @@ function createImplementStageWrapper(stages) {
|
|
|
44401
44263
|
const results = await Promise.all(tasks.map((t) => stages.implement(t)));
|
|
44402
44264
|
return output(PIPELINE_STATE_KEYS.IMPLEMENTATIONS, results, getTimeProvider().now() - start, true);
|
|
44403
44265
|
} catch (e) {
|
|
44404
|
-
return failOutput(PIPELINE_STATE_KEYS.IMPLEMENTATIONS,
|
|
44266
|
+
return failOutput(PIPELINE_STATE_KEYS.IMPLEMENTATIONS, getErrorMessage(e), getTimeProvider().now() - start);
|
|
44405
44267
|
}
|
|
44406
44268
|
}
|
|
44407
44269
|
};
|
|
@@ -44419,7 +44281,7 @@ function createQaStageWrapper(stages) {
|
|
|
44419
44281
|
const allPass = reviews.every((r) => r.verdict === "pass");
|
|
44420
44282
|
return output(PIPELINE_STATE_KEYS.QA_ITERATIONS, reviews, getTimeProvider().now() - start, allPass);
|
|
44421
44283
|
} catch (e) {
|
|
44422
|
-
return failOutput(PIPELINE_STATE_KEYS.QA_ITERATIONS,
|
|
44284
|
+
return failOutput(PIPELINE_STATE_KEYS.QA_ITERATIONS, getErrorMessage(e), getTimeProvider().now() - start);
|
|
44423
44285
|
}
|
|
44424
44286
|
}
|
|
44425
44287
|
};
|
|
@@ -44439,7 +44301,7 @@ function createSecurityStageWrapper(stages) {
|
|
|
44439
44301
|
result.passed
|
|
44440
44302
|
);
|
|
44441
44303
|
} catch (e) {
|
|
44442
|
-
return failOutput(PIPELINE_STATE_KEYS.SECURITY_PASSED,
|
|
44304
|
+
return failOutput(PIPELINE_STATE_KEYS.SECURITY_PASSED, getErrorMessage(e), getTimeProvider().now() - start);
|
|
44443
44305
|
}
|
|
44444
44306
|
}
|
|
44445
44307
|
};
|
|
@@ -44532,7 +44394,7 @@ function createAnalyzeStageWrapper() {
|
|
|
44532
44394
|
const summary = `Language: ${String(analysis.language)}, Framework: ${String(analysis.framework)}, CI: ${String(analysis.ciProvider)}, Security: ${analysis.securityTooling.join(", ") || "none"}`;
|
|
44533
44395
|
return output(PIPELINE_STATE_KEYS.RESEARCH, summary, getTimeProvider().now() - start, true);
|
|
44534
44396
|
} catch (e) {
|
|
44535
|
-
return failOutput(PIPELINE_STATE_KEYS.RESEARCH,
|
|
44397
|
+
return failOutput(PIPELINE_STATE_KEYS.RESEARCH, getErrorMessage(e), getTimeProvider().now() - start);
|
|
44536
44398
|
}
|
|
44537
44399
|
}
|
|
44538
44400
|
};
|
|
@@ -44553,7 +44415,7 @@ function createScanStageWrapper() {
|
|
|
44553
44415
|
}
|
|
44554
44416
|
return output(PIPELINE_STATE_KEYS.FINDINGS, "No repository to scan", getTimeProvider().now() - start, true);
|
|
44555
44417
|
} catch (e) {
|
|
44556
|
-
return failOutput(PIPELINE_STATE_KEYS.FINDINGS,
|
|
44418
|
+
return failOutput(PIPELINE_STATE_KEYS.FINDINGS, getErrorMessage(e), getTimeProvider().now() - start);
|
|
44557
44419
|
}
|
|
44558
44420
|
}
|
|
44559
44421
|
};
|
|
@@ -51743,16 +51605,6 @@ export {
|
|
|
51743
51605
|
registerResearchSynthesizeTool,
|
|
51744
51606
|
IssueTriageInputSchema,
|
|
51745
51607
|
registerIssueTriageTool,
|
|
51746
|
-
MAX_STRIPPED_ELEMENTS_PER_EVENT,
|
|
51747
|
-
AuditTrail,
|
|
51748
|
-
emitTrustEvent,
|
|
51749
|
-
emitPolicyEvent,
|
|
51750
|
-
emitCorroborationEvent,
|
|
51751
|
-
emitReputationEvent,
|
|
51752
|
-
emitSanitizationEvent,
|
|
51753
|
-
emitGraphExecutionEvent,
|
|
51754
|
-
createGraphAuditBridge,
|
|
51755
|
-
createAuditTrail,
|
|
51756
51608
|
RunGraphWorkflowInputSchema,
|
|
51757
51609
|
registerRunGraphWorkflowTool,
|
|
51758
51610
|
parseSpec,
|
|
@@ -51876,4 +51728,4 @@ export {
|
|
|
51876
51728
|
detectBackend,
|
|
51877
51729
|
createTaskTracker
|
|
51878
51730
|
};
|
|
51879
|
-
//# sourceMappingURL=chunk-
|
|
51731
|
+
//# sourceMappingURL=chunk-4LEUIAYB.js.map
|