@node9/proxy 2.48.2 → 2.50.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/cli-main.js +5480 -4202
- package/dist/dashboard.mjs +2452 -519
- package/dist/hook.js +530 -384
- package/dist/index.js +258 -113
- package/dist/index.mjs +258 -113
- package/dist/scan-ink.mjs +100 -0
- package/package.json +2 -2
package/dist/hook.js
CHANGED
|
@@ -456,6 +456,9 @@ function levelChecks(mode) {
|
|
|
456
456
|
function levelPackageSignals(mode) {
|
|
457
457
|
return levelOf(mode) === "soft" ? { newPackage: "off", installScript: "off" } : void 0;
|
|
458
458
|
}
|
|
459
|
+
function packRowOwasp(id, shield) {
|
|
460
|
+
return PACK_RULE_OWASP[id] ?? PACK_SHIELD_OWASP[shield];
|
|
461
|
+
}
|
|
459
462
|
function isVerdict(v) {
|
|
460
463
|
return v === "off" || v === "log" || v === "review" || v === "block";
|
|
461
464
|
}
|
|
@@ -475,6 +478,10 @@ function packRows() {
|
|
|
475
478
|
rows.push({
|
|
476
479
|
id,
|
|
477
480
|
group: "commands",
|
|
481
|
+
// A shield missing from the table falls back to tool misuse instead of
|
|
482
|
+
// throwing here: this module loads on every hook call, and a mapping
|
|
483
|
+
// omission must fail a test (owasp.spec.ts), never the gate.
|
|
484
|
+
owasp: packRowOwasp(id, shield.name) ?? "ASI02",
|
|
478
485
|
title: rule.name.replace(SHIELD_RULE_NAME, "$3").replace(/-/g, " "),
|
|
479
486
|
catches: rule.description ?? rule.reason ?? "",
|
|
480
487
|
values: ALL,
|
|
@@ -9561,7 +9568,7 @@ function matchCanaryArgs(args, values) {
|
|
|
9561
9568
|
return null;
|
|
9562
9569
|
}
|
|
9563
9570
|
}
|
|
9564
|
-
var import_url, import_picomatch, import_safe_regex2, import_picomatch2, import_module, import_picomatch3, import_safe_regex22, import_crypto, import_crypto2, import_crypto3, import_crypto4, getFilename, __filename2, MAX_REGEX_LENGTH, REGEX_CACHE_MAX, regexCache, aws_default, bash_safe_default, docker_default, filesystem_default, github_default, k8s_default, mongodb_default, postgres_default, project_jail_default, redis_default, finance_default, identity_default, publishing_default, settings_default, branches_default, ACTION_TEMPLATES, ACTION_CHECKS, GAP, prog, httpTo, httpWrite, HTTP_WRITE, HTTP_WRITE_ANY, NOT_STRIPE_TEST, postTo, STRIPE_OBJECTS, APP_SHIELD_SPECS, APP_SHIELDS, APP_SHIELD_NAMES, APP_SERVER_GLOB, GENERAL_ACTION_RULES, BUILTIN_SHIELDS, SSRF_MAX_HOST, METADATA_ADDRESSES, STRICT_TIERS, METADATA_HOSTNAMES, v4Octets, TIER_REASON, CHECK_TEXT, LEVELS, MODE_VALUES, SOFT, STRICT, BLOCK_ALL, LEVEL_CHECKS, VERDICTS, CHECK_VERDICT_RANK, ALL, BUILTIN_DANGEROUS_WORDS, PRODUCT_CHECKS, SHIELD_RULE_NAME, SHIELD_RULES_FOLDED_INTO_PRODUCT, CHECKS, CHECK_BY_ID, LEGACY_TO_ID, PROJECT_JAIL_BLOCK_READ, OVERRIDE_PREFIX, LABEL_WRAPPERS, LEGACY_READERS, syntax, KINDS, STRUCTS, unknownKinds, INVISIBLE_RE, INVISIBLE_ONE, HOMOGLYPHS, HOMOGLYPH_RE, MAX_BLOBS, MIN_DECODED, BASE64_RUN_RE, HEX_RUN_RE, HEX_ESCAPE_RUN_RE, SYSTEM_AUTH_FILES, SYSTEM_AUTH_DIRS, PASSWORD_HASH_FILES, STARTUP_NAMES, SYSTEM_DIRS, SYSTEM_DIRS_EXEMPT, UPLOAD_SYSTEM_DIRS, AGENT_INSTRUCTION_FILES, AGENT_INSTRUCTION_DIRS, LEGACY_SYSTEM_PATH_RE, MAX_ALTERNATIVES, MAX_CALL_DEPTH, MAX_CALL_WALKS, MAX_XARGS_PAYLOAD, POSITIONAL, MAX_DEPTH, MAX_PAYLOAD_DEPTH, unique, clone, SENDING_STDIN, DOWNLOAD_SHORT_VALUE, DOWNLOAD_LONG_VALUE, DOWNLOAD_OUTPUT_FLAGS, DOWNLOAD_DIR_FLAGS, base, quoteGlob, asWord, ops, MAX_INLINE_CODE, WHAT, OUTSIDE, pyImport, either, PYTHON, NODE, PERL, RUBY, PHP, TABLES, STRING_LITERAL, sharedParser, MESSAGE_FLAGS, SHELL_INTERPRETERS, DOWNLOAD_CMDS, NORMALIZE_CACHE_MAX, normalizeCache, codeBodiesCache, AST_CACHE_MAX, astCache, PARSE_FAIL, INTERPRETER_LINE, PROGRAM_DIR, ACCESS_VIEW_CACHE_MAX, accessViewCache, MAX_READING_PAYLOADS, STDIN_CODE_INTERPRETERS, RUNS_TEXT_ELSEWHERE, defaultExpansionOps, VARIABLE_READERS, FS_READ_TOOLS, GREP_SHAPE, PATTERN_VERBS, PATTERN_VERB_NAMES, GREP_FILE_OPERANDS, READER_VALUE_LETTERS, FILE_OPERAND_FLAGS, SCP_VALUE_FLAGS, CURL_SOURCE_FLAGS, CURL_VALUE_LETTERS, WGET_VALUE_LETTERS, TAR_VALUE_LETTERS, ZIP_VALUE_LETTERS, RSYNC_VALUE_LETTERS, RSYNC_SKIP, CP_VALUE_LETTERS, INSTALL_VALUE_LETTERS, COPY_VERBS, TAR_MODE_WORD, COPY_VERB_HEADS, FS_OP_PRESCREEN_RE, HOME_CACHE_ALLOWLIST, SENSITIVE_PATH_RULES, AST_FS_REGEX_RULES, SQL_DB_CLIS, SQL_DDL_RE, CHMOD_OPEN_PERM_TOKENS, COMMAND_WRAPPERS, INLINE_INTERPRETER, RUNNER_WRAPPERS, _redirStdinOps, _listOps, WRAPPER_TAKES_TARGET, FIND_EXEC_FLAGS, FS_MUTATION_TOOLS, INTERP_LEADING_TARGET, MAX_PAYLOAD_NESTING, payloadNesting, MAX_INLINE_CALLS, INLINE_EXEC_FALLBACK, UNREADABLE_SOURCE, SCRIPT_RUNNERS, SCRIPT_RUNNER_VALUE_FLAGS, MAX_SCRIPT_OPERANDS, NET_BINARIES, VALUE_FLAGS, HOME_VARIABLES, assignmentTable, currentStmtOffset, PAYLOAD_BUDGET, payloadBudget, seenPayloads, UNANALYSABLE_NESTING, ASSIGNMENT_HEADS, andOrOps, MAX_CALL_DEPTH2, MAX_CALL_WALKS2, callDepth, callWalks, FS_OP_CACHE_MAX, fsOpCache, stripDotSlash, REDIR_TRUNCATE_OPS, REDIR_FILE_IN_OPS, REDIR_HEREDOC_OPS, FIND_OPTIONS, COPY_RULE_OF, INDIRECT_SHAPE_RE, SOURCES_FILE_RE, SHELL_SET_VARS, pipeOps, callWords, JAILED_GLOB_NAMES, JAILED_DIR_NAMES, shellGlob, GLOB_META, isReaderWord, positionalAfter, NONE, UNKNOWN, FORBIDDEN_PATH_SEGMENTS, BASH_TOOL_NAMES, MCP_EXECUTORS, BUILTIN_FIELDS, ARGV_FIELDS, BARE_WORD, MAX_ARGV_CHARACTERS, exempt, RANK, SEQUENCE_OPS, BIP39_ENGLISH, BIP39_PUBLIC_VECTORS, indices, lengths, hash, MAX_MNEMONIC_HASHES, SECRET_VIEW_LIMITS, IBAN_LENGTH, IBAN_BBAN_SHAPE, B58, B58_INDEX, XPRV_VERSIONS, B62, CRC32_TABLE, GITHUB_TOKEN_RE, B64URL, B64URL_INDEX, CASK_TWO_ZERO_SUFFIX, CASK_FOUR_ZERO_SUFFIX, CF_ODD, CF_EVEN, SPANISH_LETTERS, HETU_CHARS, VERHOEFF_D, VERHOEFF_P, MAX, UNTRUSTED_TOOLS, INJECTION_SIGNALS, MENTION_QUOTE_RE, MENTION_WORD_RE, ASSIGNMENT_CONTEXT_RE, DLP_STOPWORDS, REFERENCE_VALUE_RE, IDENTIFIER_VALUE_RE, PATH_VALUE_RE, DOTTED_REFERENCE_RE, CONCATENATION_RE, EMAIL_VALUE_RE, FIXTURE_NAME_RE, DERIVATIVE_NAME_RE, QUERY_CREDENTIAL_VALUE_RE, OTP_SECRET_RE, OTP_DOC_SECRETS, ASSIGNED_SECRET_VALUE_RE, ASSIGNED_SECRET_NAME_RE, NAME_KEYWORD_RE, ARN_CONTEXT_RE, CIPHER_KEY_NAME_RE, CIPHER_NAME_PARTS, CIPHER_KEY_VALUE_RE, LARAVEL_KEY_VALUE_RE, SQL_PASSWORD_VALUE_RE, GRAFANA_KEY_VALUE_RE, BASIC_VALUE_RE, BASIC_PAIR_RE, BASIC_HEADER_RE, BASIC_HEADER_PAIR_RE, BASIC_PLACEHOLDER_RE, BASIC_TEMPLATE_MARKERS, DROPBOX_SECRET_RE, OTP_CAPTURE_RE, DB_URL_PASSWORD_RE, DLP_PATTERNS, DLP_PATTERNS_GLOBAL, SENSITIVE_PATH_PATTERNS, SENSITIVE_PATH_REGEXES, MAX_DEPTH2, MAX_STRING_BYTES, MAX_JSON_PARSE_BYTES, DLP_SCAN_LIMITS, BATCH_SEPARATOR, ENCODED_RUN_RE, IMPERATIVE, SECRET_TARGET, GUARD, SIGNALS, DESTINATION_RE, REUSED_SIGNALS, NEVER_NEGATED, NEGATION_BEFORE, RDR_IN, COPY_VERBS2, LITERAL_VERBS, GIT_PRESCREEN_RE, MAX_PAYLOAD_DEPTH2, MAX_ALIAS_DEPTH, CACHE_MAX, cache, PAYLOAD_SHELLS, CONFIG_SCOPE_FLAGS, CONFIG_VALUE_FLAGS, GLOBAL_VALUE_OPTIONS, GLOBAL_FLAG_OPTIONS, MAX_LOOP_ITEMS, GitWalk, POSITIONAL2, FORCE_PUSH, DESTRUCTIVE, UNREADABLE, PUSH_LONG_VALUE, BRANCH_LONG_VALUE, TAG_LONG_VALUE, CLEAN_LONG_VALUE, HOOKS_BYPASS, NO_VERIFY_SUBS, HOOK_KILL_SWITCHES, COMMIT_LONG_VALUE, CHMOD_OPTION_RE, STAGE_ALL, ADD_LONG_VALUE, CHECK_ID, RULE_NAME, INERT_LINE_RE, CHECK_ID2, INSTRUCTION_NAMES, SETTINGS_RE, HOOK_WORDS_RE, SHELLS, NETCATS, NET_CLIENTS, SENDERS, NETCAT_EXEC_LONG, DECL_DUMPS, PROC_ENVIRON_RE, DEV_NET_RE, SOCAT_PROGRAM_RE, SOCAT_NET_RE, PRESCREEN_RE, MAX_PAYLOAD_DEPTH3, CACHE_MAX2, cache2, dupInOp, REVERSE_SHELL_DESCRIPTION, ENV_EXFIL_DESCRIPTION, DYNAMIC_WORD, MULTICALL, SHELL_VALUE_OPTIONS, INTERPRETERS, OutboundWalk, NPM_INSTALL_VERBS, NPM_EXEC_VERBS, PNPM_INSTALL_VERBS, YARN_INSTALL_VERBS, BUN_INSTALL_VERBS, DLX_VERBS, NON_REGISTRY_RE, NPM_NAME_RE, EXACT_SEMVER_RE, NPM_VALUE_FLAGS, PNPM_VALUE_FLAGS, YARN_VALUE_FLAGS, BUN_VALUE_FLAGS, PIP_VALUE_FLAGS, UV_VALUE_FLAGS, POETRY_VALUE_FLAGS, PIPENV_VALUE_FLAGS, PIPX_VALUE_FLAGS, PY_SPEC_RE, PY_EXACT_RE, EXACT_VERSION_RE, GEM_NAME_RE, GEM_VALUE_FLAGS, BUNDLE_VALUE_FLAGS, CRATE_NAME_RE, CARGO_ADD_VALUE_FLAGS, CARGO_INSTALL_VALUE_FLAGS, GO_VALUE_FLAGS, GO_PATH_RE, NUGET_NAME_RE, DOTNET_ADD_VALUE_FLAGS, DOTNET_TOOL_VALUE_FLAGS, NUGET_VALUE_FLAGS, MAVEN_COORD_RE, COMPOSER_NAME_RE, COMPOSER_VALUE_FLAGS, EDITOR_HEADS, EXTENSION_ID_RE, MANAGER_HEADS, SHELLS2, MAX_NESTING, SHELL_VALUE_FLAGS, NPM_FAMILY, PIP_FAMILY, NPM_FETCH_VERBS, PIP_FETCH_VERBS, NPM_FLAGS, PIP_FLAGS, NPM_VARS, PIP_VARS, PRESCREEN_RE2, PIP_ATTACHED_RE, MAX_PAYLOAD_DEPTH4, PUBLIC_REGISTRY_HOSTS, TUNING_FIELDS, MAP_GOVERNED, KNOB_GOVERNED, CONFIGURABLE_CHECK_IDS, DEFAULT_EGRESS_ALLOWLIST, PRIVATE_HOST_SUFFIXES, SOURCE_COMMANDS, SINK_COMMANDS, OBFUSCATORS, SENSITIVE_PATTERNS, FLAGS_WITH_VALUES, DESTINATION_ARGS, MCP_DESTINATION_KEYS, ARGUMENT_SCAN_LIMITS, RUN_CHAR, runChar, VERDICT_RANK, SQL_DML_KEYWORDS, MAX_DESTINATIONS, MAX_SCAN_CHARS, EMAIL_RE, URL_RE, IBAN_RE, RECIPIENT_KEYS, DESTRUCTIVE_VERB_RE, PII_EMAIL_RE, PII_SSN_RE, PII_PHONE_RE, PII_CC16_RE, PII_CC15_RE, PII_CC14_RE, PII_CC13_RE, PII_CC19_RE, CARD_PATTERNS, PII_ROUTING_RE, ROUTING_LABEL_RE, ROUTING_LABEL_WINDOW, NATIONAL_ID_SHAPES, NATIONAL_ID_LABEL_RE, NATIONAL_ID_LABEL_CS_RE, idLabelIn, NATIONAL_ID_LABEL_WINDOW, NATIONAL_ID_GUARD_RE, PII_IBAN_RE, REALTIME_PII_PATTERNS, MAX_PII_SCAN_BYTES, IBAN_DESTINATION_KEYS, WHOLE_IBAN_RE, JSON_ESCAPE_RE, JSON_ESCAPES, MASKED_KINDS, ENTRY_RE, IBAN_TEXT_RE, EMAIL_TEXT_RE, ACCOUNT_KEY_RE, ACCOUNT_VALUE_RE, MAX_MASK_DEPTH, EMPTY, CURL_SEND_FLAGS, WGET_SEND_FLAGS, IWR_SEND_FLAGS, WRITE_METHODS, GH_READ, GH_WRITE, GH_HOSTNAME_FLAGS, GH_REPO_VALUE_FLAGS, GH_API_VALUE_FLAGS, GIT_FETCH, PUBLISH, SHELLS3, OWN_HEADS, MAX_DEPTH3, CWD_CHANGERS, TERMINAL_ESCAPE_RE, CONTROL_CHAR_RE, LOOP_MAX_RECORDS, CANARY_MIN_LENGTH, MAX_TEXT, MAX_DEPTH4, MAX_JSON_PARSE, URL_DEPTH, B64_DEPTH, MIN_SEGMENT, SEPARATORS, stripSeparators, looksText, CANARY_DECODERS, VIEWS, LONG_OUTPUT_THRESHOLD_BYTES;
|
|
9571
|
+
var import_url, import_picomatch, import_safe_regex2, import_picomatch2, import_module, import_picomatch3, import_safe_regex22, import_crypto, import_crypto2, import_crypto3, import_crypto4, getFilename, __filename2, MAX_REGEX_LENGTH, REGEX_CACHE_MAX, regexCache, aws_default, bash_safe_default, docker_default, filesystem_default, github_default, k8s_default, mongodb_default, postgres_default, project_jail_default, redis_default, finance_default, identity_default, publishing_default, settings_default, branches_default, ACTION_TEMPLATES, ACTION_CHECKS, GAP, prog, httpTo, httpWrite, HTTP_WRITE, HTTP_WRITE_ANY, NOT_STRIPE_TEST, postTo, STRIPE_OBJECTS, APP_SHIELD_SPECS, APP_SHIELDS, APP_SHIELD_NAMES, APP_SERVER_GLOB, GENERAL_ACTION_RULES, BUILTIN_SHIELDS, SSRF_MAX_HOST, METADATA_ADDRESSES, STRICT_TIERS, METADATA_HOSTNAMES, v4Octets, TIER_REASON, CHECK_TEXT, LEVELS, MODE_VALUES, SOFT, STRICT, BLOCK_ALL, LEVEL_CHECKS, ASI, ASI_IDS, PACK_SHIELD_OWASP, PACK_RULE_OWASP, VERDICTS, CHECK_VERDICT_RANK, ALL, BUILTIN_DANGEROUS_WORDS, PRODUCT_CHECKS, SHIELD_RULE_NAME, SHIELD_RULES_FOLDED_INTO_PRODUCT, CHECKS, CHECK_BY_ID, LEGACY_TO_ID, PROJECT_JAIL_BLOCK_READ, OVERRIDE_PREFIX, LABEL_WRAPPERS, LEGACY_READERS, syntax, KINDS, STRUCTS, unknownKinds, INVISIBLE_RE, INVISIBLE_ONE, HOMOGLYPHS, HOMOGLYPH_RE, MAX_BLOBS, MIN_DECODED, BASE64_RUN_RE, HEX_RUN_RE, HEX_ESCAPE_RUN_RE, SYSTEM_AUTH_FILES, SYSTEM_AUTH_DIRS, PASSWORD_HASH_FILES, STARTUP_NAMES, SYSTEM_DIRS, SYSTEM_DIRS_EXEMPT, UPLOAD_SYSTEM_DIRS, AGENT_INSTRUCTION_FILES, AGENT_INSTRUCTION_DIRS, LEGACY_SYSTEM_PATH_RE, MAX_ALTERNATIVES, MAX_CALL_DEPTH, MAX_CALL_WALKS, MAX_XARGS_PAYLOAD, POSITIONAL, MAX_DEPTH, MAX_PAYLOAD_DEPTH, unique, clone, SENDING_STDIN, DOWNLOAD_SHORT_VALUE, DOWNLOAD_LONG_VALUE, DOWNLOAD_OUTPUT_FLAGS, DOWNLOAD_DIR_FLAGS, base, quoteGlob, asWord, ops, MAX_INLINE_CODE, WHAT, OUTSIDE, pyImport, either, PYTHON, NODE, PERL, RUBY, PHP, TABLES, STRING_LITERAL, sharedParser, MESSAGE_FLAGS, SHELL_INTERPRETERS, DOWNLOAD_CMDS, NORMALIZE_CACHE_MAX, normalizeCache, codeBodiesCache, AST_CACHE_MAX, astCache, PARSE_FAIL, INTERPRETER_LINE, PROGRAM_DIR, ACCESS_VIEW_CACHE_MAX, accessViewCache, MAX_READING_PAYLOADS, STDIN_CODE_INTERPRETERS, RUNS_TEXT_ELSEWHERE, defaultExpansionOps, VARIABLE_READERS, FS_READ_TOOLS, GREP_SHAPE, PATTERN_VERBS, PATTERN_VERB_NAMES, GREP_FILE_OPERANDS, READER_VALUE_LETTERS, FILE_OPERAND_FLAGS, SCP_VALUE_FLAGS, CURL_SOURCE_FLAGS, CURL_VALUE_LETTERS, WGET_VALUE_LETTERS, TAR_VALUE_LETTERS, ZIP_VALUE_LETTERS, RSYNC_VALUE_LETTERS, RSYNC_SKIP, CP_VALUE_LETTERS, INSTALL_VALUE_LETTERS, COPY_VERBS, TAR_MODE_WORD, COPY_VERB_HEADS, FS_OP_PRESCREEN_RE, HOME_CACHE_ALLOWLIST, SENSITIVE_PATH_RULES, AST_FS_REGEX_RULES, SQL_DB_CLIS, SQL_DDL_RE, CHMOD_OPEN_PERM_TOKENS, COMMAND_WRAPPERS, INLINE_INTERPRETER, RUNNER_WRAPPERS, _redirStdinOps, _listOps, WRAPPER_TAKES_TARGET, FIND_EXEC_FLAGS, FS_MUTATION_TOOLS, INTERP_LEADING_TARGET, MAX_PAYLOAD_NESTING, payloadNesting, MAX_INLINE_CALLS, INLINE_EXEC_FALLBACK, UNREADABLE_SOURCE, SCRIPT_RUNNERS, SCRIPT_RUNNER_VALUE_FLAGS, MAX_SCRIPT_OPERANDS, NET_BINARIES, VALUE_FLAGS, HOME_VARIABLES, assignmentTable, currentStmtOffset, PAYLOAD_BUDGET, payloadBudget, seenPayloads, UNANALYSABLE_NESTING, ASSIGNMENT_HEADS, andOrOps, MAX_CALL_DEPTH2, MAX_CALL_WALKS2, callDepth, callWalks, FS_OP_CACHE_MAX, fsOpCache, stripDotSlash, REDIR_TRUNCATE_OPS, REDIR_FILE_IN_OPS, REDIR_HEREDOC_OPS, FIND_OPTIONS, COPY_RULE_OF, INDIRECT_SHAPE_RE, SOURCES_FILE_RE, SHELL_SET_VARS, pipeOps, callWords, JAILED_GLOB_NAMES, JAILED_DIR_NAMES, shellGlob, GLOB_META, isReaderWord, positionalAfter, NONE, UNKNOWN, FORBIDDEN_PATH_SEGMENTS, BASH_TOOL_NAMES, MCP_EXECUTORS, BUILTIN_FIELDS, ARGV_FIELDS, BARE_WORD, MAX_ARGV_CHARACTERS, exempt, RANK, SEQUENCE_OPS, BIP39_ENGLISH, BIP39_PUBLIC_VECTORS, indices, lengths, hash, MAX_MNEMONIC_HASHES, SECRET_VIEW_LIMITS, IBAN_LENGTH, IBAN_BBAN_SHAPE, B58, B58_INDEX, XPRV_VERSIONS, B62, CRC32_TABLE, GITHUB_TOKEN_RE, B64URL, B64URL_INDEX, CASK_TWO_ZERO_SUFFIX, CASK_FOUR_ZERO_SUFFIX, CF_ODD, CF_EVEN, SPANISH_LETTERS, HETU_CHARS, VERHOEFF_D, VERHOEFF_P, MAX, UNTRUSTED_TOOLS, INJECTION_SIGNALS, MENTION_QUOTE_RE, MENTION_WORD_RE, ASSIGNMENT_CONTEXT_RE, DLP_STOPWORDS, REFERENCE_VALUE_RE, IDENTIFIER_VALUE_RE, PATH_VALUE_RE, DOTTED_REFERENCE_RE, CONCATENATION_RE, EMAIL_VALUE_RE, FIXTURE_NAME_RE, DERIVATIVE_NAME_RE, QUERY_CREDENTIAL_VALUE_RE, OTP_SECRET_RE, OTP_DOC_SECRETS, ASSIGNED_SECRET_VALUE_RE, ASSIGNED_SECRET_NAME_RE, NAME_KEYWORD_RE, ARN_CONTEXT_RE, CIPHER_KEY_NAME_RE, CIPHER_NAME_PARTS, CIPHER_KEY_VALUE_RE, LARAVEL_KEY_VALUE_RE, SQL_PASSWORD_VALUE_RE, GRAFANA_KEY_VALUE_RE, BASIC_VALUE_RE, BASIC_PAIR_RE, BASIC_HEADER_RE, BASIC_HEADER_PAIR_RE, BASIC_PLACEHOLDER_RE, BASIC_TEMPLATE_MARKERS, DROPBOX_SECRET_RE, OTP_CAPTURE_RE, DB_URL_PASSWORD_RE, DLP_PATTERNS, DLP_PATTERNS_GLOBAL, SENSITIVE_PATH_PATTERNS, SENSITIVE_PATH_REGEXES, MAX_DEPTH2, MAX_STRING_BYTES, MAX_JSON_PARSE_BYTES, DLP_SCAN_LIMITS, BATCH_SEPARATOR, ENCODED_RUN_RE, IMPERATIVE, SECRET_TARGET, GUARD, SIGNALS, DESTINATION_RE, REUSED_SIGNALS, NEVER_NEGATED, NEGATION_BEFORE, RDR_IN, COPY_VERBS2, LITERAL_VERBS, GIT_PRESCREEN_RE, MAX_PAYLOAD_DEPTH2, MAX_ALIAS_DEPTH, CACHE_MAX, cache, PAYLOAD_SHELLS, CONFIG_SCOPE_FLAGS, CONFIG_VALUE_FLAGS, GLOBAL_VALUE_OPTIONS, GLOBAL_FLAG_OPTIONS, MAX_LOOP_ITEMS, GitWalk, POSITIONAL2, FORCE_PUSH, DESTRUCTIVE, UNREADABLE, PUSH_LONG_VALUE, BRANCH_LONG_VALUE, TAG_LONG_VALUE, CLEAN_LONG_VALUE, HOOKS_BYPASS, NO_VERIFY_SUBS, HOOK_KILL_SWITCHES, COMMIT_LONG_VALUE, CHMOD_OPTION_RE, STAGE_ALL, ADD_LONG_VALUE, CHECK_ID, RULE_NAME, INERT_LINE_RE, CHECK_ID2, INSTRUCTION_NAMES, SETTINGS_RE, HOOK_WORDS_RE, SHELLS, NETCATS, NET_CLIENTS, SENDERS, NETCAT_EXEC_LONG, DECL_DUMPS, PROC_ENVIRON_RE, DEV_NET_RE, SOCAT_PROGRAM_RE, SOCAT_NET_RE, PRESCREEN_RE, MAX_PAYLOAD_DEPTH3, CACHE_MAX2, cache2, dupInOp, REVERSE_SHELL_DESCRIPTION, ENV_EXFIL_DESCRIPTION, DYNAMIC_WORD, MULTICALL, SHELL_VALUE_OPTIONS, INTERPRETERS, OutboundWalk, NPM_INSTALL_VERBS, NPM_EXEC_VERBS, PNPM_INSTALL_VERBS, YARN_INSTALL_VERBS, BUN_INSTALL_VERBS, DLX_VERBS, NON_REGISTRY_RE, NPM_NAME_RE, EXACT_SEMVER_RE, NPM_VALUE_FLAGS, PNPM_VALUE_FLAGS, YARN_VALUE_FLAGS, BUN_VALUE_FLAGS, PIP_VALUE_FLAGS, UV_VALUE_FLAGS, POETRY_VALUE_FLAGS, PIPENV_VALUE_FLAGS, PIPX_VALUE_FLAGS, PY_SPEC_RE, PY_EXACT_RE, EXACT_VERSION_RE, GEM_NAME_RE, GEM_VALUE_FLAGS, BUNDLE_VALUE_FLAGS, CRATE_NAME_RE, CARGO_ADD_VALUE_FLAGS, CARGO_INSTALL_VALUE_FLAGS, GO_VALUE_FLAGS, GO_PATH_RE, NUGET_NAME_RE, DOTNET_ADD_VALUE_FLAGS, DOTNET_TOOL_VALUE_FLAGS, NUGET_VALUE_FLAGS, MAVEN_COORD_RE, COMPOSER_NAME_RE, COMPOSER_VALUE_FLAGS, EDITOR_HEADS, EXTENSION_ID_RE, MANAGER_HEADS, SHELLS2, MAX_NESTING, SHELL_VALUE_FLAGS, NPM_FAMILY, PIP_FAMILY, NPM_FETCH_VERBS, PIP_FETCH_VERBS, NPM_FLAGS, PIP_FLAGS, NPM_VARS, PIP_VARS, PRESCREEN_RE2, PIP_ATTACHED_RE, MAX_PAYLOAD_DEPTH4, PUBLIC_REGISTRY_HOSTS, TUNING_FIELDS, MAP_GOVERNED, KNOB_GOVERNED, CONFIGURABLE_CHECK_IDS, DEFAULT_EGRESS_ALLOWLIST, PRIVATE_HOST_SUFFIXES, SOURCE_COMMANDS, SINK_COMMANDS, OBFUSCATORS, SENSITIVE_PATTERNS, FLAGS_WITH_VALUES, DESTINATION_ARGS, MCP_DESTINATION_KEYS, ARGUMENT_SCAN_LIMITS, RUN_CHAR, runChar, VERDICT_RANK, SQL_DML_KEYWORDS, MAX_DESTINATIONS, MAX_SCAN_CHARS, EMAIL_RE, URL_RE, IBAN_RE, RECIPIENT_KEYS, DESTRUCTIVE_VERB_RE, PII_EMAIL_RE, PII_SSN_RE, PII_PHONE_RE, PII_CC16_RE, PII_CC15_RE, PII_CC14_RE, PII_CC13_RE, PII_CC19_RE, CARD_PATTERNS, PII_ROUTING_RE, ROUTING_LABEL_RE, ROUTING_LABEL_WINDOW, NATIONAL_ID_SHAPES, NATIONAL_ID_LABEL_RE, NATIONAL_ID_LABEL_CS_RE, idLabelIn, NATIONAL_ID_LABEL_WINDOW, NATIONAL_ID_GUARD_RE, PII_IBAN_RE, REALTIME_PII_PATTERNS, MAX_PII_SCAN_BYTES, IBAN_DESTINATION_KEYS, WHOLE_IBAN_RE, JSON_ESCAPE_RE, JSON_ESCAPES, MASKED_KINDS, ENTRY_RE, IBAN_TEXT_RE, EMAIL_TEXT_RE, ACCOUNT_KEY_RE, ACCOUNT_VALUE_RE, MAX_MASK_DEPTH, EMPTY, CURL_SEND_FLAGS, WGET_SEND_FLAGS, IWR_SEND_FLAGS, WRITE_METHODS, GH_READ, GH_WRITE, GH_HOSTNAME_FLAGS, GH_REPO_VALUE_FLAGS, GH_API_VALUE_FLAGS, GIT_FETCH, PUBLISH, SHELLS3, OWN_HEADS, MAX_DEPTH3, CWD_CHANGERS, TERMINAL_ESCAPE_RE, CONTROL_CHAR_RE, LOOP_MAX_RECORDS, CANARY_MIN_LENGTH, MAX_TEXT, MAX_DEPTH4, MAX_JSON_PARSE, URL_DEPTH, B64_DEPTH, MIN_SEGMENT, SEPARATORS, stripSeparators, looksText, CANARY_DECODERS, VIEWS, LONG_OUTPUT_THRESHOLD_BYTES;
|
|
9565
9572
|
var init_dist = __esm({
|
|
9566
9573
|
"packages/policy-engine/dist/index.mjs"() {
|
|
9567
9574
|
"use strict";
|
|
@@ -11662,6 +11669,44 @@ var init_dist = __esm({
|
|
|
11662
11669
|
strict: STRICT,
|
|
11663
11670
|
"block-all": BLOCK_ALL
|
|
11664
11671
|
};
|
|
11672
|
+
ASI = {
|
|
11673
|
+
ASI01: "Agent Goal Hijack",
|
|
11674
|
+
ASI02: "Tool Misuse and Exploitation",
|
|
11675
|
+
ASI03: "Identity and Privilege Abuse",
|
|
11676
|
+
ASI04: "Agentic Supply Chain Vulnerabilities",
|
|
11677
|
+
ASI05: "Unexpected Code Execution",
|
|
11678
|
+
ASI06: "Memory and Context Poisoning",
|
|
11679
|
+
ASI07: "Insecure Inter-Agent Communication",
|
|
11680
|
+
ASI08: "Cascading Failures",
|
|
11681
|
+
ASI09: "Human-Agent Trust Exploitation",
|
|
11682
|
+
ASI10: "Rogue Agents"
|
|
11683
|
+
};
|
|
11684
|
+
ASI_IDS = Object.keys(ASI);
|
|
11685
|
+
PACK_SHIELD_OWASP = {
|
|
11686
|
+
aws: "ASI02",
|
|
11687
|
+
"bash-safe": "ASI02",
|
|
11688
|
+
docker: "ASI02",
|
|
11689
|
+
filesystem: "ASI02",
|
|
11690
|
+
github: "ASI02",
|
|
11691
|
+
k8s: "ASI02",
|
|
11692
|
+
mongodb: "ASI02",
|
|
11693
|
+
postgres: "ASI02",
|
|
11694
|
+
redis: "ASI02",
|
|
11695
|
+
stripe: "ASI09",
|
|
11696
|
+
paypal: "ASI09",
|
|
11697
|
+
square: "ASI09",
|
|
11698
|
+
plaid: "ASI09",
|
|
11699
|
+
okta: "ASI09",
|
|
11700
|
+
auth0: "ASI09"
|
|
11701
|
+
};
|
|
11702
|
+
PACK_RULE_OWASP = {
|
|
11703
|
+
"packs.bash-safe.pipe-to-shell": "ASI05",
|
|
11704
|
+
"packs.bash-safe.obfuscated-exec": "ASI05",
|
|
11705
|
+
"packs.bash-safe.eval-remote": "ASI05",
|
|
11706
|
+
"packs.bash-safe.eval-dynamic": "ASI05",
|
|
11707
|
+
"packs.aws.iam-changes": "ASI03",
|
|
11708
|
+
"packs.postgres.grant-revoke": "ASI03"
|
|
11709
|
+
};
|
|
11665
11710
|
VERDICTS = ["off", "log", "review", "block"];
|
|
11666
11711
|
CHECK_VERDICT_RANK = { off: 0, log: 1, review: 2, block: 3 };
|
|
11667
11712
|
ALL = VERDICTS;
|
|
@@ -11670,6 +11715,7 @@ var init_dist = __esm({
|
|
|
11670
11715
|
{
|
|
11671
11716
|
id: "files.shell-startup",
|
|
11672
11717
|
group: "files",
|
|
11718
|
+
owasp: "ASI02",
|
|
11673
11719
|
title: "Shell startup files",
|
|
11674
11720
|
catches: "Writes, replacements and removals of personal shell startup files",
|
|
11675
11721
|
values: ALL,
|
|
@@ -11679,6 +11725,7 @@ var init_dist = __esm({
|
|
|
11679
11725
|
{
|
|
11680
11726
|
id: "files.system-auth",
|
|
11681
11727
|
group: "files",
|
|
11728
|
+
owasp: "ASI03",
|
|
11682
11729
|
title: "System authentication files",
|
|
11683
11730
|
catches: "Changes to system authentication files and PAM configuration",
|
|
11684
11731
|
values: ["block"],
|
|
@@ -11689,6 +11736,7 @@ var init_dist = __esm({
|
|
|
11689
11736
|
{
|
|
11690
11737
|
id: "files.password-hashes",
|
|
11691
11738
|
group: "files",
|
|
11739
|
+
owasp: "ASI03",
|
|
11692
11740
|
title: "System password hashes",
|
|
11693
11741
|
catches: "Reads and copies of /etc/shadow and /etc/gshadow",
|
|
11694
11742
|
values: ALL,
|
|
@@ -11698,6 +11746,7 @@ var init_dist = __esm({
|
|
|
11698
11746
|
{
|
|
11699
11747
|
id: "files.system-dirs",
|
|
11700
11748
|
group: "files",
|
|
11749
|
+
owasp: "ASI02",
|
|
11701
11750
|
title: "System directories",
|
|
11702
11751
|
catches: "Writes, new files and removals under /usr, /etc, /boot, /bin, /sbin, /lib and /var/log, and uploads of system files",
|
|
11703
11752
|
values: ALL,
|
|
@@ -11707,6 +11756,7 @@ var init_dist = __esm({
|
|
|
11707
11756
|
{
|
|
11708
11757
|
id: "files.agent-instructions",
|
|
11709
11758
|
group: "files",
|
|
11759
|
+
owasp: "ASI06",
|
|
11710
11760
|
title: "Agent instruction and memory files",
|
|
11711
11761
|
catches: "writes to the files every later agent session loads as instructions (CLAUDE.md, AGENTS.md, memory, agents, commands) and changes to the agent's hooks; Standard asks only when the text carries an instruction to hide, skip approvals or touch secrets",
|
|
11712
11762
|
values: ALL,
|
|
@@ -11717,6 +11767,7 @@ var init_dist = __esm({
|
|
|
11717
11767
|
{
|
|
11718
11768
|
id: "commands.inline-exec",
|
|
11719
11769
|
group: "commands",
|
|
11770
|
+
owasp: "ASI05",
|
|
11720
11771
|
title: "Inline code execution",
|
|
11721
11772
|
catches: "inline code (python -c, node -e, a heredoc into an interpreter) that deletes, sends, opens a socket, runs commands, reads protected files or decodes and runs; unreadable inline code",
|
|
11722
11773
|
values: ALL,
|
|
@@ -11726,6 +11777,7 @@ var init_dist = __esm({
|
|
|
11726
11777
|
{
|
|
11727
11778
|
id: "commands.eval-dynamic",
|
|
11728
11779
|
group: "commands",
|
|
11780
|
+
owasp: "ASI05",
|
|
11729
11781
|
title: "Eval of dynamic content",
|
|
11730
11782
|
catches: "generated executable names, shell code from stdin, or dynamic eval/-c payloads",
|
|
11731
11783
|
values: ALL,
|
|
@@ -11735,6 +11787,7 @@ var init_dist = __esm({
|
|
|
11735
11787
|
{
|
|
11736
11788
|
id: "commands.eval-remote",
|
|
11737
11789
|
group: "commands",
|
|
11790
|
+
owasp: "ASI05",
|
|
11738
11791
|
title: "Eval of a remote download",
|
|
11739
11792
|
catches: "eval or sh over the output of curl or wget",
|
|
11740
11793
|
values: ["block"],
|
|
@@ -11745,6 +11798,7 @@ var init_dist = __esm({
|
|
|
11745
11798
|
{
|
|
11746
11799
|
id: "commands.curl-pipe-shell",
|
|
11747
11800
|
group: "commands",
|
|
11801
|
+
owasp: "ASI05",
|
|
11748
11802
|
title: "Remote script piped into a shell",
|
|
11749
11803
|
catches: "curl or wget piped into sh, bash, zsh or PowerShell",
|
|
11750
11804
|
values: ALL,
|
|
@@ -11754,6 +11808,7 @@ var init_dist = __esm({
|
|
|
11754
11808
|
{
|
|
11755
11809
|
id: "commands.rm",
|
|
11756
11810
|
group: "commands",
|
|
11811
|
+
owasp: "ASI02",
|
|
11757
11812
|
title: "Delete files",
|
|
11758
11813
|
catches: "rm outside the known build-artifact paths",
|
|
11759
11814
|
values: ALL,
|
|
@@ -11763,6 +11818,7 @@ var init_dist = __esm({
|
|
|
11763
11818
|
{
|
|
11764
11819
|
id: "commands.rm-home",
|
|
11765
11820
|
group: "commands",
|
|
11821
|
+
owasp: "ASI02",
|
|
11766
11822
|
title: "Recursive delete of the home directory",
|
|
11767
11823
|
catches: "rm -rf on ~, $HOME, /home or /",
|
|
11768
11824
|
values: ["block"],
|
|
@@ -11773,6 +11829,7 @@ var init_dist = __esm({
|
|
|
11773
11829
|
{
|
|
11774
11830
|
id: "commands.chmod",
|
|
11775
11831
|
group: "commands",
|
|
11832
|
+
owasp: "ASI02",
|
|
11776
11833
|
title: "World-writable permissions",
|
|
11777
11834
|
catches: "chmod 777, 0777 or a+rwx",
|
|
11778
11835
|
values: ALL,
|
|
@@ -11782,6 +11839,7 @@ var init_dist = __esm({
|
|
|
11782
11839
|
{
|
|
11783
11840
|
id: "commands.sudo",
|
|
11784
11841
|
group: "commands",
|
|
11842
|
+
owasp: "ASI03",
|
|
11785
11843
|
title: "Elevated privileges",
|
|
11786
11844
|
catches: "a command run through sudo",
|
|
11787
11845
|
values: ALL,
|
|
@@ -11791,6 +11849,7 @@ var init_dist = __esm({
|
|
|
11791
11849
|
{
|
|
11792
11850
|
id: "commands.git-destructive",
|
|
11793
11851
|
group: "commands",
|
|
11852
|
+
owasp: "ASI02",
|
|
11794
11853
|
title: "Destructive git operation",
|
|
11795
11854
|
catches: "force push, reset --hard, clean -f, branch -D or tag delete, also through -C, env, wrappers, variables and aliases",
|
|
11796
11855
|
values: ALL,
|
|
@@ -11800,6 +11859,7 @@ var init_dist = __esm({
|
|
|
11800
11859
|
{
|
|
11801
11860
|
id: "commands.git-hooks-bypass",
|
|
11802
11861
|
group: "commands",
|
|
11862
|
+
owasp: "ASI10",
|
|
11803
11863
|
title: "Git hooks bypassed",
|
|
11804
11864
|
catches: "the agent switches off the git hooks that check its own work: --no-verify, core.hooksPath, HUSKY=0 and its peers, or a hook file removed, emptied or made non-executable",
|
|
11805
11865
|
values: ALL,
|
|
@@ -11809,6 +11869,7 @@ var init_dist = __esm({
|
|
|
11809
11869
|
{
|
|
11810
11870
|
id: "commands.git-stage-all",
|
|
11811
11871
|
group: "commands",
|
|
11872
|
+
owasp: "ASI02",
|
|
11812
11873
|
title: "Stage everything at once",
|
|
11813
11874
|
catches: "git add -A, git add ., git commit -a and other ways to stage every change instead of naming the files; off unless you switch it on",
|
|
11814
11875
|
values: ALL,
|
|
@@ -11818,6 +11879,7 @@ var init_dist = __esm({
|
|
|
11818
11879
|
{
|
|
11819
11880
|
id: "commands.reverse-shell",
|
|
11820
11881
|
group: "commands",
|
|
11882
|
+
owasp: "ASI05",
|
|
11821
11883
|
title: "Reverse shell",
|
|
11822
11884
|
catches: "a shell wired to a network socket: bash -i >& /dev/tcp/\u2026, nc -e, socat exec:, a socket fd read by a shell, a shell piped to and from nc or telnet",
|
|
11823
11885
|
values: ALL,
|
|
@@ -11827,6 +11889,7 @@ var init_dist = __esm({
|
|
|
11827
11889
|
{
|
|
11828
11890
|
id: "commands.node9-disarm",
|
|
11829
11891
|
group: "commands",
|
|
11892
|
+
owasp: "ASI10",
|
|
11830
11893
|
title: "node9 disarmed from the shell",
|
|
11831
11894
|
catches: "a node9 command that clears a session flag, trusts a destination, pauses the gate or weakens a shield, run by the agent",
|
|
11832
11895
|
values: ALL,
|
|
@@ -11836,6 +11899,7 @@ var init_dist = __esm({
|
|
|
11836
11899
|
{
|
|
11837
11900
|
id: "commands.sql-ddl",
|
|
11838
11901
|
group: "commands",
|
|
11902
|
+
owasp: "ASI02",
|
|
11839
11903
|
title: "Drop or truncate",
|
|
11840
11904
|
catches: "DROP or TRUNCATE through a database CLI or a database tool",
|
|
11841
11905
|
values: ALL,
|
|
@@ -11850,6 +11914,7 @@ var init_dist = __esm({
|
|
|
11850
11914
|
{
|
|
11851
11915
|
id: "commands.sql-no-where",
|
|
11852
11916
|
group: "commands",
|
|
11917
|
+
owasp: "ASI02",
|
|
11853
11918
|
title: "Unscoped SQL mutation",
|
|
11854
11919
|
catches: "DELETE or UPDATE without a WHERE clause",
|
|
11855
11920
|
values: ALL,
|
|
@@ -11859,6 +11924,7 @@ var init_dist = __esm({
|
|
|
11859
11924
|
{
|
|
11860
11925
|
id: "commands.temp-binary",
|
|
11861
11926
|
group: "commands",
|
|
11927
|
+
owasp: "ASI05",
|
|
11862
11928
|
title: "Binary from a temp directory",
|
|
11863
11929
|
catches: "an absolute path under /tmp, /var/tmp, /dev/shm or a world-writable file",
|
|
11864
11930
|
values: ALL,
|
|
@@ -11868,6 +11934,7 @@ var init_dist = __esm({
|
|
|
11868
11934
|
{
|
|
11869
11935
|
id: "commands.disk-destroy",
|
|
11870
11936
|
group: "commands",
|
|
11937
|
+
owasp: "ASI02",
|
|
11871
11938
|
title: "Disk or filesystem destruction",
|
|
11872
11939
|
catches: "mkfs, shred, dd and the manual-terminal disaster list",
|
|
11873
11940
|
values: ALL,
|
|
@@ -11877,6 +11944,7 @@ var init_dist = __esm({
|
|
|
11877
11944
|
{
|
|
11878
11945
|
id: "commands.dangerous-word",
|
|
11879
11946
|
group: "commands",
|
|
11947
|
+
owasp: "ASI02",
|
|
11880
11948
|
title: "Dangerous word",
|
|
11881
11949
|
catches: "a word from a pack or from the config dangerousWords list",
|
|
11882
11950
|
values: ALL,
|
|
@@ -11885,6 +11953,7 @@ var init_dist = __esm({
|
|
|
11885
11953
|
{
|
|
11886
11954
|
id: "commands.unanalysable",
|
|
11887
11955
|
group: "commands",
|
|
11956
|
+
owasp: "ASI02",
|
|
11888
11957
|
title: "Command too nested to analyse",
|
|
11889
11958
|
catches: "wrappers nested past the depth the shell parser follows",
|
|
11890
11959
|
values: ALL,
|
|
@@ -11894,6 +11963,7 @@ var init_dist = __esm({
|
|
|
11894
11963
|
{
|
|
11895
11964
|
id: "commands.unknown",
|
|
11896
11965
|
group: "commands",
|
|
11966
|
+
owasp: "ASI02",
|
|
11897
11967
|
title: "Any command no check recognised",
|
|
11898
11968
|
catches: "the strict-mode catch-all",
|
|
11899
11969
|
values: ["off", "review"],
|
|
@@ -11904,6 +11974,7 @@ var init_dist = __esm({
|
|
|
11904
11974
|
{
|
|
11905
11975
|
id: "data.secrets",
|
|
11906
11976
|
group: "data",
|
|
11977
|
+
owasp: "ASI03",
|
|
11907
11978
|
title: "Secret in arguments",
|
|
11908
11979
|
catches: "an API key, token or private key matching one of the DLP patterns",
|
|
11909
11980
|
values: ALL,
|
|
@@ -11913,6 +11984,7 @@ var init_dist = __esm({
|
|
|
11913
11984
|
{
|
|
11914
11985
|
id: "data.secrets-weak",
|
|
11915
11986
|
group: "data",
|
|
11987
|
+
owasp: "ASI03",
|
|
11916
11988
|
title: "Weak credential in arguments",
|
|
11917
11989
|
catches: "a JWT or a bearer token",
|
|
11918
11990
|
values: ALL,
|
|
@@ -11922,6 +11994,7 @@ var init_dist = __esm({
|
|
|
11922
11994
|
{
|
|
11923
11995
|
id: "data.pii",
|
|
11924
11996
|
group: "data",
|
|
11997
|
+
owasp: "ASI02",
|
|
11925
11998
|
title: "Personal data in arguments",
|
|
11926
11999
|
catches: "a social security number or a credit card number",
|
|
11927
12000
|
values: ALL,
|
|
@@ -11931,6 +12004,7 @@ var init_dist = __esm({
|
|
|
11931
12004
|
{
|
|
11932
12005
|
id: "data.credential-files",
|
|
11933
12006
|
group: "data",
|
|
12007
|
+
owasp: "ASI03",
|
|
11934
12008
|
title: "Credential file read",
|
|
11935
12009
|
catches: "~/.ssh, ~/.aws and .env files, through any reader or any file tool",
|
|
11936
12010
|
values: ALL,
|
|
@@ -11939,6 +12013,7 @@ var init_dist = __esm({
|
|
|
11939
12013
|
{
|
|
11940
12014
|
id: "data.credential-files-other",
|
|
11941
12015
|
group: "data",
|
|
12016
|
+
owasp: "ASI03",
|
|
11942
12017
|
title: "Other credential file",
|
|
11943
12018
|
catches: ".netrc, .npmrc, kube and docker config, and a copy of any credential file",
|
|
11944
12019
|
values: ALL,
|
|
@@ -11947,6 +12022,7 @@ var init_dist = __esm({
|
|
|
11947
12022
|
{
|
|
11948
12023
|
id: "data.credential-files-unknown",
|
|
11949
12024
|
group: "data",
|
|
12025
|
+
owasp: "ASI03",
|
|
11950
12026
|
title: "Files read by names known only at run time",
|
|
11951
12027
|
catches: "a reader fed names from a listing that can include credential files (find . | xargs cat)",
|
|
11952
12028
|
values: ALL,
|
|
@@ -11955,6 +12031,7 @@ var init_dist = __esm({
|
|
|
11955
12031
|
{
|
|
11956
12032
|
id: "data.pipe-chain",
|
|
11957
12033
|
group: "data",
|
|
12034
|
+
owasp: "ASI03",
|
|
11958
12035
|
title: "Sensitive file piped to the network",
|
|
11959
12036
|
catches: "a credential file read and piped into curl, nc or ssh",
|
|
11960
12037
|
values: ALL,
|
|
@@ -11964,6 +12041,7 @@ var init_dist = __esm({
|
|
|
11964
12041
|
{
|
|
11965
12042
|
id: "data.pipe-chain-obfuscated",
|
|
11966
12043
|
group: "data",
|
|
12044
|
+
owasp: "ASI03",
|
|
11967
12045
|
title: "Obfuscated exfiltration",
|
|
11968
12046
|
catches: "a sensitive file encoded or compressed on its way to the network",
|
|
11969
12047
|
values: ALL,
|
|
@@ -11976,6 +12054,7 @@ var init_dist = __esm({
|
|
|
11976
12054
|
{
|
|
11977
12055
|
id: "data.env-exfil",
|
|
11978
12056
|
group: "data",
|
|
12057
|
+
owasp: "ASI03",
|
|
11979
12058
|
title: "Environment sent out",
|
|
11980
12059
|
catches: "the whole environment (env, printenv, set, export -p, /proc/*/environ) handed to curl, nc or another sender, through $(\u2026), a pipe or a variable",
|
|
11981
12060
|
values: ALL,
|
|
@@ -11985,6 +12064,7 @@ var init_dist = __esm({
|
|
|
11985
12064
|
{
|
|
11986
12065
|
id: "data.output-secrets",
|
|
11987
12066
|
group: "data",
|
|
12067
|
+
owasp: "ASI03",
|
|
11988
12068
|
title: "Secret in tool output",
|
|
11989
12069
|
catches: "a credential a tool returned; the session is tainted, nothing is stopped",
|
|
11990
12070
|
values: ["off", "log"],
|
|
@@ -11993,6 +12073,7 @@ var init_dist = __esm({
|
|
|
11993
12073
|
{
|
|
11994
12074
|
id: "data.prompt-secrets",
|
|
11995
12075
|
group: "data",
|
|
12076
|
+
owasp: "ASI03",
|
|
11996
12077
|
title: "Secret in the prompt",
|
|
11997
12078
|
catches: "a credential pasted into the conversation",
|
|
11998
12079
|
values: ALL,
|
|
@@ -12001,6 +12082,7 @@ var init_dist = __esm({
|
|
|
12001
12082
|
{
|
|
12002
12083
|
id: "data.canary",
|
|
12003
12084
|
group: "data",
|
|
12085
|
+
owasp: "ASI03",
|
|
12004
12086
|
title: "Decoy credential used",
|
|
12005
12087
|
catches: "a planted decoy value appears in a tool call",
|
|
12006
12088
|
values: ALL,
|
|
@@ -12011,6 +12093,7 @@ var init_dist = __esm({
|
|
|
12011
12093
|
{
|
|
12012
12094
|
id: "network.unknown-host",
|
|
12013
12095
|
group: "network",
|
|
12096
|
+
owasp: "ASI02",
|
|
12014
12097
|
title: "Unknown host",
|
|
12015
12098
|
catches: "a destination on neither the allowlist nor the builtin list",
|
|
12016
12099
|
values: ["off", "review", "block"],
|
|
@@ -12020,6 +12103,7 @@ var init_dist = __esm({
|
|
|
12020
12103
|
{
|
|
12021
12104
|
id: "network.internal-addresses",
|
|
12022
12105
|
group: "network",
|
|
12106
|
+
owasp: "ASI02",
|
|
12023
12107
|
title: "Internal address",
|
|
12024
12108
|
catches: "loopback, the RFC 1918 ranges and carrier-grade NAT",
|
|
12025
12109
|
values: ["off", "block"],
|
|
@@ -12028,6 +12112,7 @@ var init_dist = __esm({
|
|
|
12028
12112
|
{
|
|
12029
12113
|
id: "network.metadata",
|
|
12030
12114
|
group: "network",
|
|
12115
|
+
owasp: "ASI02",
|
|
12031
12116
|
title: "Cloud metadata address",
|
|
12032
12117
|
catches: "169.254.169.254 and its peers, link-local and multicast",
|
|
12033
12118
|
values: ["block"],
|
|
@@ -12038,6 +12123,7 @@ var init_dist = __esm({
|
|
|
12038
12123
|
{
|
|
12039
12124
|
id: "network.taint-egress",
|
|
12040
12125
|
group: "network",
|
|
12126
|
+
owasp: "ASI01",
|
|
12041
12127
|
title: "Tainted data sent out",
|
|
12042
12128
|
catches: "a file or an output flagged earlier in the session reaches a host not on the allowlist",
|
|
12043
12129
|
values: ALL,
|
|
@@ -12051,6 +12137,7 @@ var init_dist = __esm({
|
|
|
12051
12137
|
{
|
|
12052
12138
|
id: "files.jail",
|
|
12053
12139
|
group: "files",
|
|
12140
|
+
owasp: "ASI03",
|
|
12054
12141
|
title: "Jailed path",
|
|
12055
12142
|
catches: "a path the workspace or the developer added to the jail",
|
|
12056
12143
|
values: ALL,
|
|
@@ -12060,6 +12147,7 @@ var init_dist = __esm({
|
|
|
12060
12147
|
{
|
|
12061
12148
|
id: "behavior.loops",
|
|
12062
12149
|
group: "behavior",
|
|
12150
|
+
owasp: "ASI08",
|
|
12063
12151
|
title: "Runaway loop",
|
|
12064
12152
|
catches: "the same tool call repeated past the threshold inside the window",
|
|
12065
12153
|
values: ["off", "block"],
|
|
@@ -12069,6 +12157,7 @@ var init_dist = __esm({
|
|
|
12069
12157
|
{
|
|
12070
12158
|
id: "behavior.prompt-injection",
|
|
12071
12159
|
group: "behavior",
|
|
12160
|
+
owasp: "ASI01",
|
|
12072
12161
|
title: "Prompt injection in tool output",
|
|
12073
12162
|
catches: "instructions aimed at the model inside content a tool returned",
|
|
12074
12163
|
values: ["off", "log"],
|
|
@@ -12077,6 +12166,7 @@ var init_dist = __esm({
|
|
|
12077
12166
|
{
|
|
12078
12167
|
id: "behavior.session-taint",
|
|
12079
12168
|
group: "behavior",
|
|
12169
|
+
owasp: "ASI01",
|
|
12080
12170
|
title: "Action after tainted output",
|
|
12081
12171
|
catches: "a network call or a write after a flagged file or a flagged tool output",
|
|
12082
12172
|
values: ALL,
|
|
@@ -12086,6 +12176,7 @@ var init_dist = __esm({
|
|
|
12086
12176
|
{
|
|
12087
12177
|
id: "behavior.untrusted-content",
|
|
12088
12178
|
group: "behavior",
|
|
12179
|
+
owasp: "ASI01",
|
|
12089
12180
|
title: "Send after reading outside content",
|
|
12090
12181
|
catches: "a send to an unknown destination, a destination found in what was read, or a destructive call after the session read an email, a web page or an issue",
|
|
12091
12182
|
values: ["off", "log", "review"],
|
|
@@ -12096,6 +12187,7 @@ var init_dist = __esm({
|
|
|
12096
12187
|
{
|
|
12097
12188
|
id: "loading.skill-tamper",
|
|
12098
12189
|
group: "loading",
|
|
12190
|
+
owasp: "ASI04",
|
|
12099
12191
|
title: "Skill file changed",
|
|
12100
12192
|
catches: "a skill or plugin file whose hash differs from the one approved",
|
|
12101
12193
|
values: ["off", "log", "block"],
|
|
@@ -12105,6 +12197,7 @@ var init_dist = __esm({
|
|
|
12105
12197
|
{
|
|
12106
12198
|
id: "loading.mcp-tamper",
|
|
12107
12199
|
group: "loading",
|
|
12200
|
+
owasp: "ASI04",
|
|
12108
12201
|
title: "MCP server changed",
|
|
12109
12202
|
catches: "tool definitions that differ from the pinned ones",
|
|
12110
12203
|
values: ALL,
|
|
@@ -12114,6 +12207,7 @@ var init_dist = __esm({
|
|
|
12114
12207
|
{
|
|
12115
12208
|
id: "loading.malicious-package",
|
|
12116
12209
|
group: "loading",
|
|
12210
|
+
owasp: "ASI04",
|
|
12117
12211
|
title: "Malicious package",
|
|
12118
12212
|
catches: "an install of a package the index flags",
|
|
12119
12213
|
values: ALL,
|
|
@@ -12123,6 +12217,7 @@ var init_dist = __esm({
|
|
|
12123
12217
|
{
|
|
12124
12218
|
id: "loading.unknown-registry",
|
|
12125
12219
|
group: "loading",
|
|
12220
|
+
owasp: "ASI04",
|
|
12126
12221
|
title: "Package from an unknown registry",
|
|
12127
12222
|
catches: "an install that names a registry on the command line (--registry, --index-url, -i, npm_config_registry=\u2026) that is not the public one, not in your npm, yarn, bun, pip or uv config and not on the allowlist",
|
|
12128
12223
|
values: ALL,
|
|
@@ -12137,6 +12232,7 @@ var init_dist = __esm({
|
|
|
12137
12232
|
{
|
|
12138
12233
|
id: "actions.money",
|
|
12139
12234
|
group: "actions",
|
|
12235
|
+
owasp: "ASI09",
|
|
12140
12236
|
title: "Money moves",
|
|
12141
12237
|
catches: "a refund, payout, transfer, charge or withdrawal through an app with no protection of its own",
|
|
12142
12238
|
values: ALL,
|
|
@@ -12149,6 +12245,7 @@ var init_dist = __esm({
|
|
|
12149
12245
|
{
|
|
12150
12246
|
id: "actions.access",
|
|
12151
12247
|
group: "actions",
|
|
12248
|
+
owasp: "ASI09",
|
|
12152
12249
|
title: "Accounts and access change",
|
|
12153
12250
|
catches: "a password, key, role, permission or user changed through an app with no protection of its own",
|
|
12154
12251
|
values: ALL,
|
|
@@ -12158,6 +12255,7 @@ var init_dist = __esm({
|
|
|
12158
12255
|
{
|
|
12159
12256
|
id: "actions.publish",
|
|
12160
12257
|
group: "actions",
|
|
12258
|
+
owasp: "ASI09",
|
|
12161
12259
|
title: "Something is published",
|
|
12162
12260
|
catches: "a release, package, deploy or public post through an app with no protection of its own",
|
|
12163
12261
|
values: ALL,
|
|
@@ -12170,6 +12268,7 @@ var init_dist = __esm({
|
|
|
12170
12268
|
{
|
|
12171
12269
|
id: "actions.settings",
|
|
12172
12270
|
group: "actions",
|
|
12271
|
+
owasp: "ASI09",
|
|
12173
12272
|
title: "Repository, account and mailbox settings change",
|
|
12174
12273
|
catches: "a repository made public, a deploy key, webhook or CI secret added, branch protection changed, mail forwarded outside or a public share link, through an app",
|
|
12175
12274
|
values: ALL,
|
|
@@ -12179,6 +12278,7 @@ var init_dist = __esm({
|
|
|
12179
12278
|
{
|
|
12180
12279
|
id: "actions.protected-branch",
|
|
12181
12280
|
group: "actions",
|
|
12281
|
+
owasp: "ASI09",
|
|
12182
12282
|
title: "The main branch changes through an app",
|
|
12183
12283
|
catches: "a merge, a commit straight to main or master, or a CI workflow file written through an app",
|
|
12184
12284
|
values: ALL,
|
|
@@ -18997,16 +19097,16 @@ var init_audit = __esm({
|
|
|
18997
19097
|
// src/hook-entry.ts
|
|
18998
19098
|
init_cjs_shims();
|
|
18999
19099
|
var import_commander = require("commander");
|
|
19000
|
-
var
|
|
19100
|
+
var import_fs38 = __toESM(require("fs"));
|
|
19001
19101
|
var import_os29 = __toESM(require("os"));
|
|
19002
|
-
var
|
|
19102
|
+
var import_path40 = __toESM(require("path"));
|
|
19003
19103
|
|
|
19004
19104
|
// src/cli/commands/check.ts
|
|
19005
19105
|
init_cjs_shims();
|
|
19006
19106
|
var import_chalk2 = __toESM(require("chalk"));
|
|
19007
|
-
var
|
|
19107
|
+
var import_fs36 = __toESM(require("fs"));
|
|
19008
19108
|
var import_child_process3 = require("child_process");
|
|
19009
|
-
var
|
|
19109
|
+
var import_path38 = __toESM(require("path"));
|
|
19010
19110
|
var import_os27 = __toESM(require("os"));
|
|
19011
19111
|
|
|
19012
19112
|
// src/auth/orchestrator.ts
|
|
@@ -19445,7 +19545,7 @@ function resolveLinkedServer(label2, opts = {}) {
|
|
|
19445
19545
|
|
|
19446
19546
|
// src/auth/orchestrator.ts
|
|
19447
19547
|
var import_os21 = __toESM(require("os"));
|
|
19448
|
-
var
|
|
19548
|
+
var import_path32 = __toESM(require("path"));
|
|
19449
19549
|
|
|
19450
19550
|
// src/ui/native.ts
|
|
19451
19551
|
init_cjs_shims();
|
|
@@ -20021,20 +20121,92 @@ function prepareFileAccesses(tool, args, cwd = process.cwd(), inspection = {}, h
|
|
|
20021
20121
|
|
|
20022
20122
|
// src/auth/session-script.ts
|
|
20023
20123
|
init_cjs_shims();
|
|
20024
|
-
var
|
|
20124
|
+
var import_fs12 = __toESM(require("fs"));
|
|
20025
20125
|
var import_os9 = __toESM(require("os"));
|
|
20026
|
-
var
|
|
20126
|
+
var import_path14 = __toESM(require("path"));
|
|
20027
20127
|
init_dist();
|
|
20028
20128
|
|
|
20029
20129
|
// src/auth/daemon.ts
|
|
20030
20130
|
init_cjs_shims();
|
|
20031
|
-
var
|
|
20131
|
+
var import_fs11 = __toESM(require("fs"));
|
|
20032
20132
|
var import_http = __toESM(require("http"));
|
|
20033
20133
|
var import_net = __toESM(require("net"));
|
|
20034
|
-
var
|
|
20134
|
+
var import_path13 = __toESM(require("path"));
|
|
20035
20135
|
var import_os8 = __toESM(require("os"));
|
|
20036
20136
|
init_forecast_context();
|
|
20037
20137
|
|
|
20138
|
+
// src/utils/activity-socket.ts
|
|
20139
|
+
init_cjs_shims();
|
|
20140
|
+
var import_fs10 = __toESM(require("fs"));
|
|
20141
|
+
var import_path12 = __toESM(require("path"));
|
|
20142
|
+
|
|
20143
|
+
// src/utils/own-dir.ts
|
|
20144
|
+
init_cjs_shims();
|
|
20145
|
+
var import_fs9 = __toESM(require("fs"));
|
|
20146
|
+
var import_path11 = __toESM(require("path"));
|
|
20147
|
+
var SESSION_FLAG_SUFFIX = ".node9-flag";
|
|
20148
|
+
var SESSION_FLAG_NAME = /^[A-Za-z0-9_-]{1,128}\.node9-flag$/;
|
|
20149
|
+
function isSessionFlagName(name) {
|
|
20150
|
+
return SESSION_FLAG_NAME.test(name);
|
|
20151
|
+
}
|
|
20152
|
+
function ownRealDir(st) {
|
|
20153
|
+
if (st.isSymbolicLink() || !st.isDirectory()) return false;
|
|
20154
|
+
return typeof process.getuid !== "function" || st.uid === process.getuid();
|
|
20155
|
+
}
|
|
20156
|
+
function ensureOwnDir(dir2) {
|
|
20157
|
+
try {
|
|
20158
|
+
import_fs9.default.mkdirSync(dir2, { recursive: true, mode: 448 });
|
|
20159
|
+
const st = import_fs9.default.lstatSync(dir2);
|
|
20160
|
+
return ownRealDir(st) ? { dev: st.dev, ino: st.ino } : null;
|
|
20161
|
+
} catch {
|
|
20162
|
+
return null;
|
|
20163
|
+
}
|
|
20164
|
+
}
|
|
20165
|
+
function isSameOwnDir(dir2, seen) {
|
|
20166
|
+
try {
|
|
20167
|
+
const st = import_fs9.default.lstatSync(dir2);
|
|
20168
|
+
return ownRealDir(st) && st.dev === seen.dev && st.ino === seen.ino;
|
|
20169
|
+
} catch {
|
|
20170
|
+
return false;
|
|
20171
|
+
}
|
|
20172
|
+
}
|
|
20173
|
+
function removeOldFlag(dir2, seen, name, cutoffMs) {
|
|
20174
|
+
if (!isSessionFlagName(name)) return;
|
|
20175
|
+
const p = import_path11.default.join(dir2, name);
|
|
20176
|
+
try {
|
|
20177
|
+
const st = import_fs9.default.lstatSync(p);
|
|
20178
|
+
if (!st.isFile() || st.mtimeMs >= cutoffMs) return;
|
|
20179
|
+
if (!isSameOwnDir(dir2, seen)) return;
|
|
20180
|
+
import_fs9.default.unlinkSync(p);
|
|
20181
|
+
} catch {
|
|
20182
|
+
}
|
|
20183
|
+
}
|
|
20184
|
+
|
|
20185
|
+
// src/utils/activity-socket.ts
|
|
20186
|
+
var currentUid = () => typeof process.getuid === "function" ? process.getuid() : void 0;
|
|
20187
|
+
function isPrivateDir(dir2, uid = currentUid()) {
|
|
20188
|
+
try {
|
|
20189
|
+
const st = import_fs10.default.lstatSync(dir2);
|
|
20190
|
+
if (st.isSymbolicLink() || !st.isDirectory()) return false;
|
|
20191
|
+
if (uid !== void 0 && st.uid !== uid) return false;
|
|
20192
|
+
return (st.mode & 18) === 0;
|
|
20193
|
+
} catch {
|
|
20194
|
+
return false;
|
|
20195
|
+
}
|
|
20196
|
+
}
|
|
20197
|
+
var WINDOWS_PIPE = /^\\\\\.\\pipe\\node9-activity-[0-9a-f]{32}$/;
|
|
20198
|
+
function isTrustedActivitySocket(socketPath, uid = currentUid()) {
|
|
20199
|
+
if (process.platform === "win32") return WINDOWS_PIPE.test(socketPath);
|
|
20200
|
+
try {
|
|
20201
|
+
const st = import_fs10.default.lstatSync(socketPath);
|
|
20202
|
+
if (!st.isSocket()) return false;
|
|
20203
|
+
if (uid !== void 0 && st.uid !== uid) return false;
|
|
20204
|
+
} catch {
|
|
20205
|
+
return false;
|
|
20206
|
+
}
|
|
20207
|
+
return isPrivateDir(import_path12.default.dirname(socketPath), uid);
|
|
20208
|
+
}
|
|
20209
|
+
|
|
20038
20210
|
// src/auth/decision-record.ts
|
|
20039
20211
|
init_cjs_shims();
|
|
20040
20212
|
var CHANNELS = ["terminal", "monitor", "native", "cloud"];
|
|
@@ -20184,10 +20356,20 @@ function recordFromLegacyWait(body, now = Date.now()) {
|
|
|
20184
20356
|
}
|
|
20185
20357
|
|
|
20186
20358
|
// src/auth/daemon.ts
|
|
20187
|
-
|
|
20359
|
+
function daemonActivitySocket(home = import_os8.default.homedir()) {
|
|
20360
|
+
try {
|
|
20361
|
+
const raw = import_fs11.default.readFileSync(import_path13.default.join(home, ".node9", "daemon.pid"), "utf-8");
|
|
20362
|
+
const p = JSON.parse(raw).activitySocket;
|
|
20363
|
+
return typeof p === "string" && isTrustedActivitySocket(p) ? p : null;
|
|
20364
|
+
} catch {
|
|
20365
|
+
return null;
|
|
20366
|
+
}
|
|
20367
|
+
}
|
|
20188
20368
|
var ACTIVITY_SOCKET_TIMEOUT_MS = 500;
|
|
20189
20369
|
function notifyActivitySocket(data, opts = {}) {
|
|
20190
20370
|
if (forecastRun()) return Promise.resolve(false);
|
|
20371
|
+
const target = opts.socketPath ?? daemonActivitySocket();
|
|
20372
|
+
if (!target) return Promise.resolve(false);
|
|
20191
20373
|
return new Promise((resolve) => {
|
|
20192
20374
|
let settled = false;
|
|
20193
20375
|
let sock = null;
|
|
@@ -20201,7 +20383,7 @@ function notifyActivitySocket(data, opts = {}) {
|
|
|
20201
20383
|
const timer = setTimeout(() => finish(false), opts.timeoutMs ?? ACTIVITY_SOCKET_TIMEOUT_MS);
|
|
20202
20384
|
try {
|
|
20203
20385
|
const payload = JSON.stringify(data);
|
|
20204
|
-
sock = import_net.default.createConnection(
|
|
20386
|
+
sock = import_net.default.createConnection(target);
|
|
20205
20387
|
sock.on("connect", () => {
|
|
20206
20388
|
sock.on("close", () => finish(true));
|
|
20207
20389
|
sock.end(payload);
|
|
@@ -20240,9 +20422,9 @@ var DAEMON_HOST = "127.0.0.1";
|
|
|
20240
20422
|
function getInternalToken() {
|
|
20241
20423
|
if (forecastRun()) return null;
|
|
20242
20424
|
try {
|
|
20243
|
-
const pidFile =
|
|
20244
|
-
if (!
|
|
20245
|
-
const data = JSON.parse(
|
|
20425
|
+
const pidFile = import_path13.default.join(import_os8.default.homedir(), ".node9", "daemon.pid");
|
|
20426
|
+
if (!import_fs11.default.existsSync(pidFile)) return null;
|
|
20427
|
+
const data = JSON.parse(import_fs11.default.readFileSync(pidFile, "utf-8"));
|
|
20246
20428
|
process.kill(data.pid, 0);
|
|
20247
20429
|
return data.internalToken ?? null;
|
|
20248
20430
|
} catch {
|
|
@@ -20251,12 +20433,12 @@ function getInternalToken() {
|
|
|
20251
20433
|
}
|
|
20252
20434
|
function isDaemonRunning() {
|
|
20253
20435
|
if (forecastRun()) return false;
|
|
20254
|
-
const pidFile =
|
|
20255
|
-
if (
|
|
20436
|
+
const pidFile = import_path13.default.join(import_os8.default.homedir(), ".node9", "daemon.pid");
|
|
20437
|
+
if (import_fs11.default.existsSync(pidFile)) {
|
|
20256
20438
|
let pid;
|
|
20257
20439
|
let port;
|
|
20258
20440
|
try {
|
|
20259
|
-
const data = JSON.parse(
|
|
20441
|
+
const data = JSON.parse(import_fs11.default.readFileSync(pidFile, "utf-8"));
|
|
20260
20442
|
pid = data.pid;
|
|
20261
20443
|
port = data.port;
|
|
20262
20444
|
} catch {
|
|
@@ -20274,7 +20456,7 @@ function isDaemonRunning() {
|
|
|
20274
20456
|
} catch (err) {
|
|
20275
20457
|
if (err instanceof Error && "code" in err && err.code === "ESRCH") {
|
|
20276
20458
|
try {
|
|
20277
|
-
|
|
20459
|
+
import_fs11.default.unlinkSync(pidFile);
|
|
20278
20460
|
} catch {
|
|
20279
20461
|
}
|
|
20280
20462
|
}
|
|
@@ -20690,13 +20872,13 @@ var MAX_RECORDED_WRITES = 32;
|
|
|
20690
20872
|
function readScriptFile(resolved) {
|
|
20691
20873
|
let fd;
|
|
20692
20874
|
try {
|
|
20693
|
-
fd =
|
|
20694
|
-
const st =
|
|
20875
|
+
fd = import_fs12.default.openSync(resolved, import_fs12.default.constants.O_RDONLY | (import_fs12.default.constants.O_NONBLOCK ?? 0));
|
|
20876
|
+
const st = import_fs12.default.fstatSync(fd);
|
|
20695
20877
|
if (!st.isFile() || st.size > MAX_SCRIPT_BYTES) return null;
|
|
20696
20878
|
const buf = Buffer.alloc(MAX_SCRIPT_BYTES + 1);
|
|
20697
20879
|
let n = 0;
|
|
20698
20880
|
while (n < buf.length) {
|
|
20699
|
-
const got =
|
|
20881
|
+
const got = import_fs12.default.readSync(fd, buf, n, buf.length - n, n);
|
|
20700
20882
|
if (got === 0) break;
|
|
20701
20883
|
n += got;
|
|
20702
20884
|
}
|
|
@@ -20707,7 +20889,7 @@ function readScriptFile(resolved) {
|
|
|
20707
20889
|
} finally {
|
|
20708
20890
|
if (fd !== void 0) {
|
|
20709
20891
|
try {
|
|
20710
|
-
|
|
20892
|
+
import_fs12.default.closeSync(fd);
|
|
20711
20893
|
} catch {
|
|
20712
20894
|
}
|
|
20713
20895
|
}
|
|
@@ -20715,7 +20897,7 @@ function readScriptFile(resolved) {
|
|
|
20715
20897
|
}
|
|
20716
20898
|
function absolute(p, cwd, home) {
|
|
20717
20899
|
const spelled = p === "~" || p.startsWith("~/") ? home + p.slice(1) : p;
|
|
20718
|
-
return
|
|
20900
|
+
return import_path14.default.resolve(cwd, spelled);
|
|
20719
20901
|
}
|
|
20720
20902
|
async function resolveSessionScript(toolName, args, cwd, layers, deps, home = import_os9.default.homedir()) {
|
|
20721
20903
|
try {
|
|
@@ -20777,27 +20959,27 @@ init_dist();
|
|
|
20777
20959
|
|
|
20778
20960
|
// src/exposure/known-hosts.ts
|
|
20779
20961
|
init_cjs_shims();
|
|
20780
|
-
var
|
|
20781
|
-
var
|
|
20962
|
+
var import_fs14 = __toESM(require("fs"));
|
|
20963
|
+
var import_path16 = __toESM(require("path"));
|
|
20782
20964
|
|
|
20783
20965
|
// src/utils/git-remotes.ts
|
|
20784
20966
|
init_cjs_shims();
|
|
20785
|
-
var
|
|
20786
|
-
var
|
|
20967
|
+
var import_fs13 = __toESM(require("fs"));
|
|
20968
|
+
var import_path15 = __toESM(require("path"));
|
|
20787
20969
|
init_dist();
|
|
20788
20970
|
function readSmallFile(p, max) {
|
|
20789
20971
|
let fd;
|
|
20790
20972
|
try {
|
|
20791
|
-
fd =
|
|
20792
|
-
const st =
|
|
20973
|
+
fd = import_fs13.default.openSync(p, import_fs13.default.constants.O_RDONLY | (import_fs13.default.constants.O_NOFOLLOW ?? 0));
|
|
20974
|
+
const st = import_fs13.default.fstatSync(fd);
|
|
20793
20975
|
if (!st.isFile() || st.size > max) return null;
|
|
20794
20976
|
const buf = Buffer.alloc(st.size);
|
|
20795
|
-
const n =
|
|
20977
|
+
const n = import_fs13.default.readSync(fd, buf, 0, st.size, 0);
|
|
20796
20978
|
return buf.subarray(0, n).toString("utf8");
|
|
20797
20979
|
} catch {
|
|
20798
20980
|
return null;
|
|
20799
20981
|
} finally {
|
|
20800
|
-
if (fd !== void 0)
|
|
20982
|
+
if (fd !== void 0) import_fs13.default.closeSync(fd);
|
|
20801
20983
|
}
|
|
20802
20984
|
}
|
|
20803
20985
|
function gitRemoteHost(url) {
|
|
@@ -20816,20 +20998,20 @@ function gitRemoteHost(url) {
|
|
|
20816
20998
|
return null;
|
|
20817
20999
|
}
|
|
20818
21000
|
function findGitConfig(dir2, walkUp = true) {
|
|
20819
|
-
let cur =
|
|
21001
|
+
let cur = import_path15.default.resolve(dir2);
|
|
20820
21002
|
for (let i = 0; i < (walkUp ? 64 : 1); i++) {
|
|
20821
|
-
const dotGit =
|
|
20822
|
-
const direct = readSmallFile(
|
|
21003
|
+
const dotGit = import_path15.default.join(cur, ".git");
|
|
21004
|
+
const direct = readSmallFile(import_path15.default.join(dotGit, "config"), 1e6);
|
|
20823
21005
|
if (direct !== null) return direct;
|
|
20824
21006
|
const pointer = readSmallFile(dotGit, 4096);
|
|
20825
21007
|
const m = pointer && /^gitdir:\s*(.+?)\s*$/m.exec(pointer);
|
|
20826
21008
|
if (m) {
|
|
20827
|
-
let gitDir =
|
|
20828
|
-
const common = readSmallFile(
|
|
20829
|
-
if (common !== null) gitDir =
|
|
20830
|
-
return readSmallFile(
|
|
21009
|
+
let gitDir = import_path15.default.resolve(cur, m[1]);
|
|
21010
|
+
const common = readSmallFile(import_path15.default.join(gitDir, "commondir"), 4096);
|
|
21011
|
+
if (common !== null) gitDir = import_path15.default.resolve(gitDir, common.trim());
|
|
21012
|
+
return readSmallFile(import_path15.default.join(gitDir, "config"), 1e6);
|
|
20831
21013
|
}
|
|
20832
|
-
const parent =
|
|
21014
|
+
const parent = import_path15.default.dirname(cur);
|
|
20833
21015
|
if (parent === cur) return null;
|
|
20834
21016
|
cur = parent;
|
|
20835
21017
|
}
|
|
@@ -20839,12 +21021,12 @@ var cache3 = /* @__PURE__ */ new Map();
|
|
|
20839
21021
|
function readGitRemotes(dir2, opts = {}) {
|
|
20840
21022
|
if (!dir2) return [];
|
|
20841
21023
|
const walkUp = opts.walkUp !== false;
|
|
20842
|
-
const key = `${walkUp ? "up" : "at"}:${
|
|
21024
|
+
const key = `${walkUp ? "up" : "at"}:${import_path15.default.resolve(dir2)}`;
|
|
20843
21025
|
const hit = cache3.get(key);
|
|
20844
21026
|
if (hit) return hit;
|
|
20845
21027
|
const out = [];
|
|
20846
21028
|
try {
|
|
20847
|
-
const cfg = findGitConfig(
|
|
21029
|
+
const cfg = findGitConfig(import_path15.default.resolve(dir2), walkUp);
|
|
20848
21030
|
if (cfg !== null) {
|
|
20849
21031
|
let current = null;
|
|
20850
21032
|
for (const line of cfg.split(/\r?\n/)) {
|
|
@@ -20880,15 +21062,15 @@ var ECOSYSTEMS = [
|
|
|
20880
21062
|
];
|
|
20881
21063
|
var cache4 = /* @__PURE__ */ new Map();
|
|
20882
21064
|
function manifestRoot(dir2) {
|
|
20883
|
-
let cur =
|
|
21065
|
+
let cur = import_path16.default.resolve(dir2);
|
|
20884
21066
|
for (let i = 0; i < 64; i++) {
|
|
20885
21067
|
for (const [m] of ECOSYSTEMS) {
|
|
20886
21068
|
try {
|
|
20887
|
-
if (
|
|
21069
|
+
if (import_fs14.default.existsSync(import_path16.default.join(cur, m))) return cur;
|
|
20888
21070
|
} catch {
|
|
20889
21071
|
}
|
|
20890
21072
|
}
|
|
20891
|
-
const parent =
|
|
21073
|
+
const parent = import_path16.default.dirname(cur);
|
|
20892
21074
|
if (parent === cur) return null;
|
|
20893
21075
|
cur = parent;
|
|
20894
21076
|
}
|
|
@@ -20897,7 +21079,7 @@ function manifestRoot(dir2) {
|
|
|
20897
21079
|
function knownProjectHosts(dir2) {
|
|
20898
21080
|
const empty = { hosts: /* @__PURE__ */ new Set(), repos: /* @__PURE__ */ new Set(), remotes: /* @__PURE__ */ new Map() };
|
|
20899
21081
|
if (!dir2) return empty;
|
|
20900
|
-
const key =
|
|
21082
|
+
const key = import_path16.default.resolve(dir2);
|
|
20901
21083
|
const hit = cache4.get(key);
|
|
20902
21084
|
if (hit) return hit;
|
|
20903
21085
|
const out = { hosts: /* @__PURE__ */ new Set(), repos: /* @__PURE__ */ new Set(), remotes: /* @__PURE__ */ new Map() };
|
|
@@ -20910,10 +21092,10 @@ function knownProjectHosts(dir2) {
|
|
|
20910
21092
|
const root = manifestRoot(key);
|
|
20911
21093
|
if (root !== null) {
|
|
20912
21094
|
for (const [m, registry] of ECOSYSTEMS) {
|
|
20913
|
-
if (
|
|
21095
|
+
if (import_fs14.default.existsSync(import_path16.default.join(root, m))) out.hosts.add(registry);
|
|
20914
21096
|
}
|
|
20915
21097
|
try {
|
|
20916
|
-
if (
|
|
21098
|
+
if (import_fs14.default.readdirSync(root).some((f) => f.endsWith(".gemspec")))
|
|
20917
21099
|
out.hosts.add("host:rubygems.org");
|
|
20918
21100
|
} catch {
|
|
20919
21101
|
}
|
|
@@ -20926,9 +21108,9 @@ function knownProjectHosts(dir2) {
|
|
|
20926
21108
|
|
|
20927
21109
|
// src/exposure/writes.ts
|
|
20928
21110
|
init_cjs_shims();
|
|
20929
|
-
var
|
|
21111
|
+
var import_fs15 = __toESM(require("fs"));
|
|
20930
21112
|
var import_os10 = __toESM(require("os"));
|
|
20931
|
-
var
|
|
21113
|
+
var import_path17 = __toESM(require("path"));
|
|
20932
21114
|
init_dist();
|
|
20933
21115
|
var WRITE_OPS = /* @__PURE__ */ new Set(["write", "create", "remove"]);
|
|
20934
21116
|
var LIFECYCLE_RE = /"(scripts|preinstall|install|postinstall|prepare|prepublish|prepublishOnly|prepack|postpack|publish|postpublish)"\s*:/;
|
|
@@ -20958,7 +21140,7 @@ function packageScriptsTouched(args, absPath, shellCommand) {
|
|
|
20958
21140
|
if (typeof a.content === "string") {
|
|
20959
21141
|
try {
|
|
20960
21142
|
const next = JSON.parse(a.content);
|
|
20961
|
-
const prev = JSON.parse(
|
|
21143
|
+
const prev = JSON.parse(import_fs15.default.readFileSync(absPath, "utf8"));
|
|
20962
21144
|
return JSON.stringify(next.scripts ?? null) !== JSON.stringify(prev.scripts ?? null);
|
|
20963
21145
|
} catch {
|
|
20964
21146
|
return LIFECYCLE_RE.test(a.content);
|
|
@@ -20979,7 +21161,7 @@ function judgeWritesAfterExposure(opts) {
|
|
|
20979
21161
|
seen.add(p);
|
|
20980
21162
|
if (p === "/dev" || p.startsWith("/dev/")) continue;
|
|
20981
21163
|
if (root !== null && isInside(root, p)) {
|
|
20982
|
-
if (isAgentInstructionPath(p, root) && (
|
|
21164
|
+
if (isAgentInstructionPath(p, root) && (import_path17.default.basename(p) !== "package.json" || packageScriptsTouched(opts.args, p, opts.shellCommand)))
|
|
20983
21165
|
holds.push({ path: p, why: "agent-instruction" });
|
|
20984
21166
|
continue;
|
|
20985
21167
|
}
|
|
@@ -21002,9 +21184,9 @@ function judgeWritesAfterExposure(opts) {
|
|
|
21002
21184
|
// src/exposure/marker.ts
|
|
21003
21185
|
init_cjs_shims();
|
|
21004
21186
|
var import_crypto7 = __toESM(require("crypto"));
|
|
21005
|
-
var
|
|
21187
|
+
var import_fs16 = __toESM(require("fs"));
|
|
21006
21188
|
var import_os11 = __toESM(require("os"));
|
|
21007
|
-
var
|
|
21189
|
+
var import_path18 = __toESM(require("path"));
|
|
21008
21190
|
|
|
21009
21191
|
// src/daemon/exposure-store.ts
|
|
21010
21192
|
init_cjs_shims();
|
|
@@ -21013,30 +21195,30 @@ var SESSION_EXPOSURE_TTL_MS = 4 * 60 * 60 * 1e3;
|
|
|
21013
21195
|
// src/exposure/marker.ts
|
|
21014
21196
|
init_forecast_context();
|
|
21015
21197
|
function dir() {
|
|
21016
|
-
return
|
|
21198
|
+
return import_path18.default.join(import_os11.default.homedir(), ".node9", "exposure-sessions");
|
|
21017
21199
|
}
|
|
21018
21200
|
function file(sessionId) {
|
|
21019
21201
|
const id = import_crypto7.default.createHash("sha256").update(sessionId).digest("hex").slice(0, 32);
|
|
21020
|
-
return
|
|
21202
|
+
return import_path18.default.join(dir(), id);
|
|
21021
21203
|
}
|
|
21022
21204
|
function markSessionExposed(sessionId) {
|
|
21023
21205
|
if (!sessionId) return;
|
|
21024
21206
|
if (forecastRun()) return;
|
|
21025
21207
|
try {
|
|
21026
|
-
|
|
21208
|
+
import_fs16.default.mkdirSync(dir(), { recursive: true, mode: 448 });
|
|
21027
21209
|
const f = file(sessionId);
|
|
21028
21210
|
const now = /* @__PURE__ */ new Date();
|
|
21029
21211
|
try {
|
|
21030
|
-
|
|
21212
|
+
import_fs16.default.utimesSync(f, now, now);
|
|
21031
21213
|
} catch {
|
|
21032
|
-
|
|
21214
|
+
import_fs16.default.writeFileSync(f, "", { mode: 384 });
|
|
21033
21215
|
}
|
|
21034
21216
|
if (Math.random() < 0.05) {
|
|
21035
21217
|
const cutoff = Date.now() - 24 * 60 * 60 * 1e3;
|
|
21036
|
-
for (const name of
|
|
21218
|
+
for (const name of import_fs16.default.readdirSync(dir())) {
|
|
21037
21219
|
try {
|
|
21038
|
-
const p =
|
|
21039
|
-
if (
|
|
21220
|
+
const p = import_path18.default.join(dir(), name);
|
|
21221
|
+
if (import_fs16.default.statSync(p).mtimeMs < cutoff) import_fs16.default.unlinkSync(p);
|
|
21040
21222
|
} catch {
|
|
21041
21223
|
}
|
|
21042
21224
|
}
|
|
@@ -21049,7 +21231,7 @@ function maybeSessionExposed(sessionId) {
|
|
|
21049
21231
|
const forecast = forecastRun();
|
|
21050
21232
|
if (forecast) return forecast.session.checkExposure(forecast.now) !== null;
|
|
21051
21233
|
try {
|
|
21052
|
-
const st =
|
|
21234
|
+
const st = import_fs16.default.statSync(file(sessionId));
|
|
21053
21235
|
return Date.now() - st.mtimeMs < SESSION_EXPOSURE_TTL_MS;
|
|
21054
21236
|
} catch (e) {
|
|
21055
21237
|
return e.code !== "ENOENT";
|
|
@@ -21058,7 +21240,7 @@ function maybeSessionExposed(sessionId) {
|
|
|
21058
21240
|
|
|
21059
21241
|
// src/exposure/roles.ts
|
|
21060
21242
|
init_cjs_shims();
|
|
21061
|
-
var
|
|
21243
|
+
var import_fs17 = __toESM(require("fs"));
|
|
21062
21244
|
var EXPOSURE_LABEL = "\u{1F6E1}\uFE0F Node9 Exposure";
|
|
21063
21245
|
var AGENT_INTERNAL_PREFIXES = ["ccd_", "visualize"];
|
|
21064
21246
|
function foldServerName(name) {
|
|
@@ -21068,7 +21250,7 @@ var inventoryCache = null;
|
|
|
21068
21250
|
var inventoryStamp = null;
|
|
21069
21251
|
function inventoryFileStamp() {
|
|
21070
21252
|
try {
|
|
21071
|
-
const st =
|
|
21253
|
+
const st = import_fs17.default.statSync(getMcpToolsFile());
|
|
21072
21254
|
return `${st.mtimeMs}:${st.size}`;
|
|
21073
21255
|
} catch {
|
|
21074
21256
|
return "";
|
|
@@ -21165,16 +21347,16 @@ function sourceWord(toolName) {
|
|
|
21165
21347
|
|
|
21166
21348
|
// src/auth/trusted-recipients.ts
|
|
21167
21349
|
init_cjs_shims();
|
|
21168
|
-
var
|
|
21169
|
-
var
|
|
21350
|
+
var import_fs18 = __toESM(require("fs"));
|
|
21351
|
+
var import_path19 = __toESM(require("path"));
|
|
21170
21352
|
var import_os12 = __toESM(require("os"));
|
|
21171
21353
|
init_dist();
|
|
21172
21354
|
function getTrustedRecipientsPath() {
|
|
21173
|
-
return
|
|
21355
|
+
return import_path19.default.join(import_os12.default.homedir(), ".node9", "trusted-recipients.json");
|
|
21174
21356
|
}
|
|
21175
21357
|
function readTrustedRecipients() {
|
|
21176
21358
|
try {
|
|
21177
|
-
const raw =
|
|
21359
|
+
const raw = import_fs18.default.readFileSync(getTrustedRecipientsPath(), "utf8");
|
|
21178
21360
|
const parsed = JSON.parse(raw);
|
|
21179
21361
|
return Array.isArray(parsed.entries) ? parsed.entries.filter((e) => e && typeof e.value === "string") : [];
|
|
21180
21362
|
} catch {
|
|
@@ -21183,10 +21365,10 @@ function readTrustedRecipients() {
|
|
|
21183
21365
|
}
|
|
21184
21366
|
function writeTrustedRecipients(entries) {
|
|
21185
21367
|
const filePath = getTrustedRecipientsPath();
|
|
21186
|
-
|
|
21368
|
+
import_fs18.default.mkdirSync(import_path19.default.dirname(filePath), { recursive: true });
|
|
21187
21369
|
const tmp = filePath + ".node9-tmp";
|
|
21188
|
-
|
|
21189
|
-
|
|
21370
|
+
import_fs18.default.writeFileSync(tmp, JSON.stringify({ entries }, null, 2), { mode: 384 });
|
|
21371
|
+
import_fs18.default.renameSync(tmp, filePath);
|
|
21190
21372
|
}
|
|
21191
21373
|
function addTrustedRecipient(raw, addedBy = "user") {
|
|
21192
21374
|
const value = normalizeRecipient(raw);
|
|
@@ -21201,7 +21383,7 @@ function addTrustedRecipient(raw, addedBy = "user") {
|
|
|
21201
21383
|
var cache5 = null;
|
|
21202
21384
|
function mtimeOf() {
|
|
21203
21385
|
try {
|
|
21204
|
-
return
|
|
21386
|
+
return import_fs18.default.statSync(getTrustedRecipientsPath()).mtimeMs;
|
|
21205
21387
|
} catch {
|
|
21206
21388
|
return 0;
|
|
21207
21389
|
}
|
|
@@ -21216,15 +21398,15 @@ function isTrustedRecipient(value) {
|
|
|
21216
21398
|
|
|
21217
21399
|
// src/auth/trusted-hosts.ts
|
|
21218
21400
|
init_cjs_shims();
|
|
21219
|
-
var
|
|
21220
|
-
var
|
|
21401
|
+
var import_fs19 = __toESM(require("fs"));
|
|
21402
|
+
var import_path20 = __toESM(require("path"));
|
|
21221
21403
|
var import_os13 = __toESM(require("os"));
|
|
21222
21404
|
function getTrustedHostsPath() {
|
|
21223
|
-
return
|
|
21405
|
+
return import_path20.default.join(import_os13.default.homedir(), ".node9", "trusted-hosts.json");
|
|
21224
21406
|
}
|
|
21225
21407
|
function readTrustedHosts() {
|
|
21226
21408
|
try {
|
|
21227
|
-
const raw =
|
|
21409
|
+
const raw = import_fs19.default.readFileSync(getTrustedHostsPath(), "utf8");
|
|
21228
21410
|
const parsed = JSON.parse(raw);
|
|
21229
21411
|
return Array.isArray(parsed.hosts) ? parsed.hosts : [];
|
|
21230
21412
|
} catch {
|
|
@@ -21235,7 +21417,7 @@ var _cache = null;
|
|
|
21235
21417
|
var CACHE_TTL_MS = 5e3;
|
|
21236
21418
|
function getFileMtime() {
|
|
21237
21419
|
try {
|
|
21238
|
-
return
|
|
21420
|
+
return import_fs19.default.statSync(getTrustedHostsPath()).mtimeMs;
|
|
21239
21421
|
} catch {
|
|
21240
21422
|
return 0;
|
|
21241
21423
|
}
|
|
@@ -21273,8 +21455,8 @@ function isTrustedHost(host2) {
|
|
|
21273
21455
|
|
|
21274
21456
|
// src/config/index.ts
|
|
21275
21457
|
init_cjs_shims();
|
|
21276
|
-
var
|
|
21277
|
-
var
|
|
21458
|
+
var import_fs20 = __toESM(require("fs"));
|
|
21459
|
+
var import_path21 = __toESM(require("path"));
|
|
21278
21460
|
var import_os14 = __toESM(require("os"));
|
|
21279
21461
|
|
|
21280
21462
|
// src/config-schema.ts
|
|
@@ -21468,8 +21650,8 @@ var ConfigFileSchema = import_zod.z.object({
|
|
|
21468
21650
|
}).strict();
|
|
21469
21651
|
function formatIssues(issues) {
|
|
21470
21652
|
const lines = issues.map((issue) => {
|
|
21471
|
-
const
|
|
21472
|
-
return ` \u2022 ${
|
|
21653
|
+
const path41 = issue.path.length > 0 ? issue.path.map(String).join(".") : "root";
|
|
21654
|
+
return ` \u2022 ${path41}: ${issue.message}`;
|
|
21473
21655
|
});
|
|
21474
21656
|
return `Invalid config:
|
|
21475
21657
|
${lines.join("\n")}`;
|
|
@@ -21482,9 +21664,9 @@ function prunePaths(root, paths) {
|
|
|
21482
21664
|
const yi = y[y.length - 1];
|
|
21483
21665
|
return typeof xi === "number" && typeof yi === "number" ? yi - xi : 0;
|
|
21484
21666
|
});
|
|
21485
|
-
for (const
|
|
21667
|
+
for (const path41 of ordered) {
|
|
21486
21668
|
let cur = root;
|
|
21487
|
-
for (const key of
|
|
21669
|
+
for (const key of path41.slice(0, -1)) {
|
|
21488
21670
|
if (cur === null || typeof cur !== "object") {
|
|
21489
21671
|
cur = void 0;
|
|
21490
21672
|
break;
|
|
@@ -21492,7 +21674,7 @@ function prunePaths(root, paths) {
|
|
|
21492
21674
|
cur = cur[key];
|
|
21493
21675
|
}
|
|
21494
21676
|
if (cur === null || typeof cur !== "object") continue;
|
|
21495
|
-
const last =
|
|
21677
|
+
const last = path41[path41.length - 1];
|
|
21496
21678
|
if (Array.isArray(cur)) {
|
|
21497
21679
|
const i = Number(last);
|
|
21498
21680
|
if (Number.isInteger(i) && i >= 0 && i < cur.length) {
|
|
@@ -21528,7 +21710,7 @@ function sanitizeConfig(raw) {
|
|
|
21528
21710
|
return issue.keys.map((k) => [...at, k]);
|
|
21529
21711
|
}
|
|
21530
21712
|
return [at.slice(0, -level || void 0)];
|
|
21531
|
-
}).filter((
|
|
21713
|
+
}).filter((path41) => path41.length > 0);
|
|
21532
21714
|
if (paths.length === 0 || !prunePaths(working, paths)) break;
|
|
21533
21715
|
}
|
|
21534
21716
|
if (ConfigFileSchema.safeParse(working).success) break;
|
|
@@ -22190,8 +22372,8 @@ function noteRejectedApiUrl(raw) {
|
|
|
22190
22372
|
if (rejectedApiUrlsSeen.has(key)) return;
|
|
22191
22373
|
rejectedApiUrlsSeen.add(key);
|
|
22192
22374
|
try {
|
|
22193
|
-
|
|
22194
|
-
|
|
22375
|
+
import_fs20.default.appendFileSync(
|
|
22376
|
+
import_path21.default.join(import_os14.default.homedir(), ".node9", "hook-debug.log"),
|
|
22195
22377
|
`[${(/* @__PURE__ */ new Date()).toISOString()}] REFUSED apiUrl, using the default instead: ${String(raw).slice(0, 200).replace(/[\r\n]+/g, " ")}
|
|
22196
22378
|
`
|
|
22197
22379
|
);
|
|
@@ -22208,9 +22390,9 @@ function getCredentials() {
|
|
|
22208
22390
|
};
|
|
22209
22391
|
}
|
|
22210
22392
|
try {
|
|
22211
|
-
const credPath =
|
|
22212
|
-
if (
|
|
22213
|
-
const creds = JSON.parse(
|
|
22393
|
+
const credPath = import_path21.default.join(import_os14.default.homedir(), ".node9", "credentials.json");
|
|
22394
|
+
if (import_fs20.default.existsSync(credPath)) {
|
|
22395
|
+
const creds = JSON.parse(import_fs20.default.readFileSync(credPath, "utf-8"));
|
|
22214
22396
|
const profileName = process.env.NODE9_PROFILE || "default";
|
|
22215
22397
|
const profile = creds[profileName];
|
|
22216
22398
|
if (typeof profile?.apiKey === "string" && profile.apiKey.length > 0) {
|
|
@@ -22242,7 +22424,7 @@ function readRulesCacheResilient(cacheFile) {
|
|
|
22242
22424
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
22243
22425
|
let content;
|
|
22244
22426
|
try {
|
|
22245
|
-
content =
|
|
22427
|
+
content = import_fs20.default.readFileSync(cacheFile, "utf-8");
|
|
22246
22428
|
existed = true;
|
|
22247
22429
|
} catch (err) {
|
|
22248
22430
|
if (err.code === "ENOENT") return {};
|
|
@@ -22257,10 +22439,10 @@ function readRulesCacheResilient(cacheFile) {
|
|
|
22257
22439
|
}
|
|
22258
22440
|
}
|
|
22259
22441
|
if (existed || sawReadError) {
|
|
22260
|
-
const backup =
|
|
22442
|
+
const backup = import_path21.default.join(import_path21.default.dirname(cacheFile), "rules-cache.last-good.json");
|
|
22261
22443
|
if (backup !== cacheFile) {
|
|
22262
22444
|
try {
|
|
22263
|
-
const raw = JSON.parse(
|
|
22445
|
+
const raw = JSON.parse(import_fs20.default.readFileSync(backup, "utf-8"));
|
|
22264
22446
|
logCacheReadIssue(cacheFile, "RULES_CACHE_CORRUPT_USED_BACKUP");
|
|
22265
22447
|
lastParsedRulesCache = raw;
|
|
22266
22448
|
return raw;
|
|
@@ -22283,8 +22465,8 @@ function logCacheReadIssue(cacheFile, kind) {
|
|
|
22283
22465
|
if (now - cacheReadLastLoggedAt < CACHE_LOG_REARM_MS) return;
|
|
22284
22466
|
cacheReadLastLoggedAt = now;
|
|
22285
22467
|
try {
|
|
22286
|
-
|
|
22287
|
-
|
|
22468
|
+
import_fs20.default.appendFileSync(
|
|
22469
|
+
import_path21.default.join(import_os14.default.homedir(), ".node9", "hook-debug.log"),
|
|
22288
22470
|
`[${(/* @__PURE__ */ new Date()).toISOString()}] ${kind} ${cacheFile}
|
|
22289
22471
|
`
|
|
22290
22472
|
);
|
|
@@ -22310,8 +22492,8 @@ function catalogSettingsFrom(settings, policy) {
|
|
|
22310
22492
|
}
|
|
22311
22493
|
function getConfig(cwd) {
|
|
22312
22494
|
if (!cwd && cachedConfig) return cachedConfig;
|
|
22313
|
-
const globalPath =
|
|
22314
|
-
const projectPath =
|
|
22495
|
+
const globalPath = import_path21.default.join(import_os14.default.homedir(), ".node9", "config.json");
|
|
22496
|
+
const projectPath = import_path21.default.join(cwd ?? process.cwd(), "node9.config.json");
|
|
22315
22497
|
const globalConfig = tryLoadConfig(globalPath);
|
|
22316
22498
|
const projectConfig = tryLoadConfig(projectPath, { project: true });
|
|
22317
22499
|
const mergedSettings = {
|
|
@@ -22556,7 +22738,7 @@ function getConfig(cwd) {
|
|
|
22556
22738
|
let cloudMandatesEnforcement = false;
|
|
22557
22739
|
let cloudMandatesAppPerm = false;
|
|
22558
22740
|
{
|
|
22559
|
-
const cacheFile =
|
|
22741
|
+
const cacheFile = import_path21.default.join(import_os14.default.homedir(), ".node9", "rules-cache.json");
|
|
22560
22742
|
try {
|
|
22561
22743
|
const raw = readRulesCacheResilient(cacheFile);
|
|
22562
22744
|
if (Array.isArray(raw.rules) && raw.rules.length > 0) {
|
|
@@ -22749,13 +22931,13 @@ function getConfig(cwd) {
|
|
|
22749
22931
|
}
|
|
22750
22932
|
if (Array.isArray(mc.jailPaths)) {
|
|
22751
22933
|
for (const jp of mc.jailPaths) {
|
|
22752
|
-
const
|
|
22753
|
-
if (!
|
|
22934
|
+
const path41 = typeof jp?.path === "string" ? jp.path.trim() : "";
|
|
22935
|
+
if (!path41) continue;
|
|
22754
22936
|
const verdict = jp?.verdict === "review" ? "review" : "block";
|
|
22755
|
-
for (const r of pathRules(
|
|
22937
|
+
for (const r of pathRules(path41, verdict, "org-managed jail")) {
|
|
22756
22938
|
mergedPolicy.smartRules.push({ ...r, name: `org:${r.name}` });
|
|
22757
22939
|
}
|
|
22758
|
-
mergedPolicy.managedJailPaths.push({ path:
|
|
22940
|
+
mergedPolicy.managedJailPaths.push({ path: path41, verdict });
|
|
22759
22941
|
}
|
|
22760
22942
|
}
|
|
22761
22943
|
if (Array.isArray(mc.trustedHosts)) {
|
|
@@ -22988,10 +23170,10 @@ function getConfig(cwd) {
|
|
|
22988
23170
|
}
|
|
22989
23171
|
function tryLoadConfig(filePath, options = {}) {
|
|
22990
23172
|
v2ChecksByPath.delete(filePath);
|
|
22991
|
-
if (!
|
|
23173
|
+
if (!import_fs20.default.existsSync(filePath)) return null;
|
|
22992
23174
|
let raw;
|
|
22993
23175
|
try {
|
|
22994
|
-
raw = JSON.parse(
|
|
23176
|
+
raw = JSON.parse(import_fs20.default.readFileSync(filePath, "utf-8"));
|
|
22995
23177
|
} catch (err) {
|
|
22996
23178
|
const msg = err instanceof Error ? err.message : String(err);
|
|
22997
23179
|
process.stderr.write(
|
|
@@ -23096,27 +23278,27 @@ init_forecast_context();
|
|
|
23096
23278
|
// src/policy/index.ts
|
|
23097
23279
|
init_cjs_shims();
|
|
23098
23280
|
init_dist();
|
|
23099
|
-
var
|
|
23281
|
+
var import_fs27 = __toESM(require("fs"));
|
|
23100
23282
|
|
|
23101
23283
|
// src/utils/read-capped.ts
|
|
23102
23284
|
init_cjs_shims();
|
|
23103
|
-
var
|
|
23285
|
+
var import_fs21 = __toESM(require("fs"));
|
|
23104
23286
|
function readCapped(file2, maxBytes, openFlags = "r") {
|
|
23105
23287
|
if (maxBytes < 0) return null;
|
|
23106
23288
|
let fd;
|
|
23107
23289
|
try {
|
|
23108
|
-
fd =
|
|
23290
|
+
fd = import_fs21.default.openSync(file2, openFlags);
|
|
23109
23291
|
} catch {
|
|
23110
23292
|
return null;
|
|
23111
23293
|
}
|
|
23112
23294
|
try {
|
|
23113
|
-
const st =
|
|
23295
|
+
const st = import_fs21.default.fstatSync(fd);
|
|
23114
23296
|
if (!st.isFile()) return null;
|
|
23115
23297
|
const want = Math.min(st.size, maxBytes + 1);
|
|
23116
23298
|
const buf = Buffer.alloc(want);
|
|
23117
23299
|
let read3 = 0;
|
|
23118
23300
|
while (read3 < want) {
|
|
23119
|
-
const n =
|
|
23301
|
+
const n = import_fs21.default.readSync(fd, buf, read3, want - read3, read3);
|
|
23120
23302
|
if (n <= 0) break;
|
|
23121
23303
|
read3 += n;
|
|
23122
23304
|
}
|
|
@@ -23128,7 +23310,7 @@ function readCapped(file2, maxBytes, openFlags = "r") {
|
|
|
23128
23310
|
return null;
|
|
23129
23311
|
} finally {
|
|
23130
23312
|
try {
|
|
23131
|
-
|
|
23313
|
+
import_fs21.default.closeSync(fd);
|
|
23132
23314
|
} catch {
|
|
23133
23315
|
}
|
|
23134
23316
|
}
|
|
@@ -23139,7 +23321,7 @@ function readCappedText(file2, maxBytes, openFlags = "r") {
|
|
|
23139
23321
|
}
|
|
23140
23322
|
|
|
23141
23323
|
// src/policy/index.ts
|
|
23142
|
-
var
|
|
23324
|
+
var import_path28 = __toESM(require("path"));
|
|
23143
23325
|
|
|
23144
23326
|
// src/policy/gate-order.ts
|
|
23145
23327
|
init_cjs_shims();
|
|
@@ -23356,40 +23538,40 @@ function combineWithEngine(gates, engine, opts = { panicMode: false }) {
|
|
|
23356
23538
|
// src/supply-chain/check.ts
|
|
23357
23539
|
init_cjs_shims();
|
|
23358
23540
|
var import_picomatch4 = __toESM(require("picomatch"));
|
|
23359
|
-
var
|
|
23541
|
+
var import_path25 = __toESM(require("path"));
|
|
23360
23542
|
init_dist();
|
|
23361
23543
|
|
|
23362
23544
|
// src/supply-chain/osv-index.ts
|
|
23363
23545
|
init_cjs_shims();
|
|
23364
|
-
var
|
|
23546
|
+
var import_fs23 = __toESM(require("fs"));
|
|
23365
23547
|
var import_os15 = __toESM(require("os"));
|
|
23366
|
-
var
|
|
23548
|
+
var import_path23 = __toESM(require("path"));
|
|
23367
23549
|
var import_crypto9 = require("crypto");
|
|
23368
23550
|
init_dist();
|
|
23369
23551
|
|
|
23370
23552
|
// src/utils/atomic-write.ts
|
|
23371
23553
|
init_cjs_shims();
|
|
23372
|
-
var
|
|
23373
|
-
var
|
|
23554
|
+
var import_fs22 = __toESM(require("fs"));
|
|
23555
|
+
var import_path22 = __toESM(require("path"));
|
|
23374
23556
|
var import_crypto8 = require("crypto");
|
|
23375
23557
|
function atomicWriteSync(filePath, data, options) {
|
|
23376
|
-
const dir2 =
|
|
23377
|
-
if (!
|
|
23558
|
+
const dir2 = import_path22.default.dirname(filePath);
|
|
23559
|
+
if (!import_fs22.default.existsSync(dir2)) import_fs22.default.mkdirSync(dir2, { recursive: true });
|
|
23378
23560
|
const tmpPath = `${filePath}.${(0, import_crypto8.randomUUID)()}.tmp`;
|
|
23379
23561
|
try {
|
|
23380
|
-
|
|
23562
|
+
import_fs22.default.writeFileSync(tmpPath, data, options);
|
|
23381
23563
|
} catch (err) {
|
|
23382
23564
|
try {
|
|
23383
|
-
|
|
23565
|
+
import_fs22.default.unlinkSync(tmpPath);
|
|
23384
23566
|
} catch {
|
|
23385
23567
|
}
|
|
23386
23568
|
throw err;
|
|
23387
23569
|
}
|
|
23388
23570
|
try {
|
|
23389
|
-
|
|
23571
|
+
import_fs22.default.renameSync(tmpPath, filePath);
|
|
23390
23572
|
} catch (err) {
|
|
23391
23573
|
try {
|
|
23392
|
-
|
|
23574
|
+
import_fs22.default.unlinkSync(tmpPath);
|
|
23393
23575
|
} catch {
|
|
23394
23576
|
}
|
|
23395
23577
|
throw err;
|
|
@@ -23399,10 +23581,10 @@ function atomicWriteSync(filePath, data, options) {
|
|
|
23399
23581
|
// src/supply-chain/osv-index.ts
|
|
23400
23582
|
var INDEX_FRESH_MS = 72 * 60 * 60 * 1e3;
|
|
23401
23583
|
function osvRoot() {
|
|
23402
|
-
return
|
|
23584
|
+
return import_path23.default.join(import_os15.default.homedir(), ".node9", "osv");
|
|
23403
23585
|
}
|
|
23404
23586
|
function ecoDir(eco) {
|
|
23405
|
-
return
|
|
23587
|
+
return import_path23.default.join(osvRoot(), eco);
|
|
23406
23588
|
}
|
|
23407
23589
|
function indexKey(eco, name) {
|
|
23408
23590
|
switch (eco) {
|
|
@@ -23421,11 +23603,11 @@ function shardOf(key) {
|
|
|
23421
23603
|
return (0, import_crypto9.createHash)("sha1").update(key).digest("hex").slice(0, 2);
|
|
23422
23604
|
}
|
|
23423
23605
|
function shardPath(eco, shard) {
|
|
23424
|
-
return
|
|
23606
|
+
return import_path23.default.join(ecoDir(eco), "shards", `${shard}.json`);
|
|
23425
23607
|
}
|
|
23426
23608
|
function readMeta(eco) {
|
|
23427
23609
|
try {
|
|
23428
|
-
const m = JSON.parse(
|
|
23610
|
+
const m = JSON.parse(import_fs23.default.readFileSync(import_path23.default.join(ecoDir(eco), "meta.json"), "utf8"));
|
|
23429
23611
|
if (typeof m?.syncedAt !== "string" || typeof m?.lastModifiedMs !== "number") return null;
|
|
23430
23612
|
return m;
|
|
23431
23613
|
} catch {
|
|
@@ -23434,7 +23616,7 @@ function readMeta(eco) {
|
|
|
23434
23616
|
}
|
|
23435
23617
|
function readShard(eco, shard) {
|
|
23436
23618
|
try {
|
|
23437
|
-
const s = JSON.parse(
|
|
23619
|
+
const s = JSON.parse(import_fs23.default.readFileSync(shardPath(eco, shard), "utf8"));
|
|
23438
23620
|
return s && typeof s === "object" && !Array.isArray(s) ? s : {};
|
|
23439
23621
|
} catch {
|
|
23440
23622
|
return {};
|
|
@@ -23788,19 +23970,19 @@ async function registryInfo(eco, name, version2, freshWindowMs, raw) {
|
|
|
23788
23970
|
|
|
23789
23971
|
// src/supply-chain/local-resolve.ts
|
|
23790
23972
|
init_cjs_shims();
|
|
23791
|
-
var
|
|
23792
|
-
var
|
|
23973
|
+
var import_fs24 = __toESM(require("fs"));
|
|
23974
|
+
var import_path24 = __toESM(require("path"));
|
|
23793
23975
|
var MAX_LEVELS = 32;
|
|
23794
23976
|
var LOCAL_FIRST_MANAGERS = /* @__PURE__ */ new Set(["npx", "bunx", "npm exec"]);
|
|
23795
23977
|
function resolveInstalled(name, cwd) {
|
|
23796
|
-
if (!cwd || !
|
|
23978
|
+
if (!cwd || !import_path24.default.isAbsolute(cwd)) return null;
|
|
23797
23979
|
if (!/^(?:@[^/\\]+\/)?[^/\\]+$/.test(name)) return null;
|
|
23798
|
-
let dir2 =
|
|
23980
|
+
let dir2 = import_path24.default.resolve(cwd);
|
|
23799
23981
|
for (let i = 0; i < MAX_LEVELS; i++) {
|
|
23800
|
-
const pkgDir =
|
|
23801
|
-
const manifest =
|
|
23982
|
+
const pkgDir = import_path24.default.join(dir2, "node_modules", ...name.split("/"));
|
|
23983
|
+
const manifest = import_path24.default.join(pkgDir, "package.json");
|
|
23802
23984
|
try {
|
|
23803
|
-
const raw =
|
|
23985
|
+
const raw = import_fs24.default.readFileSync(manifest, "utf8");
|
|
23804
23986
|
const parsed = JSON.parse(raw);
|
|
23805
23987
|
if (typeof parsed.version === "string" && parsed.version.length > 0) {
|
|
23806
23988
|
return { version: parsed.version, dir: pkgDir };
|
|
@@ -23808,7 +23990,7 @@ function resolveInstalled(name, cwd) {
|
|
|
23808
23990
|
return null;
|
|
23809
23991
|
} catch {
|
|
23810
23992
|
}
|
|
23811
|
-
const parent =
|
|
23993
|
+
const parent = import_path24.default.dirname(dir2);
|
|
23812
23994
|
if (parent === dir2) break;
|
|
23813
23995
|
dir2 = parent;
|
|
23814
23996
|
}
|
|
@@ -23930,7 +24112,7 @@ function checkInstalled(p, version2, misses) {
|
|
|
23930
24112
|
}
|
|
23931
24113
|
async function checkOne(p, cfg, misses, networkCapped, cwd) {
|
|
23932
24114
|
if (p.ecosystem === "npm" && LOCAL_FIRST_MANAGERS.has(p.manager) && p.localCwd !== null && (p.raw === p.name || p.version)) {
|
|
23933
|
-
const localCwd = cwd &&
|
|
24115
|
+
const localCwd = cwd && import_path25.default.isAbsolute(cwd) ? (p.localCwd ?? []).reduce((dir2, step) => import_path25.default.resolve(dir2, step), cwd) : void 0;
|
|
23934
24116
|
const installed = resolveInstalled(p.name, localCwd);
|
|
23935
24117
|
if (installed && (!p.version || p.version === installed.version))
|
|
23936
24118
|
return checkInstalled(p, installed.version, misses);
|
|
@@ -24076,8 +24258,8 @@ async function runPackageCheck(toolName, args, cfg, cwd, opts = {}) {
|
|
|
24076
24258
|
// src/supply-chain/registries.ts
|
|
24077
24259
|
init_cjs_shims();
|
|
24078
24260
|
var import_os16 = __toESM(require("os"));
|
|
24079
|
-
var
|
|
24080
|
-
var
|
|
24261
|
+
var import_path26 = __toESM(require("path"));
|
|
24262
|
+
var import_fs25 = __toESM(require("fs"));
|
|
24081
24263
|
init_dist();
|
|
24082
24264
|
var MAX_CONFIG_BYTES = 256 * 1024;
|
|
24083
24265
|
var MAX_PARENT_DIRS = 12;
|
|
@@ -24119,29 +24301,29 @@ var REGISTRY_KEY_RE = /registry|index|find-links|mirror/i;
|
|
|
24119
24301
|
var REGISTRY_SECTION_RE = /index|source|registr|scopes|mirror/i;
|
|
24120
24302
|
var URL_RE2 = /https?:\/\/[^\s"'<>,;]+/gi;
|
|
24121
24303
|
function userFiles(home, env) {
|
|
24122
|
-
const xdg = env.XDG_CONFIG_HOME ||
|
|
24304
|
+
const xdg = env.XDG_CONFIG_HOME || import_path26.default.join(home, ".config");
|
|
24123
24305
|
return [
|
|
24124
|
-
env.NPM_CONFIG_USERCONFIG || env.npm_config_userconfig ||
|
|
24125
|
-
|
|
24126
|
-
|
|
24127
|
-
|
|
24306
|
+
env.NPM_CONFIG_USERCONFIG || env.npm_config_userconfig || import_path26.default.join(home, ".npmrc"),
|
|
24307
|
+
import_path26.default.join(home, ".yarnrc"),
|
|
24308
|
+
import_path26.default.join(home, ".yarnrc.yml"),
|
|
24309
|
+
import_path26.default.join(home, ".bunfig.toml"),
|
|
24128
24310
|
env.PIP_CONFIG_FILE || "",
|
|
24129
|
-
|
|
24130
|
-
|
|
24311
|
+
import_path26.default.join(xdg, "pip", "pip.conf"),
|
|
24312
|
+
import_path26.default.join(home, ".pip", "pip.conf"),
|
|
24131
24313
|
"/etc/pip.conf",
|
|
24132
|
-
env.VIRTUAL_ENV ?
|
|
24314
|
+
env.VIRTUAL_ENV ? import_path26.default.join(env.VIRTUAL_ENV, "pip.conf") : "",
|
|
24133
24315
|
env.UV_CONFIG_FILE || "",
|
|
24134
|
-
|
|
24316
|
+
import_path26.default.join(xdg, "uv", "uv.toml"),
|
|
24135
24317
|
"/etc/uv/uv.toml"
|
|
24136
24318
|
].filter(Boolean);
|
|
24137
24319
|
}
|
|
24138
24320
|
function projectFiles(cwd) {
|
|
24139
|
-
if (!cwd || !
|
|
24321
|
+
if (!cwd || !import_path26.default.isAbsolute(cwd)) return [];
|
|
24140
24322
|
const out = [];
|
|
24141
24323
|
let dir2 = cwd;
|
|
24142
24324
|
for (let i = 0; i < MAX_PARENT_DIRS; i++) {
|
|
24143
|
-
for (const f of PROJECT_FILES) out.push(
|
|
24144
|
-
const parent =
|
|
24325
|
+
for (const f of PROJECT_FILES) out.push(import_path26.default.join(dir2, f));
|
|
24326
|
+
const parent = import_path26.default.dirname(dir2);
|
|
24145
24327
|
if (parent === dir2) break;
|
|
24146
24328
|
dir2 = parent;
|
|
24147
24329
|
}
|
|
@@ -24203,7 +24385,7 @@ function configuredRegistryHosts(cwd, env = process.env, home = import_os16.defa
|
|
|
24203
24385
|
const r = readCappedText(
|
|
24204
24386
|
file2,
|
|
24205
24387
|
MAX_CONFIG_BYTES,
|
|
24206
|
-
|
|
24388
|
+
import_fs25.default.constants.O_RDONLY | (import_fs25.default.constants.O_NONBLOCK ?? 0)
|
|
24207
24389
|
);
|
|
24208
24390
|
if (r) hostsInText(r.text, hosts);
|
|
24209
24391
|
}
|
|
@@ -24213,27 +24395,27 @@ function configuredRegistryHosts(cwd, env = process.env, home = import_os16.defa
|
|
|
24213
24395
|
|
|
24214
24396
|
// src/utils/provenance.ts
|
|
24215
24397
|
init_cjs_shims();
|
|
24216
|
-
var
|
|
24217
|
-
var
|
|
24398
|
+
var import_fs26 = __toESM(require("fs"));
|
|
24399
|
+
var import_path27 = __toESM(require("path"));
|
|
24218
24400
|
var import_os17 = __toESM(require("os"));
|
|
24219
24401
|
var SYSTEM_PREFIXES = ["/usr/bin", "/usr/sbin", "/bin", "/sbin"];
|
|
24220
24402
|
var MANAGED_PREFIXES = ["/usr/local/bin", "/opt/homebrew", "/home/linuxbrew", "/nix/store"];
|
|
24221
24403
|
var USER_PREFIXES = [
|
|
24222
|
-
|
|
24223
|
-
|
|
24224
|
-
|
|
24225
|
-
|
|
24226
|
-
|
|
24404
|
+
import_path27.default.join(import_os17.default.homedir(), "bin"),
|
|
24405
|
+
import_path27.default.join(import_os17.default.homedir(), ".local", "bin"),
|
|
24406
|
+
import_path27.default.join(import_os17.default.homedir(), ".cargo", "bin"),
|
|
24407
|
+
import_path27.default.join(import_os17.default.homedir(), ".npm-global", "bin"),
|
|
24408
|
+
import_path27.default.join(import_os17.default.homedir(), ".volta", "bin")
|
|
24227
24409
|
];
|
|
24228
24410
|
var SUSPECT_PREFIXES = ["/tmp", "/var/tmp", "/dev/shm"];
|
|
24229
24411
|
function findInPath(cmd) {
|
|
24230
|
-
if (
|
|
24412
|
+
if (import_path27.default.posix.isAbsolute(cmd)) return cmd;
|
|
24231
24413
|
const pathEnv = process.env.PATH ?? "";
|
|
24232
|
-
for (const dir2 of pathEnv.split(
|
|
24414
|
+
for (const dir2 of pathEnv.split(import_path27.default.delimiter)) {
|
|
24233
24415
|
if (!dir2) continue;
|
|
24234
|
-
const full =
|
|
24416
|
+
const full = import_path27.default.join(dir2, cmd);
|
|
24235
24417
|
try {
|
|
24236
|
-
|
|
24418
|
+
import_fs26.default.accessSync(full, import_fs26.default.constants.X_OK);
|
|
24237
24419
|
return full;
|
|
24238
24420
|
} catch {
|
|
24239
24421
|
}
|
|
@@ -24262,7 +24444,7 @@ function _classifyPath(resolved, cwd) {
|
|
|
24262
24444
|
}
|
|
24263
24445
|
function checkProvenance(cmd, cwd) {
|
|
24264
24446
|
const bare = cmd.startsWith("./") ? cmd.slice(2) : cmd;
|
|
24265
|
-
if (
|
|
24447
|
+
if (import_path27.default.posix.isAbsolute(bare)) {
|
|
24266
24448
|
const early = _classifyPath(bare, cwd);
|
|
24267
24449
|
if (early.trustLevel === "suspect") {
|
|
24268
24450
|
return { resolvedPath: bare, ...early };
|
|
@@ -24278,7 +24460,7 @@ function checkProvenance(cmd, cwd) {
|
|
|
24278
24460
|
reason: "binary not found in PATH"
|
|
24279
24461
|
};
|
|
24280
24462
|
}
|
|
24281
|
-
resolved =
|
|
24463
|
+
resolved = import_fs26.default.realpathSync(found);
|
|
24282
24464
|
} catch {
|
|
24283
24465
|
return {
|
|
24284
24466
|
resolvedPath: cmd,
|
|
@@ -24287,7 +24469,7 @@ function checkProvenance(cmd, cwd) {
|
|
|
24287
24469
|
};
|
|
24288
24470
|
}
|
|
24289
24471
|
try {
|
|
24290
|
-
const stat =
|
|
24472
|
+
const stat = import_fs26.default.statSync(resolved);
|
|
24291
24473
|
if (stat.mode & 2) {
|
|
24292
24474
|
return {
|
|
24293
24475
|
resolvedPath: resolved,
|
|
@@ -24341,9 +24523,9 @@ async function evaluatePolicy2(toolName, args, agent, cwd, opts) {
|
|
|
24341
24523
|
);
|
|
24342
24524
|
}
|
|
24343
24525
|
function isGitWorkTreeTop(dir2, cwd) {
|
|
24344
|
-
if (!
|
|
24526
|
+
if (!import_path28.default.isAbsolute(cwd)) return true;
|
|
24345
24527
|
try {
|
|
24346
|
-
return
|
|
24528
|
+
return import_fs27.default.existsSync(import_path28.default.join(import_path28.default.resolve(cwd, dir2), ".git"));
|
|
24347
24529
|
} catch {
|
|
24348
24530
|
return true;
|
|
24349
24531
|
}
|
|
@@ -24353,7 +24535,7 @@ function readAgentSettings(absPath) {
|
|
|
24353
24535
|
const r = readCappedText(
|
|
24354
24536
|
absPath,
|
|
24355
24537
|
MAX_AGENT_SETTINGS_BYTES,
|
|
24356
|
-
|
|
24538
|
+
import_fs27.default.constants.O_RDONLY | (import_fs27.default.constants.O_NONBLOCK ?? 0)
|
|
24357
24539
|
);
|
|
24358
24540
|
return r && !r.truncated ? r.text : null;
|
|
24359
24541
|
}
|
|
@@ -24363,12 +24545,12 @@ function isIgnoredTool2(toolName) {
|
|
|
24363
24545
|
|
|
24364
24546
|
// src/auth/state.ts
|
|
24365
24547
|
init_cjs_shims();
|
|
24366
|
-
var
|
|
24367
|
-
var
|
|
24548
|
+
var import_fs28 = __toESM(require("fs"));
|
|
24549
|
+
var import_path29 = __toESM(require("path"));
|
|
24368
24550
|
var import_os18 = __toESM(require("os"));
|
|
24369
24551
|
init_forecast_context();
|
|
24370
|
-
var PAUSED_FILE =
|
|
24371
|
-
var TRUST_FILE =
|
|
24552
|
+
var PAUSED_FILE = import_path29.default.join(import_os18.default.homedir(), ".node9", "PAUSED");
|
|
24553
|
+
var TRUST_FILE = import_path29.default.join(import_os18.default.homedir(), ".node9", "trust.json");
|
|
24372
24554
|
function extractCommandPattern(toolName, args) {
|
|
24373
24555
|
const lower2 = toolName.toLowerCase();
|
|
24374
24556
|
if (lower2 !== "bash" && lower2 !== "execute_bash" && lower2 !== "shell") return void 0;
|
|
@@ -24381,11 +24563,11 @@ function extractCommandPattern(toolName, args) {
|
|
|
24381
24563
|
function checkPause() {
|
|
24382
24564
|
if (forecastRun()) return { paused: false };
|
|
24383
24565
|
try {
|
|
24384
|
-
if (!
|
|
24385
|
-
const state = JSON.parse(
|
|
24566
|
+
if (!import_fs28.default.existsSync(PAUSED_FILE)) return { paused: false };
|
|
24567
|
+
const state = JSON.parse(import_fs28.default.readFileSync(PAUSED_FILE, "utf-8"));
|
|
24386
24568
|
if (state.expiry > 0 && Date.now() >= state.expiry) {
|
|
24387
24569
|
try {
|
|
24388
|
-
|
|
24570
|
+
import_fs28.default.unlinkSync(PAUSED_FILE);
|
|
24389
24571
|
} catch {
|
|
24390
24572
|
}
|
|
24391
24573
|
return { paused: false };
|
|
@@ -24398,8 +24580,8 @@ function checkPause() {
|
|
|
24398
24580
|
function getActiveTrustSession(toolName, args) {
|
|
24399
24581
|
if (forecastRun()) return false;
|
|
24400
24582
|
try {
|
|
24401
|
-
if (!
|
|
24402
|
-
const trust = JSON.parse(
|
|
24583
|
+
if (!import_fs28.default.existsSync(TRUST_FILE)) return false;
|
|
24584
|
+
const trust = JSON.parse(import_fs28.default.readFileSync(TRUST_FILE, "utf-8"));
|
|
24403
24585
|
const now = Date.now();
|
|
24404
24586
|
const active = trust.entries.filter((e) => e.expiry > now);
|
|
24405
24587
|
if (active.length !== trust.entries.length) {
|
|
@@ -24422,8 +24604,8 @@ function writeTrustSession(toolName, durationMs, args) {
|
|
|
24422
24604
|
try {
|
|
24423
24605
|
let trust = { entries: [] };
|
|
24424
24606
|
try {
|
|
24425
|
-
if (
|
|
24426
|
-
trust = JSON.parse(
|
|
24607
|
+
if (import_fs28.default.existsSync(TRUST_FILE)) {
|
|
24608
|
+
trust = JSON.parse(import_fs28.default.readFileSync(TRUST_FILE, "utf-8"));
|
|
24427
24609
|
}
|
|
24428
24610
|
} catch {
|
|
24429
24611
|
}
|
|
@@ -24445,9 +24627,9 @@ function writeTrustSession(toolName, durationMs, args) {
|
|
|
24445
24627
|
}
|
|
24446
24628
|
function getPersistentDecision(toolName) {
|
|
24447
24629
|
try {
|
|
24448
|
-
const file2 =
|
|
24449
|
-
if (!
|
|
24450
|
-
const decisions = JSON.parse(
|
|
24630
|
+
const file2 = import_path29.default.join(import_os18.default.homedir(), ".node9", "decisions.json");
|
|
24631
|
+
if (!import_fs28.default.existsSync(file2)) return null;
|
|
24632
|
+
const decisions = JSON.parse(import_fs28.default.readFileSync(file2, "utf-8"));
|
|
24451
24633
|
const d = decisions[toolName];
|
|
24452
24634
|
if (d === "allow" || d === "deny") return d;
|
|
24453
24635
|
} catch {
|
|
@@ -24457,9 +24639,9 @@ function getPersistentDecision(toolName) {
|
|
|
24457
24639
|
|
|
24458
24640
|
// src/auth/cloud.ts
|
|
24459
24641
|
init_cjs_shims();
|
|
24460
|
-
var
|
|
24642
|
+
var import_fs29 = __toESM(require("fs"));
|
|
24461
24643
|
var import_os19 = __toESM(require("os"));
|
|
24462
|
-
var
|
|
24644
|
+
var import_path30 = __toESM(require("path"));
|
|
24463
24645
|
init_audit();
|
|
24464
24646
|
init_dist();
|
|
24465
24647
|
var CLOUD_ARRAY_KEYS = /* @__PURE__ */ new Set(["exposureDestinations", "exposureDestinationHashes"]);
|
|
@@ -24495,7 +24677,7 @@ async function initNode9SaaS(toolName, args, creds, meta, riskMetadata, agentPol
|
|
|
24495
24677
|
let ciContext;
|
|
24496
24678
|
if (process.env.CI) {
|
|
24497
24679
|
try {
|
|
24498
|
-
const ciContextPath =
|
|
24680
|
+
const ciContextPath = import_path30.default.join(import_os19.default.homedir(), ".node9", "ci-context.json");
|
|
24499
24681
|
const ci = readCappedText(ciContextPath, 1e4);
|
|
24500
24682
|
if (!ci) throw new Error("ci-context.json unreadable");
|
|
24501
24683
|
if (ci.truncated) throw new Error("ci-context.json exceeds 10 KB");
|
|
@@ -24613,14 +24795,14 @@ async function resolveNode9SaaS(requestId, creds, approved, decidedBy) {
|
|
|
24613
24795
|
});
|
|
24614
24796
|
clearTimeout(timer);
|
|
24615
24797
|
if (!res.ok) {
|
|
24616
|
-
|
|
24798
|
+
import_fs29.default.appendFileSync(
|
|
24617
24799
|
HOOK_DEBUG_LOG,
|
|
24618
24800
|
`[resolve-cloud] PATCH ${safeMessage(resolveUrl, 200)} \u2192 HTTP ${res.status}
|
|
24619
24801
|
`
|
|
24620
24802
|
);
|
|
24621
24803
|
}
|
|
24622
24804
|
} catch (err) {
|
|
24623
|
-
|
|
24805
|
+
import_fs29.default.appendFileSync(
|
|
24624
24806
|
HOOK_DEBUG_LOG,
|
|
24625
24807
|
`[resolve-cloud] PATCH failed for ${safeMessage(requestId, 64)}: ${safeMessage(err)}
|
|
24626
24808
|
`
|
|
@@ -24630,19 +24812,19 @@ async function resolveNode9SaaS(requestId, creds, approved, decidedBy) {
|
|
|
24630
24812
|
|
|
24631
24813
|
// src/loop-detector.ts
|
|
24632
24814
|
init_cjs_shims();
|
|
24633
|
-
var
|
|
24634
|
-
var
|
|
24815
|
+
var import_fs30 = __toESM(require("fs"));
|
|
24816
|
+
var import_path31 = __toESM(require("path"));
|
|
24635
24817
|
var import_os20 = __toESM(require("os"));
|
|
24636
24818
|
init_dist();
|
|
24637
24819
|
init_forecast_context();
|
|
24638
24820
|
init_dist();
|
|
24639
24821
|
function loopStateFile() {
|
|
24640
|
-
return
|
|
24822
|
+
return import_path31.default.join(import_os20.default.homedir(), ".node9", "loop-state.json");
|
|
24641
24823
|
}
|
|
24642
24824
|
function readState() {
|
|
24643
24825
|
try {
|
|
24644
|
-
if (!
|
|
24645
|
-
const raw =
|
|
24826
|
+
if (!import_fs30.default.existsSync(loopStateFile())) return [];
|
|
24827
|
+
const raw = import_fs30.default.readFileSync(loopStateFile(), "utf-8");
|
|
24646
24828
|
const parsed = JSON.parse(raw);
|
|
24647
24829
|
if (!Array.isArray(parsed)) return [];
|
|
24648
24830
|
return parsed;
|
|
@@ -24651,11 +24833,11 @@ function readState() {
|
|
|
24651
24833
|
}
|
|
24652
24834
|
}
|
|
24653
24835
|
function writeState(records) {
|
|
24654
|
-
const dir2 =
|
|
24655
|
-
if (!
|
|
24836
|
+
const dir2 = import_path31.default.dirname(loopStateFile());
|
|
24837
|
+
if (!import_fs30.default.existsSync(dir2)) import_fs30.default.mkdirSync(dir2, { recursive: true });
|
|
24656
24838
|
const tmpPath = `${loopStateFile()}.${import_os20.default.hostname()}.${process.pid}.tmp`;
|
|
24657
|
-
|
|
24658
|
-
|
|
24839
|
+
import_fs30.default.writeFileSync(tmpPath, JSON.stringify(records));
|
|
24840
|
+
import_fs30.default.renameSync(tmpPath, loopStateFile());
|
|
24659
24841
|
}
|
|
24660
24842
|
function recordAndCheck(tool, args, threshold = 3, windowMs = 12e4) {
|
|
24661
24843
|
try {
|
|
@@ -25084,9 +25266,9 @@ function isMcpToolName(toolName) {
|
|
|
25084
25266
|
return /^mcp__[^_](?:[^_]|_(?!_))*?__/i.test(toolName);
|
|
25085
25267
|
}
|
|
25086
25268
|
function absoluteUploadPath(spelled, cwd) {
|
|
25087
|
-
const expanded = spelled === "~" || spelled.startsWith("~/") ?
|
|
25088
|
-
if (
|
|
25089
|
-
return cwd &&
|
|
25269
|
+
const expanded = spelled === "~" || spelled.startsWith("~/") ? import_path32.default.join(import_os21.default.homedir(), spelled.slice(1)) : spelled;
|
|
25270
|
+
if (import_path32.default.isAbsolute(expanded)) return expanded;
|
|
25271
|
+
return cwd && import_path32.default.isAbsolute(cwd) ? import_path32.default.resolve(cwd, expanded) : expanded;
|
|
25090
25272
|
}
|
|
25091
25273
|
function extractFilePaths(toolName, args, shellCommand) {
|
|
25092
25274
|
const paths = [];
|
|
@@ -25632,7 +25814,9 @@ async function _authorizeHeadlessCore(toolName, args, metaArg, options) {
|
|
|
25632
25814
|
systemAccessHandled: !isManual && fileAccess.handledPaths.has(filePath)
|
|
25633
25815
|
}) : null) ?? argumentScan(),
|
|
25634
25816
|
pii: () => detectArgsPii(args),
|
|
25635
|
-
packageCheck: () => packageCheck?.enabled && !isManual ? runPackageCheck(toolName, args, packageCheck, options?.cwd, {
|
|
25817
|
+
packageCheck: () => packageCheck?.enabled && !isManual ? runPackageCheck(toolName, args, packageCheck, options?.cwd, {
|
|
25818
|
+
offline: !!forecast && forecast.onlinePackages !== true
|
|
25819
|
+
}) : Promise.resolve(null)
|
|
25636
25820
|
});
|
|
25637
25821
|
const dlpMatch = gates.stop?.dlpMatch ?? gates.reviews.dlp ?? null;
|
|
25638
25822
|
if (dlpMatch) {
|
|
@@ -26481,29 +26665,29 @@ init_dist();
|
|
|
26481
26665
|
|
|
26482
26666
|
// src/daemon/startup-log.ts
|
|
26483
26667
|
init_cjs_shims();
|
|
26484
|
-
var
|
|
26485
|
-
var
|
|
26668
|
+
var import_fs31 = __toESM(require("fs"));
|
|
26669
|
+
var import_path33 = __toESM(require("path"));
|
|
26486
26670
|
var import_os22 = __toESM(require("os"));
|
|
26487
|
-
var DAEMON_STARTUP_LOG = () =>
|
|
26671
|
+
var DAEMON_STARTUP_LOG = () => import_path33.default.join(import_os22.default.homedir(), ".node9", "daemon-startup.log");
|
|
26488
26672
|
var MAX_STARTUP_LOG_BYTES = 256 * 1024;
|
|
26489
26673
|
function capStartupLog(file2) {
|
|
26490
26674
|
try {
|
|
26491
|
-
if (
|
|
26675
|
+
if (import_fs31.default.statSync(file2).size > MAX_STARTUP_LOG_BYTES) import_fs31.default.truncateSync(file2);
|
|
26492
26676
|
} catch {
|
|
26493
26677
|
}
|
|
26494
26678
|
}
|
|
26495
26679
|
function openStartupLogFd() {
|
|
26496
26680
|
try {
|
|
26497
26681
|
const file2 = DAEMON_STARTUP_LOG();
|
|
26498
|
-
const dir2 =
|
|
26499
|
-
if (!
|
|
26682
|
+
const dir2 = import_path33.default.dirname(file2);
|
|
26683
|
+
if (!import_fs31.default.existsSync(dir2)) import_fs31.default.mkdirSync(dir2, { recursive: true });
|
|
26500
26684
|
capStartupLog(file2);
|
|
26501
|
-
return
|
|
26685
|
+
return import_fs31.default.openSync(file2, "a");
|
|
26502
26686
|
} catch {
|
|
26503
26687
|
return void 0;
|
|
26504
26688
|
}
|
|
26505
26689
|
}
|
|
26506
|
-
var DAEMON_STARTUP_STATE = () =>
|
|
26690
|
+
var DAEMON_STARTUP_STATE = () => import_path33.default.join(import_os22.default.homedir(), ".node9", "daemon-startup-state.json");
|
|
26507
26691
|
var MAX_DETAIL = 200;
|
|
26508
26692
|
var STARTING_GRACE_MS = 90 * 1e3;
|
|
26509
26693
|
function recordStartupState(outcome, kind, detail) {
|
|
@@ -26517,18 +26701,18 @@ function recordStartupState(outcome, kind, detail) {
|
|
|
26517
26701
|
}
|
|
26518
26702
|
}
|
|
26519
26703
|
const file2 = DAEMON_STARTUP_STATE();
|
|
26520
|
-
const dir2 =
|
|
26521
|
-
if (!
|
|
26704
|
+
const dir2 = import_path33.default.dirname(file2);
|
|
26705
|
+
if (!import_fs31.default.existsSync(dir2)) import_fs31.default.mkdirSync(dir2, { recursive: true });
|
|
26522
26706
|
const state = { outcome, at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
26523
26707
|
if (kind) state.kind = kind;
|
|
26524
26708
|
if (detail) state.detail = detail.slice(0, MAX_DETAIL);
|
|
26525
26709
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
26526
26710
|
try {
|
|
26527
|
-
|
|
26528
|
-
|
|
26711
|
+
import_fs31.default.writeFileSync(tmp, JSON.stringify(state), "utf-8");
|
|
26712
|
+
import_fs31.default.renameSync(tmp, file2);
|
|
26529
26713
|
} catch (err) {
|
|
26530
26714
|
try {
|
|
26531
|
-
|
|
26715
|
+
import_fs31.default.unlinkSync(tmp);
|
|
26532
26716
|
} catch {
|
|
26533
26717
|
}
|
|
26534
26718
|
throw err;
|
|
@@ -26538,7 +26722,7 @@ function recordStartupState(outcome, kind, detail) {
|
|
|
26538
26722
|
}
|
|
26539
26723
|
function readStartupState() {
|
|
26540
26724
|
try {
|
|
26541
|
-
const raw =
|
|
26725
|
+
const raw = import_fs31.default.readFileSync(DAEMON_STARTUP_STATE(), "utf-8");
|
|
26542
26726
|
const s = JSON.parse(raw);
|
|
26543
26727
|
if (!s || typeof s.outcome !== "string" || typeof s.at !== "string") return null;
|
|
26544
26728
|
return s;
|
|
@@ -26550,26 +26734,26 @@ function readStartupState() {
|
|
|
26550
26734
|
// src/cli/daemon-starter.ts
|
|
26551
26735
|
init_cjs_shims();
|
|
26552
26736
|
var import_child_process2 = require("child_process");
|
|
26553
|
-
var
|
|
26554
|
-
var
|
|
26737
|
+
var import_path34 = __toESM(require("path"));
|
|
26738
|
+
var import_fs32 = __toESM(require("fs"));
|
|
26555
26739
|
var import_os23 = __toESM(require("os"));
|
|
26556
26740
|
function isTestingMode() {
|
|
26557
26741
|
return /^(1|true|yes)$/i.test(process.env.NODE9_TESTING ?? "");
|
|
26558
26742
|
}
|
|
26559
|
-
var SKIP_STAMP = () =>
|
|
26743
|
+
var SKIP_STAMP = () => import_path34.default.join(import_os23.default.homedir(), ".node9", ".autostart-skip-stamp");
|
|
26560
26744
|
var SKIP_THROTTLE_MS = 60 * 60 * 1e3;
|
|
26561
26745
|
function logAutostartSkipThrottled(reason) {
|
|
26562
26746
|
try {
|
|
26563
26747
|
const stamp = SKIP_STAMP();
|
|
26564
26748
|
try {
|
|
26565
|
-
if (Date.now() -
|
|
26749
|
+
if (Date.now() - import_fs32.default.statSync(stamp).mtimeMs < SKIP_THROTTLE_MS) return;
|
|
26566
26750
|
} catch {
|
|
26567
26751
|
}
|
|
26568
|
-
const dir2 =
|
|
26569
|
-
if (!
|
|
26570
|
-
|
|
26571
|
-
|
|
26572
|
-
|
|
26752
|
+
const dir2 = import_path34.default.join(import_os23.default.homedir(), ".node9");
|
|
26753
|
+
if (!import_fs32.default.existsSync(dir2)) import_fs32.default.mkdirSync(dir2, { recursive: true });
|
|
26754
|
+
import_fs32.default.writeFileSync(stamp, "", "utf-8");
|
|
26755
|
+
import_fs32.default.appendFileSync(
|
|
26756
|
+
import_path34.default.join(dir2, "hook-debug.log"),
|
|
26573
26757
|
`[${(/* @__PURE__ */ new Date()).toISOString()}] daemon-autostart-skip: ${reason}
|
|
26574
26758
|
`,
|
|
26575
26759
|
"utf-8"
|
|
@@ -26588,10 +26772,10 @@ async function autoStartDaemonAndWait() {
|
|
|
26588
26772
|
return true;
|
|
26589
26773
|
}
|
|
26590
26774
|
if (isTestingMode()) return false;
|
|
26591
|
-
if (!
|
|
26775
|
+
if (!import_path34.default.isAbsolute(process.argv[1])) return false;
|
|
26592
26776
|
let resolvedArgv1;
|
|
26593
26777
|
try {
|
|
26594
|
-
resolvedArgv1 =
|
|
26778
|
+
resolvedArgv1 = import_fs32.default.realpathSync(process.argv[1]);
|
|
26595
26779
|
} catch {
|
|
26596
26780
|
return false;
|
|
26597
26781
|
}
|
|
@@ -26629,7 +26813,7 @@ async function autoStartDaemonAndWait() {
|
|
|
26629
26813
|
} finally {
|
|
26630
26814
|
if (startupFd !== void 0) {
|
|
26631
26815
|
try {
|
|
26632
|
-
|
|
26816
|
+
import_fs32.default.closeSync(startupFd);
|
|
26633
26817
|
} catch {
|
|
26634
26818
|
}
|
|
26635
26819
|
}
|
|
@@ -26639,12 +26823,12 @@ async function autoStartDaemonAndWait() {
|
|
|
26639
26823
|
|
|
26640
26824
|
// src/skill-pin.ts
|
|
26641
26825
|
init_cjs_shims();
|
|
26642
|
-
var
|
|
26643
|
-
var
|
|
26826
|
+
var import_fs33 = __toESM(require("fs"));
|
|
26827
|
+
var import_path35 = __toESM(require("path"));
|
|
26644
26828
|
var import_os24 = __toESM(require("os"));
|
|
26645
26829
|
var import_crypto11 = __toESM(require("crypto"));
|
|
26646
|
-
function getPinsFilePath() {
|
|
26647
|
-
return
|
|
26830
|
+
function getPinsFilePath(home = import_os24.default.homedir()) {
|
|
26831
|
+
return import_path35.default.join(home, ".node9", "skill-pins.json");
|
|
26648
26832
|
}
|
|
26649
26833
|
var MAX_FILES = 5e3;
|
|
26650
26834
|
var MAX_TOTAL_BYTES = 50 * 1024 * 1024;
|
|
@@ -26658,18 +26842,18 @@ function walkDir(root) {
|
|
|
26658
26842
|
if (out.length >= MAX_FILES) return;
|
|
26659
26843
|
let entries;
|
|
26660
26844
|
try {
|
|
26661
|
-
entries =
|
|
26845
|
+
entries = import_fs33.default.readdirSync(dir2, { withFileTypes: true });
|
|
26662
26846
|
} catch {
|
|
26663
26847
|
return;
|
|
26664
26848
|
}
|
|
26665
26849
|
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
26666
26850
|
for (const entry of entries) {
|
|
26667
26851
|
if (out.length >= MAX_FILES) return;
|
|
26668
|
-
const full =
|
|
26669
|
-
const rel = relDir ?
|
|
26852
|
+
const full = import_path35.default.join(dir2, entry.name);
|
|
26853
|
+
const rel = relDir ? import_path35.default.posix.join(relDir, entry.name) : entry.name;
|
|
26670
26854
|
let lst;
|
|
26671
26855
|
try {
|
|
26672
|
-
lst =
|
|
26856
|
+
lst = import_fs33.default.lstatSync(full);
|
|
26673
26857
|
} catch {
|
|
26674
26858
|
continue;
|
|
26675
26859
|
}
|
|
@@ -26694,14 +26878,14 @@ function walkDir(root) {
|
|
|
26694
26878
|
function hashSkillRoot(absPath) {
|
|
26695
26879
|
let lst;
|
|
26696
26880
|
try {
|
|
26697
|
-
lst =
|
|
26881
|
+
lst = import_fs33.default.lstatSync(absPath);
|
|
26698
26882
|
} catch {
|
|
26699
26883
|
return { exists: false, contentHash: "", fileCount: 0 };
|
|
26700
26884
|
}
|
|
26701
26885
|
if (lst.isSymbolicLink()) return { exists: false, contentHash: "", fileCount: 0 };
|
|
26702
26886
|
if (lst.isFile()) {
|
|
26703
26887
|
try {
|
|
26704
|
-
return { exists: true, contentHash: sha256Bytes(
|
|
26888
|
+
return { exists: true, contentHash: sha256Bytes(import_fs33.default.readFileSync(absPath)), fileCount: 1 };
|
|
26705
26889
|
} catch {
|
|
26706
26890
|
return { exists: false, contentHash: "", fileCount: 0 };
|
|
26707
26891
|
}
|
|
@@ -26716,10 +26900,10 @@ function hashSkillRoot(absPath) {
|
|
|
26716
26900
|
function getRootKey(absPath) {
|
|
26717
26901
|
return import_crypto11.default.createHash("sha256").update(absPath).digest("hex").slice(0, 16);
|
|
26718
26902
|
}
|
|
26719
|
-
function readSkillPinsSafe() {
|
|
26720
|
-
const filePath = getPinsFilePath();
|
|
26903
|
+
function readSkillPinsSafe(home) {
|
|
26904
|
+
const filePath = getPinsFilePath(home);
|
|
26721
26905
|
try {
|
|
26722
|
-
const raw =
|
|
26906
|
+
const raw = import_fs33.default.readFileSync(filePath, "utf-8");
|
|
26723
26907
|
if (!raw.trim()) return { ok: false, reason: "corrupt", detail: "empty file" };
|
|
26724
26908
|
const parsed = JSON.parse(raw);
|
|
26725
26909
|
if (!parsed.roots || typeof parsed.roots !== "object" || Array.isArray(parsed.roots)) {
|
|
@@ -26733,10 +26917,10 @@ function readSkillPinsSafe() {
|
|
|
26733
26917
|
}
|
|
26734
26918
|
function writeSkillPins(data) {
|
|
26735
26919
|
const filePath = getPinsFilePath();
|
|
26736
|
-
|
|
26920
|
+
import_fs33.default.mkdirSync(import_path35.default.dirname(filePath), { recursive: true });
|
|
26737
26921
|
const tmp = `${filePath}.${import_crypto11.default.randomBytes(6).toString("hex")}.tmp`;
|
|
26738
|
-
|
|
26739
|
-
|
|
26922
|
+
import_fs33.default.writeFileSync(tmp, JSON.stringify(data, null, 2), { mode: 384 });
|
|
26923
|
+
import_fs33.default.renameSync(tmp, filePath);
|
|
26740
26924
|
}
|
|
26741
26925
|
function verifyAndPinRoots(roots) {
|
|
26742
26926
|
const pinsRead = readSkillPinsSafe();
|
|
@@ -26771,37 +26955,37 @@ function verifyAndPinRoots(roots) {
|
|
|
26771
26955
|
if (mutated) writeSkillPins(pins);
|
|
26772
26956
|
return { kind: "verified" };
|
|
26773
26957
|
}
|
|
26774
|
-
function defaultSkillRoots(_cwd) {
|
|
26775
|
-
const marketplaces =
|
|
26958
|
+
function defaultSkillRoots(_cwd, home = import_os24.default.homedir()) {
|
|
26959
|
+
const marketplaces = import_path35.default.join(home, ".claude", "plugins", "marketplaces");
|
|
26776
26960
|
const roots = [];
|
|
26777
26961
|
let registries;
|
|
26778
26962
|
try {
|
|
26779
|
-
registries =
|
|
26963
|
+
registries = import_fs33.default.readdirSync(marketplaces, { withFileTypes: true });
|
|
26780
26964
|
} catch {
|
|
26781
26965
|
return [];
|
|
26782
26966
|
}
|
|
26783
26967
|
for (const registry of registries) {
|
|
26784
26968
|
if (!registry.isDirectory()) continue;
|
|
26785
|
-
const pluginsDir =
|
|
26969
|
+
const pluginsDir = import_path35.default.join(marketplaces, registry.name, "plugins");
|
|
26786
26970
|
let plugins;
|
|
26787
26971
|
try {
|
|
26788
|
-
plugins =
|
|
26972
|
+
plugins = import_fs33.default.readdirSync(pluginsDir, { withFileTypes: true });
|
|
26789
26973
|
} catch {
|
|
26790
26974
|
continue;
|
|
26791
26975
|
}
|
|
26792
26976
|
for (const plugin of plugins) {
|
|
26793
26977
|
if (!plugin.isDirectory()) continue;
|
|
26794
|
-
roots.push(
|
|
26978
|
+
roots.push(import_path35.default.join(pluginsDir, plugin.name));
|
|
26795
26979
|
}
|
|
26796
26980
|
}
|
|
26797
26981
|
return roots;
|
|
26798
26982
|
}
|
|
26799
26983
|
function resolveUserSkillRoot(entry, cwd) {
|
|
26800
26984
|
if (!entry) return null;
|
|
26801
|
-
if (entry.startsWith("~/") || entry === "~") return
|
|
26802
|
-
if (
|
|
26803
|
-
if (!cwd || !
|
|
26804
|
-
return
|
|
26985
|
+
if (entry.startsWith("~/") || entry === "~") return import_path35.default.join(import_os24.default.homedir(), entry.slice(1));
|
|
26986
|
+
if (import_path35.default.isAbsolute(entry)) return entry;
|
|
26987
|
+
if (!cwd || !import_path35.default.isAbsolute(cwd)) return null;
|
|
26988
|
+
return import_path35.default.join(cwd, entry);
|
|
26805
26989
|
}
|
|
26806
26990
|
|
|
26807
26991
|
// src/cli/commands/check.ts
|
|
@@ -26820,12 +27004,12 @@ function isKeyedForPolicy() {
|
|
|
26820
27004
|
|
|
26821
27005
|
// src/review-pending.ts
|
|
26822
27006
|
init_cjs_shims();
|
|
26823
|
-
var
|
|
27007
|
+
var import_fs34 = __toESM(require("fs"));
|
|
26824
27008
|
var import_os25 = __toESM(require("os"));
|
|
26825
|
-
var
|
|
27009
|
+
var import_path36 = __toESM(require("path"));
|
|
26826
27010
|
init_hasher();
|
|
26827
27011
|
function storePath() {
|
|
26828
|
-
return process.env.NODE9_PENDING_STORE ||
|
|
27012
|
+
return process.env.NODE9_PENDING_STORE || import_path36.default.join(import_os25.default.homedir(), ".node9", "pending-reviews.json");
|
|
26829
27013
|
}
|
|
26830
27014
|
var TTL_TUID_MS = 72 * 60 * 60 * 1e3;
|
|
26831
27015
|
var TTL_MS2 = 6 * 60 * 60 * 1e3;
|
|
@@ -26843,7 +27027,7 @@ function reviewCorrelationKey(payload) {
|
|
|
26843
27027
|
}
|
|
26844
27028
|
function read2() {
|
|
26845
27029
|
try {
|
|
26846
|
-
const parsed = JSON.parse(
|
|
27030
|
+
const parsed = JSON.parse(import_fs34.default.readFileSync(storePath(), "utf-8"));
|
|
26847
27031
|
if (parsed && Array.isArray(parsed.entries)) return parsed;
|
|
26848
27032
|
} catch {
|
|
26849
27033
|
}
|
|
@@ -26852,11 +27036,11 @@ function read2() {
|
|
|
26852
27036
|
function write(store) {
|
|
26853
27037
|
try {
|
|
26854
27038
|
const p = storePath();
|
|
26855
|
-
const dir2 =
|
|
26856
|
-
if (!
|
|
27039
|
+
const dir2 = import_path36.default.dirname(p);
|
|
27040
|
+
if (!import_fs34.default.existsSync(dir2)) import_fs34.default.mkdirSync(dir2, { recursive: true });
|
|
26857
27041
|
const tmp = `${p}.${process.pid}.tmp`;
|
|
26858
|
-
|
|
26859
|
-
|
|
27042
|
+
import_fs34.default.writeFileSync(tmp, JSON.stringify(store));
|
|
27043
|
+
import_fs34.default.renameSync(tmp, p);
|
|
26860
27044
|
} catch {
|
|
26861
27045
|
}
|
|
26862
27046
|
}
|
|
@@ -26954,53 +27138,11 @@ function canonicalToolInput(rawToolName, input) {
|
|
|
26954
27138
|
return canonical;
|
|
26955
27139
|
}
|
|
26956
27140
|
|
|
26957
|
-
// src/utils/own-dir.ts
|
|
26958
|
-
init_cjs_shims();
|
|
26959
|
-
var import_fs33 = __toESM(require("fs"));
|
|
26960
|
-
var import_path35 = __toESM(require("path"));
|
|
26961
|
-
var SESSION_FLAG_SUFFIX = ".node9-flag";
|
|
26962
|
-
var SESSION_FLAG_NAME = /^[A-Za-z0-9_-]{1,128}\.node9-flag$/;
|
|
26963
|
-
function isSessionFlagName(name) {
|
|
26964
|
-
return SESSION_FLAG_NAME.test(name);
|
|
26965
|
-
}
|
|
26966
|
-
function ownRealDir(st) {
|
|
26967
|
-
if (st.isSymbolicLink() || !st.isDirectory()) return false;
|
|
26968
|
-
return typeof process.getuid !== "function" || st.uid === process.getuid();
|
|
26969
|
-
}
|
|
26970
|
-
function ensureOwnDir(dir2) {
|
|
26971
|
-
try {
|
|
26972
|
-
import_fs33.default.mkdirSync(dir2, { recursive: true, mode: 448 });
|
|
26973
|
-
const st = import_fs33.default.lstatSync(dir2);
|
|
26974
|
-
return ownRealDir(st) ? { dev: st.dev, ino: st.ino } : null;
|
|
26975
|
-
} catch {
|
|
26976
|
-
return null;
|
|
26977
|
-
}
|
|
26978
|
-
}
|
|
26979
|
-
function isSameOwnDir(dir2, seen) {
|
|
26980
|
-
try {
|
|
26981
|
-
const st = import_fs33.default.lstatSync(dir2);
|
|
26982
|
-
return ownRealDir(st) && st.dev === seen.dev && st.ino === seen.ino;
|
|
26983
|
-
} catch {
|
|
26984
|
-
return false;
|
|
26985
|
-
}
|
|
26986
|
-
}
|
|
26987
|
-
function removeOldFlag(dir2, seen, name, cutoffMs) {
|
|
26988
|
-
if (!isSessionFlagName(name)) return;
|
|
26989
|
-
const p = import_path35.default.join(dir2, name);
|
|
26990
|
-
try {
|
|
26991
|
-
const st = import_fs33.default.lstatSync(p);
|
|
26992
|
-
if (!st.isFile() || st.mtimeMs >= cutoffMs) return;
|
|
26993
|
-
if (!isSameOwnDir(dir2, seen)) return;
|
|
26994
|
-
import_fs33.default.unlinkSync(p);
|
|
26995
|
-
} catch {
|
|
26996
|
-
}
|
|
26997
|
-
}
|
|
26998
|
-
|
|
26999
27141
|
// src/notices/session-notice.ts
|
|
27000
27142
|
init_cjs_shims();
|
|
27001
|
-
var
|
|
27143
|
+
var import_fs35 = __toESM(require("fs"));
|
|
27002
27144
|
var import_os26 = __toESM(require("os"));
|
|
27003
|
-
var
|
|
27145
|
+
var import_path37 = __toESM(require("path"));
|
|
27004
27146
|
init_dist();
|
|
27005
27147
|
var ICON = "\u{1F6E1}\uFE0F";
|
|
27006
27148
|
var LEVEL_NAMES = {
|
|
@@ -27042,24 +27184,24 @@ function sessionNoticeEnabled(env = process.env) {
|
|
|
27042
27184
|
var FLAG_MAX_BYTES = 32;
|
|
27043
27185
|
function claimSessionNotice(sessionId, home = import_os26.default.homedir(), level = "standard") {
|
|
27044
27186
|
if (!sessionId || !SAFE_SESSION_ID.test(sessionId)) return null;
|
|
27045
|
-
const dir2 =
|
|
27187
|
+
const dir2 = import_path37.default.join(home, ".node9", "notice-sessions");
|
|
27046
27188
|
const seen = ensureOwnDir(dir2);
|
|
27047
27189
|
if (!seen) return null;
|
|
27048
|
-
const flag =
|
|
27190
|
+
const flag = import_path37.default.join(dir2, sessionId + SESSION_FLAG_SUFFIX);
|
|
27049
27191
|
let created = false;
|
|
27050
27192
|
try {
|
|
27051
27193
|
if (!isSameOwnDir(dir2, seen)) return null;
|
|
27052
|
-
const fd =
|
|
27194
|
+
const fd = import_fs35.default.openSync(flag, "wx", 384);
|
|
27053
27195
|
created = true;
|
|
27054
27196
|
try {
|
|
27055
|
-
|
|
27197
|
+
import_fs35.default.writeSync(fd, level);
|
|
27056
27198
|
} finally {
|
|
27057
|
-
|
|
27199
|
+
import_fs35.default.closeSync(fd);
|
|
27058
27200
|
}
|
|
27059
27201
|
} catch (err) {
|
|
27060
27202
|
if (created) {
|
|
27061
27203
|
try {
|
|
27062
|
-
|
|
27204
|
+
import_fs35.default.unlinkSync(flag);
|
|
27063
27205
|
} catch {
|
|
27064
27206
|
}
|
|
27065
27207
|
return null;
|
|
@@ -27083,22 +27225,22 @@ function levelChange(dir2, seen, flag, level) {
|
|
|
27083
27225
|
}
|
|
27084
27226
|
}
|
|
27085
27227
|
function readFlag(flag) {
|
|
27086
|
-
const c =
|
|
27087
|
-
const fd =
|
|
27228
|
+
const c = import_fs35.default.constants;
|
|
27229
|
+
const fd = import_fs35.default.openSync(flag, c.O_RDONLY | (c.O_NOFOLLOW ?? 0) | (c.O_NONBLOCK ?? 0));
|
|
27088
27230
|
try {
|
|
27089
|
-
const st =
|
|
27231
|
+
const st = import_fs35.default.fstatSync(fd);
|
|
27090
27232
|
if (!st.isFile() || st.nlink !== 1 || st.size > FLAG_MAX_BYTES) return null;
|
|
27091
27233
|
const buf = Buffer.alloc(FLAG_MAX_BYTES);
|
|
27092
|
-
const n =
|
|
27234
|
+
const n = import_fs35.default.readSync(fd, buf, 0, FLAG_MAX_BYTES, 0);
|
|
27093
27235
|
return buf.toString("utf8", 0, n).trim();
|
|
27094
27236
|
} finally {
|
|
27095
|
-
|
|
27237
|
+
import_fs35.default.closeSync(fd);
|
|
27096
27238
|
}
|
|
27097
27239
|
}
|
|
27098
27240
|
function removeOldFlags(dir2, seen) {
|
|
27099
27241
|
const cutoff = Date.now() - FLAG_TTL_MS;
|
|
27100
27242
|
try {
|
|
27101
|
-
for (const name of
|
|
27243
|
+
for (const name of import_fs35.default.readdirSync(dir2)) removeOldFlag(dir2, seen, name, cutoff);
|
|
27102
27244
|
} catch {
|
|
27103
27245
|
}
|
|
27104
27246
|
}
|
|
@@ -27181,9 +27323,9 @@ function registerCheckCommand(program2) {
|
|
|
27181
27323
|
} catch (err) {
|
|
27182
27324
|
const tempConfig = getConfig();
|
|
27183
27325
|
if (process.env.NODE9_DEBUG === "1" || tempConfig.settings.enableHookLogDebug) {
|
|
27184
|
-
const logPath =
|
|
27326
|
+
const logPath = import_path38.default.join(import_os27.default.homedir(), ".node9", "hook-debug.log");
|
|
27185
27327
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
27186
|
-
|
|
27328
|
+
import_fs36.default.appendFileSync(
|
|
27187
27329
|
logPath,
|
|
27188
27330
|
`[${(/* @__PURE__ */ new Date()).toISOString()}] JSON_PARSE_ERROR: ${errMsg}
|
|
27189
27331
|
RAW: ${raw}
|
|
@@ -27196,14 +27338,14 @@ RAW: ${raw}
|
|
|
27196
27338
|
const prompt = typeof payload.prompt === "string" ? payload.prompt : "";
|
|
27197
27339
|
if (process.env.NODE9_DEBUG === "1") {
|
|
27198
27340
|
try {
|
|
27199
|
-
const logPath =
|
|
27200
|
-
if (!
|
|
27201
|
-
|
|
27341
|
+
const logPath = import_path38.default.join(import_os27.default.homedir(), ".node9", "hook-debug.log");
|
|
27342
|
+
if (!import_fs36.default.existsSync(import_path38.default.dirname(logPath)))
|
|
27343
|
+
import_fs36.default.mkdirSync(import_path38.default.dirname(logPath), { recursive: true });
|
|
27202
27344
|
const sanitized = JSON.stringify({
|
|
27203
27345
|
...payload,
|
|
27204
27346
|
prompt: `<redacted, ${prompt.length} bytes>`
|
|
27205
27347
|
});
|
|
27206
|
-
|
|
27348
|
+
import_fs36.default.appendFileSync(logPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] STDIN: ${sanitized}
|
|
27207
27349
|
`);
|
|
27208
27350
|
} catch {
|
|
27209
27351
|
}
|
|
@@ -27221,7 +27363,7 @@ RAW: ${raw}
|
|
|
27221
27363
|
if (!dlpMatch && !canaryHit) {
|
|
27222
27364
|
try {
|
|
27223
27365
|
const sid = typeof payload.session_id === "string" ? payload.session_id : typeof payload.conversationId === "string" ? payload.conversationId : "";
|
|
27224
|
-
const promptCwd = typeof payload.cwd === "string" &&
|
|
27366
|
+
const promptCwd = typeof payload.cwd === "string" && import_path38.default.isAbsolute(payload.cwd) ? payload.cwd : void 0;
|
|
27225
27367
|
if (sid && getConfig(promptCwd).policy.untrustedContent?.enabled) {
|
|
27226
27368
|
await notifyUserMentions(sid, extractContentDestinations(prompt));
|
|
27227
27369
|
}
|
|
@@ -27262,8 +27404,8 @@ RAW: ${raw}
|
|
|
27262
27404
|
);
|
|
27263
27405
|
const reason = `\u{1F6A8} Node9 DLP: ${shownPattern} detected in prompt (${shownSample}). Prompt was not submitted \u2014 remove the credential and try again.`;
|
|
27264
27406
|
try {
|
|
27265
|
-
const ttyFd =
|
|
27266
|
-
|
|
27407
|
+
const ttyFd = import_fs36.default.openSync("/dev/tty", "w");
|
|
27408
|
+
import_fs36.default.writeSync(
|
|
27267
27409
|
ttyFd,
|
|
27268
27410
|
import_chalk2.default.bgRed.white.bold(`
|
|
27269
27411
|
\u{1F6A8} NODE9 DLP \u2014 PROMPT BLOCKED
|
|
@@ -27273,7 +27415,7 @@ RAW: ${raw}
|
|
|
27273
27415
|
|
|
27274
27416
|
`)
|
|
27275
27417
|
);
|
|
27276
|
-
|
|
27418
|
+
import_fs36.default.closeSync(ttyFd);
|
|
27277
27419
|
} catch {
|
|
27278
27420
|
}
|
|
27279
27421
|
const isCodex = agent2 === "Codex";
|
|
@@ -27292,17 +27434,17 @@ RAW: ${raw}
|
|
|
27292
27434
|
process.exit(2);
|
|
27293
27435
|
}
|
|
27294
27436
|
const payloadCwd = typeof payload.cwd === "string" ? payload.cwd : Array.isArray(payload.workspacePaths) && typeof payload.workspacePaths[0] === "string" ? payload.workspacePaths[0] : void 0;
|
|
27295
|
-
const safeCwdForConfig = typeof payloadCwd === "string" &&
|
|
27437
|
+
const safeCwdForConfig = typeof payloadCwd === "string" && import_path38.default.isAbsolute(payloadCwd) ? payloadCwd : void 0;
|
|
27296
27438
|
const config = getConfig(safeCwdForConfig);
|
|
27297
27439
|
const daemonDown = !isDaemonRunning();
|
|
27298
27440
|
if (config.settings.autoStartDaemon && daemonDown && !process.env.NODE9_NO_AUTO_DAEMON) {
|
|
27299
27441
|
try {
|
|
27300
27442
|
const scriptPath = process.argv[1];
|
|
27301
|
-
if (typeof scriptPath !== "string" || !
|
|
27443
|
+
if (typeof scriptPath !== "string" || !import_path38.default.isAbsolute(scriptPath))
|
|
27302
27444
|
throw new Error("node9: argv[1] is not an absolute path");
|
|
27303
|
-
const resolvedScript =
|
|
27304
|
-
const packageDist =
|
|
27305
|
-
if (!resolvedScript.startsWith(packageDist +
|
|
27445
|
+
const resolvedScript = import_fs36.default.realpathSync(scriptPath);
|
|
27446
|
+
const packageDist = import_fs36.default.realpathSync(import_path38.default.resolve(__dirname, "../.."));
|
|
27447
|
+
if (!resolvedScript.startsWith(packageDist + import_path38.default.sep) && resolvedScript !== packageDist)
|
|
27306
27448
|
throw new Error(
|
|
27307
27449
|
`node9: daemon spawn aborted \u2014 argv[1] (${resolvedScript}) is outside package dist (${packageDist})`
|
|
27308
27450
|
);
|
|
@@ -27332,17 +27474,17 @@ RAW: ${raw}
|
|
|
27332
27474
|
} finally {
|
|
27333
27475
|
if (startupFd !== void 0) {
|
|
27334
27476
|
try {
|
|
27335
|
-
|
|
27477
|
+
import_fs36.default.closeSync(startupFd);
|
|
27336
27478
|
} catch {
|
|
27337
27479
|
}
|
|
27338
27480
|
}
|
|
27339
27481
|
}
|
|
27340
27482
|
} catch (spawnErr) {
|
|
27341
|
-
const logPath =
|
|
27483
|
+
const logPath = import_path38.default.join(import_os27.default.homedir(), ".node9", "hook-debug.log");
|
|
27342
27484
|
const msg = spawnErr instanceof Error ? spawnErr.message : String(spawnErr);
|
|
27343
27485
|
recordStartupState("failed", "spawn-aborted", msg);
|
|
27344
27486
|
try {
|
|
27345
|
-
|
|
27487
|
+
import_fs36.default.appendFileSync(
|
|
27346
27488
|
logPath,
|
|
27347
27489
|
`[${(/* @__PURE__ */ new Date()).toISOString()}] daemon-autostart-failed: ${msg}
|
|
27348
27490
|
`
|
|
@@ -27356,10 +27498,10 @@ RAW: ${raw}
|
|
|
27356
27498
|
);
|
|
27357
27499
|
}
|
|
27358
27500
|
if (process.env.NODE9_DEBUG === "1" || config.settings.enableHookLogDebug) {
|
|
27359
|
-
const logPath =
|
|
27360
|
-
if (!
|
|
27361
|
-
|
|
27362
|
-
|
|
27501
|
+
const logPath = import_path38.default.join(import_os27.default.homedir(), ".node9", "hook-debug.log");
|
|
27502
|
+
if (!import_fs36.default.existsSync(import_path38.default.dirname(logPath)))
|
|
27503
|
+
import_fs36.default.mkdirSync(import_path38.default.dirname(logPath), { recursive: true });
|
|
27504
|
+
import_fs36.default.appendFileSync(
|
|
27363
27505
|
logPath,
|
|
27364
27506
|
`[${(/* @__PURE__ */ new Date()).toISOString()}] STDIN: ${JSON.stringify(raw)}
|
|
27365
27507
|
`
|
|
@@ -27380,8 +27522,8 @@ RAW: ${raw}
|
|
|
27380
27522
|
);
|
|
27381
27523
|
let ttyFd = null;
|
|
27382
27524
|
try {
|
|
27383
|
-
ttyFd =
|
|
27384
|
-
const writeTty = (line) =>
|
|
27525
|
+
ttyFd = import_fs36.default.openSync("/dev/tty", "w");
|
|
27526
|
+
const writeTty = (line) => import_fs36.default.writeSync(ttyFd, line + "\n");
|
|
27385
27527
|
if (result2?.blockKind === "protected-path") {
|
|
27386
27528
|
writeTty(
|
|
27387
27529
|
import_chalk2.default.red.bold(
|
|
@@ -27408,7 +27550,7 @@ RAW: ${raw}
|
|
|
27408
27550
|
} finally {
|
|
27409
27551
|
if (ttyFd !== null)
|
|
27410
27552
|
try {
|
|
27411
|
-
|
|
27553
|
+
import_fs36.default.closeSync(ttyFd);
|
|
27412
27554
|
} catch {
|
|
27413
27555
|
}
|
|
27414
27556
|
}
|
|
@@ -27479,8 +27621,8 @@ RAW: ${raw}
|
|
|
27479
27621
|
} catch {
|
|
27480
27622
|
}
|
|
27481
27623
|
try {
|
|
27482
|
-
const ttyFd =
|
|
27483
|
-
|
|
27624
|
+
const ttyFd = import_fs36.default.openSync("/dev/tty", "w");
|
|
27625
|
+
import_fs36.default.writeSync(
|
|
27484
27626
|
ttyFd,
|
|
27485
27627
|
import_chalk2.default.yellow(
|
|
27486
27628
|
`
|
|
@@ -27488,7 +27630,7 @@ RAW: ${raw}
|
|
|
27488
27630
|
`
|
|
27489
27631
|
)
|
|
27490
27632
|
);
|
|
27491
|
-
|
|
27633
|
+
import_fs36.default.closeSync(ttyFd);
|
|
27492
27634
|
} catch {
|
|
27493
27635
|
}
|
|
27494
27636
|
if (agent === "GitHub Copilot") {
|
|
@@ -27520,14 +27662,14 @@ RAW: ${raw}
|
|
|
27520
27662
|
const safeSessionId = /^[A-Za-z0-9_\-]{1,128}$/.test(rawSessionId) ? rawSessionId : "";
|
|
27521
27663
|
if (skillPinCfg.enabled && safeSessionId) {
|
|
27522
27664
|
try {
|
|
27523
|
-
const sessionsDir =
|
|
27524
|
-
const flagPath =
|
|
27665
|
+
const sessionsDir = import_path38.default.join(import_os27.default.homedir(), ".node9", "skill-sessions");
|
|
27666
|
+
const flagPath = import_path38.default.join(sessionsDir, `${safeSessionId}${SESSION_FLAG_SUFFIX}`);
|
|
27525
27667
|
const memo = ensureOwnDir(sessionsDir);
|
|
27526
27668
|
let flag = null;
|
|
27527
27669
|
try {
|
|
27528
|
-
const st = memo ?
|
|
27670
|
+
const st = memo ? import_fs36.default.lstatSync(flagPath) : null;
|
|
27529
27671
|
if (st && st.isFile() && st.nlink === 1)
|
|
27530
|
-
flag = JSON.parse(
|
|
27672
|
+
flag = JSON.parse(import_fs36.default.readFileSync(flagPath, "utf-8"));
|
|
27531
27673
|
} catch {
|
|
27532
27674
|
}
|
|
27533
27675
|
const writeFlag = (data2) => {
|
|
@@ -27544,8 +27686,8 @@ RAW: ${raw}
|
|
|
27544
27686
|
const sendSkillWarn = (detail, recoveryCmd) => {
|
|
27545
27687
|
let ttyFd = null;
|
|
27546
27688
|
try {
|
|
27547
|
-
ttyFd =
|
|
27548
|
-
const w = (line) =>
|
|
27689
|
+
ttyFd = import_fs36.default.openSync("/dev/tty", "w");
|
|
27690
|
+
const w = (line) => import_fs36.default.writeSync(ttyFd, line + "\n");
|
|
27549
27691
|
w(import_chalk2.default.yellow(`
|
|
27550
27692
|
\u26A0\uFE0F Node9: installed skill drift detected`));
|
|
27551
27693
|
w(import_chalk2.default.gray(` ${detail}`));
|
|
@@ -27560,7 +27702,7 @@ RAW: ${raw}
|
|
|
27560
27702
|
} finally {
|
|
27561
27703
|
if (ttyFd !== null)
|
|
27562
27704
|
try {
|
|
27563
|
-
|
|
27705
|
+
import_fs36.default.closeSync(ttyFd);
|
|
27564
27706
|
} catch {
|
|
27565
27707
|
}
|
|
27566
27708
|
}
|
|
@@ -27576,7 +27718,7 @@ RAW: ${raw}
|
|
|
27576
27718
|
return;
|
|
27577
27719
|
}
|
|
27578
27720
|
if (!flag || flag.state !== "verified" && flag.state !== "warned") {
|
|
27579
|
-
const absoluteCwd = typeof payloadCwd === "string" &&
|
|
27721
|
+
const absoluteCwd = typeof payloadCwd === "string" && import_path38.default.isAbsolute(payloadCwd) ? payloadCwd : void 0;
|
|
27580
27722
|
const extraRoots = skillPinCfg.roots;
|
|
27581
27723
|
const resolvedExtra = extraRoots.map((r) => resolveUserSkillRoot(r, absoluteCwd)).filter((r) => typeof r === "string");
|
|
27582
27724
|
const roots = [...defaultSkillRoots(absoluteCwd), ...resolvedExtra];
|
|
@@ -27618,7 +27760,7 @@ RAW: ${raw}
|
|
|
27618
27760
|
if (memo)
|
|
27619
27761
|
try {
|
|
27620
27762
|
const cutoff = Date.now() - 7 * 24 * 60 * 60 * 1e3;
|
|
27621
|
-
for (const name of
|
|
27763
|
+
for (const name of import_fs36.default.readdirSync(sessionsDir))
|
|
27622
27764
|
removeOldFlag(sessionsDir, memo, name, cutoff);
|
|
27623
27765
|
} catch {
|
|
27624
27766
|
}
|
|
@@ -27626,16 +27768,16 @@ RAW: ${raw}
|
|
|
27626
27768
|
} catch (err) {
|
|
27627
27769
|
if (process.env.NODE9_DEBUG === "1") {
|
|
27628
27770
|
try {
|
|
27629
|
-
const dbg =
|
|
27771
|
+
const dbg = import_path38.default.join(import_os27.default.homedir(), ".node9", "hook-debug.log");
|
|
27630
27772
|
const msg = err instanceof Error ? err.message : String(err);
|
|
27631
|
-
|
|
27773
|
+
import_fs36.default.appendFileSync(dbg, `[${(/* @__PURE__ */ new Date()).toISOString()}] SKILL_PIN_ERROR: ${msg}
|
|
27632
27774
|
`);
|
|
27633
27775
|
} catch {
|
|
27634
27776
|
}
|
|
27635
27777
|
}
|
|
27636
27778
|
}
|
|
27637
27779
|
}
|
|
27638
|
-
const safeCwdForAuth = typeof payloadCwd === "string" &&
|
|
27780
|
+
const safeCwdForAuth = typeof payloadCwd === "string" && import_path38.default.isAbsolute(payloadCwd) ? payloadCwd : void 0;
|
|
27639
27781
|
const askMode = resolveAskMode(agent, opts, config);
|
|
27640
27782
|
const result = await authorizeHeadless(toolName, toolInput, meta, {
|
|
27641
27783
|
cwd: safeCwdForAuth,
|
|
@@ -27653,7 +27795,7 @@ RAW: ${raw}
|
|
|
27653
27795
|
const notice = checkedBy !== "paused" && agent === "Claude Code" && !isSubagentCall && sessionNoticeEnabled() ? claimSessionNotice(safeSessionId, import_os27.default.homedir(), levelOf(config.settings.mode)) : null;
|
|
27654
27796
|
if (notice) {
|
|
27655
27797
|
try {
|
|
27656
|
-
|
|
27798
|
+
import_fs36.default.writeSync(1, sessionNoticeOutput(config.settings.mode, notice) + "\n");
|
|
27657
27799
|
} catch {
|
|
27658
27800
|
}
|
|
27659
27801
|
}
|
|
@@ -27671,12 +27813,12 @@ RAW: ${raw}
|
|
|
27671
27813
|
}
|
|
27672
27814
|
if (result.noApprovalMechanism && !isDaemonRunning() && !process.env.NODE9_NO_AUTO_DAEMON && !process.stdout.isTTY && config.settings.autoStartDaemon) {
|
|
27673
27815
|
try {
|
|
27674
|
-
const tty =
|
|
27675
|
-
|
|
27816
|
+
const tty = import_fs36.default.openSync("/dev/tty", "w");
|
|
27817
|
+
import_fs36.default.writeSync(
|
|
27676
27818
|
tty,
|
|
27677
27819
|
import_chalk2.default.cyan("\n\u{1F6E1}\uFE0F Node9: Starting approval daemon automatically...\n")
|
|
27678
27820
|
);
|
|
27679
|
-
|
|
27821
|
+
import_fs36.default.closeSync(tty);
|
|
27680
27822
|
} catch {
|
|
27681
27823
|
}
|
|
27682
27824
|
const daemonReady = await autoStartDaemonAndWait();
|
|
@@ -27703,9 +27845,9 @@ RAW: ${raw}
|
|
|
27703
27845
|
});
|
|
27704
27846
|
} catch (err) {
|
|
27705
27847
|
if (process.env.NODE9_DEBUG === "1") {
|
|
27706
|
-
const logPath =
|
|
27848
|
+
const logPath = import_path38.default.join(import_os27.default.homedir(), ".node9", "hook-debug.log");
|
|
27707
27849
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
27708
|
-
|
|
27850
|
+
import_fs36.default.appendFileSync(logPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] ERROR: ${errMsg}
|
|
27709
27851
|
`);
|
|
27710
27852
|
}
|
|
27711
27853
|
process.exit(0);
|
|
@@ -27740,12 +27882,21 @@ RAW: ${raw}
|
|
|
27740
27882
|
|
|
27741
27883
|
// src/cli/commands/log.ts
|
|
27742
27884
|
init_cjs_shims();
|
|
27743
|
-
var
|
|
27744
|
-
var
|
|
27885
|
+
var import_fs37 = __toESM(require("fs"));
|
|
27886
|
+
var import_path39 = __toESM(require("path"));
|
|
27745
27887
|
var import_os28 = __toESM(require("os"));
|
|
27746
27888
|
init_audit();
|
|
27747
27889
|
init_dist();
|
|
27748
27890
|
|
|
27891
|
+
// src/exposure/shell-fetch.ts
|
|
27892
|
+
init_cjs_shims();
|
|
27893
|
+
init_dist();
|
|
27894
|
+
function shellFetch(tool, rawInput) {
|
|
27895
|
+
if (tool !== "Bash" && tool !== "bash") return null;
|
|
27896
|
+
const cmd = rawInput && typeof rawInput === "object" && !Array.isArray(rawInput) ? rawInput.command : void 0;
|
|
27897
|
+
return typeof cmd === "string" && cmd.length > 0 ? classifyShellExposure(cmd) : null;
|
|
27898
|
+
}
|
|
27899
|
+
|
|
27749
27900
|
// src/exposure/source.ts
|
|
27750
27901
|
init_cjs_shims();
|
|
27751
27902
|
init_audit();
|
|
@@ -27959,11 +28110,6 @@ function buildArgsField(rawInput) {
|
|
|
27959
28110
|
return hashed;
|
|
27960
28111
|
}
|
|
27961
28112
|
}
|
|
27962
|
-
function shellFetch(tool, rawInput) {
|
|
27963
|
-
if (tool !== "Bash" && tool !== "bash") return null;
|
|
27964
|
-
const cmd = rawInput && typeof rawInput === "object" && !Array.isArray(rawInput) ? rawInput.command : void 0;
|
|
27965
|
-
return typeof cmd === "string" && cmd.length > 0 ? classifyShellExposure(cmd) : null;
|
|
27966
|
-
}
|
|
27967
28113
|
function registerLogCommand(program2) {
|
|
27968
28114
|
program2.command("log", { hidden: true }).description("PostToolUse hook \u2014 records executed tool calls").argument("[data]", "JSON string of the tool call").option(
|
|
27969
28115
|
"--agent <name>",
|
|
@@ -28010,12 +28156,12 @@ function registerLogCommand(program2) {
|
|
|
28010
28156
|
if (rawToolName !== tool) entry.agentToolName = rawToolName;
|
|
28011
28157
|
const payloadSessionId = payload.session_id ?? payload.conversationId;
|
|
28012
28158
|
if (payloadSessionId) entry.sessionId = payloadSessionId;
|
|
28013
|
-
const logPath =
|
|
28014
|
-
if (!
|
|
28015
|
-
|
|
28016
|
-
|
|
28159
|
+
const logPath = import_path39.default.join(import_os28.default.homedir(), ".node9", "audit.log");
|
|
28160
|
+
if (!import_fs37.default.existsSync(import_path39.default.dirname(logPath)))
|
|
28161
|
+
import_fs37.default.mkdirSync(import_path39.default.dirname(logPath), { recursive: true });
|
|
28162
|
+
import_fs37.default.appendFileSync(logPath, JSON.stringify(entry) + "\n");
|
|
28017
28163
|
const payloadCwd = typeof payload.cwd === "string" ? payload.cwd : Array.isArray(payload.workspacePaths) && typeof payload.workspacePaths[0] === "string" ? payload.workspacePaths[0] : void 0;
|
|
28018
|
-
const safeCwd = typeof payloadCwd === "string" &&
|
|
28164
|
+
const safeCwd = typeof payloadCwd === "string" && import_path39.default.isAbsolute(payloadCwd) ? payloadCwd : void 0;
|
|
28019
28165
|
if ((tool === "Bash" || tool === "bash") && isDaemonRunning()) {
|
|
28020
28166
|
const command = typeof rawInput === "object" && rawInput !== null && "command" in rawInput && typeof rawInput.command === "string" ? rawInput.command : null;
|
|
28021
28167
|
if (command) {
|
|
@@ -28236,9 +28382,9 @@ function registerLogCommand(program2) {
|
|
|
28236
28382
|
const msg = err instanceof Error ? err.message : String(err);
|
|
28237
28383
|
process.stderr.write(`[Node9] audit log error: ${msg}
|
|
28238
28384
|
`);
|
|
28239
|
-
const debugPath =
|
|
28385
|
+
const debugPath = import_path39.default.join(import_os28.default.homedir(), ".node9", "hook-debug.log");
|
|
28240
28386
|
try {
|
|
28241
|
-
|
|
28387
|
+
import_fs37.default.appendFileSync(debugPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] LOG_ERROR: ${msg}
|
|
28242
28388
|
`);
|
|
28243
28389
|
} catch {
|
|
28244
28390
|
}
|
|
@@ -28261,9 +28407,9 @@ function registerLogCommand(program2) {
|
|
|
28261
28407
|
});
|
|
28262
28408
|
}
|
|
28263
28409
|
function absolutePathFor(spelled, cwd) {
|
|
28264
|
-
const expanded = spelled === "~" || spelled.startsWith("~/") ?
|
|
28265
|
-
if (
|
|
28266
|
-
return cwd ?
|
|
28410
|
+
const expanded = spelled === "~" || spelled.startsWith("~/") ? import_path39.default.join(import_os28.default.homedir(), spelled.slice(1)) : spelled;
|
|
28411
|
+
if (import_path39.default.isAbsolute(expanded)) return expanded;
|
|
28412
|
+
return cwd ? import_path39.default.resolve(cwd, expanded) : import_path39.default.resolve(expanded);
|
|
28267
28413
|
}
|
|
28268
28414
|
async function carryTaintAcrossWrites(command, cwd) {
|
|
28269
28415
|
let pairs;
|
|
@@ -28282,13 +28428,13 @@ async function carryTaintAcrossWrites(command, cwd) {
|
|
|
28282
28428
|
continue;
|
|
28283
28429
|
}
|
|
28284
28430
|
const sensitive = scanFilePath(src, cwd);
|
|
28285
|
-
if (sensitive) await notifyTaint(dst, `copy:${sensitive.patternName}:${
|
|
28431
|
+
if (sensitive) await notifyTaint(dst, `copy:${sensitive.patternName}:${import_path39.default.basename(src)}`);
|
|
28286
28432
|
}
|
|
28287
28433
|
}
|
|
28288
28434
|
|
|
28289
28435
|
// src/hook-entry.ts
|
|
28290
28436
|
var { version } = JSON.parse(
|
|
28291
|
-
|
|
28437
|
+
import_fs38.default.readFileSync(import_path40.default.join(__dirname, "../package.json"), "utf-8")
|
|
28292
28438
|
);
|
|
28293
28439
|
var program = new import_commander.Command();
|
|
28294
28440
|
program.name("node9").description("The Sudo Command for AI Agents").version(version);
|
|
@@ -28297,9 +28443,9 @@ registerLogCommand(program);
|
|
|
28297
28443
|
process.on("unhandledRejection", (reason) => {
|
|
28298
28444
|
if (process.argv[2] === "check") {
|
|
28299
28445
|
if (process.env.NODE9_DEBUG === "1" || getConfig().settings.enableHookLogDebug) {
|
|
28300
|
-
const logPath =
|
|
28446
|
+
const logPath = import_path40.default.join(import_os29.default.homedir(), ".node9", "hook-debug.log");
|
|
28301
28447
|
const msg = reason instanceof Error ? reason.message : String(reason);
|
|
28302
|
-
|
|
28448
|
+
import_fs38.default.appendFileSync(logPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] UNHANDLED: ${msg}
|
|
28303
28449
|
`);
|
|
28304
28450
|
}
|
|
28305
28451
|
process.exit(0);
|