Giter VIP home page Giter VIP logo

Comments (10)

Annubis45 avatar Annubis45 commented on May 23, 2024 1

ok, I'll try !

from clamscan.

kylefarris avatar kylefarris commented on May 23, 2024

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.

Annubis45 avatar Annubis45 commented on May 23, 2024

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.

kylefarris avatar kylefarris commented on May 23, 2024

You would need to set scanRecursively to true if you want to see the individual files that are infected.

from clamscan.

Annubis45 avatar Annubis45 commented on May 23, 2024

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.

kylefarris avatar kylefarris commented on May 23, 2024

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.

Annubis45 avatar Annubis45 commented on May 23, 2024

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.

Annubis45 avatar Annubis45 commented on May 23, 2024

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.

kylefarris avatar kylefarris commented on May 23, 2024

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.

kylefarris avatar kylefarris commented on May 23, 2024

FTR, this issue was fixed in v2.1.1.

from clamscan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.