Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clamscan

Package Overview
Dependencies
Maintainers
2
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clamscan - npm Package Compare versions

Comparing version 1.0.6 to 1.1.0

.eslintrc.json

3

package.json
{
"name": "clamscan",
"version": "1.0.6",
"version": "1.1.0",
"author": "Kyle Farris <kfarris@chomponllc.com> (http://chomponllc.com)",

@@ -41,2 +41,3 @@ "description": "Use Node JS to scan files on your server with ClamAV's clamscan/clamdscan binary or via TCP to a remote server or local UNIX Domain socket. This is especially useful for scanning uploaded files provided by un-trusted sources.",

"chai-as-promised": "^7.1.1",
"eslint": "^6.4.0",
"mocha": "^5.2.0",

@@ -43,0 +44,0 @@ "request": "^2.88.0"

@@ -0,1 +1,2 @@

/* eslint-disable no-unused-vars */
const fs = require('fs');

@@ -40,4 +41,4 @@ const request = require('request');

const good_file_list_contents = fs.readFileSync(good_file_list).toString();
const modified_good_file_list = __dirname + '/good_files_list_tmp.txt'
fs.writeFileSync(modified_good_file_list, good_file_list_contents.split("\n").map(v => v.replace(/^\./, __dirname)).join("\n"), 'utf8');
const modified_good_file_list = __dirname + '/good_files_list_tmp.txt';
fs.writeFileSync(modified_good_file_list, good_file_list_contents.split('\n').map(v => v.replace(/^\./, __dirname)).join('\n'), 'utf8');

@@ -47,9 +48,9 @@

process.on('unhandledRejection', (reason, p) => {
if (reason && typeof reason === 'object' && 'actual' in reason) {
console.log("Reason: ", reason.message, reason.actual);
}
if (reason === null) {
console.log("No reason... here's the promise: ", p);
}
console.log('Unhandled Rejection reason:', reason);
if (reason && typeof reason === 'object' && 'actual' in reason) {
console.log('Reason: ', reason.message, reason.actual);
}
if (reason === null) {
console.log('No reason... here\'s the promise: ', p);
}
console.log('Unhandled Rejection reason:', reason);
});

@@ -59,16 +60,14 @@

overrides = overrides || {};
try {
const clamdscan = Object.assign({}, config.clamdscan, ('clamdscan' in overrides ? overrides.clamdscan : {}));
const clamscan = Object.assign({}, config.clamscan, ('clamscan' in overrides ? overrides.clamscan : {}));
const clamdscan = Object.assign({}, config.clamdscan, ('clamdscan' in overrides ? overrides.clamdscan : {}));
const clamscan = Object.assign({}, config.clamscan, ('clamscan' in overrides ? overrides.clamscan : {}));
delete overrides.clamdscan;
delete overrides.clamscan;
delete overrides.clamdscan;
delete overrides.clamscan;
const new_config = Object.assign({}, config, overrides, {clamdscan, clamscan});
const new_config = Object.assign({}, config, overrides, {clamdscan, clamscan});
return await new NodeClam().init(new_config);
} catch (err) {
throw err;
}
}
return await new NodeClam().init(new_config);
};

@@ -345,2 +344,40 @@ describe('NodeClam Module', () => {

describe('_ping', () => {
let clamscan;
beforeEach(async () => {
clamscan = await reset_clam();
});
it('should exist', () => {
should.exist(clamscan._ping);
});
it('should be a function', () => {
clamscan._ping.should.be.a('function');
});
it('should respond with a socket client (Promise API)', async () => {
const client = await clamscan._ping();
expect(client).to.be.an('object');
expect(client.writable).to.eql(true);
expect(client.readable).to.eql(true);
expect(client._hadError).to.eql(false);
expect(client).to.respondTo('on');
expect(client).to.not.respondTo('foobar');
});
it('should respond with a socket client (Callback API)', done => {
clamscan._ping((err, client) => {
check(done, () => {
expect(err).to.not.be.instanceof(Error);
expect(client).to.be.an('object');
expect(client.writable).to.eql(true);
expect(client.readable).to.eql(true);
expect(client._hadError).to.eql(false);
expect(client).to.respondTo('on');
expect(client).to.not.respondTo('foobar');
});
});
});
});
describe('is_infected', () => {

@@ -361,3 +398,3 @@ let clamscan;

expect(() => clamscan.is_infected(good_scan_file), 'nothing provided').to.not.throw(Error);
expect(() => clamscan.is_infected(good_scan_file, (err, file, is_infected) => {}), 'good function provided').to.not.throw(Error);
expect(() => clamscan.is_infected(good_scan_file, () => {}), 'good function provided').to.not.throw(Error);
expect(() => clamscan.is_infected(good_scan_file, undefined), 'undefined provided').to.not.throw(Error);

@@ -450,3 +487,3 @@ expect(() => clamscan.is_infected(good_scan_file, null), 'null provided').to.not.throw(Error);

} else {
console.log("Could not download test virus file!");
console.log('Could not download test virus file!');
console.error(error);

@@ -476,3 +513,3 @@ }

expect(viruses).to.have.length(1);
expect(viruses[0]).to.match(/^Eicar\-Test\-Signature/);
expect(viruses[0]).to.match(/^Eicar-Test-Signature/);

@@ -485,3 +522,3 @@ if (fs.existsSync(bad_scan_file)) {

} else {
console.log("Could not download test virus file!");
console.log('Could not download test virus file!');
console.error(error);

@@ -512,3 +549,3 @@ }

done(err);
})
});
});

