@leverege/build-tools 1.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.publishrc +15 -0
- package/CHANGELOG.md +30 -0
- package/LICENSE.md +3 -0
- package/README.md +32 -0
- package/lib/server/auditate/help.js +119 -0
- package/lib/server/auditate/index.js +23 -0
- package/lib/server/auditate/report.js +61 -0
- package/lib/server/circleate +549 -0
- package/lib/server/decrypt-secrets +91 -0
- package/lib/server/dnsify/CloudflareAPI.js +103 -0
- package/lib/server/dnsify/accounts.json.enc +0 -0
- package/lib/server/dnsify/index.js +92 -0
- package/lib/server/dockreate +338 -0
- package/lib/server/encrypt-secrets +31 -0
- package/lib/server/getfbcfg +23 -0
- package/lib/server/getjson +48 -0
- package/lib/server/helmdn +103 -0
- package/lib/server/helmify +289 -0
- package/lib/server/helmup +87 -0
- package/lib/server/overwhelm +303 -0
- package/lib/server/packleate/Packleator.js +269 -0
- package/lib/server/packleate/index.js +98 -0
- package/lib/server/packleate/logo-ansi.js +17 -0
- package/lib/server/pkgck +136 -0
- package/lib/server/pkglint/index.js +19 -0
- package/lib/server/test.json +4 -0
- package/lib/web/auditate/help.js +158 -0
- package/lib/web/auditate/index.js +27 -0
- package/lib/web/auditate/report.js +91 -0
- package/lib/web/dnsify/CloudflareAPI.js +250 -0
- package/lib/web/dnsify/index.js +147 -0
- package/lib/web/packleate/Packleator.js +645 -0
- package/lib/web/packleate/index.js +157 -0
- package/lib/web/packleate/logo-ansi.js +3 -0
- package/lib/web/pkglint/index.js +19 -0
- package/package.json +74 -0
- package/src/auditate/help.js +83 -0
- package/src/auditate/index.js +25 -0
- package/src/auditate/report.js +54 -0
- package/src/circleate +549 -0
- package/src/decrypt-secrets +91 -0
- package/src/dnsify/CloudflareAPI.js +99 -0
- package/src/dnsify/accounts.json.enc +0 -0
- package/src/dnsify/index.js +82 -0
- package/src/dockreate +338 -0
- package/src/encrypt-secrets +31 -0
- package/src/getfbcfg +23 -0
- package/src/getjson +48 -0
- package/src/helmdn +103 -0
- package/src/helmify +289 -0
- package/src/helmup +87 -0
- package/src/overwhelm +303 -0
- package/src/packleate/Packleator.js +271 -0
- package/src/packleate/index.js +86 -0
- package/src/packleate/logo-ansi.js +16 -0
- package/src/pkgck +136 -0
- package/src/pkglint/index.js +21 -0
- package/src/test.json +4 -0
package/.publishrc
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"validations": {
|
|
3
|
+
"vulnerableDependencies": false,
|
|
4
|
+
"uncommittedChanges": true,
|
|
5
|
+
"untrackedFiles": true,
|
|
6
|
+
"branch": "development",
|
|
7
|
+
"gitTag": true,
|
|
8
|
+
"sensitiveData": false
|
|
9
|
+
},
|
|
10
|
+
"confirm": true,
|
|
11
|
+
"publishCommand": "npm publish",
|
|
12
|
+
"publishTag": "latest",
|
|
13
|
+
"prePublishScript": "npm run build",
|
|
14
|
+
"postPublishScript": false
|
|
15
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
## [1.6.3] - 2019-07-02
|
|
5
|
+
### Added
|
|
6
|
+
- (pkglint) Added pkglint check for valid files
|
|
7
|
+
|
|
8
|
+
## [1.5.0] - 2019-06-07
|
|
9
|
+
### Added
|
|
10
|
+
- (Dnsify) Added new Dnsify script to add new DNS records to cloudflare
|
|
11
|
+
|
|
12
|
+
## [1.4.0] - 2019-05-02
|
|
13
|
+
### Added
|
|
14
|
+
- (Helmify) Added new Helmify script to bootstrap helm templates
|
|
15
|
+
|
|
16
|
+
## [0.7.1] - 2019-03-07
|
|
17
|
+
### Updated
|
|
18
|
+
- (Overwhelm) Replaced glob library to fix vulnerability issue
|
|
19
|
+
|
|
20
|
+
## [0.5.0] - 2019-03-04
|
|
21
|
+
### Replaced
|
|
22
|
+
- (Encrypt/Decrypt) Deprecate OpenSSL for GCP KMS encryption method
|
|
23
|
+
|
|
24
|
+
## [0.4.0] - 2019-02-21
|
|
25
|
+
### Added
|
|
26
|
+
- (Circleate) Added smoke test step to do security audit
|
|
27
|
+
- (Circleate) Account for edge cases with non-standard container name
|
|
28
|
+
|
|
29
|
+
### Removed
|
|
30
|
+
- (Circleate) Deleted junit reporter for test coverage
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
Copyright (c) 2018 - Leverege LLC
|
|
2
|
+
|
|
3
|
+
This proprietary software is owned by Leverege LLC ("Leverege") for its exclusive use except when otherwise noted. Any user of this software agrees to hold Leverege harmless for any and all damages or liabilities that arise out of the use of the software for any purpose. Leverege does not warrant suitability for any purpose. Except when noted, Leverege explicitly does not grant the user of the software any right to use, modify, or redistribute the source code for any purpose, and will pursue all legal remedies against violators as permitted under the laws of United States.
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Leverege Build Tools
|
|
2
|
+
|
|
3
|
+
A collection of build tools for all Leverege code.
|
|
4
|
+
|
|
5
|
+
## Installing
|
|
6
|
+
|
|
7
|
+
Install build-tools
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install --save-dev @leverege/build-tools
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And add the script you want in package.json like
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
"scripts": {
|
|
17
|
+
"circleate": "circleate"
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Tool Descriptions
|
|
22
|
+
Most of these tools should be bootstrapped with a template, but if you need descriptions of the tools:
|
|
23
|
+
|
|
24
|
+
* **circleate**: bootstrap .circleci config repo
|
|
25
|
+
* **decrypt-secrets**: decrypts secrets (env, service accounts)
|
|
26
|
+
* **dockreate**: bootstrap docker repo
|
|
27
|
+
* **encrypt-secrets**: encrypts secrets (env, service accounts)
|
|
28
|
+
|
|
29
|
+
## Authors
|
|
30
|
+
|
|
31
|
+
* **John Phelps** - Dockreate, getfbcfg, getjson, pkgck
|
|
32
|
+
* **Yitaek Hwang** - circleate, encrypt/decrypt secrets
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const groupBy = require('lodash.groupby');
|
|
4
|
+
|
|
5
|
+
const keyBy = require('lodash.keyby');
|
|
6
|
+
|
|
7
|
+
const countBy = require('lodash.countby');
|
|
8
|
+
|
|
9
|
+
const orderBy = require('lodash.orderby');
|
|
10
|
+
|
|
11
|
+
const map = require('lodash.map');
|
|
12
|
+
|
|
13
|
+
const first = require('lodash.first');
|
|
14
|
+
|
|
15
|
+
module.exports = (config = {}) => {
|
|
16
|
+
function affectsProd(resolves) {
|
|
17
|
+
return !(config['prod-only'] && resolves.every(({
|
|
18
|
+
dev
|
|
19
|
+
}) => dev));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function requireAttention(auditResult) {
|
|
23
|
+
const {
|
|
24
|
+
actions,
|
|
25
|
+
advisories
|
|
26
|
+
} = auditResult;
|
|
27
|
+
const reviewActions = actions.filter(({
|
|
28
|
+
action,
|
|
29
|
+
resolves,
|
|
30
|
+
isMajor
|
|
31
|
+
}) => (action === 'review' || isMajor) && affectsProd(resolves));
|
|
32
|
+
const reviewAdvisories = reviewActions.reduce((acc, {
|
|
33
|
+
resolves
|
|
34
|
+
}) => {
|
|
35
|
+
const advisoriesToInclude = resolves.reduce((result, {
|
|
36
|
+
id
|
|
37
|
+
}) => Object.assign({}, result, {
|
|
38
|
+
[id]: advisories[id]
|
|
39
|
+
}), {});
|
|
40
|
+
return Object.assign({}, acc, advisoriesToInclude);
|
|
41
|
+
}, {});
|
|
42
|
+
return Object.assign({}, auditResult, {
|
|
43
|
+
actions: reviewActions,
|
|
44
|
+
advisories: reviewAdvisories
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getHighestSeverity({
|
|
49
|
+
advisories
|
|
50
|
+
}) {
|
|
51
|
+
for (const severity of ['critical', 'high', 'moderate', 'low']) {
|
|
52
|
+
if (Object.keys(advisories).find(key => advisories[key].severity === severity)) {
|
|
53
|
+
return severity;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function filterAuditResultsBySeverity(auditResult, highestSeverity) {
|
|
59
|
+
const {
|
|
60
|
+
actions,
|
|
61
|
+
advisories
|
|
62
|
+
} = auditResult;
|
|
63
|
+
const groupedAdvisories = groupBy(advisories, 'severity');
|
|
64
|
+
const advisoriesForSeverity = keyBy(groupedAdvisories[highestSeverity], 'id');
|
|
65
|
+
const actionsForSeverity = actions.reduce((acc, action) => {
|
|
66
|
+
const resolvesSevereAdvisory = action.resolves.some(({
|
|
67
|
+
id
|
|
68
|
+
}) => advisoriesForSeverity[id]);
|
|
69
|
+
return resolvesSevereAdvisory ? [].concat(acc, action) : acc;
|
|
70
|
+
}, []);
|
|
71
|
+
return Object.assign({}, auditResult, {
|
|
72
|
+
actions: actionsForSeverity,
|
|
73
|
+
advisories
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function getAutoFixCount(auditResult) {
|
|
78
|
+
return auditResult.actions.filter(({
|
|
79
|
+
action,
|
|
80
|
+
resolves,
|
|
81
|
+
isMajor
|
|
82
|
+
}) => action !== 'review' && !isMajor && affectsProd(resolves)).length;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function findRootLibs(resolves) {
|
|
86
|
+
return resolves.reduce((acc, resolve) => [].concat(acc, resolve.path.split('>')[0]), []);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function getMostProblematicDependency({
|
|
90
|
+
actions
|
|
91
|
+
}) {
|
|
92
|
+
const rootLibraries = actions.reduce((libs, {
|
|
93
|
+
resolves
|
|
94
|
+
}) => [].concat(libs, findRootLibs(resolves)), []);
|
|
95
|
+
return first(orderBy(map(countBy(rootLibraries), (count, lib) => ({
|
|
96
|
+
count,
|
|
97
|
+
name: lib
|
|
98
|
+
})), ({
|
|
99
|
+
count
|
|
100
|
+
}) => count, ['desc']));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return function help(npmAuditResultJson) {
|
|
104
|
+
const npmAuditResult = JSON.parse(npmAuditResultJson);
|
|
105
|
+
const resultsThatRequireAttention = requireAttention(npmAuditResult);
|
|
106
|
+
const highestSeverity = getHighestSeverity(resultsThatRequireAttention);
|
|
107
|
+
const auditResult = filterAuditResultsBySeverity(resultsThatRequireAttention, highestSeverity);
|
|
108
|
+
const autoFixCount = getAutoFixCount(npmAuditResult);
|
|
109
|
+
const exitCode = config['exit-zero'] || !auditResult.actions.length && !autoFixCount ? 0 : 1;
|
|
110
|
+
return {
|
|
111
|
+
npmAuditResult,
|
|
112
|
+
auditResult,
|
|
113
|
+
autoFixCount,
|
|
114
|
+
mostProblematicDependency: getMostProblematicDependency(resultsThatRequireAttention),
|
|
115
|
+
highestSeverity,
|
|
116
|
+
exitCode
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const getStdin = require('get-stdin');
|
|
5
|
+
|
|
6
|
+
const options = require('minimist')(process.argv.slice(2));
|
|
7
|
+
|
|
8
|
+
const help = require('./help');
|
|
9
|
+
|
|
10
|
+
const report = require('./report');
|
|
11
|
+
|
|
12
|
+
const defaults = {
|
|
13
|
+
'exit-zero': false,
|
|
14
|
+
'prod-only': false
|
|
15
|
+
};
|
|
16
|
+
const config = Object.assign({}, defaults, options);
|
|
17
|
+
getStdin().then(help(config)).then(result => report(result).then(theReport => {
|
|
18
|
+
console.log(theReport);
|
|
19
|
+
process.exit(result.exitCode);
|
|
20
|
+
})).catch(error => {
|
|
21
|
+
console.error(error);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const auditReport = require('npm-audit-report');
|
|
4
|
+
|
|
5
|
+
const chalk = require('chalk');
|
|
6
|
+
|
|
7
|
+
function automaticFixes(autoFixCount) {
|
|
8
|
+
return autoFixCount ? `run ${chalk.yellow('`npm audit fix`')} to automatically fix ${chalk.yellow(autoFixCount)} issues. These should all be non-breaking upgrades, so don't stress.` : '';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function fixesToReview({
|
|
12
|
+
actions,
|
|
13
|
+
advisories
|
|
14
|
+
}, highestSeverity) {
|
|
15
|
+
const advisoryIds = Object.keys(advisories);
|
|
16
|
+
|
|
17
|
+
if (!actions.length || !advisoryIds.length) {
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return `Resolve the ${chalk.green(actions.length)} ${chalk.green(highestSeverity)} severity issues above and run this command again to move to the next severity.`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function mostProblematic(mostProblematicDependency) {
|
|
25
|
+
if (!mostProblematicDependency) {
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const {
|
|
30
|
+
name,
|
|
31
|
+
count
|
|
32
|
+
} = mostProblematicDependency;
|
|
33
|
+
return count && count > 2 ? `The most problematic dependency seems to be ${chalk.blue(name)} with ${chalk.blue(count)} issue${count ? 's' : ''} that need your attention.` : '';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = async function printFullReport({
|
|
37
|
+
npmAuditResult,
|
|
38
|
+
auditResult,
|
|
39
|
+
autoFixCount,
|
|
40
|
+
mostProblematicDependency,
|
|
41
|
+
highestSeverity
|
|
42
|
+
}) {
|
|
43
|
+
const {
|
|
44
|
+
report
|
|
45
|
+
} = await auditReport(npmAuditResult, {
|
|
46
|
+
reporter: 'install',
|
|
47
|
+
withColor: true,
|
|
48
|
+
withUnicode: true
|
|
49
|
+
});
|
|
50
|
+
const hints = [].concat(automaticFixes(autoFixCount)).concat(fixesToReview(auditResult, highestSeverity)).concat(mostProblematic(mostProblematicDependency)).filter(Boolean);
|
|
51
|
+
const help = hints.length ? `
|
|
52
|
+
|
|
53
|
+
${chalk.green('=== A little bit of help ===')}
|
|
54
|
+
|
|
55
|
+
Where to start:
|
|
56
|
+
${hints.reduce((acc, hint) => `${acc}
|
|
57
|
+
- ${hint}
|
|
58
|
+
`, '')}
|
|
59
|
+
` : '';
|
|
60
|
+
return `${report}${help}`;
|
|
61
|
+
};
|