Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func run() error {
orgScanned[owner] = true

repo := result.GetRepository().GetName()
repoScanned[repo] = true
repoScanned[fmt.Sprintf("%s/%s", owner, repo)] = true

workflowFile := strings.TrimPrefix(result.GetPath(), ".github/workflows/")
workflowScanned[workflowFile] = true
Expand Down Expand Up @@ -156,25 +156,31 @@ func run() error {
continue
}

secret := matches[1]
for _, dec := range rule.Decoders {
decoder, err := decoder.New(dec.Id)
if err != nil {
log.Warn().Msgf("Error creating decoder: %v", err)
continue
secret = ""
break
}

decoded, err := decoder.Decode(matches[1], dec.Repeat)
secret, err = decoder.Decode(secret, dec.Repeat)
if err != nil {
log.Warn().Msgf("Error decoding secret: %v", err)
continue
break
}
}

secretsFound[matches[1]] = true
log.Info().Msg("Found secret in build logs")
if secret == "" {
continue
}

if err := outputClient.Write(owner, repo, workflowFile, run.GetID(), decoded); err != nil {
log.Warn().Msgf("Error writing secret: %v", err)
}
secretsFound[secret] = true
log.Info().Msg("Found secret in build logs")

if err := outputClient.Write(owner, repo, workflowFile, run.GetID(), secret); err != nil {
log.Warn().Msgf("Error writing secret: %v", err)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/output/stdout/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ func PrintSummary(orgScanned map[string]bool, repoScanned map[string]bool, workf
out := fmt.Sprintf("\n=========== Summary ===========\n")
out += fmt.Sprintf("Organizations Scanned: %d\n", len(orgScanned))
for org := range orgScanned {
out += fmt.Sprintf(" - %s\n", org)
out += fmt.Sprintf(" - %s\n", org)
}

out += fmt.Sprintf("Repositories Scanned: %d\n", len(repoScanned))
for repo := range repoScanned {
out += fmt.Sprintf(" - %s\n", repo)
out += fmt.Sprintf(" - %s\n", repo)
}

out += fmt.Sprintf("Workflows Scanned: %d\n", len(workflowScanned))
for workflow := range workflowScanned {
out += fmt.Sprintf(" - %s\n", workflow)
out += fmt.Sprintf(" - %s\n", workflow)
}

out += fmt.Sprintf("Workflow Runs Scanned: %d\n", len(runsScanned))
Expand Down