-
Notifications
You must be signed in to change notification settings - Fork 510
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
✨ Included documentation for Active check #347
Conversation
Integration tests success for 73e6676695e692677e328e01143b62927a33f24d |
Some things i noticed
i would let @azeemshaikh38 @oliverchang and @naveensrinivasan to sync here and discuss a solution here, just added my thoughts above. |
I agree , I will change the implementation to use the YAML and will add HelpURL which points to the GitHub instead of remediation. |
73e6676
to
14d6dee
Compare
Updated the implementation to utilize the YAML instead of the |
Integration tests failure for 14d6deeb3beb1d7ef53a34ea3d29d78828c14847 |
* Included the documentation for Active check * Embed the checks.yaml into the binary
14d6dee
to
9214dd3
Compare
Integration tests success for 9214dd3dc18519a8a26929ce54d2f1437ef0017a |
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.
If this change is attempting to solve the "upload a SARIF file to GitHub" problem, should we first figure out the design? IMO, we should hold off on this PR before we have a consensus on how the design for the bigger problem would look like.
@@ -23,6 +23,8 @@ type CheckResult struct { | |||
Details []string | |||
ShouldRetry bool `json:"-"` | |||
Error error `json:"-"` | |||
Description string |
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.
Let's not bloat CheckResult with Description and HelpURL. We should have a separate struct for these which other packages can access as/when needed.
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.
The result is where the Help documentation needs to have the necessary stuff and this is what is being used in output.
Where else do you think this could be used?
How do you see this as bloat?
Also, what would be your suggestion?
@@ -0,0 +1,90 @@ | |||
// Copyright 2020 Security Scorecard Authors |
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.
Change filename -> check_documentation.go
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.
It is already within the checks
package. Adding prefix doesn't add any value and also _
aren't common within standard go
naming though there are few exceptions.
} | ||
|
||
// HelpDocumentation provides the documentation for the checks. | ||
type HelpDocumentation struct { |
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.
We can expose this struct to other packages to get Description/HelpURL.
} | ||
|
||
// ActiveHelpDocumentation provides the help documentation for ActiveHelpDocumentation check. | ||
func ActiveHelpDocumentation() (HelpDocumentation, error) { |
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.
Everytime a *HelpDocumentation is called, we will read the YAML file, unmarshal it and then send the result back. Instead, could we only unmarshal the first time, and have a var which saves this in memory so that the next time these fn calls happen, we only read from the in-memory var?
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.
The idea behind this is to avoid a global state. This performance is negligible. IMO avoiding state is cleaner design.
It is not just for SARIF, anyone who uses the tool would like to know details and steps to address these issues #63 |
|
||
type documentation struct { | ||
Checks struct { | ||
SecurityPolicy struct { |
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.
This is a lot of repetition and makes maintenance difficult. Can we marshal these into a map[string]CheckDescription
or something similar?
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.
There is also a con with that approach, we lose the type-safety and strings are all over the codebase.
We would have to define a constant for the string and use it which beats the purpose.
Name: r.Name, | ||
Pass: r.Pass, | ||
Confidence: r.Confidence, | ||
Description: r.Description, |
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.
I also don't think we should include these long strings in these results by default. It will blow up the latest.json and cause a lot of duplication.
If we need this for another use case, we should figure out another way to do this.
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.
I can think of a flag that either dumps the help information in the json or not.
Do you have any other suggestions?
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.
Me and Oliver synced over this today. This is what we thought - #63 wants to address the problem that if Scorecard tool fails, the user should know "why the check failed", "how confident are we about this result" and "how to fix it". This PR won't solve that issue. A simple example - if the check failed due to too many retries, we'd simply be outputting a generic description and helpURL. This does not help our case in making the tool more user friendly.
So here's my suggestion -
- Let's update all of our checks to return error_codes on failure. Each unique case of failure should have a unique error_code. These can simply be appended to []details of CheckResult for now.
- We should then update the YAML to add details/remediation corresponding to these unique failures.
- Update cmd/root.go to include the remediation string from YAML if any of the checks fail.
What do you think? Also adding @oliverchang @inferno-chromium for feedback/opinions.
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.
Sounds like a plan, yes giving actual remediation instead of everything is a nice idea. and in yes in tool run, it does not make sense to give everything, (although it can say at end, for more information on check, please see doc at ).
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.
Sounds like a good plan to me too. Raising more relevant errors messages seems way more useful. @naveensrinivasan WDYT?
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.
SG.
Shall we also provide additional information about the checks we make in the command line output (when --show-details
is provided)? I personally find it useful - even if somehow redundant with the YAML document file. Here's an example output (YES implicitly means it's a positive check outcome):
$ scorecard <> --show-details
RESULTS
-------
Repo: some-repo
Active: Fail
Confidence: 100%
Commits in last 90 days greater than 2: NO (1)
Branch-Protection: Fail
Confidence: 60%
AllowForcePushes disabled: YES
AllowDeletions disabled: YES
EnforceAdmins enabled: YES
RequireLinearHistory enabled: YES
RequiredStatusChecks enabled: YES but has no contexts
RequiredPullRequestReviews enabled: YES but with only 1 reviews
DismissStaleReviews enabled: YES
DismissalRestrictions enabled: NO
RequireCodeOwnerReviews enabled: YES
This is just a first attempt and be changed, of course.
On a related note, I'm not sure the term Confidence
makes sense in all cases. In some cases it does (say, if we find a commit with no PR we have high confidence it's not branch-protected). In other case, confidence seems to mean 'degree of protection' (Branch-Protection above)
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Feature
What is the current behavior? (You can also link to an open issue here)
The check results didn't provide a description and remediation.
What is the new behavior (if this is a feature change)?
Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
None
Other information:
None