Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9acd6d677 | ||
|
|
f55f63c254 | ||
|
|
331b1cb2a2 | ||
|
|
16c8275f4e | ||
|
|
03dd61d8bd | ||
|
|
a69c39e8e7 | ||
|
|
fb237c91a8 | ||
|
|
357c7d208b | ||
|
|
d8a4e3a668 | ||
|
|
09a279f62f | ||
|
|
36b7bf34e9 | ||
|
|
909bb3a847 | ||
|
|
f6ebb3dc15 | ||
|
|
22c90f28e8 | ||
|
|
3c37309a1e | ||
|
|
993aadaad5 | ||
|
|
70c154a5d3 | ||
|
|
05c9b299c9 | ||
|
|
abecb2fdd1 | ||
|
|
4ce884e9de | ||
|
|
5ce7fd610a |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Silent Send",
|
"name": "Silent Send",
|
||||||
"version": "0.9.44",
|
"version": "0.9.46",
|
||||||
"description": "Intercepts personal info and substitutes it with user-defined replacements before sending to AI services.",
|
"description": "Intercepts personal info and substitutes it with user-defined replacements before sending to AI services.",
|
||||||
"browser_specific_settings": {
|
"browser_specific_settings": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "Silent Send",
|
"name": "Silent Send",
|
||||||
"version": "0.9.44",
|
"version": "0.9.46",
|
||||||
"description": "Intercepts personal info and substitutes it with user-defined replacements before sending to AI services.",
|
"description": "Intercepts personal info and substitutes it with user-defined replacements before sending to AI services.",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"storage",
|
"storage",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "silent-send",
|
"name": "silent-send",
|
||||||
"version": "0.9.44",
|
"version": "0.9.46",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"description": "Browser extension that substitutes personal data before sending to AI services",
|
"description": "Browser extension that substitutes personal data before sending to AI services",
|
||||||
|
|||||||
@@ -138,6 +138,12 @@ const messageHandlers = {
|
|||||||
sendResponse({ mappings });
|
sendResponse({ mappings });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async 'add:mapping'(message, _sender, sendResponse) {
|
||||||
|
const newMapping = await Storage.addMapping(message.mapping);
|
||||||
|
const mappings = await Storage.getMappings();
|
||||||
|
sendResponse({ mapping: newMapping, mappings });
|
||||||
|
},
|
||||||
|
|
||||||
async 'get:settings'(_message, _sender, sendResponse) {
|
async 'get:settings'(_message, _sender, sendResponse) {
|
||||||
const settings = await Storage.getSettings();
|
const settings = await Storage.getSettings();
|
||||||
sendResponse({ settings });
|
sendResponse({ settings });
|
||||||
|
|||||||
+59
-24
@@ -51,8 +51,8 @@
|
|||||||
|
|
||||||
for (const m of sorted) {
|
for (const m of sorted) {
|
||||||
if (!m.enabled || !m.real?.trim() || !m.substitute?.trim()) continue;
|
if (!m.enabled || !m.real?.trim() || !m.substitute?.trim()) continue;
|
||||||
const escaped = esc(m.real);
|
const pattern = wordBoundary(m.real);
|
||||||
const regex = new RegExp(escaped, m.caseSensitive ? 'g' : 'gi');
|
const regex = new RegExp(pattern, m.caseSensitive ? 'g' : 'gi');
|
||||||
let match;
|
let match;
|
||||||
while ((match = regex.exec(result)) !== null) {
|
while ((match = regex.exec(result)) !== null) {
|
||||||
replacements.push({
|
replacements.push({
|
||||||
@@ -71,8 +71,8 @@
|
|||||||
const sorted = [...maps].sort((a, b) => b.substitute.length - a.substitute.length);
|
const sorted = [...maps].sort((a, b) => b.substitute.length - a.substitute.length);
|
||||||
for (const m of sorted) {
|
for (const m of sorted) {
|
||||||
if (!m.enabled || !m.real?.trim() || !m.substitute?.trim()) continue;
|
if (!m.enabled || !m.real?.trim() || !m.substitute?.trim()) continue;
|
||||||
const escaped = esc(m.substitute);
|
const pattern = wordBoundary(m.substitute);
|
||||||
const regex = new RegExp(escaped, m.caseSensitive ? 'g' : 'gi');
|
const regex = new RegExp(pattern, m.caseSensitive ? 'g' : 'gi');
|
||||||
result = result.replace(regex, m.real);
|
result = result.replace(regex, m.real);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -82,6 +82,15 @@
|
|||||||
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add \b only on word-character edges so "not" doesn't match inside "nothing",
|
||||||
|
// while leaving non-word edges (e.g. "@foo") alone since they self-delimit.
|
||||||
|
function wordBoundary(str) {
|
||||||
|
const escaped = esc(str);
|
||||||
|
const left = /^\w/.test(str) ? '\\b' : '';
|
||||||
|
const right = /\w$/.test(str) ? '\\b' : '';
|
||||||
|
return left + escaped + right;
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// Smart Pattern Engine (inline for page world)
|
// Smart Pattern Engine (inline for page world)
|
||||||
// ============================================================
|
// ============================================================
|
||||||
@@ -280,7 +289,7 @@
|
|||||||
// 4. Auto-detect: scan the FINAL text for unconfigured PII
|
// 4. Auto-detect: scan the FINAL text for unconfigured PII
|
||||||
// Auto-redact if enabled, otherwise just warn
|
// Auto-redact if enabled, otherwise just warn
|
||||||
if (settings.autoDetect !== false) {
|
if (settings.autoDetect !== false) {
|
||||||
const warnings = autoDetectPII(finalText, identity, { detectProperNouns: settings.detectProperNouns === true })
|
const warnings = autoDetectPII(finalText, identity, { detectProperNouns: settings.detectProperNouns === true, mappings })
|
||||||
.filter(w => !ignoredDetections.has(w.value));
|
.filter(w => !ignoredDetections.has(w.value));
|
||||||
if (warnings.length > 0) {
|
if (warnings.length > 0) {
|
||||||
// Auto-redact detected PII in the outbound text
|
// Auto-redact detected PII in the outbound text
|
||||||
@@ -471,6 +480,14 @@
|
|||||||
addAll(ident.names); addAll(ident.emails);
|
addAll(ident.names); addAll(ident.emails);
|
||||||
addAll(ident.usernames); addAll(ident.hostnames); addAll(ident.phones);
|
addAll(ident.usernames); addAll(ident.hostnames); addAll(ident.phones);
|
||||||
}
|
}
|
||||||
|
// Also skip values covered by mappings (both real and substitute)
|
||||||
|
if (opts?.mappings) {
|
||||||
|
for (const m of opts.mappings) {
|
||||||
|
if (!m.enabled) continue;
|
||||||
|
if (m.real) configured.add(m.real.toLowerCase());
|
||||||
|
if (m.substitute) configured.add(m.substitute.toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const findings = [];
|
const findings = [];
|
||||||
for (const pat of PII_PATTERNS) {
|
for (const pat of PII_PATTERNS) {
|
||||||
@@ -1035,8 +1052,8 @@
|
|||||||
const pairs = getRevealPairs();
|
const pairs = getRevealPairs();
|
||||||
let result = text;
|
let result = text;
|
||||||
for (const p of pairs) {
|
for (const p of pairs) {
|
||||||
const escaped = esc(p.from);
|
const pattern = wordBoundary(p.from);
|
||||||
const regex = new RegExp(escaped, p.caseSensitive ? 'g' : 'gi');
|
const regex = new RegExp(pattern, p.caseSensitive ? 'g' : 'gi');
|
||||||
result = result.replace(regex, p.to);
|
result = result.replace(regex, p.to);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -1077,9 +1094,9 @@
|
|||||||
const pairs = getRevealPairs();
|
const pairs = getRevealPairs();
|
||||||
let result = text;
|
let result = text;
|
||||||
for (const p of pairs) {
|
for (const p of pairs) {
|
||||||
const escaped = esc(p.to); // p.to is the real value
|
const pattern = wordBoundary(p.to);
|
||||||
const regex = new RegExp(escaped, p.caseSensitive ? 'g' : 'gi');
|
const regex = new RegExp(pattern, p.caseSensitive ? 'g' : 'gi');
|
||||||
result = result.replace(regex, p.from); // p.from is the substitute
|
result = result.replace(regex, p.from);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1406,21 +1423,29 @@
|
|||||||
const fake = decodeURIComponent(btn.dataset.fake);
|
const fake = decodeURIComponent(btn.dataset.fake);
|
||||||
const cat = btn.dataset.cat || 'general';
|
const cat = btn.dataset.cat || 'general';
|
||||||
|
|
||||||
// Add to mappings via storage
|
// Immediately dismiss this notification item (same as ignore)
|
||||||
const result = await getStorageData('ss_mappings');
|
btn.closest('.ss-ps-item').remove();
|
||||||
const currentMappings = result || [];
|
if (!preSendWarningEl.querySelector('.ss-ps-item')) {
|
||||||
currentMappings.push({
|
preSendWarningEl.classList.remove('visible');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optimistically add to local mappings so re-scan skips this value
|
||||||
|
const tempMapping = {
|
||||||
id: crypto.randomUUID(),
|
id: crypto.randomUUID(),
|
||||||
real, substitute: fake,
|
real, substitute: fake,
|
||||||
category: cat,
|
category: cat,
|
||||||
caseSensitive: false,
|
caseSensitive: false,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
createdAt: Date.now(),
|
createdAt: Date.now(),
|
||||||
});
|
};
|
||||||
await setStorageData('ss_mappings', currentMappings);
|
mappings = [...mappings, tempMapping];
|
||||||
|
|
||||||
// Update local mappings so the fetch interceptor uses them immediately
|
// Persist via background script (handles encryption);
|
||||||
mappings = currentMappings;
|
// update local mappings with the authoritative list on success
|
||||||
|
addMappingViaBackground({ real, substitute: fake, category: cat })
|
||||||
|
.then(updatedMappings => {
|
||||||
|
if (updatedMappings.length) mappings = updatedMappings;
|
||||||
|
});
|
||||||
|
|
||||||
// Replace the PII value in the current input right now
|
// Replace the PII value in the current input right now
|
||||||
if (inputEl) {
|
if (inputEl) {
|
||||||
@@ -1429,11 +1454,6 @@
|
|||||||
if (inputScanTimer) clearTimeout(inputScanTimer);
|
if (inputScanTimer) clearTimeout(inputScanTimer);
|
||||||
inputScanTimer = setTimeout(() => scanInputForPII(inputEl), 150);
|
inputScanTimer = setTimeout(() => scanInputForPII(inputEl), 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Visual feedback
|
|
||||||
btn.textContent = '\u2714';
|
|
||||||
btn.style.color = '#4ade80';
|
|
||||||
btn.disabled = true;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1493,6 +1513,21 @@
|
|||||||
window.postMessage({ type: 'ss:storage-set', key, value }, '*');
|
window.postMessage({ type: 'ss:storage-set', key, value }, '*');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addMappingViaBackground(mapping) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
const id = 'ss-add-' + Math.random();
|
||||||
|
const handler = (event) => {
|
||||||
|
if (event.data?.type === 'ss:add-mapping-result' && event.data.id === id) {
|
||||||
|
window.removeEventListener('message', handler);
|
||||||
|
resolve(event.data.mappings || []);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.addEventListener('message', handler);
|
||||||
|
window.postMessage({ type: 'ss:add-mapping', mapping, id }, '*');
|
||||||
|
setTimeout(() => { window.removeEventListener('message', handler); resolve([]); }, 2000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Scan input on type and paste
|
// Scan input on type and paste
|
||||||
let inputScanTimer = null;
|
let inputScanTimer = null;
|
||||||
|
|
||||||
@@ -1503,7 +1538,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const warnings = autoDetectPII(text, identity, { detectProperNouns: settings.detectProperNouns === true })
|
const warnings = autoDetectPII(text, identity, { detectProperNouns: settings.detectProperNouns === true, mappings })
|
||||||
.filter(w => !ignoredDetections.has(w.value));
|
.filter(w => !ignoredDetections.has(w.value));
|
||||||
if (warnings.length > 0) {
|
if (warnings.length > 0) {
|
||||||
showPreSendWarning(warnings, target);
|
showPreSendWarning(warnings, target);
|
||||||
|
|||||||
@@ -193,6 +193,26 @@
|
|||||||
if (event.data?.type === 'ss:storage-set') {
|
if (event.data?.type === 'ss:storage-set') {
|
||||||
await api.storage.local.set({ [event.data.key]: event.data.value });
|
await api.storage.local.set({ [event.data.key]: event.data.value });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.data?.type === 'ss:add-mapping') {
|
||||||
|
try {
|
||||||
|
const response = await api.runtime.sendMessage({
|
||||||
|
type: 'add:mapping',
|
||||||
|
mapping: event.data.mapping,
|
||||||
|
});
|
||||||
|
window.postMessage({
|
||||||
|
type: 'ss:add-mapping-result',
|
||||||
|
id: event.data.id,
|
||||||
|
mappings: response?.mappings || [],
|
||||||
|
}, '*');
|
||||||
|
} catch {
|
||||||
|
window.postMessage({
|
||||||
|
type: 'ss:add-mapping-result',
|
||||||
|
id: event.data.id,
|
||||||
|
mappings: [],
|
||||||
|
}, '*');
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ const SubstitutionEngine = {
|
|||||||
for (const mapping of sorted) {
|
for (const mapping of sorted) {
|
||||||
if (!mapping.enabled || !mapping.real?.trim() || !mapping.substitute?.trim()) continue;
|
if (!mapping.enabled || !mapping.real?.trim() || !mapping.substitute?.trim()) continue;
|
||||||
|
|
||||||
const escaped = this._escapeRegex(mapping.real);
|
const pattern = this._wordBoundaryPattern(mapping.real);
|
||||||
const regex = new RegExp(escaped, mapping.caseSensitive ? 'g' : 'gi');
|
const regex = new RegExp(pattern, mapping.caseSensitive ? 'g' : 'gi');
|
||||||
let match;
|
let match;
|
||||||
|
|
||||||
while ((match = regex.exec(result)) !== null) {
|
while ((match = regex.exec(result)) !== null) {
|
||||||
@@ -56,8 +56,8 @@ const SubstitutionEngine = {
|
|||||||
for (const mapping of sorted) {
|
for (const mapping of sorted) {
|
||||||
if (!mapping.enabled || !mapping.real?.trim() || !mapping.substitute?.trim()) continue;
|
if (!mapping.enabled || !mapping.real?.trim() || !mapping.substitute?.trim()) continue;
|
||||||
|
|
||||||
const escaped = this._escapeRegex(mapping.substitute);
|
const pattern = this._wordBoundaryPattern(mapping.substitute);
|
||||||
const regex = new RegExp(escaped, mapping.caseSensitive ? 'g' : 'gi');
|
const regex = new RegExp(pattern, mapping.caseSensitive ? 'g' : 'gi');
|
||||||
result = result.replace(regex, mapping.real);
|
result = result.replace(regex, mapping.real);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,8 +73,8 @@ const SubstitutionEngine = {
|
|||||||
for (const mapping of mappings) {
|
for (const mapping of mappings) {
|
||||||
if (!mapping.enabled || !mapping.real?.trim()) continue;
|
if (!mapping.enabled || !mapping.real?.trim()) continue;
|
||||||
|
|
||||||
const escaped = this._escapeRegex(mapping.real);
|
const pattern = this._wordBoundaryPattern(mapping.real);
|
||||||
const regex = new RegExp(escaped, mapping.caseSensitive ? 'g' : 'gi');
|
const regex = new RegExp(pattern, mapping.caseSensitive ? 'g' : 'gi');
|
||||||
|
|
||||||
if (regex.test(text)) {
|
if (regex.test(text)) {
|
||||||
found.push({
|
found.push({
|
||||||
@@ -105,8 +105,8 @@ const SubstitutionEngine = {
|
|||||||
for (const mapping of sorted) {
|
for (const mapping of sorted) {
|
||||||
if (!mapping.enabled || !mapping.real?.trim() || !mapping.substitute?.trim()) continue;
|
if (!mapping.enabled || !mapping.real?.trim() || !mapping.substitute?.trim()) continue;
|
||||||
|
|
||||||
const escaped = this._escapeRegex(mapping.real);
|
const pattern = this._wordBoundaryPattern(mapping.real);
|
||||||
const regex = new RegExp(escaped, mapping.caseSensitive ? 'g' : 'gi');
|
const regex = new RegExp(pattern, mapping.caseSensitive ? 'g' : 'gi');
|
||||||
let match;
|
let match;
|
||||||
|
|
||||||
while ((match = regex.exec(original)) !== null) {
|
while ((match = regex.exec(original)) !== null) {
|
||||||
@@ -145,6 +145,16 @@ const SubstitutionEngine = {
|
|||||||
_escapeRegex(str) {
|
_escapeRegex(str) {
|
||||||
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Wrap an escaped literal in \b only on edges that are word characters,
|
||||||
|
// so "not" → "bad" matches "not" but not "nothing", while mappings whose
|
||||||
|
// edges aren't word chars (e.g. "@foo", "foo.com ") still work.
|
||||||
|
_wordBoundaryPattern(str) {
|
||||||
|
const escaped = this._escapeRegex(str);
|
||||||
|
const left = /^\w/.test(str) ? '\\b' : '';
|
||||||
|
const right = /\w$/.test(str) ? '\\b' : '';
|
||||||
|
return left + escaped + right;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Support both module and content-script contexts
|
// Support both module and content-script contexts
|
||||||
|
|||||||
@@ -345,6 +345,18 @@ test('Disabled mapping is skipped', () => {
|
|||||||
if (result.text.includes('Alex Demo')) throw 'Disabled mapping should not substitute';
|
if (result.text.includes('Alex Demo')) throw 'Disabled mapping should not substitute';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Mapping matches whole words only', () => {
|
||||||
|
const result = SubstitutionEngine.substitute('nothing is not a thing, not even this', [
|
||||||
|
{ real: 'not', substitute: 'bad', enabled: true }
|
||||||
|
]);
|
||||||
|
if (result.text.includes('bahing') || result.text.includes('badhing')) {
|
||||||
|
throw `Should not match inside "nothing", got: ${result.text}`;
|
||||||
|
}
|
||||||
|
if (!/\bbad\b/.test(result.text)) {
|
||||||
|
throw `Should still match standalone "not", got: ${result.text}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// SMART PATTERNS
|
// SMART PATTERNS
|
||||||
// ============================================================
|
// ============================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user