/** * Security helpers for spawn operations * * Provides environment variable filtering and credential masking * to prevent command injection and credential leakage. */ /** * Environment variables that MUST NOT be passed from user input to spawned processes. * These can be exploited for: * - Code execution hijacking (PATH, NODE_OPTIONS) * - Dynamic linker injection (LD_PRELOAD, DYLD_INSERT_LIBRARIES) * - Interpreter code injection (PYTHONPATH, RUBYLIB) * - Credential/identity hijacking (HOME, AWS_CONFIG_FILE) * - Shell injection (BASH_ENV, ENV) */ export declare const DANGEROUS_ENV_VARS: Set; /** * Filter dangerous environment variables from a record. * Returns a new object with only safe environment variables. */ export declare function filterDangerousEnvVars(env: Record): Record; /** * Matches the FULL agent token: prefix (16 base32) + separator (.) + secret (40 base32), * for both scoped-family kinds — `fjall_ak_` (scoped) and `fjall_dk_` (deploy). * Base32 alphabet: A-Z2-7. The `.` separator MUST be included or the secret leaks unmasked. * Single source of truth — all masking call sites import this. Coupled to the prefix * SSoT `AGENT_TOKEN_PREFIXES` at webapp/app/.server/models/auth/agent-token-kind.ts — * a new token kind there MUST extend this alternation. * * Public form has NO `g` flag — `.test()` consumers must not share `lastIndex` across calls. * The global form lives in `SCOPED_TOKEN_GLOBAL_REGEX` below for the iteration site. */ export declare const SCOPED_TOKEN_REGEX: RegExp; /** * Marker embedded in every maskSensitiveOutput replacement except the PEM * branch (which uses REDACTED_KEY_SENTINEL). Exported so display surfaces * that detect masked values (e.g. the webapp changeset preview) import the * marker rather than re-declaring the literal. */ export declare const MASKED_VALUE_MARKER = "***"; /** * Sentinel embedded in the PEM-branch replacement * (`-----BEGIN [REDACTED] PRIVATE KEY-----`). Exported for the same * detection consumers as MASKED_VALUE_MARKER. */ export declare const REDACTED_KEY_SENTINEL = "[REDACTED]"; /** * Mask sensitive information in output strings to prevent credential leakage. * Patterns: postgres://user:pass@host, password=xxx, secret=xxx, apikey=xxx, * GitHub tokens (ghu_/ghs_/ghp_/gho_/github_pat_), bare AWS access-key IDs * (AKIA-prefixed and ASIA-prefixed), AWS secret keys (env, INI, and JSON key * spellings), session tokens, agent tokens (`fjall_ak_` scoped, `fjall_dk_` * deploy), legacy personal API keys (`fj_<8 hex>_<48 hex>`). * * Single source of truth — consumer loggers (CLI, worker, webapp) MUST * NOT re-implement these patterns inline. See * the credential-masking standard, § "Masking Patterns Live in @fjall/util". */ export declare function maskSensitiveOutput(output: string): string; /** * Parse a shell command string into an array of arguments. * Handles single quotes, double quotes, and escaped characters. * Throws on unbalanced quotes to prevent unexpected argument splitting. */ export declare function parseShellArgs(command: string): string[];