Skip to content

Commit 6e95d7d

Browse files
Merge pull request #31 from snyk/feat/human-readable-ostest
feat: DGP-408 - add human-readable output
2 parents f024dc3 + ec80b74 commit 6e95d7d

38 files changed

+2959
-125
lines changed

.golangci.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ linters-settings:
3636
enable-all: true
3737
disable:
3838
- fieldalignment
39-
ireturn:
40-
allow:
41-
- error
42-
- github.com/snyk/go-application-framework/pkg/workflow.Data
4339
lll:
4440
line-length: 160
4541
misspell:
@@ -122,7 +118,8 @@ linters:
122118
- goprintffuncname
123119
- gosec
124120
- interfacebloat
125-
- ireturn
121+
# TODO(ireturn): revisit in a followup; required for the output workflow
122+
#- ireturn
126123
- lll
127124
- misspell
128125
- nakedret
@@ -152,6 +149,11 @@ linters:
152149

153150
issues:
154151
exclude-rules:
152+
- path: internal/legacy/definitions/oapi\.gen\.go
153+
linters:
154+
- godot
155+
- tagliatelle
156+
- wrapcheck
155157
- path: _test\.go
156158
linters:
157159
- bodyclose
@@ -163,4 +165,4 @@ issues:
163165
- testpackage
164166
include:
165167
- EXC0012
166-
- EXC0014
168+
- EXC0014

go.mod

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,20 @@ go 1.23.10
55
toolchain go1.24.1
66

77
require (
8+
github.com/charmbracelet/lipgloss v0.10.0
9+
github.com/gkampitakis/go-snaps v0.5.3
810
github.com/golang/mock v1.6.0
911
github.com/google/uuid v1.6.0
12+
github.com/muesli/termenv v0.15.2
1013
github.com/oapi-codegen/runtime v1.1.1
1114
github.com/rs/zerolog v1.34.0
1215
github.com/snyk/code-client-go v1.21.3
16+
github.com/snyk/error-catalog-golang-public v0.0.0-20250429130542-564b0605020e
1317
github.com/snyk/go-application-framework v0.0.0-20250624132329-67306d427077
1418
github.com/spf13/pflag v1.0.6
1519
github.com/stretchr/testify v1.10.0
1620
golang.org/x/net v0.38.0
21+
golang.org/x/sync v0.13.0
1722
)
1823

