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

Feat: allow suppression of rules from the reports page #4623

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sknep
Copy link
Contributor

@sknep sknep commented Oct 15, 2024

Changes proposed in this pull request:

Adds report suppression information to each finding
Allows the user to add or delete rules using the given rule id for each finding.
Cleans up use of "scanType" now that we have sbt, which has an id and a type

security considerations

none

@sknep sknep requested a review from drewbo October 15, 2024 22:11
@sknep
Copy link
Contributor Author

sknep commented Oct 15, 2024

Do you think text-based is enough? i'm worried about an actual "toggle" button being distractingly visible at the top of each finding.
Screenshot 2024-10-15 at 5 12 26 PM
Screenshot 2024-10-15 at 5 12 03 PM

Screenshot 2024-10-15 at 5 12 21 PM
Screenshot 2024-10-15 at 5 12 17 PM

@apburnes
Copy link
Contributor

@sknep will you run make lint and fix the linting errors before we review?

@apburnes
Copy link
Contributor

What's your thoughts on adding another toggle location at the top of the page in the violated rules list? Like 👇
Screenshot 2024-10-16 at 12 27 04 PM

@sknep
Copy link
Contributor Author

sknep commented Oct 17, 2024

hmm... I don't really want folks to be able to suppress without fully understanding the finding. Also that spot is already kind of busy/full, and keeping these reports scannable is important to me. But what do you think?

Copy link
Contributor

@drewbo drewbo left a comment

Choose a reason for hiding this comment

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

I like the idea of having this alongside the rule (not in the top summary) and we can test out whether folks notice/use it in the future. I think maybe it could be more noticable but 🤷 . It looks like the suppression toggle logic has 2 issues:

  • I think it's reversed because of some react hook "stuff" going on
  • If a user removes a suppression that had a match property, that would be removed when trying to re-enable it (maybe that's okay, we should just note)


const type = appMatch(task.BuildTaskType);

const fullJSON = {
...taskJSON, report, type, siteId: task.Build.Site.id,
...taskJSON, report, type, siteId: task.Build.Site.id, siteBuildTaskId: task.SiteBuildTask.id,
Copy link
Contributor

Choose a reason for hiding this comment

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

siteBuildTaskId doesn't need to be added here now that it's been added to the serializer/json/include

Comment on lines 16 to 21
const [customerRules, setCustomerRules] = useState(sbtCustomRules);
const willBeSuppressed = customerRules.find(r => r.id === ruleId);

useEffect(() => {
setCustomerRules(sbtCustomRules);
}, [sbtCustomRules]);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm caveating this comment by saying we should probably investigate swapping in a consistent querying library like react-query because I've also lost the plot a little on hook re-rending logic. But I think this might be the block that is causing you issues: I don't know that you need a useEffect call because sbtCustomRules are used to initialize the local state already. And they shouldn't change since we aren't refetching the report while on this page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So i deleted the useEffect, but I am not sure that the set state for customer rules is working... it seems to issue at the same time as the update function, so I just passed in the new array as a param instead. Is that bad? I feel like it needs a promise somewhere, but I haven't seen a pattern like that in how we manage updates

@sknep sknep force-pushed the feat-add-asr-rule-from-report branch from ab8b159 to 786430f Compare October 18, 2024 20:04
@sknep sknep requested a review from drewbo October 18, 2024 20:07
@sknep sknep force-pushed the feat-add-asr-rule-from-report branch from 786430f to 3a29282 Compare October 21, 2024 20:39
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