-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathbasic-scan.js
More file actions
30 lines (24 loc) · 805 Bytes
/
basic-scan.js
File metadata and controls
30 lines (24 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// basic-scan.js
// Scan a single file and log the Verdict.
// Run: node examples/basic-scan.js
// Expects: clamscan installed and in PATH.
'use strict';
const path = require('path');
const { scan, Verdict } = require('pompelmi');
async function main() {
const filePath = path.resolve('./uploads/document.pdf');
const result = await scan(filePath);
if (result === Verdict.Clean) {
console.log('Clean:', filePath);
} else if (result === Verdict.Malicious) {
console.error('Malicious file detected:', filePath);
process.exit(1);
} else if (result === Verdict.ScanError) {
console.warn('Scan could not complete — treating file as untrusted:', filePath);
process.exit(1);
}
}
main().catch((err) => {
console.error('Scan failed:', err.message);
process.exit(1);
});