Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1894 Only limit scan name if it is too long
Browse files Browse the repository at this point in the history
The function to generate scan names trims the name if it is too long,
during tests I had it happen that it was short enough and then the
program crashes with a panic because the index is out of range. This
checks the length before to prevent the panic.

Signed-off-by: Lukas Fischer <lukas.fischer@iteratec.com>
Lukas Fischer committed Sep 22, 2023
1 parent d0b38b7 commit a45cce0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions auto-discovery/cloud-aws/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
@@ -314,8 +314,12 @@ func getScanName(req Request, name string) string {
result = strings.ReplaceAll(result, ".", "-")
result = strings.ReplaceAll(result, "/", "-")

//limit scan name length to kubernetes limits
return result[:62]
// limit scan name length to kubernetes limits
if len(result) > 62 {
result = result[:62]
}

return result
}

func GetClient() (client.Client, string, error) {

0 comments on commit a45cce0

Please sign in to comment.