Skip to content

Commit d55cc27

Browse files
authored
fix: replace deprecated go-acc with integrated coverage tool (#1526)
# Description For the control-plane code go-acc is used for generating coverage report. This module is now archived and uses dependencies with vulnerabilities (e.g. [CVE-2026-33186](GHSA-p77j-4mvh-x3m3) ). ## Action The deprecated dependency is removed and the coverage report generating is reimplemented with the integrated `go tool cover` tool. This PR also resolves issue #1357 by upgrading go-grpc version to 1.79.3. ## Type of Change - [ ] Bugfix - [ ] New Feature - [ ] Breaking Change - [x] Refactor - [ ] Documentation - [ ] Other (please describe) ## Checklist - [x] I have read the [contributing guidelines](/agntcy/repo-template/blob/main/CONTRIBUTING.md) - [x] Existing issues have been referenced (where applicable) - [x] I have verified this change is not present in other open pull requests - [x] Functionality is documented - [x] All code style checks pass - [x] New code contribution is covered by automated tests - [x] All new and existing tests pass --------- Signed-off-by: Mark Marton <mark.p.marton@gmail.com>
1 parent 05f4357 commit d55cc27

5 files changed

Lines changed: 93 additions & 257 deletions

File tree

control-plane/Taskfile.yaml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Copyright AGNTCY Contributors (https://github.com/agntcy)
22
# SPDX-License-Identifier: Apache-2.0
3-
43
---
54
version: "3"
65

@@ -95,20 +94,27 @@ tasks:
9594
control-plane:coverage-reports:
9695
desc: Check test coverage
9796
deps:
98-
- tools:all
97+
- control-plane:test:if-no-coverage-data
98+
vars:
99+
# Returns the .coverage directory path for each module where tests are available.
100+
COVERAGE_LOCS: $(conc=; sep=; for mod in {{.MODULES}}; do if [ -n "$(find "$mod"
101+
-type f -name '*_test.go' 2>/dev/null | head -1)" ]; then
102+
conc="$conc$sep${mod}/.coverage"; sep=,; fi; done; echo "$conc")
99103
cmds:
100104
- task: control-plane:gogen
101-
- task: control-plane:foreach-module
102-
vars:
103-
CMD: |
104-
{{.TOOLS_INSTALL_DIR}}/go-acc --output=$(basename ${dir})-coverage.out ./...
105+
- mkdir -p {{.REPO_ROOT}}/control-plane/.coverage
106+
- go tool covdata textfmt -i={{.COVERAGE_LOCS}} -o
107+
{{.REPO_ROOT}}/control-plane/.coverage/profile
105108

106109
control-plane:coverage:
107110
desc: Show coverage in browser
111+
dir: "{{.REPO_ROOT}}/control-plane/control-plane"
108112
deps:
109113
- control-plane:coverage-reports
114+
vars:
115+
COVERAGE_PROFILE: "{{.REPO_ROOT}}/control-plane/.coverage/profile"
110116
cmds:
111-
- echo find . -name '*coverage.out' -execdir go tool cover -html=./{} \;
117+
- go tool cover -html={{.COVERAGE_PROFILE}}
112118

113119
control-plane:test:
114120
desc: Run go tests
@@ -118,7 +124,22 @@ tasks:
118124
- task: control-plane:gogen
119125
- task: control-plane:foreach-module
120126
vars:
121-
CMD: go test --tags=test -failfast -v 2>&1 ./...
127+
CMD: "mkdir -p $PWD/.coverage && go test --tags=test -failfast -cover -v 2>&1
128+
./... -args -test.gocoverdir=$PWD/.coverage"
129+
130+
control-plane:test:if-no-coverage-data:
131+
internal: true
132+
desc: Run go tests only when no module under MODULES has a .coverage directory
133+
status:
134+
- |
135+
for mod in {{.MODULES}}; do
136+
if [ ! -d "$mod/.coverage" ]; then
137+
exit 1
138+
fi
139+
done
140+
exit 0
141+
cmds:
142+
- task: control-plane:test
122143

123144
control-plane:fetch:
124145
desc: Download go modules
@@ -173,7 +194,6 @@ tasks:
173194
- task: control-plane:control-plane:build
174195
- task: control-plane:token-service:build
175196

176-
177197
# control plane related tasks
178198
control-plane:control-plane:build:
179199
desc: Builds the control plane binary

control-plane/control-plane/internal/util/certificates.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
)
1717

1818
func LoadCertificates(ctx context.Context, apiConfig config.APIConfig) (credentials.TransportCredentials, error) {
19-
2019
zlog := zerolog.Ctx(ctx)
2120

2221
var tlsConfig *tls.Config
@@ -60,17 +59,13 @@ func LoadCertificates(ctx context.Context, apiConfig config.APIConfig) (credenti
6059
}
6160
}
6261

63-
// Add custom verification callback for detailed logging
64-
tlsConfig.VerifyPeerCertificate = func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {
65-
zlog.Debug().Int("cert_count", len(rawCerts)).Msg("Received client certificates")
66-
67-
for i, rawCert := range rawCerts {
68-
cert, err := x509.ParseCertificate(rawCert)
69-
if err != nil {
70-
zlog.Error().Err(err).Int("cert_index", i).Msg("Failed to parse client certificate")
71-
continue
72-
}
62+
// Log peer certs after verification. Use VerifyConnection (not VerifyPeerCertificate) so logging
63+
// still runs when TLS session resumption is used; VerifyPeerCertificate can be skipped on resume (gosec G123).
64+
tlsConfig.VerifyConnection = func(state tls.ConnectionState) error {
65+
certs := state.PeerCertificates
66+
zlog.Debug().Int("cert_count", len(certs)).Msg("Received client certificates")
7367

68+
for i, cert := range certs {
7469
zlog.Debug().
7570
Int("cert_index", i).
7671
Str("subject", cert.Subject.String()).
@@ -80,8 +75,8 @@ func LoadCertificates(ctx context.Context, apiConfig config.APIConfig) (credenti
8075
Time("not_after", cert.NotAfter).
8176
Msg("Client certificate details")
8277
}
83-
// log size of verified chains
84-
zlog.Debug().Int("verified_chain_count", len(verifiedChains)).Msg("Verified certificate chains")
78+
79+
zlog.Debug().Int("verified_chain_count", len(state.VerifiedChains)).Msg("Verified certificate chains")
8580

8681
return nil
8782
}

internal/tools/go.mod

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ go 1.25.5
44

55
require (
66
github.com/golangci/golangci-lint v1.64.8
7-
github.com/ory/go-acc v0.2.8
87
github.com/pavius/impi v0.0.3
98
go.opentelemetry.io/build-tools/multimod v0.29.0
109
golang.org/x/vuln v1.1.4
11-
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1
12-
google.golang.org/protobuf v1.36.10
10+
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.1
11+
google.golang.org/protobuf v1.36.11
1312
)
1413

1514
require (
@@ -21,7 +20,7 @@ require (
2120
github.com/Antonboom/errname v1.0.0 // indirect
2221
github.com/Antonboom/nilnil v1.0.1 // indirect
2322
github.com/Antonboom/testifylint v1.5.2 // indirect
24-
github.com/BurntSushi/toml v1.5.0 // indirect
23+
github.com/BurntSushi/toml v1.6.0 // indirect
2524
github.com/Crocmagnon/fatcontext v0.7.1 // indirect
2625
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
2726
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.1 // indirect
@@ -45,7 +44,7 @@ require (
4544
github.com/butuzov/ireturn v0.3.1 // indirect
4645
github.com/butuzov/mirror v1.3.0 // indirect
4746
github.com/catenacyber/perfsprint v0.8.2 // indirect
48-
github.com/ccojocar/zxcvbn-go v1.0.2 // indirect
47+
github.com/ccojocar/zxcvbn-go v1.0.4 // indirect
4948
github.com/cespare/xxhash/v2 v2.3.0 // indirect
5049
github.com/charithe/durationcheck v0.0.10 // indirect
5150
github.com/chavacava/garif v0.1.0 // indirect
@@ -56,8 +55,6 @@ require (
5655
github.com/daixiang0/gci v0.13.5 // indirect
5756
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
5857
github.com/denis-tingaikin/go-header v0.5.0 // indirect
59-
github.com/dgraph-io/ristretto v0.2.0 // indirect
60-
github.com/dustin/go-humanize v1.0.1 // indirect
6158
github.com/emirpasic/gods v1.18.1 // indirect
6259
github.com/ettle/strcase v0.2.0 // indirect
6360
github.com/fatih/color v1.18.0 // indirect
@@ -77,7 +74,7 @@ require (
7774
github.com/go-toolsmith/astp v1.1.0 // indirect
7875
github.com/go-toolsmith/strparse v1.1.0 // indirect
7976
github.com/go-toolsmith/typep v1.1.0 // indirect
80-
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
77+
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
8178
github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect
8279
github.com/gobwas/glob v0.2.3 // indirect
8380
github.com/gofrs/flock v0.12.1 // indirect
@@ -90,7 +87,6 @@ require (
9087
github.com/golangci/revgrep v0.8.0 // indirect
9188
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect
9289
github.com/google/go-cmp v0.7.0 // indirect
93-
github.com/google/uuid v1.6.0 // indirect
9490
github.com/gordonklaus/ineffassign v0.1.0 // indirect
9591
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
9692
github.com/gostaticanalysis/comment v1.5.0 // indirect
@@ -101,7 +97,6 @@ require (
10197
github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
10298
github.com/hashicorp/go-version v1.7.0 // indirect
10399
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
104-
github.com/hashicorp/hcl v1.0.0 // indirect
105100
github.com/hexops/gotextdiff v1.0.3 // indirect
106101
github.com/inconshreveable/mousetrap v1.1.0 // indirect
107102
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
@@ -125,7 +120,6 @@ require (
125120
github.com/ldez/usetesting v0.4.2 // indirect
126121
github.com/leonklingele/grouper v1.1.2 // indirect
127122
github.com/macabu/inamedparam v0.1.3 // indirect
128-
github.com/magiconair/properties v1.8.10 // indirect
129123
github.com/maratori/testableexamples v1.0.0 // indirect
130124
github.com/maratori/testpackage v1.1.1 // indirect
131125
github.com/matoous/godox v1.1.0 // indirect
@@ -134,20 +128,15 @@ require (
134128
github.com/mattn/go-runewidth v0.0.16 // indirect
135129
github.com/mgechev/revive v1.7.0 // indirect
136130
github.com/mitchellh/go-homedir v1.1.0 // indirect
137-
github.com/mitchellh/mapstructure v1.5.0 // indirect
138131
github.com/moricho/tparallel v0.3.2 // indirect
139132
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
140133
github.com/nakabonne/nestif v0.3.1 // indirect
141134
github.com/nishanths/exhaustive v0.12.0 // indirect
142135
github.com/nishanths/predeclared v0.2.2 // indirect
143136
github.com/nunnatsa/ginkgolinter v0.19.1 // indirect
144137
github.com/olekukonko/tablewriter v0.0.5 // indirect
145-
github.com/ory/viper v1.7.5 // indirect
146-
github.com/pborman/uuid v1.2.1 // indirect
147-
github.com/pelletier/go-toml v1.9.5 // indirect
148-
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
138+
github.com/pelletier/go-toml/v2 v2.3.0 // indirect
149139
github.com/pjbgf/sha1cd v0.5.0 // indirect
150-
github.com/pkg/errors v0.9.1 // indirect
151140
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
152141
github.com/polyfloyd/go-errorlint v1.7.1 // indirect
153142
github.com/prometheus/client_golang v1.22.0 // indirect
@@ -169,7 +158,7 @@ require (
169158
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect
170159
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
171160
github.com/sashamelentyev/usestdlibvars v1.28.0 // indirect
172-
github.com/securego/gosec/v2 v2.22.2 // indirect
161+
github.com/securego/gosec/v2 v2.25.0 // indirect
173162
github.com/sergi/go-diff v1.4.0 // indirect
174163
github.com/sirupsen/logrus v1.9.3 // indirect
175164
github.com/sivchari/containedctx v1.0.3 // indirect
@@ -179,8 +168,7 @@ require (
179168
github.com/sourcegraph/go-diff v0.7.0 // indirect
180169
github.com/spf13/afero v1.15.0 // indirect
181170
github.com/spf13/cast v1.10.0 // indirect
182-
github.com/spf13/cobra v1.10.1 // indirect
183-
github.com/spf13/jwalterweatherman v1.1.0 // indirect
171+
github.com/spf13/cobra v1.10.2 // indirect
184172
github.com/spf13/pflag v1.0.10 // indirect
185173
github.com/spf13/viper v1.21.0 // indirect
186174
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
@@ -211,20 +199,17 @@ require (
211199
go.uber.org/multierr v1.11.0 // indirect
212200
go.uber.org/zap v1.27.0 // indirect
213201
go.yaml.in/yaml/v3 v3.0.4 // indirect
214-
golang.org/x/crypto v0.46.0 // indirect
202+
golang.org/x/crypto v0.50.0 // indirect
215203
golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect
216-
golang.org/x/mod v0.30.0 // indirect
217-
golang.org/x/net v0.48.0 // indirect
218-
golang.org/x/sync v0.19.0 // indirect
219-
golang.org/x/sys v0.39.0 // indirect
220-
golang.org/x/telemetry v0.0.0-20251111182119-bc8e575c7b54 // indirect
221-
golang.org/x/text v0.32.0 // indirect
222-
golang.org/x/tools v0.39.0 // indirect
204+
golang.org/x/mod v0.35.0 // indirect
205+
golang.org/x/net v0.53.0 // indirect
206+
golang.org/x/sync v0.20.0 // indirect
207+
golang.org/x/sys v0.43.0 // indirect
208+
golang.org/x/telemetry v0.0.0-20260409153401-be6f6cb8b1fa // indirect
209+
golang.org/x/text v0.36.0 // indirect
210+
golang.org/x/tools v0.44.0 // indirect
223211
golang.org/x/tools/go/expect v0.1.1-deprecated // indirect
224212
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated // indirect
225-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
226-
google.golang.org/grpc v1.79.3 // indirect
227-
gopkg.in/ini.v1 v1.67.0 // indirect
228213
gopkg.in/warnings.v0 v0.1.2 // indirect
229214
gopkg.in/yaml.v2 v2.4.0 // indirect
230215
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)