diff --git a/.golangci.yaml b/.golangci.yaml index f31b2d4..6c56923 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -108,7 +108,7 @@ linters: - gomoddirectives - gomodguard - goprintffuncname - # - gosec + - gosec - grouper - importas - interfacebloat diff --git a/common/repository.go b/common/repository.go index a925e2e..adf7dc0 100644 --- a/common/repository.go +++ b/common/repository.go @@ -1,12 +1,7 @@ package common import ( - "crypto/sha1" - "fmt" "net/url" - "strings" - - log "github.com/sirupsen/logrus" ) // Repository is a single code repository. FileRawURL contains the direct url to the raw file. @@ -19,30 +14,3 @@ type Repository struct { Publisher Publisher Headers map[string]string } - -// generateID generates a hash based on unique git repo URL. -func (repo *Repository) GenerateID() string { - hash := sha1.New() - _, err := hash.Write([]byte(repo.URL.String())) - if err != nil { - log.Errorf("Error generating the repository hash: %+v", err) - - return "" - } - - return fmt.Sprintf("%x", hash.Sum(nil)) -} - -// generateSlug generates a readable unique string based on repository name. -func (repo *Repository) GenerateSlug() string { - vendorAndName := strings.ReplaceAll(repo.Name, "/", "-") - vendorAndName = strings.ReplaceAll(vendorAndName, ".", "_") - - if repo.Publisher.Id == "" { - ID := repo.GenerateID() - - return fmt.Sprintf("%s-%s", vendorAndName, ID[0:6]) - } - - return fmt.Sprintf("%s-%s", repo.Publisher.Id, vendorAndName) -} diff --git a/metrics/prometheus.go b/metrics/prometheus.go index ff78410..93a3a25 100644 --- a/metrics/prometheus.go +++ b/metrics/prometheus.go @@ -66,7 +66,7 @@ func RegisterPrometheusCounter(name, helpText, namespace string) { func StartPrometheusMetricsServer() { http.Handle("/metrics", promhttp.Handler()) - err := http.ListenAndServe(":8081", nil) + err := http.ListenAndServe(":8081", nil) //nolint:gosec if err != nil { log.Warningf("monitoring endpoint non available: %v: ", err) } diff --git a/scanner/github.go b/scanner/github.go index e6fd6e9..27691b9 100644 --- a/scanner/github.go +++ b/scanner/github.go @@ -200,7 +200,7 @@ func secondaryRateLimit(err *github.AbuseRateLimitError) { if err.RetryAfter != nil { duration = *err.RetryAfter } else { - duration = time.Duration(rand.Intn(100)) * time.Second + duration = time.Duration(rand.Intn(100)) * time.Second //nolint:gosec } log.Infof("GitHub secondary rate limit hit, for %s", duration)