From 740995190e2c70ad658749dfa68dd44b1fa63e64 Mon Sep 17 00:00:00 2001 From: Martijn de Boer Date: Sun, 7 Jan 2018 09:41:17 +0100 Subject: [PATCH] Add eslint-plugin-security and config --- .eslintrc.json | 12 ++++++++++-- drivers/pimoroniunicorn.js | 7 +++---- package-lock.json | 28 ++++++++++++++++++++++++++-- package.json | 1 + 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 562e640..14e6060 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,7 +3,13 @@ "es6": true, "node": true }, - "extends": "eslint:recommended", + "plugins": [ + "security" + ], + "extends": [ + "eslint:recommended", + "plugin:security/recommended" + ], "parserOptions": { "sourceType": "module" }, @@ -25,6 +31,8 @@ "always" ], "no-case-declarations": "off", - "no-console": "off" + "no-console": "off", + "security/detect-new-buffer": "off", + "security/detect-object-injection": "off" } } \ No newline at end of file diff --git a/drivers/pimoroniunicorn.js b/drivers/pimoroniunicorn.js index 8fcb925..7ab2c78 100644 --- a/drivers/pimoroniunicorn.js +++ b/drivers/pimoroniunicorn.js @@ -9,16 +9,15 @@ class PimoroniUnicorn extends Driver { super(); this.spi = false; - this.spiPath = '/dev/spidev0.0'; } write( buffer ) { if ( this.spi === false) { - if ( fs.existsSync( this.spiPath ) ) { + if ( fs.existsSync( '/dev/spidev0.0' ) ) { let SPI = require( 'pi-spi' ); - this.spi = SPI.initialize( this.spiPath ); + this.spi = SPI.initialize( '/dev/spidev0.0' ); } else { - console.warn( 'Device path ' + this.spiPath + ' was unavailable.' ); + console.warn( 'Device path \'/dev/spidev0.0\' was unavailable.' ); return; } } diff --git a/package-lock.json b/package-lock.json index 82d7714..2cdd8e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1027,6 +1027,15 @@ } } }, + "eslint-plugin-security": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-security/-/eslint-plugin-security-1.4.0.tgz", + "integrity": "sha512-xlS7P2PLMXeqfhyf3NpqbvbnW04kN8M9NtmhpR3XGyOvt/vNKS7XPXT5EDbwKW9vCjWH4PpfQvgD/+JgN0VJKA==", + "dev": true, + "requires": { + "safe-regex": "1.1.0" + } + }, "eslint-scope": { "version": "3.7.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.1.tgz", @@ -1506,7 +1515,7 @@ } }, "debug": { - "version": "2.6.9", + "version": "2.6.8", "bundled": true, "dev": true, "optional": true, @@ -2146,7 +2155,7 @@ "dev": true, "optional": true, "requires": { - "debug": "2.6.9", + "debug": "2.6.8", "fstream": "1.0.11", "fstream-ignore": "1.0.5", "once": "1.4.0", @@ -4831,6 +4840,12 @@ "signal-exit": "3.0.2" } }, + "ret": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", + "dev": true + }, "right-align": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", @@ -4880,6 +4895,15 @@ "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, + "safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, + "requires": { + "ret": "0.1.15" + } + }, "sane": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/sane/-/sane-2.2.0.tgz", diff --git a/package.json b/package.json index 6ce3570..948ea95 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ }, "devDependencies": { "eslint": "^4.15.0", + "eslint-plugin-security": "^1.4.0", "jest": "^22.0.4" }, "scripts": {