Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce gosec for Static Application Security Testing (SAST) #394

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ tmp/
.vscode/
.kubeconfig-kind-integration
test/functional/functional.test

# gosec
gosec-report.sarif
37 changes: 24 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
#
# SPDX-License-Identifier: Apache-2.0

ENSURE_GARDENER_MOD := $(shell go get github.com/gardener/gardener@$$(go list -m -f "{{.Version}}" github.com/gardener/gardener))
GARDENER_HACK_DIR := $(shell go list -m -f "{{.Dir}}" github.com/gardener/gardener)/hack
ENSURE_CONTROLLER_MANAGER_LIB_MOD := $(shell go get github.com/gardener/controller-manager-library@$$(go list -m -f "{{.Version}}" github.com/gardener/controller-manager-library))
CONTROLLER_MANAGER_LIB_HACK_DIR := $(shell go list -m -f "{{.Dir}}" github.com/gardener/controller-manager-library)/hack
REGISTRY := europe-docker.pkg.dev/gardener-project/public
EXECUTABLE := dns-controller-manager
REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
HACK_DIR := $(REPO_ROOT)/hack
PROJECT := github.com/gardener/external-dns-management
IMAGE_REPOSITORY := $(REGISTRY)/dns-controller-manager
VERSION := $(shell cat VERSION)
Expand All @@ -17,21 +20,12 @@ IMAGE_TAG := $(VERSION)
#########################################

TOOLS_DIR := hack/tools
GOLANGCI_LINT_VERSION := v1.60.2

include $(CONTROLLER_MANAGER_LIB_HACK_DIR)/tools.mk

HELM := $(TOOLS_BIN_DIR)/helm

HELM_VERSION ?= v3.13.1


$(HELM): $(call tool_version_file,$(HELM),$(HELM_VERSION))
@curl -sSfL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | HELM_INSTALL_DIR=$(TOOLS_BIN_DIR) PATH=$(PATH):$(TOOLS_BIN_DIR) USE_SUDO=false bash -s -- --version $(HELM_VERSION)
include $(GARDENER_HACK_DIR)/tools.mk

.PHONY: tidy
tidy:
@go mod tidy
@cp $(GARDENER_HACK_DIR)/sast.sh $(HACK_DIR)/sast.sh && chmod +xw $(HACK_DIR)/sast.sh

.PHONY: clean
clean:
Expand All @@ -41,8 +35,11 @@ clean:
@rm -f pkg/apis/dns/v1alpha1/zz_generated*

.PHONY: check
check: format $(GOIMPORTS) $(GOLANGCI_LINT)
@TOOLS_BIN_DIR="$(TOOLS_DIR)/bin" bash $(CONTROLLER_MANAGER_LIB_HACK_DIR)/check.sh --golangci-lint-config=./.golangci.yaml ./cmd/... ./pkg/... ./test/...
check: sast-report fastcheck

.PHONY: fastcheck
fastcheck: format $(GOIMPORTS) $(GOLANGCI_LINT)
@TOOLS_BIN_DIR="$(TOOLS_BIN_DIR)" bash $(CONTROLLER_MANAGER_LIB_HACK_DIR)/check.sh --golangci-lint-config=./.golangci.yaml ./cmd/... ./pkg/... ./test/...
@echo "Running go vet..."
@go vet ./cmd/... ./pkg/... ./test/...

Expand Down Expand Up @@ -104,3 +101,17 @@ integrationtests: $(GINKGO)
.PHONY: docker-images
docker-images:
@docker build -t $(IMAGE_REPOSITORY):$(IMAGE_TAG) -f Dockerfile --target dns-controller-manager .

# TODO(martinweindel): Remove once https://github.com/gardener/gardener/pull/10642 is available as release.
TOOLS_PKG_PATH := $(shell go list -tags tools -f '{{ .Dir }}' github.com/gardener/gardener/hack/tools 2>/dev/null)
.PHONY: adjust-install-gosec.sh
adjust-install-gosec.sh:
@chmod +xw $(TOOLS_PKG_PATH)/install-gosec.sh

.PHONY: sast
sast: adjust-install-gosec.sh $(GOSEC)
@./hack/sast.sh

.PHONY: sast-report
sast-report: adjust-install-gosec.sh $(GOSEC)
@./hack/sast.sh --gosec-report true
147 changes: 90 additions & 57 deletions charts/external-dns-management/templates/crds.yaml

Large diffs are not rendered by default.

65 changes: 33 additions & 32 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/gardener/external-dns-management

go 1.22.4
go 1.23.0

toolchain go1.22.5
toolchain go1.23.2

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.12.0
Expand All @@ -14,7 +14,7 @@ require (
github.com/aws/aws-sdk-go v1.44.173
github.com/cloudflare/cloudflare-go v0.11.4
github.com/gardener/controller-manager-library v0.2.1-0.20240816122604-33f686e858cc
github.com/gardener/gardener v1.101.0
github.com/gardener/gardener v1.105.0
github.com/go-openapi/runtime v0.24.1
github.com/go-openapi/strfmt v0.21.2
github.com/gophercloud/gophercloud v0.24.0
Expand All @@ -23,27 +23,27 @@ require (
github.com/joeig/go-powerdns/v3 v3.10.0
github.com/miekg/dns v1.1.58
github.com/netlify/open-api v1.1.0
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.34.0
github.com/prometheus/client_golang v1.18.0
github.com/onsi/ginkgo/v2 v2.20.0
github.com/onsi/gomega v1.34.1
github.com/prometheus/client_golang v1.20.0
go.uber.org/atomic v1.10.0
go.uber.org/automaxprocs v1.5.3
golang.org/x/oauth2 v0.20.0
go.uber.org/automaxprocs v1.6.0
golang.org/x/oauth2 v0.22.0
golang.org/x/sync v0.8.0
golang.org/x/tools v0.24.0
golang.org/x/tools v0.25.0
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2
google.golang.org/api v0.149.0
google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.34.1
istio.io/api v1.22.3
google.golang.org/protobuf v1.34.2
istio.io/api v1.22.5
istio.io/client-go v1.22.0
k8s.io/api v0.29.7
k8s.io/apiextensions-apiserver v0.29.7
k8s.io/apimachinery v0.29.7
k8s.io/client-go v0.29.7
k8s.io/code-generator v0.29.7
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
sigs.k8s.io/controller-runtime v0.17.5
k8s.io/api v0.29.9
k8s.io/apiextensions-apiserver v0.29.9
k8s.io/apimachinery v0.29.9
k8s.io/client-go v0.29.9
k8s.io/code-generator v0.29.9
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6
sigs.k8s.io/controller-runtime v0.17.6
sigs.k8s.io/controller-tools v0.14.0
sigs.k8s.io/gateway-api v1.0.0
sigs.k8s.io/kind v0.18.0
Expand All @@ -54,17 +54,17 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/internal v1.9.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Masterminds/semver/v3 v3.3.0 // indirect
github.com/alessio/shellescape v1.4.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/analysis v0.21.2 // indirect
github.com/go-openapi/errors v0.20.4 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
Expand All @@ -83,7 +83,7 @@ require (
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 // indirect
github.com/google/uuid v1.6.0 // indirect
Expand All @@ -95,11 +95,11 @@ require (
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand All @@ -110,22 +110,23 @@ require (
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.59.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.mongodb.org/mongo-driver v1.8.3 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
golang.org/x/lint v0.0.0-20190930215403-16217165b5de // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.6.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c // indirect
Expand Down
Loading