mirror of
https://github.com/anchore/syft.git
synced 2026-11-01 15:06:36 +01:00
* fix(ai): keep merging GGUF layers when one fails to parse a single unparseable layer in an OCI GGUF artifact skipped the merge, so the named model lost its parts and nameless layers were dropped. The error is still returned. Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix(ai): only send GGUF layers to the GGUF cataloger the media type glob `application/vnd.docker.ai*` also matched config, model.file, license and safetensors layers, so every safetensors OCI model reported spurious "invalid GGUF magic number" unknowns. Match `application/vnd.docker.ai.gguf.v3` exactly. Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix(ai): don't wrap safetensors parameter counts - tensors whose shape product overflows uint64 are skipped instead of wrapping - per-file and per-shard parameter totals saturate instead of wrapping - parameter count and dominant dtype are computed in one pass - GGUF licenses are created with the scan context, and drop no-op unknown checks Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * refactor(ai): derive safetensors model info from the header in one place the file and OCI layer parsers built identical metadata from a parsed header. Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * fix(ai): keep the GGUF media type with the GGUF cataloger also corrects stale comments in the GGUF merge processor. Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package ai
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/anchore/syft/syft/file"
|
|
"github.com/anchore/syft/syft/pkg"
|
|
)
|
|
|
|
func newGGUFPackage(ctx context.Context, metadata *pkg.GGUFFileHeader, modelName, version, license string, locations ...file.Location) pkg.Package {
|
|
p := pkg.Package{
|
|
Name: modelName,
|
|
Version: version,
|
|
Locations: file.NewLocationSet(locations...),
|
|
Type: pkg.ModelPkg,
|
|
Licenses: pkg.NewLicenseSet(pkg.NewLicensesFromValuesWithContext(ctx, license)...),
|
|
Metadata: *metadata,
|
|
// NOTE: PURL is intentionally not set as the package-url spec
|
|
// has not yet finalized support for ML model packages
|
|
}
|
|
p.SetID()
|
|
|
|
return p
|
|
}
|
|
|
|
// newSafeTensorsPackage creates a SafeTensors package with the given metadata
|
|
// and locations. Name and Licenses are intentionally not set here and done at the processor level
|
|
func newSafeTensorsPackage(metadata *pkg.SafeTensorsModelInfo, locations ...file.Location) pkg.Package {
|
|
p := pkg.Package{
|
|
Locations: file.NewLocationSet(locations...),
|
|
Type: pkg.ModelPkg,
|
|
Metadata: *metadata,
|
|
// PURL is intentionally not set: package-url has not yet finalized ML model support.
|
|
}
|
|
p.SetID()
|
|
|
|
return p
|
|
}
|