refactor: rename all secret scanner internals to auto-redact
Full internal rename since still in testing — no backwards compat needed: - secret-scanner.js → auto-redact.js - SecretScanner → AutoRedact - SECRET_PATTERNS → REDACT_PATTERNS - secretScanning → autoRedact (setting key) - customSecretPatterns → customRedactPatterns (setting key) - scanAndRedactSecrets → runAutoRedact (function) - All DOM ids, CSS classes, and variable names updated - category: 'secret' → category: 'redact' - getOrgSecretPatterns → getOrgRedactPatterns https://claude.ai/code/session_01KF4i7Ra7zCEDskxDBaNtcT
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Silent Send - Auto Redact (Secret Scanner)
|
||||
* Silent Send - Auto Redact
|
||||
*
|
||||
* Detects common secret/credential patterns in text and either
|
||||
* warns or auto-redacts them. This catches things the identity-based
|
||||
@@ -15,7 +15,7 @@
|
||||
* - severity: 'critical' (always redact) or 'warning' (flag but allow)
|
||||
*/
|
||||
|
||||
const SECRET_PATTERNS = [
|
||||
const REDACT_PATTERNS = [
|
||||
// --- API Keys ---
|
||||
{
|
||||
name: 'OpenAI API Key',
|
||||
@@ -163,13 +163,13 @@ const SECRET_PATTERNS = [
|
||||
},
|
||||
];
|
||||
|
||||
const SecretScanner = {
|
||||
const AutoRedact = {
|
||||
/**
|
||||
* Build the full pattern list (built-in + custom).
|
||||
* Custom patterns come from settings.customSecretPatterns.
|
||||
* Custom patterns come from settings.customRedactPatterns.
|
||||
*/
|
||||
_buildPatterns(customPatterns) {
|
||||
const all = [...SECRET_PATTERNS];
|
||||
const all = [...REDACT_PATTERNS];
|
||||
if (Array.isArray(customPatterns)) {
|
||||
for (const cp of customPatterns) {
|
||||
if (!cp.enabled || !cp.pattern) continue;
|
||||
@@ -189,7 +189,7 @@ const SecretScanner = {
|
||||
/**
|
||||
* Scan text for secrets. Returns list of findings.
|
||||
* @param {string} text
|
||||
* @param {Array} [customPatterns] — from settings.customSecretPatterns
|
||||
* @param {Array} [customPatterns] — from settings.customRedactPatterns
|
||||
*/
|
||||
scan(text, customPatterns) {
|
||||
const findings = [];
|
||||
@@ -232,7 +232,7 @@ const SecretScanner = {
|
||||
* Redact all critical secrets in text. Warnings are not auto-redacted.
|
||||
* Returns { text, redactions[] }
|
||||
* @param {string} text
|
||||
* @param {Array} [customPatterns] — from settings.customSecretPatterns
|
||||
* @param {Array} [customPatterns] — from settings.customRedactPatterns
|
||||
*/
|
||||
redact(text, customPatterns) {
|
||||
const findings = this.scan(text, customPatterns);
|
||||
@@ -249,7 +249,7 @@ const SecretScanner = {
|
||||
redactions.push({
|
||||
original: f.value,
|
||||
replaced: f.redactTo,
|
||||
category: 'secret',
|
||||
category: 'redact',
|
||||
pattern: f.name,
|
||||
});
|
||||
}
|
||||
@@ -266,7 +266,7 @@ const SecretScanner = {
|
||||
};
|
||||
|
||||
if (typeof globalThis !== 'undefined') {
|
||||
globalThis.SecretScanner = SecretScanner;
|
||||
globalThis.AutoRedact = AutoRedact;
|
||||
}
|
||||
|
||||
export default SecretScanner;
|
||||
export default AutoRedact;
|
||||
@@ -202,7 +202,7 @@ const OrgPolicy = {
|
||||
*
|
||||
* @returns {Array} additional patterns to add to auto-redact
|
||||
*/
|
||||
async getOrgSecretPatterns() {
|
||||
async getOrgRedactPatterns() {
|
||||
const policy = await this.getPolicy();
|
||||
if (!policy?.requiredSecretPatterns?.length) return [];
|
||||
|
||||
|
||||
+2
-2
@@ -34,13 +34,13 @@ const DEFAULT_SETTINGS = {
|
||||
enabled: true,
|
||||
showHighlights: false,
|
||||
revealMode: false,
|
||||
secretScanning: true,
|
||||
autoRedact: true,
|
||||
autoDetect: true,
|
||||
autoRedactDetected: true,
|
||||
autoAddDetected: true,
|
||||
maxLogEntries: 100,
|
||||
customDomains: [],
|
||||
customSecretPatterns: [],
|
||||
customRedactPatterns: [],
|
||||
categories: ['name', 'email', 'phone', 'address', 'ssn', 'dob', 'domain', 'password', 'general'],
|
||||
browserSync: false,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user