@@ -49,19 +49,11 @@ func Upload(sb *types.Sbom, workspace string, apikey string) error {
49
49
}
50
50
51
51
newTransaction := context .NewTransaction
52
- image , err := transactSbom (sb , newTransaction )
52
+ _ , err := transactSbom (sb , newTransaction )
53
53
if err != nil {
54
54
return errors .Wrap (err , "failed to transact image" )
55
55
}
56
56
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
-
65
57
return nil
66
58
}
67
59
@@ -103,11 +95,12 @@ func transactSbom(sb *types.Sbom, newTransaction func() skill.Transaction) (*Ima
103
95
diffIds := diffIdChainIds (config )
104
96
digests := digestChainIds (manifest )
105
97
106
- repository := RepositoryEntity {
98
+ repository := skill . MakeEntity ( RepositoryEntity {
107
99
Host : host ,
108
100
Name : name ,
109
101
Platforms : skill.ManyRef {Add : []string {parsePlatform (sb )}},
110
- }
102
+ }, "$repo" )
103
+ transaction .AddEntities (repository )
111
104
112
105
layers := make ([]LayerEntity , 0 )
113
106
lc := 0
@@ -133,19 +126,20 @@ func transactSbom(sb *types.Sbom, newTransaction func() skill.Transaction) (*Ima
133
126
lc ++
134
127
}
135
128
136
- image := ImageEntity {
129
+ image := skill . MakeEntity ( ImageEntity {
137
130
Digest : sb .Source .Image .Digest ,
138
131
CreatedAt : & config .Created .Time ,
139
- Repository : & repository ,
140
- Repositories : & [] RepositoryEntity { repository },
132
+ Repository : "$repo" ,
133
+ Repositories : & skill. ManyRef { Add : [] string { "$repo" } },
141
134
Labels : & labels ,
142
135
Ports : & ports ,
143
136
Env : & env ,
144
137
EnvironmentVariables : & envVars ,
145
138
Layers : & layers ,
146
139
BlobDigest : digests [len (digests )- 1 ].String (),
147
140
DiffChainId : diffIds [len (diffIds )- 1 ].String (),
148
- }
141
+ }, "$image" )
142
+
149
143
if sha != "" {
150
144
image .Sha = sha
151
145
}
@@ -164,16 +158,16 @@ func transactSbom(sb *types.Sbom, newTransaction func() skill.Transaction) (*Ima
164
158
tag := TagEntity {
165
159
Name : t ,
166
160
UpdatedAt : config .Created .Time ,
167
- Repository : repository ,
161
+ Repository : "$repo" ,
168
162
Digest : sb .Source .Image .Digest ,
169
- Image : image ,
163
+ Image : "$ image" ,
170
164
}
171
165
transaction .AddEntities (tag )
172
166
}
173
167
}
174
168
175
169
platform := PlatformEntity {
176
- Image : image ,
170
+ Image : "" ,
177
171
Os : sb .Source .Image .Platform .Os ,
178
172
Architecture : sb .Source .Image .Platform .Architecture ,
179
173
Variant : sb .Source .Image .Platform .Variant ,
@@ -190,9 +184,10 @@ func transactSbom(sb *types.Sbom, newTransaction func() skill.Transaction) (*Ima
190
184
for _ , packages := range packageChunks {
191
185
transaction := newTransaction ().Ordered ()
192
186
193
- image = ImageEntity {
187
+ image = skill . MakeEntity ( ImageEntity {
194
188
Digest : sb .Source .Image .Digest ,
195
- }
189
+ }, "$image" )
190
+ transaction .AddEntities (image )
196
191
197
192
for _ , p := range packages {
198
193
files := make ([]FileEntity , 0 )
@@ -220,7 +215,7 @@ func transactSbom(sb *types.Sbom, newTransaction func() skill.Transaction) (*Ima
220
215
221
216
dep := DependencyEntity {
222
217
Scopes : []string {"provided" },
223
- Parent : image ,
218
+ Parent : "$ image" ,
224
219
Package : pkg ,
225
220
Files : files ,
226
221
}
@@ -235,12 +230,10 @@ func transactSbom(sb *types.Sbom, newTransaction func() skill.Transaction) (*Ima
235
230
}
236
231
}
237
232
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" )
244
237
if sb .Artifacts != nil {
245
238
image .SbomState = Indexed
246
239
}
@@ -338,19 +331,19 @@ func parseReference(sb *types.Sbom) (string, string, error) {
338
331
339
332
type PlatformEntity struct {
340
333
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"`
345
338
}
346
339
347
340
type TagEntity struct {
348
341
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"`
354
347
}
355
348
356
349
type RepositoryEntity struct {
@@ -395,8 +388,8 @@ type ImageEntity struct {
395
388
skill.Entity `entity-type:"docker/image"`
396
389
Digest string `edn:"docker.image/digest"`
397
390
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"`
400
393
Tags * skill.ManyRef `edn:"docker.image/tags,omitempty"`
401
394
Labels * []LabelEntity `edn:"docker.image/labels,omitempty"`
402
395
Ports * [][2 ]string `edn:"docker.image/ports,omitempty"`
@@ -445,7 +438,7 @@ type FileEntity struct {
445
438
type DependencyEntity struct {
446
439
skill.Entity `entity-type:"package/dependency"`
447
440
Scopes []string `edn:"package.dependency/scopes"`
448
- Parent ImageEntity `edn:"package.dependency/parent"`
441
+ Parent string `edn:"package.dependency/parent"`
449
442
Package PackageEntity `edn:"package.dependency/package"`
450
443
Files []FileEntity `edn:"package.dependency/files"`
451
444
}
0 commit comments