1924
require (
@@ -24,14 +29,15 @@ require (
2429
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
2530
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
2631
github.com/cenkalti/backoff/v5 v5.0.2 // indirect
27-
github.com/charmbracelet/lipgloss v0.10.0 // indirect
2832
github.com/cloudflare/circl v1.6.0 // indirect
2933
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
3034
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
3135
github.com/dprotaso/go-yit v0.0.0-20240618133044-5a0af90af097 // indirect
3236
github.com/emirpasic/gods v1.18.1 // indirect
3337
github.com/fsnotify/fsnotify v1.5.4 // indirect
3438
github.com/getkin/kin-openapi v0.131.0 // indirect
39+
github.com/gkampitakis/ciinfo v0.3.0 // indirect
40+
github.com/gkampitakis/go-diff v1.3.2 // indirect
3541
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
3642
github.com/go-git/go-billy/v5 v5.6.2 // indirect
3743
github.com/go-git/go-git/v5 v5.14.0 // indirect
@@ -53,16 +59,18 @@ require (
5359
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
5460
github.com/josharian/intern v1.0.0 // indirect
5561
github.com/kevinburke/ssh_config v1.2.0 // indirect
62+
github.com/kr/pretty v0.3.1 // indirect
63+
github.com/kr/text v0.2.0 // indirect
5664
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
5765
github.com/magiconair/properties v1.8.6 // indirect
5866
github.com/mailru/easyjson v0.9.0 // indirect
67+
github.com/maruel/natural v1.1.1 // indirect
5968
github.com/mattn/go-colorable v0.1.14 // indirect
6069
github.com/mattn/go-isatty v0.0.20 // indirect
6170
github.com/mattn/go-runewidth v0.0.15 // indirect
6271
github.com/mitchellh/mapstructure v1.5.0 // indirect
6372
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
6473
github.com/muesli/reflow v0.3.0 // indirect
65-
github.com/muesli/termenv v0.15.2 // indirect
6674
github.com/oapi-codegen/oapi-codegen/v2 v2.4.1 // indirect
6775
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect
6876
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect
@@ -77,10 +85,10 @@ require (
7785
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
7886
github.com/puzpuzpuz/xsync v1.5.2 // indirect
7987
github.com/rivo/uniseg v0.4.7 // indirect
88+
github.com/rogpeppe/go-internal v1.14.1 // indirect
8089
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect
8190
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
8291
github.com/skeema/knownhosts v1.3.1 // indirect
83-
github.com/snyk/error-catalog-golang-public v0.0.0-20250429130542-564b0605020e // indirect
8492
github.com/snyk/go-httpauth v0.0.0-20231117135515-eb445fea7530 // indirect
8593
github.com/speakeasy-api/jsonpath v0.6.1 // indirect
8694
github.com/speakeasy-api/openapi-overlay v0.10.1 // indirect
@@ -90,6 +98,10 @@ require (
9098
github.com/spf13/jwalterweatherman v1.1.0 // indirect
9199
github.com/spf13/viper v1.13.0 // indirect
92100
github.com/subosito/gotenv v1.4.1 // indirect
101+
github.com/tidwall/gjson v1.17.0 // indirect
102+
github.com/tidwall/match v1.1.1 // indirect
103+
github.com/tidwall/pretty v1.2.1 // indirect
104+
github.com/tidwall/sjson v1.2.5 // indirect
93105
github.com/vmware-labs/yaml-jsonpath v0.3.2 // indirect
94106
github.com/xanzy/ssh-agent v0.3.3 // indirect
95107
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
@@ -98,7 +110,6 @@ require (
98110
golang.org/x/crypto v0.37.0 // indirect
99111
golang.org/x/mod v0.24.0 // indirect
100112
golang.org/x/oauth2 v0.27.0 // indirect
101-
golang.org/x/sync v0.13.0 // indirect
102113
golang.org/x/sys v0.32.0 // indirect
103114
golang.org/x/text v0.24.0 // indirect
104115
golang.org/x/tools v0.31.0 // indirect

go.sum

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ github.com/cloudflare/circl v1.6.0 h1:cr5JKic4HI+LkINy2lg3W2jF8sHCVTBncJr5gIIq7q
2828
github.com/cloudflare/circl v1.6.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
2929
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
3030
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
31+
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
3132
github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s=
3233
github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=
3334
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -204,6 +205,7 @@ github.com/pjbgf/sha1cd v0.3.2 h1:a9wb0bp1oC2TGwStyn0Umc/IGKQnEgF0vVaZ8QF8eo4=
204205
github.com/pjbgf/sha1cd v0.3.2/go.mod h1:zQWigSxVmsHEZow5qaLtPYxpcKMMQpa09ixqBxuCS6A=
205206
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
206207
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
208+
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
207209
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
208210
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
209211
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -215,6 +217,7 @@ github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
215217
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
216218
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
217219
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
220+
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
218221
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
219222
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
220223
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
@@ -269,10 +272,12 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
269272
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
270273
github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs=
271274
github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
275+
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
272276
github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM=
273277
github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
274278
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
275279
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
280+
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
276281
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
277282
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
278283
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=

internal/bundlestore/client.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@ func NewClient(httpClient *http.Client, csConfig CodeClientConfig, cScanner code
6262
}
6363
}
6464

65+
// host returns the appropriate host URL based on configuration.
6566
func (c *HTTPClient) host() string {
6667
if c.CodeClientConfig.IsFedramp() {
6768
return c.SnykApi() + "/hidden/orgs/" + c.CodeClientConfig.Organization() + "/code"
6869
}
6970
return c.SnykCodeApi()
7071
}
7172

73+
// request sends an HTTP request to the bundle store.
7274
func (c *HTTPClient) request(
7375
ctx context.Context,
7476
method string,
@@ -117,6 +119,8 @@ func (c *HTTPClient) request(
117119
return responseBody, nil
118120
}
119121

122+
// createBundle creates a new bundle with the given file hashes.
123+
//
120124
//nolint:gocritic // Code copied verbatim from code-client-go
121125
func (c *HTTPClient) createBundle(ctx context.Context, fileHashes map[string]string) (string, []string, error) {
122126
requestBody, err := json.Marshal(fileHashes)
@@ -137,6 +141,8 @@ func (c *HTTPClient) createBundle(ctx context.Context, fileHashes map[string]str
137141
return bundle.BundleHash, bundle.MissingFiles, nil
138142
}
139143

144+
// extendBundle extends an existing bundle with new or removed files.
145+
//
140146
//nolint:gocritic // Code copied verbatim from code-client-go
141147
func (c *HTTPClient) extendBundle(ctx context.Context, bundleHash string, files map[string]BundleFile, removedFiles []string) (string, []string, error) {
142148
requestBody, err := json.Marshal(ExtendBundleRequest{

0 commit comments

Comments
 (0)