From e9c959e34f8bfc3d38c21f68c4b39c3e51e8a16b Mon Sep 17 00:00:00 2001 From: aurieh <auriteh@gmail.com> Date: Thu, 15 Dec 2016 15:41:48 +0200 Subject: [PATCH] Eslint, deps --- .eslintrc.json | 4 ++-- lib/getfile.js | 4 ++-- lib/refreshclam.js | 10 +++++----- lib/scanner.js | 8 ++++---- package.json | 4 ++++ 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 67130f7..8f22562 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -6,6 +6,6 @@ "promise" ], "rules": { - "semi": "always" + "semi": [2, "always"] } -} \ No newline at end of file +} diff --git a/lib/getfile.js b/lib/getfile.js index a10472a..4ab1ee8 100644 --- a/lib/getfile.js +++ b/lib/getfile.js @@ -1,4 +1,4 @@ -module.exports = function getFile(S3, key) { +module.exports = function getFile (S3, key) { return new Promise((resolve, reject) => { S3.getObject({ Bucket: `${process.env.SERVICE}-filestore-${process.env.STAGE}-1`, @@ -8,4 +8,4 @@ module.exports = function getFile(S3, key) { resolve(file); }); }); -} \ No newline at end of file +}; diff --git a/lib/refreshclam.js b/lib/refreshclam.js index d87d511..deea5ec 100644 --- a/lib/refreshclam.js +++ b/lib/refreshclam.js @@ -1,15 +1,15 @@ const exec = require('child_process').exec; -const debug = require("debug")("scanner"); +const debug = require('debug')('scanner'); -module.exports = function refresh() { +module.exports = function refresh () { return new Promise((resolve, reject) => { - debug('Updating virus database') + debug('Updating virus database'); const proc = exec('freshclam', [], {stdio: 'inherit'}); proc.on('error', reject); proc.on('exit', code => { if (code !== 0) return void reject(new Error(`Clamscan exited with code ${code}`)); debug('Finished updating'); resolve(); - }) + }); }); -} \ No newline at end of file +}; diff --git a/lib/scanner.js b/lib/scanner.js index 3128696..60b1838 100644 --- a/lib/scanner.js +++ b/lib/scanner.js @@ -3,20 +3,20 @@ const fs = require('fs'); const path = require('path'); const getFile = require('./getfile'); -module.exports = function scanFile(notif, S3) { +module.exports = function scanFile (notif, S3) { return new Promise((resolve, reject) => { const key = notif.Records[0].s3.object.key; getFile(S3, key).then(file => { const filepath = path.resolve(path.join(__dirname, '/files/', key)); fs.writeFile(filepath, file.body, (err) => { if (err) return void reject(err); - clam.is_infected(filepath, (err, _, is_infected) => { + clam.is_infected(filepath, (err, _, isInfected) => { fs.unlink(filepath, (unlinkErr) => { if (err || unlinkErr) return void reject(err || unlinkErr); - resolve({infected: is_infected}); + resolve({infected: isInfected}); }); }); }); }, reject); }); -} \ No newline at end of file +}; diff --git a/package.json b/package.json index 030bd75..03806f2 100644 --- a/package.json +++ b/package.json @@ -27,5 +27,9 @@ "eslint-config-standard": "^6.2.1", "eslint-plugin-promise": "^3.4.0", "eslint-plugin-standard": "^2.0.1" + }, + "dependencies": { + "clamscan": "^0.8.4", + "debug": "^2.4.4" } } -- GitLab