41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const secretPatterns = [
|
|
/sk-[a-zA-Z0-9]{20,}/g,
|
|
/eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*/g,
|
|
/api[_-]?key\s*[:=]\s*['"][a-zA-Z0-9]{16,}['"]/gi,
|
|
/token\s*[:=]\s*['"][a-zA-Z0-9]{16,}['"]/gi,
|
|
];
|
|
|
|
const filesToCheck = [
|
|
'src/types.ts', 'src/background.ts', 'src/options.ts',
|
|
'src/popup/popup.ts', 'src/popup/popup.html', 'src/popup/popup.css',
|
|
'src/content/email-scanner.ts',
|
|
'src/utils/storage.ts', 'src/utils/categories.ts', 'src/utils/export.ts',
|
|
'options.html', 'package.json', 'vite.config.ts',
|
|
'tsconfig.json', 'tsconfig.test.json', '.gitignore'
|
|
];
|
|
|
|
let found = false;
|
|
for (const file of filesToCheck) {
|
|
const fp = path.join(__dirname, '..', file);
|
|
if (!fs.existsSync(fp)) continue;
|
|
const content = fs.readFileSync(fp, 'utf8');
|
|
for (const pattern of secretPatterns) {
|
|
const matches = content.match(pattern);
|
|
if (matches) {
|
|
console.log(`SECRET FOUND in ${file}: ${matches[0].substring(0, 30)}...`);
|
|
found = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (found) {
|
|
console.log('SECRETS DETECTED - aborting');
|
|
process.exit(1);
|
|
} else {
|
|
console.log('No secrets found');
|
|
process.exit(0);
|
|
}
|