Files
ECC/.cursor/hooks/before-read-file.js
T

21 lines
803 B
JavaScript

#!/usr/bin/env node
const { readStdin, hookEnabled } = require('./adapter');
readStdin().then(raw => {
if (!hookEnabled('pre:read:sensitive-file-warning', ['minimal', 'standard', 'strict'])) {
process.stdout.write(raw);
return;
}
try {
const input = JSON.parse(raw);
const filePath = [input.file_path, input.path, input.file]
.find(value => typeof value === 'string' && value.trim()) || '';
if (/\.(env|key|pem)$|\.env\.|credentials|secret/i.test(filePath)) {
console.error('[ECC] WARNING: Reading sensitive file: ' + filePath);
console.error('[ECC] Ensure this data is not exposed in outputs');
}
} catch {
// Preserve the existing fail-open behavior for malformed Cursor payloads.
}
process.stdout.write(raw);
}).catch(() => process.exit(0));