Skip to content

Support JSON Output#104

Draft
eliasm307 wants to merge 1 commit intojeemok:masterfrom
eliasm307:feat/support-json-output
Draft

Support JSON Output#104
eliasm307 wants to merge 1 commit intojeemok:masterfrom
eliasm307:feat/support-json-output

Conversation

@eliasm307
Copy link
Copy Markdown

Resolves #82

): void {
outputJson: boolean,
exceptionsReport: string[][],
): void => {
Copy link
Copy Markdown
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?

"scripts": {
"preaudit": "npm run build",
"audit": "node lib audit -x 1064843,1067245",
"audit": "node lib audit -j -x 1064843,1067245",
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

consoleInfoStub.restore();
});

// todo add json output tests
Copy link
Copy Markdown
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

printExceptionReport(EXCEPTION_TABLE_DATA);
});

// todo add json output tests
Copy link
Copy Markdown
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

});
});

// todo add json output tests
Copy link
Copy Markdown
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
Copy Markdown
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"
 ]
}

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