Skip to content

Commit

Permalink
chore: staticcheck results modify (#45)
Browse files Browse the repository at this point in the history
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
  • Loading branch information
testwill committed Jun 26, 2023
1 parent aafc46f commit c887a0b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions pkg/adapter/anchore/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"encoding/json"
"errors"
"fmt"
log "github.com/sirupsen/logrus"
"net/http"
"regexp"
"strings"
"time"

log "github.com/sirupsen/logrus"

"github.com/anchore/harbor-scanner-adapter/pkg/adapter"
"github.com/anchore/harbor-scanner-adapter/pkg/adapter/anchore/client"
"github.com/anchore/harbor-scanner-adapter/pkg/model/anchore"
Expand Down Expand Up @@ -282,7 +283,7 @@ func (s *HarborScannerAdapter) GetHarborVulnerabilityReport(scanId string, inclu
DescriptionCache.Add(cacheKeyForVuln(&desc), desc.Description)
}

descriptionTime := time.Now().Sub(start)
descriptionTime := time.Since(start)
log.WithFields(log.Fields{"duration": descriptionTime}).Debug("time to get descriptions")
} else {
log.Debug("Skipping vuln description merge, as dictated by configuration")
Expand Down
2 changes: 1 addition & 1 deletion pkg/adapter/anchore/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func unmarshalError(body []byte, response gorequest.Response) (anchore.Error, er
result.Detail["instance"] = jsonError.Instance
result.Detail["status"] = jsonError.Status
return result, nil
} else if body != nil && len(body) > 0 {
} else if len(body) > 0 {
// Try to unmarshal an anchore error
err := json.Unmarshal(body, &result)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/adapter/anchore/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package anchore
import (
"encoding/json"
"fmt"
"github.com/anchore/harbor-scanner-adapter/pkg/adapter/anchore/client"
log "github.com/sirupsen/logrus"
"io/ioutil"
"net"
"os"
"strconv"
"strings"

"github.com/anchore/harbor-scanner-adapter/pkg/adapter/anchore/client"
log "github.com/sirupsen/logrus"
)

type AdapterConfig struct {
Expand Down Expand Up @@ -173,7 +173,7 @@ func GetConfig() (AdapterConfig, error) {

if path, ok := os.LookupEnv(AuthConfigFile); ok {
log.Printf("Using config file at %v", path)
content, err := ioutil.ReadFile(path)
content, err := os.ReadFile(path)
if err != nil {
log.Error("error reading config file")
return cfg, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/http/api/v1/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (h *APIHandler) CreateScan(res http.ResponseWriter, req *http.Request) {

func (h *APIHandler) GetScanReport(res http.ResponseWriter, req *http.Request) {
vars := mux.Vars(req)
scanId, _ := vars["scanId"]
scanId := vars["scanId"]

requestedTypes := req.Header[AcceptHeader]
numTypes := len(requestedTypes)
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/harbor/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestMarshalJSON(t *testing.T) {
t.Fail()
}

if strings.Index(string(s), "High") == -1 {
if !strings.Contains(string(s), "High") {
log.Printf("Incorrect marshalling: %v", string(s))
t.Fail()
}
Expand Down

0 comments on commit c887a0b

Please sign in to comment.