Skip to content

Commit

Permalink
fix: removing underscore from VulnerabilityReport names (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusfm authored Jun 6, 2024
1 parent 45f595b commit 38efb24
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/worker/vuln.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var vulnReportTypeMeta = metav1.TypeMeta{
APIVersion: v1alpha2.SchemeGroupVersion.String(),
}

var nonAlphanumericRegex = regexp.MustCompile(`\W+`)
var nonAlphanumericRegex = regexp.MustCompile(`[\W|_]+`)

func handleVulnerability(ctx context.Context, cfg *config, results io.Reader, client *zora.Clientset) error {
log := logr.FromContextOrDiscard(ctx)
Expand Down
21 changes: 21 additions & 0 deletions pkg/worker/vuln_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,24 @@ func newTime(s string) *metav1.Time {
}
return &metav1.Time{Time: p}
}

func Test_cleanString(t *testing.T) {
tests := []struct {
name string
arg string
want string
}{
{
name: "ok",
arg: `asdfghjklç"!@#$%¨&*()_+'1234567890-=¬¹²³£¢¬{[]}\§[]{}ªº´~^,.;/<>:?°\|àáãâ`,
want: "asdfghjkl1234567890",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := cleanString(tt.arg); got != tt.want {
t.Errorf("cleanString() = %v, want %v", got, tt.want)
}
})
}
}

0 comments on commit 38efb24

Please sign in to comment.