This repository has been archived by the owner on Feb 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from InfoSec812/Issue_41-_-Fix_issues_with_lar…
…ge_audit_data_response Issue 41: Fix issues with large audit data response
- Loading branch information
Showing
4 changed files
with
86 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,8 +27,8 @@ const CRIT_THRESHOLD = 3; | |
*/ | ||
test('Validate when err is NULL', () => { | ||
const test_data = readFileSync('test_data/zero_vulnerabilities.json', 'utf8'); | ||
let { exitCode, cli_output } = parse_audit_results(null, test_data, LOW_THRESHOLD, false); | ||
expect(cli_output).toBe('No vulnerabilities found.\n'); | ||
let { exitCode, cliOutput } = parse_audit_results(null, test_data, LOW_THRESHOLD, false); | ||
expect(cliOutput).toBe('No vulnerabilities found.\n'); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
|
@@ -37,7 +37,7 @@ test('Validate when err is NULL', () => { | |
*/ | ||
test('Validate when err is NULL and JSON output is desired', () => { | ||
const test_data = readFileSync('test_data/zero_vulnerabilities.json', 'utf8'); | ||
let { exitCode, cli_output } = parse_audit_results(null, test_data, LOW_THRESHOLD, false, true); | ||
const { exitCode, cliOutput } = parse_audit_results(null, test_data, LOW_THRESHOLD, false, true); | ||
const expectedOutput = { | ||
"actions": [], | ||
"advisories": {}, | ||
|
@@ -57,7 +57,7 @@ test('Validate when err is NULL and JSON output is desired', () => { | |
}, | ||
"runId": "3fdcb3d6-c9f3-4e6f-9e4f-c77d1e0dac86" | ||
} | ||
const actualObject = JSON.parse(cli_output); | ||
const actualObject = JSON.parse(cliOutput); | ||
expect(actualObject.actions).toEqual([]); | ||
expect(actualObject.advisories).toEqual({}); | ||
expect(actualObject.muted).toEqual([]); | ||
|
@@ -79,8 +79,8 @@ test('Validate when err is NULL and JSON output is desired', () => { | |
*/ | ||
test('Validate run with 0 vulnerabilities', () => { | ||
const test_data = readFileSync('test_data/zero_vulnerabilities.json', 'utf8'); | ||
let { exitCode, cli_output } = parse_audit_results("", test_data, LOW_THRESHOLD, false); | ||
expect(cli_output).toBe(''); | ||
let { exitCode, cliOutput } = parse_audit_results("", test_data, LOW_THRESHOLD, false); | ||
expect(cliOutput).toBe(''); | ||
expect(exitCode).toBe(0); | ||
}); | ||
|
||
|
@@ -90,11 +90,11 @@ test('Validate run with 0 vulnerabilities', () => { | |
*/ | ||
test('Validate run with 7 vulnerabilities', () => { | ||
const test_data = readFileSync('test_data/vue_js_app.json', 'utf8'); | ||
let { exitCode, cli_output } = parse_audit_results("", test_data, LOW_THRESHOLD, false); | ||
expect(cli_output).not.toContain('{'); | ||
expect(cli_output).toContain("growl"); | ||
expect(cli_output).toContain('https://www.npmjs.com/advisories/'); | ||
expect(cli_output).toContain('The following vulnerabilities are low severity or higher:'); | ||
let { exitCode, cliOutput } = parse_audit_results("", test_data, LOW_THRESHOLD, false); | ||
expect(cliOutput).not.toContain('{'); | ||
expect(cliOutput).toContain("growl"); | ||
expect(cliOutput).toContain('https://www.npmjs.com/advisories/'); | ||
expect(cliOutput).toContain('The following vulnerabilities are low severity or higher:'); | ||
expect(exitCode).toBe(1); | ||
}); | ||
|
||
|
@@ -104,11 +104,11 @@ test('Validate run with 7 vulnerabilities', () => { | |
*/ | ||
test('Validate run with 7 vulnerabilities, a high severity cutoff, and production-only', () => { | ||
const test_data = readFileSync('test_data/vue_js_app.json', 'utf8'); | ||
let { exitCode, cli_output } = parse_audit_results("", test_data, HIGH_THRESHOLD, true); | ||
expect(cli_output).not.toContain('{'); | ||
expect(cli_output).toContain("[email protected]"); | ||
expect(cli_output).toContain('https://www.npmjs.com/advisories/'); | ||
expect(cli_output).toContain('The following production vulnerabilities are high severity or higher:'); | ||
let { exitCode, cliOutput } = parse_audit_results("", test_data, HIGH_THRESHOLD, true); | ||
expect(cliOutput).not.toContain('{'); | ||
expect(cliOutput).toContain("[email protected]"); | ||
expect(cliOutput).toContain('https://www.npmjs.com/advisories/'); | ||
expect(cliOutput).toContain('The following production vulnerabilities are high severity or higher:'); | ||
expect(exitCode).toBe(1); | ||
}); | ||
|
||
|
@@ -117,13 +117,12 @@ test('Validate run with 7 vulnerabilities, a high severity cutoff, and productio | |
*/ | ||
test('Validate run with 7 vulnerabilities and JSON output', () => { | ||
const test_data = readFileSync('test_data/vue_js_app.json', 'utf8'); | ||
let { exitCode, cli_output } = parse_audit_results("", test_data, LOW_THRESHOLD, true, true); | ||
const actualObject = JSON.parse(cli_output); | ||
console.log(cli_output+"\n\n"); | ||
expect(cli_output).toContain('"https-proxy-agent"'); | ||
expect(cli_output).toContain('"version"'); | ||
expect(cli_output).toContain('"module_name"'); | ||
expect(cli_output.substring((cli_output.length - 1), cli_output.length)).toBe('\n'); | ||
let { exitCode, cliOutput } = parse_audit_results("", test_data, LOW_THRESHOLD, true, true); | ||
const actualObject = JSON.parse(cliOutput); | ||
expect(cliOutput).toContain('"https-proxy-agent"'); | ||
expect(cliOutput).toContain('"version"'); | ||
expect(cliOutput).toContain('"module_name"'); | ||
expect(cliOutput.substring((cliOutput.length - 1), cliOutput.length)).toBe('\n'); | ||
expect(actualObject.metadata.dependencies).toBeDefined(); | ||
expect(actualObject.metadata.devDependencies).toBeDefined(); | ||
expect(actualObject.metadata.optionalDependencies).toBeDefined(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters