Skip to content

Commit

Permalink
fix: discord finished without secret scanning (#112)
Browse files Browse the repository at this point in the history
- chore: validate format on preRun
- fix: discord finished without secret scanning

---------

Co-authored-by: Jossef Harush Kadouri <[email protected]>
  • Loading branch information
Baruch Odem (Rothkoff) and jossef authored Jun 28, 2023
1 parent 7953f50 commit 011c0e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func validateFormat(stdout string, reportPath []string) {
}

func preRun(cmd *cobra.Command, args []string) {
validateFormat(stdoutFormatVar, reportPathVar)
secrets, err := secrets.Init(includeRuleVar, excludeRuleVar)
if err != nil {
log.Fatal().Msg(err.Error())
Expand Down Expand Up @@ -168,8 +169,6 @@ func preRun(cmd *cobra.Command, args []string) {
func postRun(cmd *cobra.Command, args []string) {
channels.WaitGroup.Wait()

validateFormat(stdoutFormatVar, reportPathVar)

cfg := config.LoadConfig("2ms", Version)

// Wait for last secret to be added to report
Expand Down
6 changes: 2 additions & 4 deletions plugins/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (p *DiscordPlugin) DefineCommand(channels Channels) (*cobra.Command, error)
return nil, fmt.Errorf("error while marking '%s' flag as required: %w", serversFlag, err)
}
flags.StringSliceVar(&p.Channels, channelsFlag, []string{}, "Discord channels IDs to scan. If not provided, all channels will be scanned")
flags.DurationVar(&p.BackwardDuration, fromDateFlag, defaultDateFrom, "The time interval to scan from the current time. For example, 24h for 24 hours or 7d for 7 days.")
flags.DurationVar(&p.BackwardDuration, fromDateFlag, defaultDateFrom, "The time interval to scan from the current time. For example, 24h for 24 hours or 336h0m0s for 14 days.")
flags.IntVar(&p.Count, messagesCountFlag, 0, "The number of messages to scan. If not provided, all messages will be scanned until the fromDate flag value.")

discordCmd.Run = func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -86,8 +86,6 @@ func (p *DiscordPlugin) initialize(cmd *cobra.Command) error {
}

func (p *DiscordPlugin) getItems(itemsChan chan Item, errChan chan error, wg *sync.WaitGroup) {
defer wg.Done()

p.errChan = errChan
p.itemChan = itemsChan
p.waitGroup = wg
Expand All @@ -101,7 +99,7 @@ func (p *DiscordPlugin) getItems(itemsChan chan Item, errChan chan error, wg *sy
guilds := p.getGuildsByNameOrIDs()
log.Info().Msgf("Found %d guilds", len(guilds))

wg.Add(len(guilds))
p.waitGroup.Add(len(guilds))
for _, guild := range guilds {
go p.readGuildMessages(guild)
}
Expand Down

0 comments on commit 011c0e5

Please sign in to comment.