/** * Secret and PII rule table, adapted from dsh-secret-scrub v0.1.2. * * MIT License * * Copyright (c) 2026 jkt-check * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Derived from dsh-secret-scrub v0.1.2 (MIT, Copyright (c) 2026 jkt-check). * Modified by gythialy, 2026-10-19: converted to TypeScript for dsh-sensitive-guard; placeholders and values are now supplied by the engine. * * @module dsh-sensitive-guard/redact/rules */ import type { Level } from '../contracts.js'; /** Rule tier: 0 = core credentials, 1 = assignments, 2 = PII and fallbacks. */ export type RuleTier = 0 | 1 | 2; /** Post-match validator; returning false keeps the original text uncounted. */ export type RuleValidator = (match: string) => boolean; /** One compiled rule. Patterns are global and shared; callers must reset lastIndex. */ export interface CompiledSecretRule { readonly category: string; readonly tier: RuleTier; readonly pattern: RegExp; readonly validate?: RuleValidator; /** PII rules emit keyed `[[PII_...]]` pseudonyms instead of secret placeholders. */ readonly pii?: boolean; /** * Skip matches fully inside the path of an absolute `http(s)` URL: those * segments are document identifiers, not credentials. Query strings, * fragments, and every rule without this flag keep their normal behaviour. */ readonly exemptInUrlPath?: boolean; } /** Categories that use keyed PII pseudonyms instead of random secret ids. */ export declare const PII_CATEGORIES: ReadonlySet; /** * Built-in rules, all global-flagged, ordered by tier ascending and, within * a tier, from most specific to most general. Tiers 0–1 are prefix-anchored * (provider key prefixes, assignment shapes, URL authority forms); tier 2 * matches shapes (PII and high-entropy runs). The ordering lets broad * multi-line and provider-prefixed rules claim their spans before the generic * fallbacks (`generic-sk-key`, `generic-bearer`, `high-entropy`) run. * `private-key` spans lines and runs first so nothing else claims pieces of a * PEM body; `id-cn` runs before `credit-card` so a Luhn-valid 17–19 digit * run categorizes as the more specific PII id; `generic-bearer` and * `high-entropy` are the per-tier fallbacks. */ export declare const SECRET_RULES: readonly CompiledSecretRule[]; /** Map a configured level to its highest active tier. */ export declare function maxTier(level: Level): RuleTier; //# sourceMappingURL=rules.d.ts.map