Skip to content
Merged
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
10 changes: 3 additions & 7 deletions pkg/engine/toolname.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package engine

import (
"crypto/md5"
"encoding/hex"
"path/filepath"
"regexp"
"strings"
Expand All @@ -21,20 +19,18 @@ func ToolNormalizer(tool string) string {
if strings.HasSuffix(tool, system.Suffix) {
tool = strings.TrimSuffix(tool, filepath.Ext(tool))
}
tool = strings.TrimPrefix(tool, "sys.")

if validToolName.MatchString(tool) {
return tool
}

name := invalidChars.ReplaceAllString(tool, "-")
name := invalidChars.ReplaceAllString(tool, "_")
if len(name) > 55 {
name = name[:55]
}

hash := md5.Sum([]byte(tool))
hexed := hex.EncodeToString(hash[:])

return name + "-" + hexed[:8]
return name
}

func PickToolName(toolName string, existing map[string]struct{}) string {
Expand Down