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

Add support to ignore api component errors #394

Merged
merged 6 commits into from
Nov 1, 2023

Conversation

blva
Copy link
Contributor

@blva blva commented Oct 3, 2023

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2023

Codecov Report

Merging #394 (9ab3d0e) into main (61335a8) will increase coverage by 0.11%.
Report is 3 commits behind head on main.
The diff coverage is 68.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##             main     #394      +/-   ##
==========================================
+ Coverage   80.86%   80.97%   +0.11%     
==========================================
  Files         208      209       +1     
  Lines       12232    12237       +5     
==========================================
+ Hits         9891     9909      +18     
+ Misses       1983     1971      -12     
+ Partials      358      357       -1     
Flag Coverage Δ
unittests 80.97% <68.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
checker/api_change.go 38.63% <100.00%> (ø)
checker/change_utils.go 100.00% <100.00%> (ø)
checker/check-components-schemas-removed.go 100.00% <100.00%> (ø)
checker/component_change.go 32.50% <100.00%> (+6.85%) ⬆️
checker/ignore.go 92.10% <ø> (+12.10%) ⬆️
internal/flatten.go 80.32% <100.00%> (ø)
internal/handlers.go 80.64% <100.00%> (ø)
load/source.go 64.28% <50.00%> (ø)
checker/security_change.go 5.00% <0.00%> (-0.13%) ⬇️
internal/run.go 74.32% <61.29%> (+10.43%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -1 +1,3 @@
GET /api/{domain}/{project}/badges/security-score removed the success response with the status '200'
API removed the schema 'rules' [api-schema-removed]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should prefix each line by its type, like this:

API GET /api/{domain}/{project}/badges/security-score removed the success response with the status '200'
components removed the schema 'rules' [api-schema-removed]
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure I'm following what you mean by type? here in this line we don't have the "httpMethod + endpoint" because it's a schema change, which is described in components

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, reread this and now i got it! yes that will be better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

update: I'm trying to update this but I seem to have found a bug in the unmarshalling/test. We are unmarshalling response as ApiChange, which leads to the wrong formatting. Checking if we can unmarshal w/ Change instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wont stress about trying to unmarshall different types as Changes is an interface, we can easilly just update this file w/ correct expectation (which is what we display)


for errIndex, err := range errs {
if err.GetLevel() != level {
continue
}

typeOfChange := fmt.Sprintf("%T", err)
if typeOfChange != "checker.ComponentChange" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we implement this through the Change interface instead of adding this if?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, great idea, I'm adding the check for empty ignore paths within the MatchIgnore

@blva blva requested a review from reuvenharrison October 26, 2023 13:22
@@ -1 +1,4 @@
GET /api/{domain}/{project}/badges/security-score removed the success response with the status '200'
in components removed the schema 'rules'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest to require the keyword "components" to ignore a component.

return false
func (c ComponentChange) MatchIgnore(ignorePath, ignoreLine string) bool {
return strings.Contains(ignoreLine, strings.ToLower(GetUncolorizedText(c))) &&
strings.Contains(ignoreLine, "components")
Copy link
Collaborator

@reuvenharrison reuvenharrison Oct 31, 2023

Choose a reason for hiding this comment

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

I suggest to require the keyword "components" to ignore a change in components.

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 think we'll need to remove this based on the json output it wouldn't work:

[{"id":"api-schema-removed","text":"removed the schema 'SchemaValue'","level":3,"source":"Components"}

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand what you mean by "based on the json output it wouldn't work".
Can you explain the use case in more detail?

Copy link
Collaborator

@reuvenharrison reuvenharrison left a comment

Choose a reason for hiding this comment

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

Hi @blva.
I made a few minor changes.
Please review and if you agree I'll merge the PR.
Thanks,
Reuven

p.s., one more thing: we need to document this so people can use it

Copy link
Contributor Author

@blva blva left a comment

Choose a reason for hiding this comment

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

Thanks @reuvenharrison, please consider this my approval 👍

@reuvenharrison reuvenharrison merged commit 7bcfa04 into Tufin:main Nov 1, 2023
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.

3 participants