Skip to content

Commit efa13e6

Browse files
committed
chore: rename validateSBOM func
1 parent d47fb89 commit efa13e6

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

internal/uv/uvclient.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (c client) ExportSBOM(inputDir string) (*scaplugin.Finding, error) {
5050
return nil, fmt.Errorf("failed to execute uv export: %w", err)
5151
}
5252

53-
metadata, err := validateSBOM(output)
53+
metadata, err := extractMetadata(output)
5454
if err != nil {
5555
return nil, err
5656
}
@@ -69,8 +69,8 @@ func (c client) ExportSBOM(inputDir string) (*scaplugin.Finding, error) {
6969
}, nil
7070
}
7171

72-
// Verifies that the SBOM is valid JSON and has a root component.
73-
func validateSBOM(sbomData []byte) (*scaplugin.Metadata, error) {
72+
// Extracts metadata from the SBOM and validates that it is valid JSON with a root component.
73+
func extractMetadata(sbomData []byte) (*scaplugin.Metadata, error) {
7474
var sbom struct {
7575
Metadata struct {
7676
Component *struct {

internal/uv/uvclient_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func TestParseAndValidateVersion_UnparseableOutput(t *testing.T) {
162162
}
163163
}
164164

165-
func TestValidateSBOM_Success(t *testing.T) {
165+
func TestExtractMetadata_Success(t *testing.T) {
166166
tests := []struct {
167167
name string
168168
sbom string
@@ -249,7 +249,7 @@ func TestValidateSBOM_Success(t *testing.T) {
249249

250250
for _, tt := range tests {
251251
t.Run(tt.name, func(t *testing.T) {
252-
metadata, err := validateSBOM([]byte(tt.sbom))
252+
metadata, err := extractMetadata([]byte(tt.sbom))
253253
assert.NoError(t, err)
254254
require.NotNil(t, metadata)
255255
assert.Equal(t, "pip", metadata.PackageManager)
@@ -259,7 +259,7 @@ func TestValidateSBOM_Success(t *testing.T) {
259259
}
260260
}
261261

262-
func TestValidateSBOM_MissingComponent(t *testing.T) {
262+
func TestExtractMetadata_MissingComponent(t *testing.T) {
263263
tests := []struct {
264264
name string
265265
sbom string
@@ -302,7 +302,7 @@ func TestValidateSBOM_MissingComponent(t *testing.T) {
302302

303303
for _, tt := range tests {
304304
t.Run(tt.name, func(t *testing.T) {
305-
metadata, err := validateSBOM([]byte(tt.sbom))
305+
metadata, err := extractMetadata([]byte(tt.sbom))
306306
assert.Nil(t, metadata)
307307
require.Error(t, err)
308308
var catalogErr snyk_errors.Error
@@ -312,8 +312,8 @@ func TestValidateSBOM_MissingComponent(t *testing.T) {
312312
}
313313
}
314314

315-
func TestValidateSBOM_InvalidJSON(t *testing.T) {
316-
metadata, err := validateSBOM([]byte("invalid json"))
315+
func TestExtractMetadata_InvalidJSON(t *testing.T) {
316+
metadata, err := extractMetadata([]byte("invalid json"))
317317
assert.Nil(t, metadata)
318318
require.Error(t, err)
319319
var catalogErr snyk_errors.Error

0 commit comments

Comments
 (0)