@@ -49,19 +49,11 @@ func Upload(sb *types.Sbom, workspace string, apikey string) error {
4949 }
5050
5151 newTransaction := context .NewTransaction
52- image , err := transactSbom (sb , newTransaction )
52+ _ , err := transactSbom (sb , newTransaction )
5353 if err != nil {
5454 return errors .Wrap (err , "failed to transact image" )
5555 }
5656
57- imageName := ""
58- if image .Repository .Host != "hub.docker.com" {
59- imageName = image .Repository .Host + "/"
60- }
61- imageName += image .Repository .Name
62-
63- skill .Log .Infof ("Inspect image at https://dso.docker.com/%s/overview/images/%s/digests/%s" , workspace , imageName , image .Digest )
64-
6557 return nil
6658}
6759
@@ -103,11 +95,12 @@ func transactSbom(sb *types.Sbom, newTransaction func() skill.Transaction) (*Ima
10395 diffIds := diffIdChainIds (config )
10496 digests := digestChainIds (manifest )
10597
106- repository := RepositoryEntity {
98+ repository := skill . MakeEntity ( RepositoryEntity {
10799 Host : host ,
108100 Name : name ,
109101 Platforms : skill.ManyRef {Add : []string {parsePlatform (sb )}},
110- }
102+ }, "$repo" )
103+ transaction .AddEntities (repository )
111104
112105 layers := make ([]LayerEntity , 0 )
113106 lc := 0
@@ -133,19 +126,20 @@ func transactSbom(sb *types.Sbom, newTransaction func() skill.Transaction) (*Ima
133126 lc ++
134127 }
135128
136- image := ImageEntity {
129+ image := skill . MakeEntity ( ImageEntity {
137130 Digest : sb .Source .Image .Digest ,
138131 CreatedAt : & config .Created .Time ,
139- Repository : & repository ,
140- Repositories : & [] RepositoryEntity { repository },
132+ Repository : "$repo" ,
133+ Repositories : & skill. ManyRef { Add : [] string { "$repo" } },
141134 Labels : & labels ,
142135 Ports : & ports ,
143136 Env : & env ,
144137 EnvironmentVariables : & envVars ,
145138 Layers : & layers ,
146139 BlobDigest : digests [len (digests )- 1 ].String (),
147140 DiffChainId : diffIds [len (diffIds )- 1 ].String (),
148- }
141+ }, "$image" )
142+
149143 if sha != "" {
150144 image .Sha = sha
151145 }
@@ -164,16 +158,16 @@ func transactSbom(sb *types.Sbom, newTransaction func() skill.Transaction) (*Ima
164158 tag := TagEntity {
165159 Name : t ,
166160 UpdatedAt : config .Created .Time ,
167- Repository : repository ,
161+ Repository : "$repo" ,
168162 Digest : sb .Source .Image .Digest ,
169- Image : image ,
163+ Image : "$ image" ,
170164 }
171165 transaction .AddEntities (tag )
172166 }
173167 }
174168
175169 platform := PlatformEntity {
176- Image : image ,
170+ Image : "" ,
177171 Os : sb .Source .Image .Platform .Os ,
178172 Architecture : sb .Source .Image .Platform .Architecture ,
179173 Variant : sb .Source .Image .Platform .Variant ,
@@ -190,9 +184,10 @@ func transactSbom(sb *types.Sbom, newTransaction func() skill.Transaction) (*Ima
190184 for _ , packages := range packageChunks {
191185 transaction := newTransaction ().Ordered ()
192186
193- image = ImageEntity {
187+ image = skill . MakeEntity ( ImageEntity {
194188 Digest : sb .Source .Image .Digest ,
195- }
189+ }, "$image" )
190+ transaction .AddEntities (image )
196191
197192 for _ , p := range packages {
198193 files := make ([]FileEntity , 0 )
@@ -220,7 +215,7 @@ func transactSbom(sb *types.Sbom, newTransaction func() skill.Transaction) (*Ima
220215
221216 dep := DependencyEntity {
222217 Scopes : []string {"provided" },
223- Parent : image ,
218+ Parent : "$ image" ,
224219 Package : pkg ,
225220 Files : files ,
226221 }
@@ -235,12 +230,10 @@ func transactSbom(sb *types.Sbom, newTransaction func() skill.Transaction) (*Ima
235230 }
236231 }
237232
238- image = ImageEntity {
239- Digest : sb .Source .Image .Digest ,
240- Repository : & repository ,
241- Repositories : & []RepositoryEntity {repository },
242- SbomState : Indexed ,
243- }
233+ image = skill .MakeEntity (ImageEntity {
234+ Digest : sb .Source .Image .Digest ,
235+ SbomState : Indexed ,
236+ }, "$repo" )
244237 if sb .Artifacts != nil {
245238 image .SbomState = Indexed
246239 }
@@ -338,19 +331,19 @@ func parseReference(sb *types.Sbom) (string, string, error) {
338331
339332type PlatformEntity struct {
340333 skill.Entity `entity-type:"docker/platform"`
341- Image ImageEntity `edn:"docker.platform/image"`
342- Os string `edn:"docker.platform/os"`
343- Architecture string `edn:"docker.platform/architecture"`
344- Variant string `edn:"docker.platform/variant,omitempty"`
334+ Image string `edn:"docker.platform/image"`
335+ Os string `edn:"docker.platform/os"`
336+ Architecture string `edn:"docker.platform/architecture"`
337+ Variant string `edn:"docker.platform/variant,omitempty"`
345338}
346339
347340type TagEntity struct {
348341 skill.Entity `entity-type:"docker/tag"`
349- Name string `edn:"docker.tag/name"`
350- UpdatedAt time.Time `edn:"docker.tag/updated-at"`
351- Repository RepositoryEntity `edn:"docker.tag/repository"`
352- Digest string `edn:"docker.tag/digest"`
353- Image ImageEntity `edn:"docker.tag/image"`
342+ Name string `edn:"docker.tag/name"`
343+ UpdatedAt time.Time `edn:"docker.tag/updated-at"`
344+ Repository string `edn:"docker.tag/repository"`
345+ Digest string `edn:"docker.tag/digest"`
346+ Image string `edn:"docker.tag/image"`
354347}
355348
356349type RepositoryEntity struct {
@@ -395,8 +388,8 @@ type ImageEntity struct {
395388 skill.Entity `entity-type:"docker/image"`
396389 Digest string `edn:"docker.image/digest"`
397390 CreatedAt * time.Time `edn:"docker.image/created-at,omitempty"`
398- Repository * RepositoryEntity `edn:"docker.image/repository,omitempty"`
399- Repositories * [] RepositoryEntity `edn:"docker.image/repositories,omitempty"`
391+ Repository string `edn:"docker.image/repository,omitempty"`
392+ Repositories * skill. ManyRef `edn:"docker.image/repositories,omitempty"`
400393 Tags * skill.ManyRef `edn:"docker.image/tags,omitempty"`
401394 Labels * []LabelEntity `edn:"docker.image/labels,omitempty"`
402395 Ports * [][2 ]string `edn:"docker.image/ports,omitempty"`
@@ -445,7 +438,7 @@ type FileEntity struct {
445438type DependencyEntity struct {
446439 skill.Entity `entity-type:"package/dependency"`
447440 Scopes []string `edn:"package.dependency/scopes"`
448- Parent ImageEntity `edn:"package.dependency/parent"`
441+ Parent string `edn:"package.dependency/parent"`
449442 Package PackageEntity `edn:"package.dependency/package"`
450443 Files []FileEntity `edn:"package.dependency/files"`
451444}
0 commit comments