@@ -554,3 +591,3 @@

expect(viruses).to.have.length(1);
expect(viruses[0]).to.match(/^Eicar\-Test\-Signature/);
expect(viruses[0]).to.match(/^Eicar-Test-Signature/);

@@ -593,2 +630,3 @@ done();

expect(is_infected).to.eql(true);
// eslint-disable-next-line no-useless-catch
} catch (err) {

@@ -603,9 +641,5 @@ throw err;

it('should respond with an empty array of viruses when file is NOT infected', async () => {
try {
const {viruses} = await clamscan.is_infected(good_scan_file);
expect(viruses).to.be.an('array');
expect(viruses).to.have.length(0);
} catch (err) {
throw err;
}
const {viruses} = await clamscan.is_infected(good_scan_file);
expect(viruses).to.be.an('array');
expect(viruses).to.have.length(0);
});

@@ -621,3 +655,4 @@

expect(viruses).to.have.length(1);
expect(viruses[0]).to.match(/^Eicar\-Test\-Signature/);
expect(viruses[0]).to.match(/^Eicar-Test-Signature/);
// eslint-disable-next-line no-useless-catch
} catch (err) {

@@ -692,3 +727,3 @@ throw err;

done(err);
})
});
});

@@ -975,3 +1010,3 @@ it('should behave just like is_infected (async/await)', async () => {

expect(viruses).to.have.length(1);
expect(viruses[0]).to.match(/^Eicar\-Test\-Signature/);
expect(viruses[0]).to.match(/^Eicar-Test-Signature/);

@@ -982,3 +1017,3 @@ if (fs.existsSync(bad_scan_file)) fs.unlinkSync(bad_scan_file);

} else {
console.log("Could not download test virus file!");
console.log('Could not download test virus file!');
console.error(error);

@@ -1085,3 +1120,3 @@ }

} else {
console.log("Could not download test virus file!");
console.log('Could not download test virus file!');
console.error(error);

@@ -1100,6 +1135,6 @@ }

expect(err).to.not.be.instanceof(Error);
expect(viruses).to.not.be.empty
expect(viruses).to.not.be.empty;
expect(viruses).to.be.an('array');
expect(viruses).to.have.length(1);
expect(viruses[0]).to.match(/^Eicar\-Test\-Signature/);
expect(viruses[0]).to.match(/^Eicar-Test-Signature/);

@@ -1110,3 +1145,3 @@ if (fs.existsSync(bad_scan_file)) fs.unlinkSync(bad_scan_file);

} else {
console.log("Could not download test virus file!");
console.log('Could not download test virus file!');
console.error(error);

@@ -1132,3 +1167,3 @@ }

return rs;
}
};

@@ -1179,3 +1214,3 @@ it('should exist', () => {

} catch (e) {
console.error("Annoying error: ", e);
console.error('Annoying error: ', e);
}

@@ -1276,3 +1311,2 @@ });

let clamscan;
let num = 0;

@@ -1322,3 +1356,3 @@ before(async () => {

});
})
});
});

@@ -1353,4 +1387,2 @@

output.on('finish', () => {
const ref_file = 'fasdfa';
// const ref_file = await fs_readfile(good_scan_file);
Promise.all([

@@ -1357,0 +1389,0 @@ expect(fs_stat(passthru_file), 'get passthru file stats').to.not.be.rejectedWith(Error),

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc