Skip to content

Conversation

@tarkatronic
Copy link
Contributor

@tarkatronic tarkatronic commented May 23, 2023

Fixes #46

WIP! The following is a full checklist of items to complete:

  • Overall summary report uses Block Kit
  • Team report uses Block Kit
    • Per-repository icon is determined by level of severities
    • Summary line has a breakdown by severity (Moving to future enhancement)
  • Console reporter tests are updated to reflect API changes
  • Slack reporter tests are updated to reflect everything changing

This changes from super simple text formatting to using full Slack Block Kit functionality. Open to suggestions on further improvements here!

Notably, one request from #46 that is not solved here is sorting repositories in the team report by level of vuln severity. That felt like a whole other "thing", and easy enough to split out into a separate enhancement. A follow-up feature request will be filed to cover that.

@tarkatronic tarkatronic requested review from a team and SteveKekacs May 23, 2023 22:22
@tarkatronic tarkatronic added this to the Version 1.0 milestone May 23, 2023
@tarkatronic
Copy link
Contributor Author

@SteveKekacs I got all the tests fixed up now for this refactor. The one planned piece I haven't done yet is the team report summary line. Specifically the breakdown by severity as seen in your example here
Screenshot 2023-05-25 at 3 06 39 PM

How vital do you feel that is to this overall rework? I'm debating leaving that as a future enhancement as well as the sorting order, to not let perfect be the enemy of good. What are your thoughts on that?

@codecov
Copy link

codecov bot commented May 25, 2023

Codecov Report

Merging #56 (49fe77d) into main (9b78d09) will increase coverage by 3.94%.
The diff coverage is 90.69%.

@@            Coverage Diff             @@
##             main      #56      +/-   ##
==========================================
+ Coverage   48.07%   52.01%   +3.94%     
==========================================
  Files          13       13              
  Lines         441      496      +55     
==========================================
+ Hits          212      258      +46     
- Misses        228      235       +7     
- Partials        1        3       +2     
Flag Coverage Δ
unittests 52.01% <90.69%> (+3.94%) ⬆️

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

Impacted Files Coverage Δ
internal/scan.go 0.00% <0.00%> (ø)
reporting/console.go 92.50% <ø> (ø)
reporting/slack.go 95.23% <93.60%> (-4.77%) ⬇️

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

@SteveKekacs
Copy link

@SteveKekacs I got all the tests fixed up now for this refactor. The one planned piece I haven't done yet is the team report summary line. Specifically the breakdown by severity as seen in your example here

Screenshot 2023-05-25 at 3 06 39 PM

How vital do you feel that is to this overall rework? I'm debating leaving that as a future enhancement as well as the sorting order, to not let perfect be the enemy of good. What are your thoughts on that?

Yeah totally fine IMO to do as a follow up 👍

@tarkatronic tarkatronic marked this pull request as ready for review May 25, 2023 21:19
@tarkatronic tarkatronic enabled auto-merge May 25, 2023 22:16
}
reporters = append(reporters, &reporting.ConsoleReporter{Config: userConfig})

reportTime := time.Now().Format(time.RFC1123)
Copy link

@developerDemetri developerDemetri May 25, 2023

Choose a reason for hiding this comment

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

[q] do we want to explicitly set UTC() here?
Looking at the source code, I don't think it actually changes anything
https://github.com/golang/go/blob/go1.20.4/src/time/time.go#L1129

since setLoc ignores UTC
https://github.com/golang/go/blob/go1.20.4/src/time/time.go#L207-L209

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a great call! Especially when we create the Datadog reporter, I think we will definitely want to have this normalized to UTC. And in fact, taking it one step further, I think that we will want to pass just the raw timestamp to reporters and let them format it.

Even one step further beyond that, we can introduce a config option to let users control the formatting of the timestamp. 😄

return nil
}
if teamInfo.Slack_channel == "" {
log.Debug().Str("team", teamID).Any("repos", repos).Msg("Skipping report since Slack channel is not configured.")

Choose a reason for hiding this comment

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

[q] This seems like more than a Debug? Either an Info or Warn since important configuration is missing?

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 really debated back and forth on that one. The reason I went with debug is because, with a sufficient size org, this could get pretty spammy. I remember at $previousEmployer, there were thousands of repos, and that would just be... way too much.

Though I suppose at info level it wouldn't show by default 🤔 We may want to just go through and do a pass on log levels in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prettify Slack Alert

4 participants