1111# ORY_CONSOLE_API_URL - Console API URL (default: https://api.console.ory.sh)
1212# ORY_PROJECT_API_URL - Project API URL template (default: https://%s.projects.oryapis.com)
1313
14+ SHELL := /bin/bash -o pipefail
1415BINARY_NAME := terraform-provider-orynetwork
1516INSTALL_DIR := ~/.terraform.d/plugins/registry.terraform.io/ory/orynetwork/0.0.1/$(shell go env GOOS) _$(shell go env GOARCH)
1617
18+ # Platform detection for tool downloads
19+ OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
20+ ARCH := $(shell uname -m)
21+ ifeq ($(ARCH ) ,x86_64)
22+ ARCH := amd64
23+ endif
24+ ifeq ($(ARCH ) ,aarch64)
25+ ARCH := arm64
26+ endif
27+
1728.PHONY : help
1829help : # # Show this help
1930 @grep -E ' ^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | sort | awk ' BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
@@ -34,6 +45,12 @@ deps-ci: ## Install dependencies for CI environment
3445 @echo " Installing jq..."
3546 @if command -v apt-get > /dev/null 2>&1 ; then sudo apt-get update && sudo apt-get install -y jq; fi
3647
48+ # Ory CLI for dependency management
49+ .bin/ory :
50+ @mkdir -p .bin
51+ @curl --retry 7 --retry-connrefused -sSfL https://raw.githubusercontent.com/ory/meta/master/install.sh | bash -s -- -d -b .bin ory v0.3.4
52+ @touch -a -m .bin/ory
53+
3754# ==============================================================================
3855# BUILD
3956# ==============================================================================
@@ -55,20 +72,51 @@ clean: ## Remove build artifacts
5572# CODE QUALITY
5673# ==============================================================================
5774
75+ # Code quality tool binaries
76+ .bin/golangci-lint : .deps/golangci-lint.yaml .bin/ory
77+ @VERSION=$$(.bin/ory dev ci deps url -o $(OS ) -a $(ARCH ) -c .deps/golangci-lint.yaml ) ; \
78+ echo " Installing golangci-lint $$ {VERSION}..." ; \
79+ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b .bin $$ {VERSION}
80+
81+ .bin/tfplugindocs : .deps/tfplugindocs.yaml .bin/ory
82+ @mkdir -p .bin
83+ @URL=$$(.bin/ory dev ci deps url -o $(OS ) -a $(ARCH ) -c .deps/tfplugindocs.yaml ) ; \
84+ echo " Downloading tfplugindocs from $$ {URL}..." ; \
85+ curl -sSfL " $$ {URL}" -o /tmp/tfplugindocs.zip; \
86+ unzip -q -o /tmp/tfplugindocs.zip -d .bin tfplugindocs; \
87+ rm /tmp/tfplugindocs.zip; \
88+ chmod +x .bin/tfplugindocs
89+
90+ .bin/go-licenses : .deps/go-licenses.yaml .bin/ory
91+ @VERSION=$$(.bin/ory dev ci deps url -o $(OS ) -a $(ARCH ) -c .deps/go-licenses.yaml ) ; \
92+ echo " Installing go-licenses $$ {VERSION}..." ; \
93+ GOBIN=$(PWD ) /.bin go install github.com/google/go-licenses@$$ {VERSION}
94+
5895.PHONY : format
59- format : # # Format all code (Go, Terraform, modules, docs, lint fixes)
96+ format : .bin/tfplugindocs .bin/golangci-lint # # Format all code (Go, Terraform, modules, docs, lint fixes)
6097 go fmt ./...
6198 gofmt -s -w .
6299 terraform fmt -recursive examples/
63100 go mod tidy
64- @command -v tfplugindocs > /dev/null 2>&1 || { echo " Installing tfplugindocs..." ; go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest; }
65- tfplugindocs generate --provider-name ory
66- @command -v golangci-lint > /dev/null 2>&1 || { echo " Installing golangci-lint v2..." ; go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest; }
67- golangci-lint run --fix ./...
101+ .bin/tfplugindocs generate --provider-name ory
102+ .bin/golangci-lint run --fix ./...
68103
69104.PHONY : lint
70- lint : # # Run Go linter (without fixes)
71- golangci-lint run ./...
105+ lint : .bin/golangci-lint # # Run Go linter (without fixes)
106+ .bin/golangci-lint run ./...
107+
108+ .PHONY : licenses
109+ licenses : .bin/go-licenses # # Check dependency licenses
110+ @# go-licenses has known issues with Go 1.25+ stdlib packages (github.com/google/go-licenses/issues/128)
111+ @# Suppress stderr noise about stdlib, but fail if disallowed licenses are found (exit code 3)
112+ @.bin/go-licenses check ./... --disallowed_types=forbidden,restricted 2> /dev/null; \
113+ EXIT_CODE=$$? ; \
114+ if [ $$ EXIT_CODE -eq 3 ]; then \
115+ echo " ERROR: Disallowed licenses found!" ; \
116+ .bin/go-licenses check ./... --disallowed_types=forbidden,restricted; \
117+ exit 1; \
118+ fi ; \
119+ echo " License check passed"
72120
73121# ==============================================================================
74122# TESTING
@@ -106,6 +154,56 @@ test-acc-all: env-check ## Run all acceptance tests including optional ones
106154 ORY_SCHEMA_TESTS_ENABLED=true \
107155 ./scripts/run-acceptance-tests.sh -p 1 -v -timeout 30m ./...
108156
157+ # ==============================================================================
158+ # SECURITY SCANNING
159+ # ==============================================================================
160+
161+ .PHONY : sec
162+ sec : sec-vuln sec-gosec sec-gitleaks # # Run all security scans
163+
164+ # Security tool binaries
165+ .bin/govulncheck : .deps/govulncheck.yaml .bin/ory
166+ @VERSION=$$(.bin/ory dev ci deps url -o $(OS ) -a $(ARCH ) -c .deps/govulncheck.yaml ) ; \
167+ echo " Installing govulncheck $$ {VERSION}..." ; \
168+ GOBIN=$(PWD ) /.bin go install golang.org/x/vuln/cmd/govulncheck@$$ {VERSION}
169+
170+ .bin/gosec : .deps/gosec.yaml .bin/ory
171+ @mkdir -p .bin
172+ @URL=$$(.bin/ory dev ci deps url -o $(OS ) -a $(ARCH ) -c .deps/gosec.yaml ) ; \
173+ echo " Downloading gosec from $$ {URL}..." ; \
174+ curl -sSfL " $$ {URL}" | tar -xz -C .bin gosec; \
175+ chmod +x .bin/gosec
176+
177+ .bin/gitleaks : .deps/gitleaks.yaml .bin/ory
178+ @mkdir -p .bin
179+ @URL=$$(.bin/ory dev ci deps url -o $(OS ) -a $(ARCH ) -c .deps/gitleaks.yaml ) ; \
180+ echo " Downloading gitleaks from $$ {URL}..." ; \
181+ curl -sSfL " $$ {URL}" | tar -xz -C .bin gitleaks; \
182+ chmod +x .bin/gitleaks
183+
184+ .bin/trivy : .deps/trivy.yaml .bin/ory
185+ @mkdir -p .bin
186+ @URL=$$(.bin/ory dev ci deps url -o $(OS ) -a $(ARCH ) -c .deps/trivy.yaml ) ; \
187+ echo " Downloading trivy from $$ {URL}..." ; \
188+ curl -sSfL " $$ {URL}" | tar -xz -C .bin trivy; \
189+ chmod +x .bin/trivy
190+
191+ .PHONY : sec-vuln
192+ sec-vuln : .bin/govulncheck # # Run govulncheck for Go vulnerability scanning
193+ .bin/govulncheck ./...
194+
195+ .PHONY : sec-gosec
196+ sec-gosec : .bin/gosec # # Run gosec for Go security analysis
197+ .bin/gosec ./...
198+
199+ .PHONY : sec-gitleaks
200+ sec-gitleaks : .bin/gitleaks # # Run gitleaks for secret detection
201+ .bin/gitleaks detect --source . --verbose
202+
203+ .PHONY : sec-trivy
204+ sec-trivy : .bin/trivy build # # Run trivy vulnerability scan on built binary
205+ .bin/trivy fs --scanners vuln,secret,misconfig --severity CRITICAL,HIGH .
206+
109207# ==============================================================================
110208# ENVIRONMENT HELPERS
111209# ==============================================================================
0 commit comments