Skip to content
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
4 changes: 4 additions & 0 deletions .github/workflows/flow-build-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ defaults:
run:
shell: bash

permissions:
contents: read
actions: read

jobs:
code:
name: Code
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/flow-pull-request-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ concurrency:
group: pr-checks-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read
actions: read

jobs:
build:
name: Code
Expand All @@ -32,6 +36,15 @@ jobs:
custom-job-label: Check
enable-lint-check: true

vuln-check:
name: Vulnerability Check
uses: ./.github/workflows/zxc-compile-code.yaml
needs:
- build
with:
custom-job-label: Govulncheck
enable-vuln-check: true

unit-tests:
name: Unit Tests
uses: ./.github/workflows/zxc-compile-code.yaml
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/zxc-code-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ defaults:
permissions:
contents: read
actions: read
pull-requests: write
checks: write
statuses: write

jobs:
analyze:
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/zxc-compile-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ on:
type: boolean
required: false
default: false
enable-vuln-check:
description: "Go Vulnerability Check Enabled"
type: boolean
required: false
default: false
enable-docker-build:
description: "Docker Build Enabled"
type: boolean
Expand All @@ -41,12 +46,8 @@ defaults:
shell: bash

permissions:
id-token: write
contents: read
actions: read
pull-requests: write
checks: write
statuses: write

env:
KIND_NODE_IMAGE: kindest/node:v1.32.2@sha256:142f543559cc55d64e1ab9341df08e5ced84bd2e893736da8f51320f26f5950b
Expand Down Expand Up @@ -93,6 +94,10 @@ jobs:
if: ${{ inputs.enable-lint-check && !cancelled() && !failure() }}
run: task lint

- name: Vulnerability Check
if: ${{ inputs.enable-vuln-check && !cancelled() && !failure() }}
run: task vuln

- name: Unit Tests
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
run: task test:unit
Expand Down
20 changes: 20 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,32 @@ linters:
- misspell
- unconvert
- gocritic
- gosec
exclusions:
rules:
- path: _test\.go
linters:
- errcheck
- unused
- gosec
- path: ^test/
linters:
- gosec
# Operator-supplied CLI/config paths; UC reads are O_NOFOLLOW-hardened
- path: ^internal/(beacon|uc)/
linters:
- gosec
text: "G304"
# math/rand only orders registry candidates
- path: ^internal/controller/
linters:
- gosec
text: "G404"
# Reason code name, not a credential
- path: ^internal/registry/reasons\.go
linters:
- gosec
text: "G101"
# Ignore deprecated Requeue field - it's still commonly used in controller-runtime
- linters:
- staticcheck
Expand Down
13 changes: 13 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ tasks:
cmds:
- golangci-lint run --timeout=5m

vuln:
desc: Scan for reachable Go vulnerabilities (govulncheck)
deps: [ tools:govulncheck ]
cmds:
- govulncheck ./...

lint:fix:
desc: Run linters and fix issues
deps: [ tools:golangci-lint ]
Expand Down Expand Up @@ -522,6 +528,7 @@ tasks:
- task: tools:controller-gen
- task: tools:setup-envtest
- task: tools:golangci-lint
- task: tools:govulncheck
- task: tools:yq

# Pinned (not @latest): controller-gen output must be deterministic so
Expand All @@ -546,6 +553,12 @@ tasks:
- task: tools:install
vars: { BIN: golangci-lint, PKG: github.com/golangci/golangci-lint/v2/cmd/golangci-lint, MOD: github.com/golangci/golangci-lint/v2, VER: v2.14.0 }

tools:govulncheck:
internal: true
cmds:
- task: tools:install
vars: { BIN: govulncheck, PKG: golang.org/x/vuln/cmd/govulncheck, MOD: golang.org/x/vuln, VER: v1.9.0 }

tools:yq:
internal: true
cmds:
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/networkupgradeprepare_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ func (r *NetworkUpgradePrepareReconciler) targetsBySelector(
common.Debug(ctx, operatorv1alpha1.ReasonPrefetchCreated).
Msg("Using pod-node targeting: consensus nodeSelector matched no nodes")
return nil, false
case int32(len(candidateNodes)) > maxNodes:
case len(candidateNodes) > int(maxNodes):
// Genuine degradation: the matched pool is larger than the cap, so we
// cannot cache on every node the pod could reschedule onto. Surface it.
common.Warn(ctx, operatorv1alpha1.ReasonPrefetchCreated).
Expand Down
2 changes: 1 addition & 1 deletion internal/uc/cr_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s *CRStore) Persist(operationID, step string, cr *unstructured.Unstructure
// Write atomically: write a temp file then rename, so a crash mid-write can
// never leave a truncated CR on disk that recovery would try to re-send.
tmp := path + ".tmp"
if err := os.WriteFile(tmp, data, 0o640); err != nil {
if err := os.WriteFile(tmp, data, 0o600); err != nil {
return "", errx.WithHints(
errx.WithReason(errPersist.Wrap(err, "write CR %s", tmp), ReasonCRPersistWriteFailed),
"Confirm --cr-persist-path is on a writable volume with free space",
Expand Down
2 changes: 1 addition & 1 deletion internal/uc/log_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (m *LogMonitor) persist(code int32, name string) {
if err != nil {
return
}
_ = os.WriteFile(m.persistPath, data, 0o644)
_ = os.WriteFile(m.persistPath, data, 0o600)
}

// LogFileMtime returns the mtime of the configured consensus log file in unix
Expand Down
Loading