-
Notifications
You must be signed in to change notification settings - Fork 249
Baseline support #106
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
Baseline support #106
Changes from 2 commits
c4cd04c
fb388e9
4bfa815
e824d1e
26a3bc0
217eb0f
e8bbf3f
a530a69
fa2ef7e
4c9434b
458cf83
8c4b03a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| from pprint import pprint | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not totally done. |
||
| import json | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't notice this before but from looking at the Code Climate issues at the bottom of the PR, there are a couple of pep8 ones. Normally people have 2 lines between imports and the next class or function call like in |
||
|
|
||
| def isSame(res, base): | ||
| if res == base: | ||
| return(True) | ||
| return(False) | ||
|
|
||
| def compare(results, baseline): | ||
|
|
||
| baseline = json.load(open(baseline)) | ||
| results = json.load(open(results)) | ||
| result = {'generated_at':results["generated_at"], 'vulnerabilities':[]} | ||
|
|
||
| if "generated_at" in results and baseline: | ||
| if not isSame(results["generated_at"], baseline["generated_at"]): | ||
| pprint(results["generated_at"]) | ||
|
|
||
| if "vulnerabilities" in results and baseline: | ||
| if not isSame(results["vulnerabilities"], baseline["vulnerabilities"]): | ||
| for i in range(len(results["vulnerabilities"])): | ||
| if results["vulnerabilities"][i] not in baseline["vulnerabilities"]: | ||
| result["vulnerabilities"].append(results["vulnerabilities"][i]) | ||
|
|
||
| result = json.dumps(result, indent=4) | ||
| print(result) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what is happening (I think) is that the previous call to report closes sys.stdout.
then does
with fileobj:which closes it.The solution I think is to do
before we do
if args.json.You can loop through vulnerabilities and return "vulnerabilities - baseline". This will make it work both for
jsonoutput andtextoutput.See https://github.com/Yelp/detect-secrets/blob/b16acf1e8dc1e05366a9bfbd7ce35ed611adb94d/detect_secrets/pre_commit_hook.py#L34-L37 for an example of how we have
resultsand then just returnresults - baseline.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, i will edit it