Merge pull request #2435 from strapi/add-snyk

Check dependencies vulnerability with Snyk
This commit is contained in:
Jim LAURIE 2018-12-12 12:05:10 +01:00 committed by GitHub
commit 816ed33ed2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 409 additions and 23 deletions

9
.snyk Normal file
View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:31:33.160Z
patch: {}

View File

@ -6,14 +6,15 @@ git:
language: node_js
node_js:
- "10"
- "11"
- '10'
- '11'
before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- git fetch -a
- git fetch origin master
# - sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
# - npm cache clean --force
# - rm -rf node_modules/
@ -21,10 +22,14 @@ before_install:
install:
- npm run setup --debug
before_script:
- git fetch origin master:master
script:
- npm run lint
- npm run doc
- npm run snyk
cache:
directories:
- "node_modules"
- 'node_modules'

View File

@ -20,7 +20,8 @@
"redux-saga": "^0.14.3",
"request": "^2.87.0",
"shelljs": "^0.7.7",
"strapi-lint": "file:packages/strapi-lint"
"strapi-lint": "file:packages/strapi-lint",
"snyk": "^1.99.0"
},
"scripts": {
"clean": "npm run removesymlinkdependencies && npx rimraf package-lock.json && npx rimraf packages/*/package-lock.json",
@ -32,8 +33,9 @@
"setup:build": "npm run setup --build",
"setup": "npm run clean:all && npm install ./packages/strapi-lint --save-dev && npm install && node ./scripts/setup.js && npm run clean",
"lint": "node ./scripts/lint.js",
"test": "node ./test/start.js",
"prettier": "node ./packages/strapi-lint/lib/internals/prettier/index.js"
"test": "snyk test && node ./test/start.js",
"prettier": "node ./packages/strapi-lint/lib/internals/prettier/index.js",
"snyk": "node ./scripts/snyk.js"
},
"author": {
"email": "hi@strapi.io",

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:35:17.133Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:35:52.618Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:35:54.864Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:35:57.351Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:35:59.679Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:36:04.222Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:36:06.569Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:36:09.263Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:36:25.992Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:35:22.585Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:36:48.647Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:36:51.201Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:36:53.294Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:36:55.758Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:36:58.340Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:37:00.449Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:37:04.113Z
patch: {}

View File

@ -15,7 +15,12 @@ const exec = (command, args) => {
stdio: 'pipe',
encoding: 'utf-8',
};
try {
return execFileSync(command, args, options);
} catch (err) {
return '';
}
};
const execGitCmd = args =>
@ -26,10 +31,15 @@ const execGitCmd = args =>
const listChangedFiles = () => {
const mergeBase = execGitCmd(['merge-base', 'HEAD', 'master']);
try {
return new Set([
...execGitCmd(['diff', '--name-only', '--diff-filter=ACMRTUB', mergeBase]),
...execGitCmd(['ls-files', '--others', '--exclude-standard']),
]);
} catch (err) {
return [];
}
};
module.exports = listChangedFiles;

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:37:06.512Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:37:14.459Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:37:23.290Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:37:31.383Z
patch: {}

View File

@ -0,0 +1,17 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:37:34.495Z
qs:
- '*':
reason: Temporarily ignore
expires: 2019-01-31T00:00:00.000Z
apollo-server-koa@2.2.6:
- '*':
reason: Temporarily ignore
expires: 2019-01-04T16:34:24.069Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:37:42.177Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:37:50.220Z
patch: {}

View File

@ -0,0 +1,17 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:37:58.353Z
qs:
- '*':
reason: Temporarily ignore
expires: 2019-01-31T00:00:00.000Z
purest:
- '*':
reason: Temporarily ignore
expires: 2019-01-31T00:00:00.000Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:38:00.833Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:38:03.075Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:38:05.425Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:38:07.540Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:38:09.622Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:38:11.663Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:38:13.835Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:38:15.967Z
patch: {}

View File

@ -0,0 +1,9 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:38:18.270Z
patch: {}

13
packages/strapi/.snyk Normal file
View File

@ -0,0 +1,13 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
shelljs:
- '*':
reason: testing
expires: 2019-01-04T14:35:06.536Z
koa-body:
- '*':
reason: Temporarily ignore
expires: 2019-01-04T16:46:20.156Z
patch: {}

25
scripts/snyk.js Normal file
View File

@ -0,0 +1,25 @@
const fs = require('fs');
const path = require('path');
const shell = require('shelljs');
try {
const packages = fs.readdirSync(path.resolve(process.cwd(), 'packages'), 'utf8');
shell.cd('packages/strapi');
packages
.filter(pkg => pkg.indexOf('strapi') !== -1)
.forEach(pkg => {
shell.cd('../' + pkg);
shell.echo(`Testing ${pkg} dependencies`);
const data = shell.exec('snyk test --severity-threshold=high', { silent: true });
if (data.code !== 0 && data.stdout.indexOf('Missing node_modules folder') === -1) {
shell.echo(data.stdout);
process.exit(1);
}
});
} catch (error) {
console.error(error);
}