Skip to content

Commit f3012d3

Browse files
committed
gosec
1 parent fece767 commit f3012d3

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ tidy:
1313

1414
# Run tests
1515
test: tidy fmt vet
16+
gosec ./...
1617
go test ./... -coverprofile=coverage.out
1718
go tool cover -func=coverage.out
1819

@@ -30,3 +31,6 @@ tools:
3031
ifeq (, $(shell which goreleaser))
3132
$(shell go get github.com/goreleaser/goreleaser)
3233
endif
34+
ifeq (, $(shell which gosec))
35+
$(shell go get -u github.com/securego/gosec/v2/cmd/gosec)
36+
endif

cert/cert.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ func Print(targetURL string) error {
4141

4242
// FetchCertificates fetch the certificate chain from te target URL
4343
func FetchCertificates(targetURL string) ([]*x509.Certificate, error) {
44+
// #nosec G402 we are checking the cert, hence we allow insecure ones
45+
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{
46+
InsecureSkipVerify: true,
47+
}
4448

45-
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
46-
49+
// #nosec G107
4750
resp, err := http.Get(targetURL)
4851

4952
if err != nil {

cert/jks/jks.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func exportCerts(certs []*x509.Certificate, targetURL string, certIndexes []int,
3232
var ks keystore.KeyStore
3333
if jksSource != "" {
3434

35+
// #nosec G304
3536
s, err := os.Open(jksSource)
3637
if err != nil {
3738
return err

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ require (
66
github.com/pavel-v-chernykh/keystore-go v2.1.0+incompatible
77
github.com/spf13/cobra v1.2.1
88
github.com/stretchr/testify v1.7.0
9+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
910
)

go.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,9 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
552552
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
553553
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
554554
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
555-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
556555
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
556+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
557+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
557558
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
558559
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
559560
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

0 commit comments

Comments
 (0)