Skip to content

Commit a6dcde6

Browse files
Add client-side discovery API (#37)
* chore: update cmw v0.1.0 -> v0.2.0 Signed-off-by: Thomas Fossati <[email protected]> * feat(verification): add discovery client Signed-off-by: Thomas Fossati <[email protected]> * chore(ci): refresh Signed-off-by: Thomas Fossati <[email protected]> * feat(challengeresponse): add StaticEvidenceBuilder StaticEvidenceBuilder is a simple EvidenceBuilder that always returns the same static evidence and media type. This is can be used when the evidence is already available and does not need to be dynamically generated (RP mode) or for testing purposes. Signed-off-by: Thomas Fossati <[email protected]> --------- Signed-off-by: Thomas Fossati <[email protected]>
1 parent ab8774e commit a6dcde6

File tree

15 files changed

+545
-124
lines changed

15 files changed

+545
-124
lines changed

.github/workflows/ci-go-cover.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# 2. Update README.md to use the new path to badge.svg because the path includes the workflow name.
1616

1717
name: cover ≥82.9%
18-
on: [push]
18+
on: [push, pull_request]
1919
jobs:
2020

2121
# Verify minimum coverage is reached using `go test -short -cover` on latest-ubuntu with default version of Go.
@@ -24,8 +24,11 @@ jobs:
2424
name: Coverage
2525
runs-on: ubuntu-latest
2626
steps:
27+
- uses: actions/setup-go@v5
28+
with:
29+
go-version: "1.23.0"
2730
- name: Checkout code
28-
uses: actions/checkout@v2
31+
uses: actions/checkout@v4
2932
- name: Go Coverage
3033
run: |
3134
go version

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
# GitHub Actions - CI for Go to build & test. See ci-go-cover.yml and linters.yml for code coverage and linters.
22
# Taken from: https://github.com/fxamacker/cbor/workflows/ci.yml (thanks!)
33
name: ci
4-
on: [push]
4+
on: [push, pull_request]
55
jobs:
66

77
# Test on Ubuntu
88
tests:
99
name: Test on Ubuntu
1010
runs-on: ubuntu-latest
1111
steps:
12+
- uses: actions/setup-go@v5
13+
with:
14+
go-version: "1.23.0"
1215
- name: Checkout code
13-
uses: actions/checkout@v1
16+
uses: actions/checkout@v4
1417
with:
1518
fetch-depth: 1
1619
- name: Run tests
1720
run: |
1821
go version
19-
make test
22+
make test

.github/workflows/linters.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
# Go Linters - GitHub Actions
22
name: linters
3-
on: [push]
3+
on: [push, pull_request]
44
jobs:
55

66
# Check linters on latest-ubuntu with default version of Go.
77
lint:
88
name: Lint
99
runs-on: ubuntu-latest
10-
env:
11-
GO111MODULE: on
1210
steps:
13-
- name: Setup go
14-
uses: actions/setup-go@v3
11+
- uses: actions/setup-go@v3
1512
with:
16-
go-version: "1.19"
13+
go-version: "1.23"
1714
- name: Checkout code
1815
uses: actions/checkout@v2
1916
- name: Install golangci-lint
2017
run: |
2118
go version
22-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.48.0
19+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.1.6
2320
- name: Run required linters in .golangci.yml plus hard-coded ones here
2421
run: make -w GOLINT=$(go env GOPATH)/bin/golangci-lint lint
25-
- name: Run optional linters (not required to pass)
26-
run: make GOLINT=$(go env GOPATH)/bin/golangci-lint lint-extra

.golangci.yml

Lines changed: 67 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,69 @@
11
# Do not delete linter settings. Linters like gocritic can be enabled on the command line.
22

3-
linters-settings:
4-
dupl:
5-
threshold: 100
6-
funlen:
7-
lines: 100
8-
statements: 50
9-
goconst:
10-
min-len: 2
11-
min-occurrences: 3
12-
gocritic:
13-
enabled-tags:
14-
- diagnostic
15-
- experimental
16-
- opinionated
17-
- performance
18-
- style
19-
disabled-checks:
20-
- dupImport # https://github.com/go-critic/go-critic/issues/845
21-
- ifElseChain
22-
- octalLiteral
23-
- paramTypeCombine
24-
- whyNoLint
25-
- wrapperFunc
26-
gofmt:
27-
simplify: false
28-
goimports:
29-
golint:
30-
min-confidence: 0
31-
govet:
32-
check-shadowing: true
33-
lll:
34-
line-length: 140
35-
maligned:
36-
suggest-new: true
37-
misspell:
38-
locale: US
39-
40-
linters:
41-
disable-all: true
3+
formatters:
424
enable:
43-
- deadcode
44-
- errcheck
45-
- goconst
46-
- gocyclo
475
- gofmt
486
- goimports
49-
- golint
50-
- gosec
51-
- govet
52-
- ineffassign
53-
- maligned
54-
- misspell
55-
- staticcheck
56-
- structcheck
57-
- typecheck
58-
- unconvert
59-
- unused
60-
- varcheck
7+
settings:
8+
gofmt:
9+
simplify: false
6110

11+
linters:
12+
default: none
13+
enable:
14+
- dupl # style
15+
- errcheck # bugs
16+
- funlen # complexity
17+
- goconst # style
18+
- gocritic # metalinter
19+
- gocyclo # complexity
20+
- gosec # bugs
21+
- govet # bugs
22+
- ineffassign
23+
- lll # style
24+
- misspell # comment
25+
- staticcheck # metalinter
26+
- unconvert # style
27+
- unused # unused
28+
exclusions:
29+
rules:
30+
- path: '(.+)_test\.go'
31+
linters:
32+
- dupl
33+
- funlen
34+
- lll
35+
- goconst
36+
settings:
37+
dupl:
38+
threshold: 100
39+
funlen:
40+
lines: 100
41+
statements: 50
42+
goconst:
43+
min-len: 2
44+
min-occurrences: 3
45+
gocritic:
46+
enabled-tags:
47+
- diagnostic
48+
- experimental
49+
- opinionated
50+
- performance
51+
- style
52+
disabled-checks:
53+
- dupImport # https://github.com/go-critic/go-critic/issues/845
54+
- ifElseChain
55+
- octalLiteral
56+
- paramTypeCombine
57+
- whyNoLint
58+
- wrapperFunc
59+
- hugeParam
60+
govet:
61+
enable:
62+
- shadow
63+
lll:
64+
line-length: 140
65+
misspell:
66+
locale: US
6267

6368
issues:
6469
# max-issues-per-linter default is 50. Set to 0 to disable limit.
@@ -72,14 +77,16 @@ issues:
7277
- goconst
7378
- dupl
7479
- gomnd
75-
- lll
80+
- lll
7681
- path: doc\.go
7782
linters:
7883
- goimports
7984
- gomnd
8085
- lll
86+
- path: psatoken_fuzz_test.go
87+
linters:
88+
# the Fuzz function is only invoked by go-fuzz, therefore golangci will
89+
# see it as unused
90+
- unused
8191

82-
# golangci.com configuration
83-
# https://github.com/golangci/golangci/wiki/Configuration
84-
service:
85-
golangci-lint-version: 1.23.x # use the fixed version to not introduce new linters unexpectedly
92+
version: "2"

auth/tls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func NewTLSTransport(certPaths []string) (*http.Transport, error) {
1919
}
2020

2121
for _, certPath := range certPaths {
22-
rawCert, err := os.ReadFile(certPath)
22+
rawCert, err := os.ReadFile(certPath) // nolint: gosec
2323
if err != nil {
2424
return nil, fmt.Errorf("could not read cert: %w", err)
2525
}

common/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func ResolveReference(baseURI, referenceURI string) (string, error) {
4343
}
4444

4545
func DecodeJSONBody(res *http.Response, j interface{}) error {
46-
defer res.Body.Close()
46+
defer res.Body.Close() // nolint: errcheck
4747

4848
return json.NewDecoder(res.Body).Decode(&j)
4949
}

go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
module github.com/veraison/apiclient
22

3-
go 1.19
3+
go 1.23.0
44

55
require (
66
github.com/google/uuid v1.3.0
77
github.com/mitchellh/mapstructure v1.5.0
88
github.com/moogar0880/problems v0.1.1
9-
github.com/stretchr/testify v1.8.2
10-
github.com/veraison/cmw v0.1.0
9+
github.com/stretchr/testify v1.10.0
10+
github.com/veraison/cmw v0.2.0
11+
golang.org/x/oauth2 v0.11.0
1112
)
1213

1314
require (
1415
github.com/davecgh/go-spew v1.1.1 // indirect
15-
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
16+
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
1617
github.com/golang/protobuf v1.5.3 // indirect
1718
github.com/pmezard/go-difflib v1.0.0 // indirect
1819
github.com/x448/float16 v0.8.4 // indirect
19-
golang.org/x/net v0.14.0 // indirect
20-
golang.org/x/oauth2 v0.11.0 // indirect
20+
golang.org/x/net v0.21.0 // indirect
2121
google.golang.org/appengine v1.6.7 // indirect
2222
google.golang.org/protobuf v1.31.0 // indirect
2323
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
21
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
32
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88=
5-
github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
3+
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
4+
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
65
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
76
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
87
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
98
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
109
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
10+
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
11+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1112
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
1213
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
1314
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
@@ -16,21 +17,16 @@ github.com/moogar0880/problems v0.1.1 h1:bktLhq8NDG/czU2ZziYNigBFksx13RaYe5AVdNm
1617
github.com/moogar0880/problems v0.1.1/go.mod h1:5Dxrk2sD7BfBAgnOzQ1yaTiuCYdGPUh49L8Vhfky62c=
1718
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1819
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
19-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
20-
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
21-
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
22-
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
23-
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
24-
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
25-
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
26-
github.com/veraison/cmw v0.1.0 h1:vD6tBlGPROCW/HlDcG1jh+XUJi5ihrjXatKZBjrv8mU=
27-
github.com/veraison/cmw v0.1.0/go.mod h1:WoBrlgByc6C1FeHhdze1/bQx1kv5d1sWKO5ezEf4Hs4=
20+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
21+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
22+
github.com/veraison/cmw v0.2.0 h1:BWEvwZnD4nn5osq6XwQpTRcGxwV+Su4t6ytdAbVXAJY=
23+
github.com/veraison/cmw v0.2.0/go.mod h1:OiYKk1t6/Fmmg30ZpSMzi4nKr5kt3374sNTkgxC5BDs=
2824
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
2925
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
3026
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
3127
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
32-
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
33-
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
28+
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
29+
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
3430
golang.org/x/oauth2 v0.11.0 h1:vPL4xzxBM4niKCW6g9whtaWVXTJf1U5e4aZxxFx/gbU=
3531
golang.org/x/oauth2 v0.11.0/go.mod h1:LdF7O/8bLR/qWK9DrpXmbHLTouvRHK0SgJl0GmDBchk=
3632
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -46,6 +42,5 @@ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs
4642
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
4743
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
4844
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
49-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
5045
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
5146
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

provisioning/provisioning.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,10 @@ func (cfg SubmitConfig) Run(endorsement []byte, mediaType string) error {
128128
// see whether the server is handling our request synchronously or not
129129
// (sync)
130130
if res.StatusCode == http.StatusOK {
131-
if j.Status == common.APIStatusSuccess {
131+
switch j.Status {
132+
case common.APIStatusSuccess:
132133
return nil
133-
} else if j.Status == common.APIStatusFailed {
134+
case common.APIStatusFailed:
134135
s := "submission failed"
135136
if j.FailureReason != nil {
136137
s += fmt.Sprintf(": %s", *j.FailureReason)

0 commit comments

Comments
 (0)