From 1a8562554a7d29b4e031bd9973d61f2210e7363b Mon Sep 17 00:00:00 2001 From: Christopher Phillips <32073428+spiffcs@users.noreply.github.com> Date: Thu, 13 Nov 2025 01:47:49 -0500 Subject: [PATCH] fix: update after rebase Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com> --- syft/source/ocimodelsource/metadata.go | 32 +++++++++---------- .../source/ocimodelsource/oci_model_source.go | 14 ++++---- .../ocimodelsource/oci_model_source_test.go | 10 ++---- syft/source/ocimodelsource/resolver.go | 13 ++------ .../sourceproviders/source_providers.go | 10 +++--- 5 files changed, 32 insertions(+), 47 deletions(-) diff --git a/syft/source/ocimodelsource/metadata.go b/syft/source/ocimodelsource/metadata.go index e951089b5..dfc0a2310 100644 --- a/syft/source/ocimodelsource/metadata.go +++ b/syft/source/ocimodelsource/metadata.go @@ -6,20 +6,20 @@ import "github.com/anchore/syft/syft/source" // This is similar to ImageMetadata but includes model-specific fields and OCI artifact annotations. type OCIModelMetadata struct { // Core OCI artifact metadata (mirrors ImageMetadata) - UserInput string `json:"userInput"` - ID string `json:"artifactID"` - ManifestDigest string `json:"manifestDigest"` - MediaType string `json:"mediaType"` - Tags []string `json:"tags"` - Size int64 `json:"artifactSize"` - Layers []source.LayerMetadata `json:"layers"` - RawManifest []byte `json:"manifest"` - RawConfig []byte `json:"config"` - RepoDigests []string `json:"repoDigests"` - Architecture string `json:"architecture"` - Variant string `json:"architectureVariant,omitempty"` - OS string `json:"os"` - Labels map[string]string `json:"labels,omitempty"` + UserInput string `json:"userInput"` + ID string `json:"artifactID"` + ManifestDigest string `json:"manifestDigest"` + MediaType string `json:"mediaType"` + Tags []string `json:"tags"` + Size int64 `json:"artifactSize"` + Layers []source.LayerMetadata `json:"layers"` + RawManifest []byte `json:"manifest"` + RawConfig []byte `json:"config"` + RepoDigests []string `json:"repoDigests"` + Architecture string `json:"architecture"` + Variant string `json:"architectureVariant,omitempty"` + OS string `json:"os"` + Labels map[string]string `json:"labels,omitempty"` // OCI-specific metadata Annotations map[string]string `json:"annotations,omitempty"` @@ -32,8 +32,8 @@ type OCIModelMetadata struct { // GGUFLayerInfo represents metadata about a GGUF layer in the OCI artifact. type GGUFLayerInfo struct { Digest string `json:"digest"` - Size int64 `json:"size"` // Full blob size in registry - MediaType string `json:"mediaType"` // Should be "application/vnd.docker.ai.gguf.v3" + Size int64 `json:"size"` // Full blob size in registry + MediaType string `json:"mediaType"` // Should be "application/vnd.docker.ai.gguf.v3" Annotations map[string]string `json:"annotations,omitempty"` FetchedBytes int64 `json:"fetchedBytes"` // How many bytes we actually fetched via range-GET } diff --git a/syft/source/ocimodelsource/oci_model_source.go b/syft/source/ocimodelsource/oci_model_source.go index 807dee7c3..d8ccc289d 100644 --- a/syft/source/ocimodelsource/oci_model_source.go +++ b/syft/source/ocimodelsource/oci_model_source.go @@ -18,12 +18,12 @@ var _ source.Source = (*ociModelSource)(nil) // Config holds the configuration for an OCI model artifact source. type Config struct { - Reference string - Platform string - Alias source.Alias - Client *RegistryClient - Metadata *OCIModelMetadata - TempFiles map[string]string // Virtual path -> temp file path + Reference string + Platform string + Alias source.Alias + Client *RegistryClient + Metadata *OCIModelMetadata + TempFiles map[string]string // Virtual path -> temp file path } // ociModelSource implements the source.Source interface for OCI model artifacts. @@ -53,7 +53,7 @@ func NewFromArtifact(artifact *ModelArtifact, client *RegistryClient, alias sour } // Extract virtual path from annotations - virtualPath := extractVirtualPath(idx, extractAnnotations(layer.Annotations)) + virtualPath := extractVirtualPath(idx) // Create temp file tempPath, err := createTempFileFromData(headerData, virtualPath) diff --git a/syft/source/ocimodelsource/oci_model_source_test.go b/syft/source/ocimodelsource/oci_model_source_test.go index 747479f07..1977c3618 100644 --- a/syft/source/ocimodelsource/oci_model_source_test.go +++ b/syft/source/ocimodelsource/oci_model_source_test.go @@ -14,13 +14,7 @@ func TestExtractVirtualPath(t *testing.T) { expected string }{ { - name: "with title annotation", - layerIndex: 0, - annotations: map[string]string{"org.opencontainers.image.title": "model.gguf"}, - expected: "/model.gguf", - }, - { - name: "without title annotation", + name: "use index as model layer virtual path", layerIndex: 1, annotations: map[string]string{}, expected: "/model-layer-1.gguf", @@ -29,7 +23,7 @@ func TestExtractVirtualPath(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - result := extractVirtualPath(tt.layerIndex, tt.annotations) + result := extractVirtualPath(tt.layerIndex) assert.Equal(t, tt.expected, result) }) } diff --git a/syft/source/ocimodelsource/resolver.go b/syft/source/ocimodelsource/resolver.go index 4762059dc..0ed98e8ad 100644 --- a/syft/source/ocimodelsource/resolver.go +++ b/syft/source/ocimodelsource/resolver.go @@ -8,9 +8,9 @@ import ( "path/filepath" "strings" - stereofile "github.com/anchore/stereoscope/pkg/file" "github.com/bmatcuk/doublestar/v4" + stereofile "github.com/anchore/stereoscope/pkg/file" "github.com/anchore/syft/syft/file" ) @@ -177,16 +177,7 @@ func (r *ociModelResolver) cleanup() error { // extractVirtualPath generates a virtual path for a GGUF layer. // This simulates where the file would be in the artifact. -func extractVirtualPath(layerIndex int, annotations map[string]string) string { - // Check if there's a title annotation that specifies the filename - if title, ok := annotations["org.opencontainers.image.title"]; ok && title != "" { - // Ensure it starts with / - if !strings.HasPrefix(title, "/") { - return "/" + title - } - return title - } - // Fall back to default naming +func extractVirtualPath(layerIndex int) string { return fmt.Sprintf("/model-layer-%d.gguf", layerIndex) } diff --git a/syft/source/sourceproviders/source_providers.go b/syft/source/sourceproviders/source_providers.go index 4d4f3bc03..74b715774 100644 --- a/syft/source/sourceproviders/source_providers.go +++ b/syft/source/sourceproviders/source_providers.go @@ -13,11 +13,11 @@ import ( ) const ( - FileTag = stereoscope.FileTag - DirTag = stereoscope.DirTag - PullTag = stereoscope.PullTag - SnapTag = "snap" - OCIModelTag = "oci-model" + FileTag = stereoscope.FileTag + DirTag = stereoscope.DirTag + PullTag = stereoscope.PullTag + SnapTag = "snap" + OCIModelTag = "oci-model" ) // All returns all the configured source providers known to syft