Comments (10)
ok, I'll try !
from clamscan.
Please refer to the docs: https://github.com/kylefarris/clamscan#note
Relevant passage:
The goodFiles and badFiles parameters of the end_callback callback in this method will only contain the directories that were scanned in all but the following scenarios:
- A file_callback callback is provided, and scanRecursively is set to true.
- The scanner is set to clamdscan and scanRecursively is set to false.
from clamscan.
Hi,
Here my code:
console.log('AnalyseFiles:');
const clamscan = await new NodeClam().init({ scanRecursively: false});
const version = await clamscan.getVersion();
console.log(`ClamAV Version: ${version}`);
clamscan.scanDir('./files/', (err, goodFiles, badFiles, viruses) => {
if (err) return console.error(err);
if (badFiles.length > 0) {
console.log(`${path} was infected. The offending files (${badFiles.join (', ')}) have been quarantined.`);
console.log(`Viruses Found: ${viruses.join(', ')}`);
} else {
console.log("Everything looks good! No problems here!.");
}
},
(error, file, isInfected) =>{
console.log(`${file} is ${isInfected ? 'infected' : 'clean'}`);
});
and the result is :
ClamAV Version: ClamAV 0.103.5/26459/Sun Feb 20 10:22:37 2022
Attachment is infected
ContentVersion is infected
Everything looks good! No problems here!
files directory is :
---files
----- Attachment
-----------file1
-----------file2
-----------file3
----- ContentVersion
-----------file4
-----------file5
from clamscan.
You would need to set scanRecursively
to true
if you want to see the individual files that are infected.
from clamscan.
Thank you for your answser.
When I set scanRecursively to true, I get this error:
node_modules/clamscan/index.js:1529
if (err) return hasCb ? endCb(err, goodFiles, badFiles,viruses, []) : reject(new NodeClamError({ badFiles }, err));
from clamscan.
That can't be the entire error. That's just the stacktrace showing where the error was thrown. I'd need to know what error was actually thrown here as the could be any number of things.
from clamscan.
Hi,
I restarted eveything from scratch:
my code:
console.log('AnalyseFiles:');
const clamscan = await new NodeClam().init({ debugMode:true, scanRecursively: true});
const version = await clamscan.getVersion();
console.log(`ClamAV Version: ${version}`);
clamscan.scanDir('./filesdir/', (err, goodFiles, badFiles, viruses) => {
if (err) return console.error(err);
if (badFiles.length > 0) {
console.log(`MYLOG - it was infected. The offending files (${badFiles.join (', ')}) have been quarantined.`);
console.log(`MYLOG - Viruses Found: ${viruses.join(', ')}`);
} else {
console.log("MYLOG - Everything looks good! No problems here!.");
}
},
(error, file, isInfected) =>{
console.log(`MYLOG - ${file} is ${isInfected ? 'infected' : 'clean'}`);
});
My directory :
---filesdir
----- rep1
-----------file1
----- rep2
-----------file1
-----------file2
And the result:
node-clam: DEBUG MODE ON
node-clam: Configured clam command: /usr/bin/clamdscan --no-summary --fdpass --multiscan --version
ClamAV Version: ClamAV 0.103.5/26473/Sun Mar 6 10:27:13 2022
node-clam: Scanning a list of 6 passed files. [
'filesdir',
'filesdir/rep1',
'filesdir/rep1/file1',
'filesdir/rep2',
'filesdir/rep2/file1',
'filesdir/rep2/file2'
]
node-clam: Scanning filesdir/rep1/file1
node-clam: Configured clam command: /usr/bin/clamdscan --no-summary --fdpass --multiscan filesdir/rep1/file1
node-clam: Scanning filesdir/rep2/file1
node-clam: Configured clam command: /usr/bin/clamdscan --no-summary --fdpass --multiscan filesdir/rep2/file1
node-clam: Scanning filesdir/rep2/file2
node-clam: Configured clam command: /usr/bin/clamdscan --no-summary --fdpass --multiscan filesdir/rep2/file2
node-clam: Scanning a list of 2 passed files. [ 'filesdir/rep1', 'filesdir/rep1/file1' ]
node-clam: Configured clam command: /usr/bin/clamdscan --no-summary --fdpass --multiscan filesdir/rep1 filesdir/rep1/file1
node-clam: Scanning a list of 6 passed files. [
'filesdir',
'filesdir/rep1',
'filesdir/rep1/file1',
'filesdir/rep2',
'filesdir/rep2/file1',
'filesdir/rep2/file2'
]
node-clam: Configured clam command: /usr/bin/clamdscan --no-summary --fdpass --multiscan filesdir filesdir/rep1 filesdir/rep1/file1 filesdir/rep2 filesdir/rep2/file1 filesdir/rep2/file2
node-clam: Scan Response: /filesdir/rep2/file2: Win.Test.EICAR_HDB-1 FOUND
node-clam: File is INFECTED!
node-clam: File is OK!
node-clam: File is OK!
node-clam: Scanning a list of 3 passed files. [ 'filesdir/rep2', 'filesdir/rep2/file1', 'filesdir/rep2/file2' ]
node-clam: Configured clam command: /usr/bin/clamdscan --no-summary --fdpass --multiscan filesdir/rep2 filesdir/rep2/file1 filesdir/rep2/file2
node-clam: stdout: /filesdir/rep1: OK
/filesdir/rep1/file1: OK
node-clam: /filesdir/rep1 is OK!
node-clam: /filesdir/rep1/file1 is OK!
node-clam: stdout: /filesdir/rep2/file2: Win.Test.EICAR_HDB-1 FOUND
/filesdir/rep2/file1: OK
/filesdir/rep2/file2: Win.Test.EICAR_HDB-1 FOUND
node-clam: /filesdir/rep2/file2 is INFECTED!
node-clam: /filesdir/rep2/file1 is OK!
node-clam: /filesdir/rep2/file2 is INFECTED!
node-clam: stdout: /filesdir/rep2/file2: Win.Test.EICAR_HDB-1 FOUND
/filesdir/rep1: OK
/filesdir/rep1/file1: OK
/filesdir/rep2/file2: Win.Test.EICAR_HDB-1 FOUND
/filesdir/rep2/file1: OK
/filesdir/rep2/file2: Win.Test.EICAR_HDB-1 FOUND
node-clam: /filesdir/rep2/file2 is INFECTED!
node-clam: /filesdir/rep1 is OK!
node-clam: /filesdir/rep1/file1 is OK!
node-clam: /filesdir/rep2/file2 is INFECTED!
node-clam: /filesdir/rep2/file1 is OK!
node-clam: /filesdir/rep2/file2 is INFECTED!
And when I put breakpoints in callback functions, I never reach it.
I also tried the promise syntaxe and stay stuck in it. I got the same result and never reach the next line.
const {goodFiles, badFiles} = await clamscan.scanDir('./filesdir/');
I'm sorry if this thread has changed since the start. If you want I can open a new one.
from clamscan.
My analyse is :
scandir need a resolve/reject result, but when I call it with my option, it does:
scandir ==> scanFiles ==> doscan ==> ...
Scandir return a promise that make a "return scanfile(...)" and scanfile return a promise (line 1978)
So, my guess is the promise of scandir is never resolved.
line 1978 :
return this.scanFiles(files, endCb, fileCb);
IMO, it should be replaced by something like this:
const scanResult= await this.scanFiles(files, endCb, fileCb);
return hasCb
? endCb(null, [], [])
: resolve(scanResult);
from clamscan.
That's more like it. Yeah, from looking at your debug log, it all looks like it's working up to a point. I haven't had a chance to look at the source code yet but your analysis seems correct in theory. Why don't you see if you can fix the issue and run some tests? A PR would be really help since I'm quite busy this week.
Thanks for all your hard work.
from clamscan.
FTR, this issue was fixed in v2.1.1.
from clamscan.
Related Issues (20)
- Frequent failed clamAV scan fails HOT 2
- Premature end of ClamAV socket stream behind telepresence proxy HOT 18
- Clamav file size limit - throw custom error HOT 10
- Socket times out when remote scanning EICAR test file HOT 7
- node-clam: Could not verify the clamdscan binary HOT 2
- scanStream returning isInfected = true even when its not HOT 4
- Receiving null response from ScanFile HOT 2
- Missing error handler for tcp client
- TypeError: clamscan.isInfected is not a function HOT 1
- Retry on ECONNREFUSED for ClamAV using TCP sockets HOT 1
- No/Empty Response HOT 1
- Virus analysis tools should use local heuristical analysis/sandboxes plus artificial CNS HOT 4
- 3.8 GB file gives issue - RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range HOT 2
- node 16 and aws-sdk HOT 2
- Clam API Server HOT 1
- Occasionally getting the 502 Proxy error while running this clamscan service on the Prod server. HOT 3
- Fix code scanning alert - Inefficient regular expression
- execFile & Clamdscan result parsing HOT 4
- Chunked passthrough? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clamscan.