diff options
author | Whymarrh Whitby <whymarrh.whitby@gmail.com> | 2019-06-06 23:56:27 +0800 |
---|---|---|
committer | Whymarrh Whitby <whymarrh.whitby@gmail.com> | 2019-06-07 02:10:14 +0800 |
commit | ea142a4dd65c45694f663885d509aae147430f97 (patch) | |
tree | 9cb4a3c716a64eef740714e6d8da21886bd883ae /.circleci/scripts | |
parent | 569a8e59459c0a716b1528616925f39f7645da1e (diff) | |
download | tangerine-wallet-browser-ea142a4dd65c45694f663885d509aae147430f97.tar tangerine-wallet-browser-ea142a4dd65c45694f663885d509aae147430f97.tar.gz tangerine-wallet-browser-ea142a4dd65c45694f663885d509aae147430f97.tar.bz2 tangerine-wallet-browser-ea142a4dd65c45694f663885d509aae147430f97.tar.lz tangerine-wallet-browser-ea142a4dd65c45694f663885d509aae147430f97.tar.xz tangerine-wallet-browser-ea142a4dd65c45694f663885d509aae147430f97.tar.zst tangerine-wallet-browser-ea142a4dd65c45694f663885d509aae147430f97.zip |
ci: Enable npm audit check
Diffstat (limited to '.circleci/scripts')
-rwxr-xr-x | .circleci/scripts/npm-audit | 12 | ||||
-rw-r--r-- | .circleci/scripts/npm-audit-check.js | 24 |
2 files changed, 36 insertions, 0 deletions
diff --git a/.circleci/scripts/npm-audit b/.circleci/scripts/npm-audit new file mode 100755 index 000000000..00a6876ff --- /dev/null +++ b/.circleci/scripts/npm-audit @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e +set -u +set -o pipefail + +if ! npm audit +then + ! npm audit --json > audit.json + printf '%s\n' '' + node .circleci/scripts/npm-audit-check.js +fi diff --git a/.circleci/scripts/npm-audit-check.js b/.circleci/scripts/npm-audit-check.js new file mode 100644 index 000000000..2fb408add --- /dev/null +++ b/.circleci/scripts/npm-audit-check.js @@ -0,0 +1,24 @@ +const path = require('path') +const audit = require(path.join(__dirname, '..', '..', 'audit.json')) +const error = audit.error +const advisories = Object.keys(audit.advisories || []).map((k) => audit.advisories[k]) + +if (error) { + process.exit(1) +} + +let count = 0 +for (const advisory of advisories) { + if (advisory.severity === 'low') { + continue + } + + count += advisory.findings.some((finding) => (!finding.dev && !finding.optional)) +} + +if (count > 0) { + console.log(`Audit shows ${count} moderate or high severity advisories _in the production dependencies_`) + process.exit(1) +} else { + console.log(`Audit shows _zero_ moderate or high severity advisories _in the production dependencies_`) +} |