import type { RuleContext, RuleMatch } from "./types"; export declare function runRegex(pattern: RegExp, context: RuleContext): RuleMatch[]; export declare function isLikelyExampleText(text: string): boolean; export declare function clampConfidence(value: number): number; export declare function isLikelyPatternDeclarationLine(line: string): boolean; export declare function isLikelyPromptUsageLine(line: string): boolean; export declare function isLikelyRuleMetadataLine(line: string): boolean; /** * Computes the Shannon entropy of a string in bits per character. * High entropy (> ~4.5) indicates a randomly-generated credential rather than a * human-readable placeholder. Used by credential rules to boost confidence on * real-looking key material and suppress placeholder false positives. * * Range: 0 (all identical chars) to log2(charsetSize) (uniform distribution). * Typical values: English prose ~4.0, random hex ~4.0, random base64 ~5.5–6.0. */ export declare function shannonEntropy(value: string): number; /** Entropy threshold above which a string is considered real credential material. */ export declare const HIGH_ENTROPY_THRESHOLD = 4.5; /** Confidence boost applied when a matched token has Shannon entropy above the threshold. */ export declare const ENTROPY_BOOST = 0.1; /** * Returns a confidence value boosted by ENTROPY_BOOST when the secret portion * of the match has high Shannon entropy, then clamped to [0, 1]. */ export declare function entropyBoostedConfidence(baseConfidence: number, secretPart: string): number; /** * Strips zero-width characters commonly used to break regex word-boundary * detection. Examples: U+200B (zero-width space), U+200C (zero-width * non-joiner), U+200D (zero-width joiner), U+FEFF (BOM / zero-width * no-break space). */ export declare function stripZeroWidthChars(input: string): string; export declare function normalizeConfusables(input: string): string; /** * Returns a normalised version of the input suitable for regex matching. * Applies: * 1. NFKC normalisation (collapses compatibility-equivalent characters) * 2. Cross-script confusable mapping (Cyrillic/Greek homoglyphs → Latin) * 3. Zero-width character stripping * 4. Lowercasing */ export declare function normalizeForDetection(input: string): string; /** * Strips hyphens between word characters to catch split-word evasion * techniques like "ig-nore" or "for-get". */ export declare function stripIntraWordHyphens(input: string): string; /** * Known jailbreak / roleplay framing phrases used to make models disregard * safety instructions without using the classic "ignore previous" wording. */ export declare const JAILBREAK_PATTERNS: RegExp[]; /** * Known indirect system-prompt extraction phrases that do not use the classic * "reveal system prompt" wording. */ export declare const INDIRECT_EXTRACTION_PATTERNS: RegExp[]; /** * Non-English prompt injection phrases covering the most common languages * used in attacks. Kept compact to avoid false positives from innocent * documentation. */ export declare const MULTILINGUAL_INJECTION_PATTERNS: RegExp[]; /** * Decodes a ROT13-encoded string. ROT13 is a Caesar cipher that shifts each * letter by 13 positions (A-Z / a-z). It is self-inverse: applying ROT13 * twice returns the original text. * * Attackers use ROT13 to evade regex-based pattern matching on injection * keywords. For example, "ignore previous instructions" becomes * "vtaber cerivbhf vafgehpgvbaf" which does not match keyword patterns. * * This function decodes the full string so callers can then check it against * known injection patterns. */ export declare function rot13Decode(input: string): string; /** * Checks whether decoded content contains ROT13-encoded injection phrases. * * Heuristic: if the input text has a high proportion of alphabetic characters * (>=60%) and the ROT13-decoded version matches any of the provided injection * patterns while the original text does not, it is likely a ROT13 obfuscation * attempt. * * @param original - The original (potentially encoded) content * @param patterns - Array of regex patterns to check against decoded text * @returns The first decoded injection match, or null if none found */ export declare function detectRot13Injection(original: string, patterns: RegExp[]): { decoded: string; pattern: RegExp; match: RegExpExecArray; } | null; /** * Returns true when the line contains token-splitting patterns commonly used * to evade word-boundary detection (e.g. string concatenation, array joins, * template-literal breaks). */ export declare function hasTokenSplittingPattern(line: string): boolean;