Skip to content

Commit e7f9376

Browse files
authored
Improve attachment verification failure messages (#44)
1 parent dd5615c commit e7f9376

5 files changed

Lines changed: 272 additions & 278 deletions

File tree

evidence/verify/verifiers/attachment_verifier.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import (
1414
)
1515

1616
const (
17-
attachmentMetadataNotFoundReason = "attachment metadata not found in GraphQL response"
17+
attachmentMetadataNotFoundReason = "attachment not found in Evidence"
18+
attachmentArtifactNotFoundReason = "attachment not found in Artifactory"
19+
checksumMismatchReason = "checksum mismatch"
1820
attachmentMetadataUnavailableReason = "unable to get attachment metadata from GraphQL (query without attachments)"
1921
attachmentVerificationFailedReason = "attachment failed verification"
2022
)
@@ -76,7 +78,7 @@ func (v *attachmentVerifier) verify(evidence *model.SearchEvidenceEdge, result *
7678
fileInfo, fileInfoErr := v.artifactoryClient.FileInfo(actualAttachment.DownloadPath)
7779
if fileInfoErr != nil && isAttachmentNotFoundError(fileInfoErr) {
7880
verification.VerificationStatus = model.Failed
79-
verification.FailureReason = "file not found"
81+
verification.FailureReason = attachmentArtifactNotFoundReason
8082
verifications = append(verifications, verification)
8183
hasFailures = true
8284
continue
@@ -89,7 +91,7 @@ func (v *attachmentVerifier) verify(evidence *model.SearchEvidenceEdge, result *
8991
verification.ActualSha256 = fileInfo.Checksums.Sha256
9092
if verification.ActualSha256 != expected.Sha256 {
9193
verification.VerificationStatus = model.Failed
92-
verification.FailureReason = "checksum mismatch"
94+
verification.FailureReason = checksumMismatchReason
9395
hasFailures = true
9496
}
9597
verifications = append(verifications, verification)

evidence/verify/verifiers/attachment_verifier_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func TestAttachmentVerifier_Verify_FileNotFound404(t *testing.T) {
232232
assert.NoError(t, err)
233233
assert.Equal(t, model.Failed, result.VerificationResult.AttachmentsVerificationStatus)
234234
if assert.Len(t, result.AttachmentsVerification, 1) {
235-
assert.Equal(t, "file not found", result.AttachmentsVerification[0].FailureReason)
235+
assert.Equal(t, attachmentArtifactNotFoundReason, result.AttachmentsVerification[0].FailureReason)
236236
assert.Equal(t, model.Failed, result.AttachmentsVerification[0].VerificationStatus)
237237
}
238238
}

evidence/verify/verifiers/evidence_verifier_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ func TestVerify_AttachmentsVerificationFailsWhenMetadataMissing(t *testing.T) {
375375
verification := (*result.EvidenceVerifications)[0]
376376
assert.Equal(t, model.Failed, verification.VerificationResult.AttachmentsVerificationStatus)
377377
assert.Equal(t, "attachment failed verification", verification.VerificationResult.FailureReason)
378-
assert.Equal(t, "attachment metadata not found in GraphQL response", verification.AttachmentsVerification[0].FailureReason)
378+
assert.Equal(t, attachmentMetadataNotFoundReason, verification.AttachmentsVerification[0].FailureReason)
379379
}
380380

381381
func TestVerify_AttachmentsVerificationReturnsErrorWhenMetadataUnavailableViaFallback(t *testing.T) {

go.mod

Lines changed: 61 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module github.com/jfrog/jfrog-cli-evidence
22

3-
go 1.25.5
3+
go 1.25.7
44

55
require (
66
github.com/distribution/reference v0.6.0
77
github.com/gookit/color v1.6.0
88
github.com/jfrog/build-info-go v1.13.0
9-
github.com/jfrog/froggit-go v1.21.0
9+
github.com/jfrog/froggit-go v1.21.1
1010
github.com/jfrog/gofrog v1.7.6
1111
github.com/jfrog/jfrog-cli-artifactory v0.8.0
1212
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251015045218-1a38c9e47097
@@ -19,18 +19,17 @@ require (
1919
github.com/stretchr/testify v1.11.1
2020
github.com/urfave/cli v1.22.17
2121
go.uber.org/mock v0.6.0
22-
golang.org/x/crypto v0.47.0
22+
golang.org/x/crypto v0.49.0
2323
gopkg.in/yaml.v3 v3.0.1
2424
)
2525

2626
require (
27-
cloud.google.com/go/kms v1.24.0 // indirect
28-
cloud.google.com/go/longrunning v0.8.0 // indirect
27+
cloud.google.com/go/kms v1.26.0 // indirect
2928
dario.cat/mergo v1.0.2 // indirect
3029
github.com/BurntSushi/toml v1.6.0 // indirect
31-
github.com/CycloneDX/cyclonedx-go v0.9.3 // indirect
30+
github.com/CycloneDX/cyclonedx-go v0.10.0 // indirect
3231
github.com/Microsoft/go-winio v0.6.2 // indirect
33-
github.com/ProtonMail/go-crypto v1.3.0 // indirect
32+
github.com/ProtonMail/go-crypto v1.4.1 // indirect
3433
github.com/VividCortex/ewma v1.2.0 // indirect
3534
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
3635
github.com/andybalholm/brotli v1.2.0 // indirect
@@ -41,8 +40,7 @@ require (
4140
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
4241
github.com/cespare/xxhash/v2 v2.3.0 // indirect
4342
github.com/chzyer/readline v1.5.1 // indirect
44-
github.com/clipperhouse/stringish v0.1.1 // indirect
45-
github.com/clipperhouse/uax29/v2 v2.4.0 // indirect
43+
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
4644
github.com/cloudflare/circl v1.6.3 // indirect
4745
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
4846
github.com/cyberphone/json-canonicalization v0.0.0-20241213102144-19d51d7fe467 // indirect
@@ -56,69 +54,69 @@ require (
5654
github.com/fsnotify/fsnotify v1.9.0 // indirect
5755
github.com/gfleury/go-bitbucket-v1 v0.0.0-20240917142304-df385efaac68 // indirect
5856
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
59-
github.com/go-git/go-billy/v5 v5.7.0 // indirect
60-
github.com/go-git/go-git/v5 v5.16.5 // indirect
57+
github.com/go-git/go-billy/v5 v5.8.0 // indirect
58+
github.com/go-git/go-git/v5 v5.17.0 // indirect
6159
github.com/go-logr/logr v1.4.3 // indirect
6260
github.com/go-logr/stdr v1.2.2 // indirect
63-
github.com/go-openapi/analysis v0.24.2 // indirect
64-
github.com/go-openapi/errors v0.22.6 // indirect
65-
github.com/go-openapi/jsonpointer v0.22.4 // indirect
66-
github.com/go-openapi/jsonreference v0.21.4 // indirect
67-
github.com/go-openapi/loads v0.23.2 // indirect
68-
github.com/go-openapi/runtime v0.29.2 // indirect
69-
github.com/go-openapi/spec v0.22.3 // indirect
70-
github.com/go-openapi/strfmt v0.25.0 // indirect
71-
github.com/go-openapi/swag v0.25.4 // indirect
72-
github.com/go-openapi/swag/cmdutils v0.25.4 // indirect
73-
github.com/go-openapi/swag/conv v0.25.4 // indirect
74-
github.com/go-openapi/swag/fileutils v0.25.4 // indirect
75-
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
76-
github.com/go-openapi/swag/jsonutils v0.25.4 // indirect
77-
github.com/go-openapi/swag/loading v0.25.4 // indirect
78-
github.com/go-openapi/swag/mangling v0.25.4 // indirect
79-
github.com/go-openapi/swag/netutils v0.25.4 // indirect
80-
github.com/go-openapi/swag/stringutils v0.25.4 // indirect
81-
github.com/go-openapi/swag/typeutils v0.25.4 // indirect
82-
github.com/go-openapi/swag/yamlutils v0.25.4 // indirect
83-
github.com/go-openapi/validate v0.25.1 // indirect
61+
github.com/go-openapi/analysis v0.25.0 // indirect
62+
github.com/go-openapi/errors v0.22.7 // indirect
63+
github.com/go-openapi/jsonpointer v0.22.5 // indirect
64+
github.com/go-openapi/jsonreference v0.21.5 // indirect
65+
github.com/go-openapi/loads v0.23.3 // indirect
66+
github.com/go-openapi/runtime v0.29.3 // indirect
67+
github.com/go-openapi/spec v0.22.4 // indirect
68+
github.com/go-openapi/strfmt v0.26.1 // indirect
69+
github.com/go-openapi/swag v0.25.5 // indirect
70+
github.com/go-openapi/swag/cmdutils v0.25.5 // indirect
71+
github.com/go-openapi/swag/conv v0.25.5 // indirect
72+
github.com/go-openapi/swag/fileutils v0.25.5 // indirect
73+
github.com/go-openapi/swag/jsonname v0.25.5 // indirect
74+
github.com/go-openapi/swag/jsonutils v0.25.5 // indirect
75+
github.com/go-openapi/swag/loading v0.25.5 // indirect
76+
github.com/go-openapi/swag/mangling v0.25.5 // indirect
77+
github.com/go-openapi/swag/netutils v0.25.5 // indirect
78+
github.com/go-openapi/swag/stringutils v0.25.5 // indirect
79+
github.com/go-openapi/swag/typeutils v0.25.5 // indirect
80+
github.com/go-openapi/swag/yamlutils v0.25.5 // indirect
81+
github.com/go-openapi/validate v0.25.2 // indirect
8482
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
8583
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 // indirect
8684
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
8785
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
8886
github.com/golang/snappy v1.0.0 // indirect
89-
github.com/google/certificate-transparency-go v1.3.2 // indirect
90-
github.com/google/go-containerregistry v0.20.7 // indirect
87+
github.com/google/certificate-transparency-go v1.3.3 // indirect
88+
github.com/google/go-containerregistry v0.21.3 // indirect
9189
github.com/google/go-github/v74 v74.0.0 // indirect
9290
github.com/google/go-querystring v1.2.0 // indirect
9391
github.com/google/uuid v1.6.0 // indirect
94-
github.com/grokify/mogo v0.72.6 // indirect
95-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.5 // indirect
92+
github.com/grokify/mogo v0.74.0 // indirect
93+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirect
9694
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
9795
github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
98-
github.com/in-toto/attestation v1.1.2 // indirect
96+
github.com/in-toto/attestation v1.2.0 // indirect
9997
github.com/in-toto/in-toto-golang v0.10.0 // indirect
10098
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
10199
github.com/jedib0t/go-pretty/v6 v6.7.8 // indirect
102100
github.com/jedisct1/go-minisign v0.0.0-20241212093149-d2f9f49435c7 // indirect
103101
github.com/jfrog/archiver/v3 v3.6.3 // indirect
104-
github.com/kevinburke/ssh_config v1.4.0 // indirect
105-
github.com/klauspost/compress v1.18.3 // indirect
102+
github.com/kevinburke/ssh_config v1.6.0 // indirect
103+
github.com/klauspost/compress v1.18.5 // indirect
106104
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
107105
github.com/klauspost/pgzip v1.2.6 // indirect
108106
github.com/ktrysmt/go-bitbucket v0.9.88 // indirect
109107
github.com/manifoldco/promptui v0.9.0 // indirect
110108
github.com/mattn/go-colorable v0.1.14 // indirect
111109
github.com/mattn/go-isatty v0.0.20 // indirect
112-
github.com/mattn/go-runewidth v0.0.19 // indirect
110+
github.com/mattn/go-runewidth v0.0.21 // indirect
113111
github.com/mattn/go-tty v0.0.7 // indirect
114112
github.com/microsoft/azure-devops-go-api/azuredevops/v7 v7.1.0 // indirect
115113
github.com/minio/sha256-simd v1.0.1 // indirect
116114
github.com/mitchellh/mapstructure v1.5.0 // indirect
117115
github.com/nwaples/rardecode/v2 v2.2.2 // indirect
118-
github.com/oklog/ulid v1.3.1 // indirect
116+
github.com/oklog/ulid/v2 v2.1.1 // indirect
119117
github.com/opencontainers/go-digest v1.0.0 // indirect
120-
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
121-
github.com/pierrec/lz4/v4 v4.1.25 // indirect
118+
github.com/pelletier/go-toml/v2 v2.3.0 // indirect
119+
github.com/pierrec/lz4/v4 v4.1.26 // indirect
122120
github.com/pjbgf/sha1cd v0.5.0 // indirect
123121
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
124122
github.com/pkg/term v1.2.0-beta.2 // indirect
@@ -128,60 +126,51 @@ require (
128126
github.com/sagikazarmark/locafero v0.12.0 // indirect
129127
github.com/sergi/go-diff v1.4.0 // indirect
130128
github.com/shibumi/go-pathspec v1.3.0 // indirect
131-
github.com/sigstore/rekor v1.5.0 // indirect
132-
github.com/sigstore/rekor-tiles/v2 v2.1.0 // indirect
129+
github.com/sigstore/rekor v1.5.1 // indirect
130+
github.com/sigstore/rekor-tiles/v2 v2.2.1 // indirect
133131
github.com/sigstore/sigstore v1.10.4 // indirect
134-
github.com/sigstore/timestamp-authority/v2 v2.0.4 // indirect
132+
github.com/sigstore/timestamp-authority/v2 v2.0.5 // indirect
135133
github.com/skeema/knownhosts v1.3.2 // indirect
136134
github.com/spf13/afero v1.15.0 // indirect
137135
github.com/spf13/cast v1.10.0 // indirect
138136
github.com/spf13/pflag v1.0.10 // indirect
139137
github.com/stretchr/objx v0.5.3 // indirect
140138
github.com/subosito/gotenv v1.6.0 // indirect
141139
github.com/theupdateframework/go-tuf/v2 v2.4.1 // indirect
142-
github.com/transparency-dev/formats v0.0.0-20260119090622-e70c80e9488a // indirect
140+
github.com/transparency-dev/formats v0.1.0 // indirect
143141
github.com/transparency-dev/merkle v0.0.2 // indirect
144142
github.com/ulikunitz/xz v0.5.15 // indirect
145-
github.com/vbauerster/mpb/v8 v8.11.3 // indirect
143+
github.com/vbauerster/mpb/v8 v8.12.0 // indirect
146144
github.com/xanzy/go-gitlab v0.115.0 // indirect
147145
github.com/xanzy/ssh-agent v0.3.3 // indirect
148146
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
149147
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
150-
go.mongodb.org/mongo-driver v1.17.7 // indirect
151148
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
152149
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.64.0 // indirect
153150
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0 // indirect
154-
go.opentelemetry.io/otel v1.39.0 // indirect
155-
go.opentelemetry.io/otel/metric v1.39.0 // indirect
156-
go.opentelemetry.io/otel/trace v1.39.0 // indirect
151+
go.opentelemetry.io/otel v1.42.0 // indirect
152+
go.opentelemetry.io/otel/metric v1.42.0 // indirect
153+
go.opentelemetry.io/otel/trace v1.42.0 // indirect
157154
go.yaml.in/yaml/v3 v3.0.4 // indirect
158-
golang.org/x/exp v0.0.0-20260112195511-716be5621a96 // indirect
159-
golang.org/x/mod v0.32.0 // indirect
160-
golang.org/x/net v0.49.0 // indirect
161-
golang.org/x/oauth2 v0.34.0 // indirect
162-
golang.org/x/sync v0.19.0 // indirect
163-
golang.org/x/sys v0.40.0 // indirect
164-
golang.org/x/term v0.39.0 // indirect
165-
golang.org/x/text v0.33.0 // indirect
166-
golang.org/x/time v0.14.0 // indirect
167-
google.golang.org/api v0.262.0 // indirect
168-
google.golang.org/genproto v0.0.0-20260122232226-8e98ce8d340d // indirect
169-
google.golang.org/genproto/googleapis/api v0.0.0-20260122232226-8e98ce8d340d // indirect
170-
google.golang.org/genproto/googleapis/rpc v0.0.0-20260122232226-8e98ce8d340d // indirect
155+
golang.org/x/exp v0.0.0-20260312153236-7ab1446f8b90 // indirect
156+
golang.org/x/mod v0.34.0 // indirect
157+
golang.org/x/net v0.52.0 // indirect
158+
golang.org/x/oauth2 v0.36.0 // indirect
159+
golang.org/x/sync v0.20.0 // indirect
160+
golang.org/x/sys v0.42.0 // indirect
161+
golang.org/x/term v0.41.0 // indirect
162+
golang.org/x/text v0.35.0 // indirect
163+
golang.org/x/time v0.15.0 // indirect
164+
google.golang.org/genproto/googleapis/api v0.0.0-20260319201613-d00831a3d3e7 // indirect
165+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260319201613-d00831a3d3e7 // indirect
171166
google.golang.org/grpc v1.79.3 // indirect
172167
google.golang.org/protobuf v1.36.11 // indirect
173168
gopkg.in/warnings.v0 v0.1.2 // indirect
169+
k8s.io/klog/v2 v2.140.0 // indirect
174170
)
175171

176172
// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20250529104758-6d769a684388
177173

178174
// replace github.com/jfrog/jfrog-cli-artifactory => github.com/jfrog/jfrog-cli-artifactory v0.3.2-0.20250527103322-0361d8f5612d
179175

180176
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20251008065356-96379eb1add0
181-
182-
// Pin go-bitbucket-v1 to version compatible with froggit-go@v1.20.6
183-
replace github.com/gfleury/go-bitbucket-v1 => github.com/gfleury/go-bitbucket-v1 v0.0.0-20230825095122-9bc1711434ab
184-
185-
// Pin go-bitbucket to v0.9.87 which is compatible with froggit-go@v1.21.0
186-
// v0.9.88 changed NewBasicAuth to return (*Client, error) instead of *Client
187-
replace github.com/ktrysmt/go-bitbucket => github.com/ktrysmt/go-bitbucket v0.9.87

0 commit comments

Comments
 (0)