Skip to content

Commit e7ee327

Browse files
committed
feat: ability to do application scope reports
Signed-off-by: Julio Jimenez <[email protected]>
1 parent 667ce81 commit e7ee327

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

internal/sbom/mend.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,18 @@ func (m *MendClient) RequestSBOMExport(ctx context.Context, outputFile string) e
173173
}
174174

175175
// Add scope
176+
var url string
176177
switch {
177178
case m.projectUUID != "":
178179
payload["scopeType"] = "project"
179180
payload["scopeUuid"] = m.projectUUID
180181
uuids := strings.Split(m.projectUUIDs, ",")
181182
payload["projectUuids"] = uuids
183+
url = fmt.Sprintf("%s/api/v3.0/projects/%s/dependencies/reports/SBOM", m.baseURL, m.projectUUID)
182184
case m.productUUID != "":
183-
payload["scopeType"] = "product"
184-
payload["scopeUuid"] = m.productUUID
185185
uuids := strings.Split(m.projectUUIDs, ",")
186186
payload["projectUuids"] = uuids
187+
url = fmt.Sprintf("%s/api/v3.0/applications/%s/dependencies/reports/SBOM", m.baseURL, m.productUUID)
187188
case m.orgScopeUUID != "":
188189
payload["scopeType"] = "organization"
189190
payload["scopeUuid"] = m.orgScopeUUID
@@ -194,9 +195,6 @@ func (m *MendClient) RequestSBOMExport(ctx context.Context, outputFile string) e
194195
return fmt.Errorf("failed to marshal payload: %w", err)
195196
}
196197

197-
url := fmt.Sprintf("%s/api/v3.0/projects/%s/dependencies/reports/SBOM",
198-
m.baseURL, m.projectUUID)
199-
200198
req, err := http.NewRequestWithContext(ctx, "POST", url, bytes.NewReader(payloadBytes))
201199
if err != nil {
202200
return fmt.Errorf("failed to create request: %w", err)

0 commit comments

Comments
 (0)