Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 555beaa

Browse files
cdupuiskipz
authored andcommitted
Add username and password
1 parent ee56287 commit 555beaa

3 files changed

Lines changed: 24 additions & 10 deletions

File tree

docker/ops.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package docker
22

33
import (
44
"github.com/docker/distribution/reference"
5-
"github.com/docker/index-cli-plugin/sbom"
5+
"github.com/docker/index-cli-plugin/lsp"
66
"github.com/moby/buildkit/frontend/dockerfile/parser"
77

88
//"reflect"
@@ -53,7 +53,7 @@ func parse_uri(s string) (Reference, error) {
5353
return Reference{Path: path, Domain: domain, Tag: tag, Digest: digest}, err
5454
}
5555

56-
func generate_sbom(message *babashka.Message, s string) error {
56+
func generate_sbom(message *babashka.Message, image string, username string, password string) error {
5757
tx_channel := make(chan string)
5858

5959
go func() error {
@@ -72,7 +72,13 @@ func generate_sbom(message *babashka.Message, s string) error {
7272
return nil
7373
}()
7474

75-
return sbom.Send(s, tx_channel)
75+
l := lsp.New()
76+
77+
if username != "" && password != "" {
78+
l.WithAuth(username, password)
79+
}
80+
81+
return l.Send(image, tx_channel)
7682
}
7783

7884
func generate_hashes(message *babashka.Message, s string) error {
@@ -94,7 +100,7 @@ func generate_hashes(message *babashka.Message, s string) error {
94100
return nil
95101
}()
96102

97-
return sbom.SendFileHashes(s, tx_channel)
103+
return lsp.New().SendFileHashes(s, tx_channel)
98104
}
99105

100106
func ProcessMessage(message *babashka.Message) (any, error) {
@@ -173,8 +179,8 @@ func ProcessMessage(message *babashka.Message) (any, error) {
173179
if err := json.Unmarshal([]byte(message.Args), &args); err != nil {
174180
return nil, err
175181
}
176-
177-
err := generate_sbom(message, args[0])
182+
// TODO add username and password to inbound message
183+
err := generate_sbom(message, args[0], "", "")
178184
if err != nil {
179185
babashka.WriteErrorResponse(message, err)
180186
}

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.19
44

55
require (
66
github.com/docker/distribution v2.8.1+incompatible
7+
github.com/docker/index-cli-plugin v0.0.33-0.20230203084141-88bf36ae38c6
78
github.com/jackpal/bencode-go v1.0.0
89
github.com/moby/buildkit v0.10.6
910
)
@@ -27,7 +28,7 @@ require (
2728
github.com/Masterminds/semver/v3 v3.1.1 // indirect
2829
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
2930
github.com/Microsoft/go-winio v0.5.2 // indirect
30-
github.com/Microsoft/hcsshim v0.9.4 // indirect
31+
github.com/Microsoft/hcsshim v0.9.5 // indirect
3132
github.com/ProtonMail/go-crypto v0.0.0-20220824120805-4b6e5c587895 // indirect
3233
github.com/acobaugh/osrelease v0.1.0 // indirect
3334
github.com/acomagu/bufpipe v1.0.3 // indirect
@@ -48,7 +49,7 @@ require (
4849
github.com/cespare/xxhash/v2 v2.1.2 // indirect
4950
github.com/cloudflare/circl v1.1.0 // indirect
5051
github.com/containerd/cgroups v1.0.4 // indirect
51-
github.com/containerd/containerd v1.6.8 // indirect
52+
github.com/containerd/containerd v1.6.12 // indirect
5253
github.com/containerd/continuity v0.3.0 // indirect
5354
github.com/containerd/fifo v1.0.0 // indirect
5455
github.com/containerd/stargz-snapshotter/estargz v0.12.0 // indirect
@@ -66,7 +67,6 @@ require (
6667
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
6768
github.com/docker/go-metrics v0.0.1 // indirect
6869
github.com/docker/go-units v0.5.0 // indirect
69-
github.com/docker/index-cli-plugin v0.0.27-0.20230104225926-3eb6de3c7d6b // indirect
7070
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
7171
github.com/dustin/go-humanize v1.0.0 // indirect
7272
github.com/ekzhu/minhash-lsh v0.0.0-20171225071031-5c06ee8586a1 // indirect
@@ -116,7 +116,7 @@ require (
116116
github.com/mattn/go-colorable v0.1.13 // indirect
117117
github.com/mattn/go-isatty v0.0.16 // indirect
118118
github.com/mattn/go-runewidth v0.0.13 // indirect
119-
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
119+
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
120120
github.com/mholt/archiver/v3 v3.5.1 // indirect
121121
github.com/microsoft/go-rustaudit v0.0.0-20220730194248-4b17361d90a5 // indirect
122122
github.com/miekg/pkcs11 v1.1.1 // indirect

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ github.com/Microsoft/hcsshim v0.8.23/go.mod h1:4zegtUJth7lAvFyc6cH2gGQ5B3OFQim01
126126
github.com/Microsoft/hcsshim v0.9.2/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc=
127127
github.com/Microsoft/hcsshim v0.9.4 h1:mnUj0ivWy6UzbB1uLFqKR6F+ZyiDc7j4iGgHTpO+5+I=
128128
github.com/Microsoft/hcsshim v0.9.4/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc=
129+
github.com/Microsoft/hcsshim v0.9.5 h1:AbV+VPfTrIVffukazHcpxmz/sRiE6YaMDzHWR9BXZHo=
130+
github.com/Microsoft/hcsshim v0.9.5/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc=
129131
github.com/Microsoft/hcsshim/test v0.0.0-20201218223536-d3e5debf77da/go.mod h1:5hlzMzRKMLyo42nCZ9oml8AdTlq/0cvIaBv6tK1RehU=
130132
github.com/Microsoft/hcsshim/test v0.0.0-20210227013316-43a75bb4edd3/go.mod h1:mw7qgWloBUl75W/gVH3cQszUg1+gUITj7D6NY7ywVnY=
131133
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
@@ -307,6 +309,8 @@ github.com/containerd/containerd v1.5.8/go.mod h1:YdFSv5bTFLpG2HIYmfqDpSYYTDX+mc
307309
github.com/containerd/containerd v1.6.1/go.mod h1:1nJz5xCZPusx6jJU8Frfct988y0NpumIq9ODB0kLtoE=
308310
github.com/containerd/containerd v1.6.8 h1:h4dOFDwzHmqFEP754PgfgTeVXFnLiRc6kiqC7tplDJs=
309311
github.com/containerd/containerd v1.6.8/go.mod h1:By6p5KqPK0/7/CgO/A6t/Gz+CUYUu2zf1hUaaymVXB0=
312+
github.com/containerd/containerd v1.6.12 h1:kJ9b3mOFKf8yqo05Ob+tMoxvt1pbVWhnB0re9Y+k+8c=
313+
github.com/containerd/containerd v1.6.12/go.mod h1:K4Bw7gjgh4TnkmQY+py/PYQGp4e7xgnHAeg87VeWb3A=
310314
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
311315
github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
312316
github.com/containerd/continuity v0.0.0-20191127005431-f65d91d395eb/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
@@ -466,6 +470,8 @@ github.com/docker/index-cli-plugin v0.0.27-0.20230104215933-7910587620f1 h1:7l/w
466470
github.com/docker/index-cli-plugin v0.0.27-0.20230104215933-7910587620f1/go.mod h1:Ii4IZOFwVpfut3fbBjjQxO5yeAfHSYuUy6wcsmTsDec=
467471
github.com/docker/index-cli-plugin v0.0.27-0.20230104225926-3eb6de3c7d6b h1:CaERx6JLL22nubKUZIVleIiXgMnSwyhi7jS0AcjJfgs=
468472
github.com/docker/index-cli-plugin v0.0.27-0.20230104225926-3eb6de3c7d6b/go.mod h1:Ii4IZOFwVpfut3fbBjjQxO5yeAfHSYuUy6wcsmTsDec=
473+
github.com/docker/index-cli-plugin v0.0.33-0.20230203084141-88bf36ae38c6 h1:L4ncM7lESPnUkuiwyCrYw/6IKGDNdgWgKds4pKzjwt0=
474+
github.com/docker/index-cli-plugin v0.0.33-0.20230203084141-88bf36ae38c6/go.mod h1:8lunxSyNMPeJRCF6aQB7JlhUXzEAB9X9XpzdCVP+WfA=
469475
github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE=
470476
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE=
471477
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
@@ -911,6 +917,8 @@ github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4
911917
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
912918
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
913919
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
920+
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
921+
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
914922
github.com/maxbrunsfeld/counterfeiter/v6 v6.2.2/go.mod h1:eD9eIE7cdwcMi9rYluz88Jz2VyhSmden33/aXg4oVIY=
915923
github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Clwo=
916924
github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4=

0 commit comments

Comments
 (0)