Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JSON Output #104

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eliasm307
Copy link

Resolves #82

): void {
outputJson: boolean,
exceptionsReport: string[][],
): void => {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason functions dont use a single object argument? This could be neater but I noticed all other functions provide individual args like this?

@@ -17,7 +17,7 @@
},
"scripts": {
"preaudit": "npm run build",
"audit": "node lib audit -x 1064843,1067245",
"audit": "node lib audit -j -x 1064843,1067245",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporary for testing

printSecurityReport(report, columnsToInclude);
}
if (outputJson) {
printJsonOutput(result, exceptionsReport);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with json output we only print the json, any other logs should be suppressed so the output can be parsed as json

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some args made not optional to be more explicit and avoid forgetting setting something

@@ -155,4 +155,6 @@ describe('Events handling', () => {
consoleWarnStub.restore();
consoleInfoStub.restore();
});

// todo add json output tests
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests tbc, looking for feedback on the approach before investing time in tests

@@ -16,6 +16,8 @@ describe('Print utils', () => {
it('exception table visual', () => {
printExceptionReport(EXCEPTION_TABLE_DATA);
});

// todo add json output tests
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests tbc, looking for feedback on the approach before investing time in tests

@@ -542,6 +542,8 @@ describe('Vulnerability utils', () => {
consoleStub.restore();
});
});

// todo add json output tests
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests tbc, looking for feedback on the approach before investing time in tests

@eliasm307
Copy link
Author

eliasm307 commented Dec 1, 2024

@jeemok Hello, i've made this PR to resolve #82 however I have not created the tests as I would like feedback on the approach before I invest time into testing. Please let me know if this looks ok or if you think there is a better way.

Also, here is an example of the json output:

{
 "failed": false,
 "unhandledVulnerabilityIds": [
   "1100563"
 ],
 "vulnerabilitiesReport": [
   {
     "id": "1100563",
     "module": "cross-spawn",
     "title": "Regular Expression Denial of Service (ReDoS) in cross-spawn",
     "paths": "cross-spawn",
     "severity": "high",
     "url": "https://github.com/advisories/GHSA-3xgq-45jj-v275",
     "isExcepted": "n"
   },
   {
     "id": "1099561",
     "module": "path-to-regexp",
     "title": "path-to-regexp outputs backtracking regular expressions",
     "paths": "path-to-regexp",
     "severity": "high",
     "url": "https://github.com/advisories/GHSA-9wv6-86v2-598j",
     "isExcepted": "y"
   }
 ],
 "exceptionsReport": [
   {
     "id": "1064843",
     "status": "active",
     "expiry": "",
     "notes": ""
   },
   {
     "id": "106724",
     "status": "active",
     "expiry": "",
     "notes": ""
   },
   {
     "id": "1099561",
     "status": "active",
     "expiry": "",
     "notes": ""
   }
 ],
 "unusedExceptionIds": [
   "1064843",
   "106724"
 ]
}

@eliasm307 eliasm307 marked this pull request as draft December 1, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON output
1 participant