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

Undetermined reason for undetermined contextual analysis status #155

Merged
merged 14 commits into from
Sep 12, 2024

Conversation

barv-jfrog
Copy link
Contributor

@barv-jfrog barv-jfrog commented Aug 25, 2024

  • The pull request is targeting the dev branch.
  • The code has been validated to compile successfully by running go vet ./....
  • The code has been formatted properly using go fmt ./....
  • All static analysis checks passed.
  • All tests have passed. If this feature is not already covered by the tests, new tests have been added.
  • All changes are detailed at the description. if not already covered at JFrog Documentation, new documentation have been added.

Description:
Scanners return a reason for why the result was undetermined. This result is on the scanner level (Rule), and not on evidence level in contrary to applicable status which returns "reason" on the evidence level. We need to support this undetermined reason and show it next to "applicable" and "scannerDescription".

}

func GetRuleUndeterminedReason(rule *sarif.ReportingDescriptor) string {
return GetRuleProperty("undetermined_reason", rule)

Choose a reason for hiding this comment

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

The function split is positive overall - but I don't see any other usage for GetRuleProperty, so in that case, I don't see a reason for the dedicated fucntion.
Couldn't we use it for the applicability status itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can use it for applicability status as it is also received in the Rule property. Do you want me to change applicability fetch to this function ?

Choose a reason for hiding this comment

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

yes - otherwise the usage of the this generic function just one misses the point IMO

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes please do use the new GetRuleProperty when applicable. but the GetRuleUndeterminedReason does not belong here. please move it to jasutils package.
This files is only for utils to access, create or set values in sarif

@@ -13,14 +13,16 @@ func CreateRunWithDummyResults(results ...*sarif.Result) *sarif.Run {
return run
}

func CreateRunWithDummyResultAndRuleProperties(property, value string, result *sarif.Result) *sarif.Run {
func CreateRunWithDummyResultAndRuleMultipleProperties(result *sarif.Result, properties, values []string) *sarif.Run {

Choose a reason for hiding this comment

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

The function name indicates that we have a function for multipleProperties, and a one for single.
If it's just that one function - I think you can keep the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok fixed

@@ -13,14 +13,16 @@ func CreateRunWithDummyResults(results ...*sarif.Result) *sarif.Run {
return run
}

func CreateRunWithDummyResultAndRuleProperties(property, value string, result *sarif.Result) *sarif.Run {
func CreateRunWithDummyResultAndRuleMultipleProperties(result *sarif.Result, properties, values []string) *sarif.Run {

Choose a reason for hiding this comment

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

Also - why did you switch the order of the args?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it was nicer to have the arrays at the end of the function, what do you think?

@@ -96,6 +96,7 @@ type CveRow struct {
type Applicability struct {
Status string `json:"status"`
ScannerDescription string `json:"scannerDescription,omitempty"`
UndeterminedReason string `json:"undeterminedReason,omitempty"`

Choose a reason for hiding this comment

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

where do we use it? UndeterminedReason is being inserted into - but not called...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is only in simple-json, and it is under CveRow (CveRow has Applicability struct as one of its components, it gets printed automatically)

run.Tool.Driver.Rules[0].Properties[property] = value
run.Tool.Driver.Rules[0].Properties = make(sarif.Properties, len(properties))
for index, _ := range properties {
run.Tool.Driver.Rules[0].Properties[properties[index]] = values[index]

Choose a reason for hiding this comment

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

suggest makeing sure that len(values)==len(properties)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, fixed

Copy link
Contributor

@attiasas attiasas left a comment

Choose a reason for hiding this comment

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

LGTM, please check out my comments

}

func GetRuleUndeterminedReason(rule *sarif.ReportingDescriptor) string {
return GetRuleProperty("undetermined_reason", rule)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes please do use the new GetRuleProperty when applicable. but the GetRuleUndeterminedReason does not belong here. please move it to jasutils package.
This files is only for utils to access, create or set values in sarif

formats/sarifutils/test_sarifutils.go Outdated Show resolved Hide resolved
@attiasas attiasas added the improvement Automatically generated release notes label Sep 5, 2024
@barv-jfrog barv-jfrog added the safe to test Approve running integration tests on a pull request label Sep 5, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Sep 5, 2024
@barv-jfrog barv-jfrog added the safe to test Approve running integration tests on a pull request label Sep 5, 2024
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Sep 5, 2024
@attiasas attiasas self-requested a review September 9, 2024 06:27
Copy link

github-actions bot commented Sep 9, 2024

👍 Frogbot scanned this pull request and did not find any new security issues.


@attiasas attiasas merged commit 13e64cc into jfrog:dev Sep 12, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Automatically generated release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants