diff --git a/cmd/syft/internal/commands/scan.go b/cmd/syft/internal/commands/scan.go index bc510948a..e669a46a8 100644 --- a/cmd/syft/internal/commands/scan.go +++ b/cmd/syft/internal/commands/scan.go @@ -59,7 +59,9 @@ const ( nonImageSchemeHelp = ` {{.appName}} {{.command}} dir:path/to/yourproject read directly from a path on disk (any directory) {{.appName}} {{.command}} file:path/to/yourproject/file read directly from a path on disk (any single file) ` - scanSchemeHelp = "\n " + schemeHelpHeader + "\n" + imageSchemeHelp + nonImageSchemeHelp + modelSchemeHelp = ` {{.appName}} {{.command}} oci-model-registry:ai/llama3.2 scan an OCI model artifact from a registry (e.g. Docker Hub AI models) +` + scanSchemeHelp = "\n " + schemeHelpHeader + "\n" + imageSchemeHelp + modelSchemeHelp + nonImageSchemeHelp scanHelp = scanExample + scanSchemeHelp ) diff --git a/internal/constants.go b/internal/constants.go index 940b2b043..a6f0bdae7 100644 --- a/internal/constants.go +++ b/internal/constants.go @@ -3,10 +3,12 @@ package internal const ( // JSONSchemaVersion is the current schema version output by the JSON encoder // This is roughly following the "SchemaVer" guidelines for versioning the JSON schema. Please see schema/json/README.md for details on how to increment. - JSONSchemaVersion = "16.1.2" + JSONSchemaVersion = "16.1.3" // Changelog // 16.1.0 - reformulated the python pdm fields (added "URL" and removed the unused "path" field). // 16.1.1 - correct elf package osCpe field according to the document of systemd (also add appCpe field) + // 16.1.2 - placeholder for 16.1.2 changelog + // 16.1.3 - add GGUFFileParts to GGUFFileHeader metadata ) diff --git a/internal/jsonschema/main.go b/internal/jsonschema/main.go index 62a100410..f5dc06f2c 100644 --- a/internal/jsonschema/main.go +++ b/internal/jsonschema/main.go @@ -82,12 +82,29 @@ func assembleTypeContainer(items []any) (any, map[string]string) { return reflect.New(structType).Elem().Interface(), mapping } +//nolint:funlen func build() *jsonschema.Schema { + // create metadata mapping first so we can use it in the Namer function for self-referential types + pkgMetadataContainer, pkgMetadataMapping := assembleTypeContainer(packagemetadata.AllTypes()) + pkgMetadataContainerType := reflect.TypeOf(pkgMetadataContainer) + + // create a set of valid metadata display names for lookup + // (since Namer now returns display names, the schema definitions use display names as keys) + pkgMetadataDisplayNames := make(map[string]struct{}, len(pkgMetadataMapping)) + for _, displayName := range pkgMetadataMapping { + pkgMetadataDisplayNames[displayName] = struct{}{} + } + reflector := &jsonschema.Reflector{ BaseSchemaID: schemaID(), AllowAdditionalProperties: true, Namer: func(r reflect.Type) string { - return strings.TrimPrefix(r.Name(), "JSON") + name := strings.TrimPrefix(r.Name(), "JSON") + // if this is a metadata type, use the mapped name for consistent references + if mappedName, ok := pkgMetadataMapping[name]; ok { + return mappedName + } + return name }, CommentMap: make(map[string]string), } @@ -123,9 +140,6 @@ func build() *jsonschema.Schema { copyAliasFieldComments(reflector.CommentMap, repoRoot) } - pkgMetadataContainer, pkgMetadataMapping := assembleTypeContainer(packagemetadata.AllTypes()) - pkgMetadataContainerType := reflect.TypeOf(pkgMetadataContainer) - // srcMetadataContainer := assembleTypeContainer(sourcemetadata.AllTypes()) // srcMetadataContainerType := reflect.TypeOf(srcMetadataContainer) @@ -144,11 +158,10 @@ func build() *jsonschema.Schema { continue } - displayName, ok := pkgMetadataMapping[typeName] - if ok { - // this is a package metadata type... - documentSchema.Definitions[displayName] = definition - metadataNames = append(metadataNames, displayName) + if _, ok := pkgMetadataDisplayNames[typeName]; ok { + // this is a package metadata type (typeName is already the display name from Namer) + documentSchema.Definitions[typeName] = definition + metadataNames = append(metadataNames, typeName) } else { // this is a type that the metadata type uses (e.g. DpkgFileRecord) documentSchema.Definitions[typeName] = definition diff --git a/internal/packagemetadata/discover_type_names.go b/internal/packagemetadata/discover_type_names.go index f9783db10..704c98c0b 100644 --- a/internal/packagemetadata/discover_type_names.go +++ b/internal/packagemetadata/discover_type_names.go @@ -26,6 +26,7 @@ var knownNonMetadataTypeNames = strset.New( // known to be metadata types themselves. Adding to this list will prevent the removal of the type from the schema. var knownMetadataTypeNames = strset.New( "DotnetPortableExecutableEntry", + "GGUFFileHeader", ) func DiscoverTypeNames() ([]string, error) { diff --git a/internal/sourcemetadata/discover_type_names.go b/internal/sourcemetadata/discover_type_names.go index 905de200a..f4a96e390 100644 --- a/internal/sourcemetadata/discover_type_names.go +++ b/internal/sourcemetadata/discover_type_names.go @@ -94,25 +94,33 @@ func findMetadataDefinitionNamesInFile(path string) ([]string, []string, error) // loop over all types declared in the type declaration for _, typ := range spec.Specs { - // check if the type is a struct type - spec, ok := typ.(*ast.TypeSpec) - if !ok || spec.Type == nil { + typeSpec, ok := typ.(*ast.TypeSpec) + if !ok || typeSpec.Type == nil { continue } - structType, ok := spec.Type.(*ast.StructType) - if !ok { - continue - } - - // check if the struct type ends with "Metadata" - name := spec.Name.String() + name := typeSpec.Name.String() // only look for exported types that end with "Metadata" - if isMetadataTypeCandidate(name) { - // print the full declaration of the struct type - metadataDefinitions = append(metadataDefinitions, name) + if !isMetadataTypeCandidate(name) { + continue + } + + metadataDefinitions = append(metadataDefinitions, name) + + // handle struct types (e.g., "type FooMetadata struct {...}") + if structType, ok := typeSpec.Type.(*ast.StructType); ok { usedTypeNames = append(usedTypeNames, typeNamesUsedInStruct(structType)...) + continue + } + + // handle type definitions from another type (e.g., "type FooMetadata BarMetadata") + // if the base type is NOT a metadata candidate, track it as used + // (e.g., we want both ImageMetadata and OCIModelMetadata which is an alias to it) + if ident, ok := typeSpec.Type.(*ast.Ident); ok { + if !isMetadataTypeCandidate(ident.Name) { + usedTypeNames = append(usedTypeNames, ident.Name) + } } } } diff --git a/internal/sourcemetadata/generated.go b/internal/sourcemetadata/generated.go index 2cfbb6e87..66dd030f6 100644 --- a/internal/sourcemetadata/generated.go +++ b/internal/sourcemetadata/generated.go @@ -6,5 +6,5 @@ import "github.com/anchore/syft/syft/source" // AllTypes returns a list of all source metadata types that syft supports (that are represented in the source.Description.Metadata field). func AllTypes() []any { - return []any{source.DirectoryMetadata{}, source.FileMetadata{}, source.ImageMetadata{}, source.SnapMetadata{}} + return []any{source.DirectoryMetadata{}, source.FileMetadata{}, source.ImageMetadata{}, source.OCIModelMetadata{}, source.SnapMetadata{}} } diff --git a/internal/sourcemetadata/names.go b/internal/sourcemetadata/names.go index 353b798ed..6db43ba81 100644 --- a/internal/sourcemetadata/names.go +++ b/internal/sourcemetadata/names.go @@ -12,6 +12,7 @@ var jsonNameFromType = map[reflect.Type][]string{ reflect.TypeOf(source.FileMetadata{}): {"file"}, reflect.TypeOf(source.ImageMetadata{}): {"image"}, reflect.TypeOf(source.SnapMetadata{}): {"snap"}, + reflect.TypeOf(source.OCIModelMetadata{}): {"oci-model"}, } func AllTypeNames() []string { diff --git a/schema/json/schema-16.1.3.json b/schema/json/schema-16.1.3.json new file mode 100644 index 000000000..125c92005 --- /dev/null +++ b/schema/json/schema-16.1.3.json @@ -0,0 +1,4248 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "anchore.io/schema/syft/json/16.1.3/document", + "$ref": "#/$defs/Document", + "$defs": { + "AlpmDbEntry": { + "properties": { + "basepackage": { + "type": "string", + "description": "BasePackage is the base package name this package was built from (source package in Arch build system)" + }, + "package": { + "type": "string", + "description": "Package is the package name as found in the desc file" + }, + "version": { + "type": "string", + "description": "Version is the package version as found in the desc file" + }, + "description": { + "type": "string", + "description": "Description is a human-readable package description" + }, + "architecture": { + "type": "string", + "description": "Architecture is the target CPU architecture as defined in Arch architecture spec (e.g. x86_64, aarch64, or \"any\" for arch-independent packages)" + }, + "size": { + "type": "integer", + "description": "Size is the installed size in bytes" + }, + "packager": { + "type": "string", + "description": "Packager is the name and email of the person who packaged this (RFC822 format)" + }, + "url": { + "type": "string", + "description": "URL is the upstream project URL" + }, + "validation": { + "type": "string", + "description": "Validation is the validation method used for package integrity (e.g. pgp signature, sha256 checksum)" + }, + "reason": { + "type": "integer", + "description": "Reason is the installation reason tracked by pacman (0=explicitly installed by user, 1=installed as dependency)" + }, + "files": { + "items": { + "$ref": "#/$defs/AlpmFileRecord" + }, + "type": "array", + "description": "Files are the files installed by this package" + }, + "backup": { + "items": { + "$ref": "#/$defs/AlpmFileRecord" + }, + "type": "array", + "description": "Backup is the list of configuration files that pacman backs up before upgrades" + }, + "provides": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Provides are virtual packages provided by this package (allows other packages to depend on capabilities rather than specific packages)" + }, + "depends": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Depends are the runtime dependencies required by this package" + } + }, + "type": "object", + "required": [ + "basepackage", + "package", + "version", + "description", + "architecture", + "size", + "packager", + "url", + "validation", + "reason", + "files", + "backup" + ], + "description": "AlpmDBEntry is a struct that represents the package data stored in the pacman flat-file stores for arch linux." + }, + "AlpmFileRecord": { + "properties": { + "path": { + "type": "string", + "description": "Path is the file path relative to the filesystem root" + }, + "type": { + "type": "string", + "description": "Type is the file type (e.g. regular file, directory, symlink)" + }, + "uid": { + "type": "string", + "description": "UID is the file owner user ID as recorded by pacman" + }, + "gid": { + "type": "string", + "description": "GID is the file owner group ID as recorded by pacman" + }, + "time": { + "type": "string", + "format": "date-time", + "description": "Time is the file modification timestamp" + }, + "size": { + "type": "string", + "description": "Size is the file size in bytes" + }, + "link": { + "type": "string", + "description": "Link is the symlink target path if this is a symlink" + }, + "digest": { + "items": { + "$ref": "#/$defs/Digest" + }, + "type": "array", + "description": "Digests contains file content hashes for integrity verification" + } + }, + "type": "object", + "description": "AlpmFileRecord represents a single file entry within an Arch Linux package with its associated metadata tracked by pacman." + }, + "ApkDbEntry": { + "properties": { + "package": { + "type": "string", + "description": "Package is the package name as found in the installed file" + }, + "originPackage": { + "type": "string", + "description": "OriginPackage is the original source package name this binary was built from (used to track which aport/source built this)" + }, + "maintainer": { + "type": "string", + "description": "Maintainer is the package maintainer name and email" + }, + "version": { + "type": "string", + "description": "Version is the package version as found in the installed file" + }, + "architecture": { + "type": "string", + "description": "Architecture is the target CPU architecture" + }, + "url": { + "type": "string", + "description": "URL is the upstream project URL" + }, + "description": { + "type": "string", + "description": "Description is a human-readable package description" + }, + "size": { + "type": "integer", + "description": "Size is the package archive size in bytes (.apk file size)" + }, + "installedSize": { + "type": "integer", + "description": "InstalledSize is the total size of installed files in bytes" + }, + "pullDependencies": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Dependencies are the runtime dependencies required by this package" + }, + "provides": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Provides are virtual packages provided by this package (for capability-based dependencies)" + }, + "pullChecksum": { + "type": "string", + "description": "Checksum is the package content checksum for integrity verification" + }, + "gitCommitOfApkPort": { + "type": "string", + "description": "GitCommit is the git commit hash of the APK port definition in Alpine's aports repository" + }, + "files": { + "items": { + "$ref": "#/$defs/ApkFileRecord" + }, + "type": "array", + "description": "Files are the files installed by this package" + } + }, + "type": "object", + "required": [ + "package", + "originPackage", + "maintainer", + "version", + "architecture", + "url", + "description", + "size", + "installedSize", + "pullDependencies", + "provides", + "pullChecksum", + "gitCommitOfApkPort", + "files" + ], + "description": "ApkDBEntry represents all captured data for the alpine linux package manager flat-file store." + }, + "ApkFileRecord": { + "properties": { + "path": { + "type": "string", + "description": "Path is the file path relative to the filesystem root" + }, + "ownerUid": { + "type": "string", + "description": "OwnerUID is the file owner user ID" + }, + "ownerGid": { + "type": "string", + "description": "OwnerGID is the file owner group ID" + }, + "permissions": { + "type": "string", + "description": "Permissions is the file permission mode string (e.g. \"0755\", \"0644\")" + }, + "digest": { + "$ref": "#/$defs/Digest", + "description": "Digest is the file content hash for integrity verification" + } + }, + "type": "object", + "required": [ + "path" + ], + "description": "ApkFileRecord represents a single file listing and metadata from a APK DB entry (which may have many of these file records)." + }, + "BinarySignature": { + "properties": { + "matches": { + "items": { + "$ref": "#/$defs/ClassifierMatch" + }, + "type": "array" + } + }, + "type": "object", + "required": [ + "matches" + ], + "description": "BinarySignature represents a set of matched values within a binary file." + }, + "BitnamiSbomEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is the package name as found in the Bitnami SPDX file" + }, + "arch": { + "type": "string", + "description": "Architecture is the target CPU architecture (amd64 or arm64 in Bitnami images)" + }, + "distro": { + "type": "string", + "description": "Distro is the distribution name this package is for (base OS like debian, ubuntu, etc.)" + }, + "revision": { + "type": "string", + "description": "Revision is the Bitnami-specific package revision number (incremented for Bitnami rebuilds of same upstream version)" + }, + "version": { + "type": "string", + "description": "Version is the package version as found in the Bitnami SPDX file" + }, + "path": { + "type": "string", + "description": "Path is the installation path in the filesystem where the package is located" + }, + "files": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Files are the file paths owned by this package (tracked via SPDX relationships)" + } + }, + "type": "object", + "required": [ + "name", + "arch", + "distro", + "revision", + "version", + "path", + "files" + ], + "description": "BitnamiSBOMEntry represents all captured data from Bitnami packages described in Bitnami' SPDX files." + }, + "CConanFileEntry": { + "properties": { + "ref": { + "type": "string", + "description": "Ref is the package reference string in format name/version@user/channel" + } + }, + "type": "object", + "required": [ + "ref" + ], + "description": "ConanfileEntry represents a single \"Requires\" entry from a conanfile.txt." + }, + "CConanInfoEntry": { + "properties": { + "ref": { + "type": "string", + "description": "Ref is the package reference string in format name/version@user/channel" + }, + "package_id": { + "type": "string", + "description": "PackageID is a unique package variant identifier" + } + }, + "type": "object", + "required": [ + "ref" + ], + "description": "ConaninfoEntry represents a single \"full_requires\" entry from a conaninfo.txt." + }, + "CConanLockEntry": { + "properties": { + "ref": { + "type": "string", + "description": "Ref is the package reference string in format name/version@user/channel" + }, + "package_id": { + "type": "string", + "description": "PackageID is a unique package variant identifier computed from settings/options (static hash in Conan 1.x, can have collisions with complex dependency graphs)" + }, + "prev": { + "type": "string", + "description": "Prev is the previous lock entry reference for versioning" + }, + "requires": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Requires are the runtime package dependencies" + }, + "build_requires": { + "items": { + "type": "string" + }, + "type": "array", + "description": "BuildRequires are the build-time dependencies (e.g. cmake, compilers)" + }, + "py_requires": { + "items": { + "type": "string" + }, + "type": "array", + "description": "PythonRequires are the Python dependencies needed for Conan recipes" + }, + "options": { + "$ref": "#/$defs/KeyValues", + "description": "Options are package configuration options as key-value pairs (e.g. shared=True, fPIC=True)" + }, + "path": { + "type": "string", + "description": "Path is the filesystem path to the package in Conan cache" + }, + "context": { + "type": "string", + "description": "Context is the build context information" + } + }, + "type": "object", + "required": [ + "ref" + ], + "description": "ConanV1LockEntry represents a single \"node\" entry from a conan.lock V1 file." + }, + "CConanLockV2Entry": { + "properties": { + "ref": { + "type": "string", + "description": "Ref is the package reference string in format name/version@user/channel" + }, + "packageID": { + "type": "string", + "description": "PackageID is a unique package variant identifier (dynamic in Conan 2.0, more accurate than V1)" + }, + "username": { + "type": "string", + "description": "Username is the Conan user/organization name" + }, + "channel": { + "type": "string", + "description": "Channel is the Conan channel name indicating stability/purpose (e.g. stable, testing, experimental)" + }, + "recipeRevision": { + "type": "string", + "description": "RecipeRevision is a git-like revision hash (RREV) of the recipe" + }, + "packageRevision": { + "type": "string", + "description": "PackageRevision is a git-like revision hash of the built binary package" + }, + "timestamp": { + "type": "string", + "description": "TimeStamp is when this package was built/locked" + } + }, + "type": "object", + "required": [ + "ref" + ], + "description": "ConanV2LockEntry represents a single \"node\" entry from a conan.lock V2 file." + }, + "CPE": { + "properties": { + "cpe": { + "type": "string", + "description": "Value is the CPE string identifier." + }, + "source": { + "type": "string", + "description": "Source is the source where this CPE was obtained or generated from." + } + }, + "type": "object", + "required": [ + "cpe" + ], + "description": "CPE represents a Common Platform Enumeration identifier used for matching packages to known vulnerabilities in security databases." + }, + "ClassifierMatch": { + "properties": { + "classifier": { + "type": "string" + }, + "location": { + "$ref": "#/$defs/Location" + } + }, + "type": "object", + "required": [ + "classifier", + "location" + ], + "description": "ClassifierMatch represents a single matched value within a binary file and the \"class\" name the search pattern represents." + }, + "CocoaPodfileLockEntry": { + "properties": { + "checksum": { + "type": "string", + "description": "Checksum is the SHA-1 hash of the podspec file for integrity verification (generated via `pod ipc spec ... | openssl sha1`), ensuring all team members use the same pod specification version" + } + }, + "type": "object", + "required": [ + "checksum" + ], + "description": "CocoaPodfileLockEntry represents a single entry from the \"Pods\" section of a Podfile.lock file." + }, + "CondaLink": { + "properties": { + "source": { + "type": "string", + "description": "Source is the original path where the package was extracted from cache." + }, + "type": { + "type": "integer", + "description": "Type indicates the link type (1 for hard link, 2 for soft link, 3 for copy)." + } + }, + "type": "object", + "required": [ + "source", + "type" + ], + "description": "CondaLink represents link metadata from a Conda package's link.json file describing package installation source." + }, + "CondaMetadataEntry": { + "properties": { + "arch": { + "type": "string", + "description": "Arch is the target CPU architecture for the package (e.g., \"arm64\", \"x86_64\")." + }, + "name": { + "type": "string", + "description": "Name is the package name as found in the conda-meta JSON file." + }, + "version": { + "type": "string", + "description": "Version is the package version as found in the conda-meta JSON file." + }, + "build": { + "type": "string", + "description": "Build is the build string identifier (e.g., \"h90dfc92_1014\")." + }, + "build_number": { + "type": "integer", + "description": "BuildNumber is the sequential build number for this version." + }, + "channel": { + "type": "string", + "description": "Channel is the Conda channel URL where the package was retrieved from." + }, + "subdir": { + "type": "string", + "description": "Subdir is the subdirectory within the channel (e.g., \"osx-arm64\", \"linux-64\")." + }, + "noarch": { + "type": "string", + "description": "Noarch indicates if the package is platform-independent (e.g., \"python\", \"generic\")." + }, + "license": { + "type": "string", + "description": "License is the package license identifier." + }, + "license_family": { + "type": "string", + "description": "LicenseFamily is the general license category (e.g., \"MIT\", \"Apache\", \"GPL\")." + }, + "md5": { + "type": "string", + "description": "MD5 is the MD5 hash of the package archive." + }, + "sha256": { + "type": "string", + "description": "SHA256 is the SHA-256 hash of the package archive." + }, + "size": { + "type": "integer", + "description": "Size is the package archive size in bytes." + }, + "timestamp": { + "type": "integer", + "description": "Timestamp is the Unix timestamp when the package was built." + }, + "fn": { + "type": "string", + "description": "Filename is the original package archive filename (e.g., \"zlib-1.2.11-h90dfc92_1014.tar.bz2\")." + }, + "url": { + "type": "string", + "description": "URL is the full download URL for the package archive." + }, + "extracted_package_dir": { + "type": "string", + "description": "ExtractedPackageDir is the local cache directory where the package was extracted." + }, + "depends": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Depends is the list of runtime dependencies with version constraints." + }, + "files": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Files is the list of files installed by this package." + }, + "paths_data": { + "$ref": "#/$defs/CondaPathsData", + "description": "PathsData contains detailed file metadata from the paths.json file." + }, + "link": { + "$ref": "#/$defs/CondaLink", + "description": "Link contains installation source metadata from the link.json file." + } + }, + "type": "object", + "required": [ + "name", + "version", + "build", + "build_number" + ], + "description": "CondaMetaPackage represents metadata for a Conda package extracted from the conda-meta/*.json files." + }, + "CondaPathData": { + "properties": { + "_path": { + "type": "string", + "description": "Path is the file path relative to the Conda environment root." + }, + "path_type": { + "type": "string", + "description": "PathType indicates the link type for the file (e.g., \"hardlink\", \"softlink\", \"directory\")." + }, + "sha256": { + "type": "string", + "description": "SHA256 is the SHA-256 hash of the file contents." + }, + "sha256_in_prefix": { + "type": "string", + "description": "SHA256InPrefix is the SHA-256 hash of the file after prefix replacement during installation." + }, + "size_in_bytes": { + "type": "integer", + "description": "SizeInBytes is the file size in bytes." + } + }, + "type": "object", + "required": [ + "_path", + "path_type", + "sha256", + "sha256_in_prefix", + "size_in_bytes" + ], + "description": "CondaPathData represents metadata for a single file within a Conda package from the paths.json file." + }, + "CondaPathsData": { + "properties": { + "paths_version": { + "type": "integer", + "description": "PathsVersion is the schema version of the paths data format." + }, + "paths": { + "items": { + "$ref": "#/$defs/CondaPathData" + }, + "type": "array", + "description": "Paths is the list of file metadata entries for all files in the package." + } + }, + "type": "object", + "required": [ + "paths_version", + "paths" + ], + "description": "CondaPathsData represents the paths.json file structure from a Conda package containing file metadata." + }, + "Coordinates": { + "properties": { + "path": { + "type": "string", + "description": "RealPath is the canonical absolute form of the path accessed (all symbolic links have been followed and relative path components like '.' and '..' have been removed)." + }, + "layerID": { + "type": "string", + "description": "FileSystemID is an ID representing and entire filesystem. For container images, this is a layer digest. For directories or a root filesystem, this is blank." + } + }, + "type": "object", + "required": [ + "path" + ], + "description": "Coordinates contains the minimal information needed to describe how to find a file within any possible source object (e.g." + }, + "DartPubspec": { + "properties": { + "homepage": { + "type": "string", + "description": "Homepage is the package homepage URL" + }, + "repository": { + "type": "string", + "description": "Repository is the source code repository URL" + }, + "documentation": { + "type": "string", + "description": "Documentation is the documentation site URL" + }, + "publish_to": { + "type": "string", + "description": "PublishTo is the package repository to publish to, or \"none\" to prevent accidental publishing" + }, + "environment": { + "$ref": "#/$defs/DartPubspecEnvironment", + "description": "Environment is SDK version constraints for Dart and Flutter" + }, + "platforms": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Platforms are the supported platforms (Android, iOS, web, etc.)" + }, + "ignored_advisories": { + "items": { + "type": "string" + }, + "type": "array", + "description": "IgnoredAdvisories are the security advisories to explicitly ignore for this package" + } + }, + "type": "object", + "description": "DartPubspec is a struct that represents a package described in a pubspec.yaml file" + }, + "DartPubspecEnvironment": { + "properties": { + "sdk": { + "type": "string", + "description": "SDK is the Dart SDK version constraint (e.g. \"\u003e=2.12.0 \u003c3.0.0\")" + }, + "flutter": { + "type": "string", + "description": "Flutter is the Flutter SDK version constraint if this is a Flutter package" + } + }, + "type": "object", + "description": "DartPubspecEnvironment represents SDK version constraints from the environment section of pubspec.yaml." + }, + "DartPubspecLockEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is the package name as found in the pubspec.lock file" + }, + "version": { + "type": "string", + "description": "Version is the package version as found in the pubspec.lock file" + }, + "hosted_url": { + "type": "string", + "description": "HostedURL is the URL of the package repository for hosted packages (typically pub.dev, but can be custom repository identified by hosted-url). When PUB_HOSTED_URL environment variable changes, lockfile tracks the source." + }, + "vcs_url": { + "type": "string", + "description": "VcsURL is the URL of the VCS repository for git/path dependencies (for packages fetched from version control systems like Git)" + } + }, + "type": "object", + "required": [ + "name", + "version" + ], + "description": "DartPubspecLockEntry is a struct that represents a single entry found in the \"packages\" section in a Dart pubspec.lock file." + }, + "Descriptor": { + "properties": { + "name": { + "type": "string", + "description": "Name is the name of the tool that generated this SBOM (e.g., \"syft\")." + }, + "version": { + "type": "string", + "description": "Version is the version of the tool that generated this SBOM." + }, + "configuration": { + "description": "Configuration contains the tool configuration used during SBOM generation." + } + }, + "type": "object", + "required": [ + "name", + "version" + ], + "description": "Descriptor identifies the tool that generated this SBOM document, including its name, version, and configuration used during catalog generation." + }, + "Digest": { + "properties": { + "algorithm": { + "type": "string", + "description": "Algorithm specifies the hash algorithm used (e.g., \"sha256\", \"md5\")." + }, + "value": { + "type": "string", + "description": "Value is the hexadecimal string representation of the hash." + } + }, + "type": "object", + "required": [ + "algorithm", + "value" + ], + "description": "Digest represents a cryptographic hash of file contents." + }, + "Document": { + "properties": { + "artifacts": { + "items": { + "$ref": "#/$defs/Package" + }, + "type": "array", + "description": "Artifacts is the list of packages discovered and placed into the catalog" + }, + "artifactRelationships": { + "items": { + "$ref": "#/$defs/Relationship" + }, + "type": "array" + }, + "files": { + "items": { + "$ref": "#/$defs/File" + }, + "type": "array", + "description": "note: must have omitempty" + }, + "source": { + "$ref": "#/$defs/Source", + "description": "Source represents the original object that was cataloged" + }, + "distro": { + "$ref": "#/$defs/LinuxRelease", + "description": "Distro represents the Linux distribution that was detected from the source" + }, + "descriptor": { + "$ref": "#/$defs/Descriptor", + "description": "Descriptor is a block containing self-describing information about syft" + }, + "schema": { + "$ref": "#/$defs/Schema", + "description": "Schema is a block reserved for defining the version for the shape of this JSON document and where to find the schema document to validate the shape" + } + }, + "type": "object", + "required": [ + "artifacts", + "artifactRelationships", + "source", + "distro", + "descriptor", + "schema" + ], + "description": "Document represents the syft cataloging findings as a JSON document" + }, + "DotnetDepsEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is the package name as found in the deps.json file" + }, + "version": { + "type": "string", + "description": "Version is the package version as found in the deps.json file" + }, + "path": { + "type": "string", + "description": "Path is the relative path to the package within the deps structure (e.g. \"app.metrics/3.0.0\")" + }, + "sha512": { + "type": "string", + "description": "Sha512 is the SHA-512 hash of the NuGet package content WITHOUT the signed content for verification (won't match hash from NuGet API or manual calculation of .nupkg file)" + }, + "hashPath": { + "type": "string", + "description": "HashPath is the relative path to the .nupkg.sha512 hash file (e.g. \"app.metrics.3.0.0.nupkg.sha512\")" + }, + "type": { + "type": "string", + "description": "Type is type of entry could be package or project for internal refs" + }, + "executables": { + "additionalProperties": { + "$ref": "#/$defs/DotnetPortableExecutableEntry" + }, + "type": "object", + "description": "Executables are the map of .NET Portable Executable files within this package with their version resources" + } + }, + "type": "object", + "required": [ + "name", + "version", + "path", + "sha512", + "hashPath" + ], + "description": "DotnetDepsEntry is a struct that represents a single entry found in the \"libraries\" section in a .NET [*.]deps.json file." + }, + "DotnetPackagesLockEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is the package name as found in the packages.lock.json file" + }, + "version": { + "type": "string", + "description": "Version is the package version as found in the packages.lock.json file" + }, + "contentHash": { + "type": "string", + "description": "ContentHash is the hash of the package content for verification" + }, + "type": { + "type": "string", + "description": "Type is the dependency type indicating how this dependency was added (Direct=explicit in project file, Transitive=pulled in by another package, Project=project reference)" + } + }, + "type": "object", + "required": [ + "name", + "version", + "contentHash", + "type" + ], + "description": "DotnetPackagesLockEntry is a struct that represents a single entry found in the \"dependencies\" section in a .NET packages.lock.json file." + }, + "DotnetPortableExecutableEntry": { + "properties": { + "assemblyVersion": { + "type": "string", + "description": "AssemblyVersion is the .NET assembly version number (strong-named version)" + }, + "legalCopyright": { + "type": "string", + "description": "LegalCopyright is the copyright notice string" + }, + "comments": { + "type": "string", + "description": "Comments are additional comments or description embedded in PE resources" + }, + "internalName": { + "type": "string", + "description": "InternalName is the internal name of the file" + }, + "companyName": { + "type": "string", + "description": "CompanyName is the company that produced the file" + }, + "productName": { + "type": "string", + "description": "ProductName is the name of the product this file is part of" + }, + "productVersion": { + "type": "string", + "description": "ProductVersion is the version of the product (may differ from AssemblyVersion)" + } + }, + "type": "object", + "required": [ + "assemblyVersion", + "legalCopyright", + "companyName", + "productName", + "productVersion" + ], + "description": "DotnetPortableExecutableEntry is a struct that represents a single entry found within \"VersionResources\" section of a .NET Portable Executable binary file." + }, + "DpkgArchiveEntry": { + "properties": { + "package": { + "type": "string", + "description": "Package is the package name as found in the status file" + }, + "source": { + "type": "string", + "description": "Source is the source package name this binary was built from (one source can produce multiple binary packages)" + }, + "version": { + "type": "string", + "description": "Version is the binary package version as found in the status file" + }, + "sourceVersion": { + "type": "string", + "description": "SourceVersion is the source package version (may differ from binary version when binNMU rebuilds occur)" + }, + "architecture": { + "type": "string", + "description": "Architecture is the target architecture per Debian spec (specific arch like amd64/arm64, wildcard like any, architecture-independent \"all\", or \"source\" for source packages)" + }, + "maintainer": { + "type": "string", + "description": "Maintainer is the package maintainer's name and email in RFC822 format (name must come first, then email in angle brackets)" + }, + "installedSize": { + "type": "integer", + "description": "InstalledSize is the total size of installed files in kilobytes" + }, + "provides": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Provides are the virtual packages provided by this package (allows other packages to depend on capabilities. Can include versioned provides like \"libdigest-md5-perl (= 2.55.01)\")" + }, + "depends": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Depends are the packages required for this package to function (will not be installed unless these requirements are met, creates strict ordering constraint)" + }, + "preDepends": { + "items": { + "type": "string" + }, + "type": "array", + "description": "PreDepends are the packages that must be installed and configured BEFORE even starting installation of this package (stronger than Depends, discouraged unless absolutely necessary as it adds strict constraints for apt)" + }, + "files": { + "items": { + "$ref": "#/$defs/DpkgFileRecord" + }, + "type": "array", + "description": "Files are the files installed by this package" + } + }, + "type": "object", + "required": [ + "package", + "source", + "version", + "sourceVersion", + "architecture", + "maintainer", + "installedSize", + "files" + ], + "description": "DpkgArchiveEntry represents package metadata extracted from a .deb archive file." + }, + "DpkgDbEntry": { + "properties": { + "package": { + "type": "string", + "description": "Package is the package name as found in the status file" + }, + "source": { + "type": "string", + "description": "Source is the source package name this binary was built from (one source can produce multiple binary packages)" + }, + "version": { + "type": "string", + "description": "Version is the binary package version as found in the status file" + }, + "sourceVersion": { + "type": "string", + "description": "SourceVersion is the source package version (may differ from binary version when binNMU rebuilds occur)" + }, + "architecture": { + "type": "string", + "description": "Architecture is the target architecture per Debian spec (specific arch like amd64/arm64, wildcard like any, architecture-independent \"all\", or \"source\" for source packages)" + }, + "maintainer": { + "type": "string", + "description": "Maintainer is the package maintainer's name and email in RFC822 format (name must come first, then email in angle brackets)" + }, + "installedSize": { + "type": "integer", + "description": "InstalledSize is the total size of installed files in kilobytes" + }, + "provides": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Provides are the virtual packages provided by this package (allows other packages to depend on capabilities. Can include versioned provides like \"libdigest-md5-perl (= 2.55.01)\")" + }, + "depends": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Depends are the packages required for this package to function (will not be installed unless these requirements are met, creates strict ordering constraint)" + }, + "preDepends": { + "items": { + "type": "string" + }, + "type": "array", + "description": "PreDepends are the packages that must be installed and configured BEFORE even starting installation of this package (stronger than Depends, discouraged unless absolutely necessary as it adds strict constraints for apt)" + }, + "files": { + "items": { + "$ref": "#/$defs/DpkgFileRecord" + }, + "type": "array", + "description": "Files are the files installed by this package" + } + }, + "type": "object", + "required": [ + "package", + "source", + "version", + "sourceVersion", + "architecture", + "maintainer", + "installedSize", + "files" + ], + "description": "DpkgDBEntry represents all captured data for a Debian package DB entry; available fields are described at http://manpages.ubuntu.com/manpages/xenial/man1/dpkg-query.1.html in the --showformat section." + }, + "DpkgFileRecord": { + "properties": { + "path": { + "type": "string", + "description": "Path is the file path relative to the filesystem root" + }, + "digest": { + "$ref": "#/$defs/Digest", + "description": "Digest is the file content hash (typically MD5 for dpkg compatibility with legacy systems)" + }, + "isConfigFile": { + "type": "boolean", + "description": "IsConfigFile is whether this file is marked as a configuration file (dpkg will preserve user modifications during upgrades)" + } + }, + "type": "object", + "required": [ + "path", + "isConfigFile" + ], + "description": "DpkgFileRecord represents a single file attributed to a debian package." + }, + "ELFSecurityFeatures": { + "properties": { + "symbolTableStripped": { + "type": "boolean", + "description": "SymbolTableStripped indicates whether debugging symbols have been removed." + }, + "stackCanary": { + "type": "boolean", + "description": "StackCanary indicates whether stack smashing protection is enabled." + }, + "nx": { + "type": "boolean", + "description": "NoExecutable indicates whether NX (no-execute) protection is enabled for the stack." + }, + "relRO": { + "type": "string", + "description": "RelocationReadOnly indicates the RELRO protection level." + }, + "pie": { + "type": "boolean", + "description": "PositionIndependentExecutable indicates whether the binary is compiled as PIE." + }, + "dso": { + "type": "boolean", + "description": "DynamicSharedObject indicates whether the binary is a shared library." + }, + "safeStack": { + "type": "boolean", + "description": "LlvmSafeStack represents a compiler-based security mechanism that separates the stack into a safe stack for storing return addresses and other critical data, and an unsafe stack for everything else, to mitigate stack-based memory corruption errors\nsee https://clang.llvm.org/docs/SafeStack.html" + }, + "cfi": { + "type": "boolean", + "description": "ControlFlowIntegrity represents runtime checks to ensure a program's control flow adheres to the legal paths determined at compile time, thus protecting against various types of control-flow hijacking attacks\nsee https://clang.llvm.org/docs/ControlFlowIntegrity.html" + }, + "fortify": { + "type": "boolean", + "description": "ClangFortifySource is a broad suite of extensions to libc aimed at catching misuses of common library functions\nsee https://android.googlesource.com/platform//bionic/+/d192dbecf0b2a371eb127c0871f77a9caf81c4d2/docs/clang_fortify_anatomy.md" + } + }, + "type": "object", + "required": [ + "symbolTableStripped", + "nx", + "relRO", + "pie", + "dso" + ], + "description": "ELFSecurityFeatures captures security hardening and protection mechanisms in ELF binaries." + }, + "ElfBinaryPackageNoteJsonPayload": { + "properties": { + "type": { + "type": "string", + "description": "Type is the type of the package (e.g. \"rpm\", \"deb\", \"apk\", etc.)" + }, + "architecture": { + "type": "string", + "description": "Architecture of the binary package (e.g. \"amd64\", \"arm\", etc.)" + }, + "osCPE": { + "type": "string", + "description": "OSCPE is a CPE name for the OS, typically corresponding to CPE_NAME in os-release (e.g. cpe:/o:fedoraproject:fedora:33)\n\nDeprecated: in Syft 2.0 the struct tag will be corrected to `osCpe` to match the systemd spec casing." + }, + "appCpe": { + "type": "string", + "description": "AppCpe is a CPE name for the upstream Application, as found in NVD CPE search (e.g. cpe:2.3:a:gnu:coreutils:5.0)" + }, + "os": { + "type": "string", + "description": "OS is the OS name, typically corresponding to ID in os-release (e.g. \"fedora\")" + }, + "osVersion": { + "type": "string", + "description": "osVersion is the version of the OS, typically corresponding to VERSION_ID in os-release (e.g. \"33\")" + }, + "system": { + "type": "string", + "description": "System is a context-specific name for the system that the binary package is intended to run on or a part of" + }, + "vendor": { + "type": "string", + "description": "Vendor is the individual or organization that produced the source code for the binary" + }, + "sourceRepo": { + "type": "string", + "description": "SourceRepo is the URL to the source repository for which the binary was built from" + }, + "commit": { + "type": "string", + "description": "Commit is the commit hash of the source repository for which the binary was built from" + } + }, + "type": "object", + "description": "ELFBinaryPackageNoteJSONPayload Represents metadata captured from the .note.package section of an ELF-formatted binary" + }, + "ElixirMixLockEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is the package name as found in the mix.lock file" + }, + "version": { + "type": "string", + "description": "Version is the package version as found in the mix.lock file" + }, + "pkgHash": { + "type": "string", + "description": "PkgHash is the outer checksum (SHA-256) of the entire Hex package tarball for integrity verification (preferred method, replaces deprecated inner checksum)" + }, + "pkgHashExt": { + "type": "string", + "description": "PkgHashExt is the extended package hash format (inner checksum is deprecated - SHA-256 of concatenated file contents excluding CHECKSUM file, now replaced by outer checksum)" + } + }, + "type": "object", + "required": [ + "name", + "version", + "pkgHash", + "pkgHashExt" + ], + "description": "ElixirMixLockEntry is a struct that represents a single entry in a mix.lock file" + }, + "ErlangRebarLockEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is the package name as found in the rebar.lock file" + }, + "version": { + "type": "string", + "description": "Version is the package version as found in the rebar.lock file" + }, + "pkgHash": { + "type": "string", + "description": "PkgHash is the outer checksum (SHA-256) of the entire Hex package tarball for integrity verification (preferred method over deprecated inner checksum)" + }, + "pkgHashExt": { + "type": "string", + "description": "PkgHashExt is the extended package hash format (inner checksum deprecated - was SHA-256 of concatenated file contents)" + } + }, + "type": "object", + "required": [ + "name", + "version", + "pkgHash", + "pkgHashExt" + ], + "description": "ErlangRebarLockEntry represents a single package entry from the \"deps\" section within an Erlang rebar.lock file." + }, + "Executable": { + "properties": { + "format": { + "type": "string", + "description": "Format denotes either ELF, Mach-O, or PE" + }, + "hasExports": { + "type": "boolean", + "description": "HasExports indicates whether the binary exports symbols." + }, + "hasEntrypoint": { + "type": "boolean", + "description": "HasEntrypoint indicates whether the binary has an entry point function." + }, + "importedLibraries": { + "items": { + "type": "string" + }, + "type": "array", + "description": "ImportedLibraries lists the shared libraries required by this executable." + }, + "elfSecurityFeatures": { + "$ref": "#/$defs/ELFSecurityFeatures", + "description": "ELFSecurityFeatures contains ELF-specific security hardening information when Format is ELF." + } + }, + "type": "object", + "required": [ + "format", + "hasExports", + "hasEntrypoint", + "importedLibraries" + ], + "description": "Executable contains metadata about binary files and their security features." + }, + "File": { + "properties": { + "id": { + "type": "string", + "description": "ID is a unique identifier for this file within the SBOM." + }, + "location": { + "$ref": "#/$defs/Coordinates", + "description": "Location is the file path and layer information where this file was found." + }, + "metadata": { + "$ref": "#/$defs/FileMetadataEntry", + "description": "Metadata contains filesystem metadata such as permissions, ownership, and file type." + }, + "contents": { + "type": "string", + "description": "Contents is the file contents for small files." + }, + "digests": { + "items": { + "$ref": "#/$defs/Digest" + }, + "type": "array", + "description": "Digests contains cryptographic hashes of the file contents." + }, + "licenses": { + "items": { + "$ref": "#/$defs/FileLicense" + }, + "type": "array", + "description": "Licenses contains license information discovered within this file." + }, + "executable": { + "$ref": "#/$defs/Executable", + "description": "Executable contains executable metadata if this file is a binary." + }, + "unknowns": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Unknowns contains unknown fields for forward compatibility." + } + }, + "type": "object", + "required": [ + "id", + "location" + ], + "description": "File represents a file discovered during cataloging with its metadata, content digests, licenses, and relationships to packages." + }, + "FileLicense": { + "properties": { + "value": { + "type": "string", + "description": "Value is the raw license identifier or text as found in the file." + }, + "spdxExpression": { + "type": "string", + "description": "SPDXExpression is the parsed SPDX license expression." + }, + "type": { + "type": "string", + "description": "Type is the license type classification (e.g., declared, concluded, discovered)." + }, + "evidence": { + "$ref": "#/$defs/FileLicenseEvidence", + "description": "Evidence contains supporting evidence for this license detection." + } + }, + "type": "object", + "required": [ + "value", + "spdxExpression", + "type" + ], + "description": "FileLicense represents license information discovered within a file's contents or metadata, including the matched license text and SPDX expression." + }, + "FileLicenseEvidence": { + "properties": { + "confidence": { + "type": "integer", + "description": "Confidence is the confidence score for this license detection (0-100)." + }, + "offset": { + "type": "integer", + "description": "Offset is the byte offset where the license text starts in the file." + }, + "extent": { + "type": "integer", + "description": "Extent is the length of the license text in bytes." + } + }, + "type": "object", + "required": [ + "confidence", + "offset", + "extent" + ], + "description": "FileLicenseEvidence contains supporting evidence for a license detection in a file, including the byte offset, extent, and confidence level." + }, + "FileMetadataEntry": { + "properties": { + "mode": { + "type": "integer", + "description": "Mode is the Unix file permission mode in octal format." + }, + "type": { + "type": "string", + "description": "Type is the file type (e.g., \"RegularFile\", \"Directory\", \"SymbolicLink\")." + }, + "linkDestination": { + "type": "string", + "description": "LinkDestination is the target path for symbolic links." + }, + "userID": { + "type": "integer", + "description": "UserID is the file owner user ID." + }, + "groupID": { + "type": "integer", + "description": "GroupID is the file owner group ID." + }, + "mimeType": { + "type": "string", + "description": "MIMEType is the MIME type of the file contents." + }, + "size": { + "type": "integer", + "description": "Size is the file size in bytes." + } + }, + "type": "object", + "required": [ + "mode", + "type", + "userID", + "groupID", + "mimeType", + "size" + ], + "description": "FileMetadataEntry contains filesystem-level metadata attributes such as permissions, ownership, type, and size for a cataloged file." + }, + "GgufFileHeader": { + "properties": { + "ggufVersion": { + "type": "integer", + "description": "GGUFVersion is the GGUF format version (e.g., 3)" + }, + "fileSize": { + "type": "integer", + "description": "FileSize is the size of the GGUF file in bytes (best-effort if available from resolver)" + }, + "architecture": { + "type": "string", + "description": "Architecture is the model architecture (from general.architecture, e.g., \"qwen3moe\", \"llama\")" + }, + "quantization": { + "type": "string", + "description": "Quantization is the quantization type (e.g., \"IQ4_NL\", \"Q4_K_M\")" + }, + "parameters": { + "type": "integer", + "description": "Parameters is the number of model parameters (if present in header)" + }, + "tensorCount": { + "type": "integer", + "description": "TensorCount is the number of tensors in the model" + }, + "header": { + "type": "object", + "description": "RemainingKeyValues contains the remaining key-value pairs from the GGUF header that are not already\nrepresented as typed fields above. This preserves additional metadata fields for reference\n(namespaced with general.*, llama.*, etc.) while avoiding duplication." + }, + "metadataHash": { + "type": "string", + "description": "MetadataKeyValuesHash is a xx64 hash of all key-value pairs from the GGUF header metadata.\nThis hash is computed over the complete header metadata (including the fields extracted\ninto typed fields above) and provides a stable identifier for the model configuration\nacross different file locations or remotes. It allows matching identical models even\nwhen stored in different repositories or with different filenames." + }, + "parts": { + "items": { + "$ref": "#/$defs/GgufFileHeader" + }, + "type": "array", + "description": "Parts contains headers from additional GGUF files that were merged\ninto this package during post-processing (e.g., from OCI layers without model names)." + } + }, + "type": "object", + "required": [ + "ggufVersion", + "tensorCount" + ], + "description": "GGUFFileHeader represents metadata extracted from a GGUF (GPT-Generated Unified Format) model file." + }, + "GithubActionsUseStatement": { + "properties": { + "value": { + "type": "string", + "description": "Value is the action reference (e.g. \"actions/checkout@v3\")" + }, + "comment": { + "type": "string", + "description": "Comment is the inline comment associated with this uses statement" + } + }, + "type": "object", + "required": [ + "value" + ], + "description": "GitHubActionsUseStatement represents a single 'uses' statement in a GitHub Actions workflow file referencing an action or reusable workflow." + }, + "GoModuleBuildinfoEntry": { + "properties": { + "goBuildSettings": { + "$ref": "#/$defs/KeyValues", + "description": "BuildSettings contains the Go build settings and flags used to compile the binary (e.g., GOARCH, GOOS, CGO_ENABLED)." + }, + "goCompiledVersion": { + "type": "string", + "description": "GoCompiledVersion is the version of Go used to compile the binary." + }, + "architecture": { + "type": "string", + "description": "Architecture is the target CPU architecture for the binary (extracted from GOARCH build setting)." + }, + "h1Digest": { + "type": "string", + "description": "H1Digest is the Go module hash in h1: format for the main module from go.sum." + }, + "mainModule": { + "type": "string", + "description": "MainModule is the main module path for the binary (e.g., \"github.com/anchore/syft\")." + }, + "goCryptoSettings": { + "items": { + "type": "string" + }, + "type": "array", + "description": "GoCryptoSettings contains FIPS and cryptographic configuration settings if present." + }, + "goExperiments": { + "items": { + "type": "string" + }, + "type": "array", + "description": "GoExperiments lists experimental Go features enabled during compilation (e.g., \"arenas\", \"cgocheck2\")." + } + }, + "type": "object", + "required": [ + "goCompiledVersion", + "architecture" + ], + "description": "GolangBinaryBuildinfoEntry represents all captured data for a Golang binary" + }, + "GoModuleEntry": { + "properties": { + "h1Digest": { + "type": "string", + "description": "H1Digest is the Go module hash in h1: format from go.sum for verifying module contents." + } + }, + "type": "object", + "description": "GolangModuleEntry represents all captured data for a Golang source scan with go.mod/go.sum" + }, + "GoSourceEntry": { + "properties": { + "h1Digest": { + "type": "string", + "description": "H1Digest is the Go module hash in h1: format from go.sum for verifying module contents." + }, + "os": { + "type": "string", + "description": "OperatingSystem is the target OS for build constraints (e.g., \"linux\", \"darwin\", \"windows\")." + }, + "architecture": { + "type": "string", + "description": "Architecture is the target CPU architecture for build constraints (e.g., \"amd64\", \"arm64\")." + }, + "buildTags": { + "type": "string", + "description": "BuildTags are the build tags used to conditionally compile code (e.g., \"integration,debug\")." + }, + "cgoEnabled": { + "type": "boolean", + "description": "CgoEnabled indicates whether CGO was enabled for this package." + } + }, + "type": "object", + "required": [ + "cgoEnabled" + ], + "description": "GolangSourceEntry represents all captured data for a Golang package found through source analysis" + }, + "HaskellHackageStackEntry": { + "properties": { + "pkgHash": { + "type": "string", + "description": "PkgHash is the package content hash for verification" + } + }, + "type": "object", + "description": "HackageStackYamlEntry represents a single entry from the \"extra-deps\" section of a stack.yaml file." + }, + "HaskellHackageStackLockEntry": { + "properties": { + "pkgHash": { + "type": "string", + "description": "PkgHash is the package content hash for verification" + }, + "snapshotURL": { + "type": "string", + "description": "SnapshotURL is the URL to the Stack snapshot this package came from" + } + }, + "type": "object", + "description": "HackageStackYamlLockEntry represents a single entry from the \"packages\" section of a stack.yaml.lock file." + }, + "HomebrewFormula": { + "properties": { + "tap": { + "type": "string", + "description": "Tap is Homebrew tap this formula belongs to (e.g. \"homebrew/core\")" + }, + "homepage": { + "type": "string", + "description": "Homepage is the upstream project homepage URL" + }, + "description": { + "type": "string", + "description": "Description is a human-readable formula description" + } + }, + "type": "object", + "description": "HomebrewFormula represents metadata about a Homebrew formula package extracted from formula JSON files." + }, + "IDLikes": { + "items": { + "type": "string" + }, + "type": "array", + "description": "IDLikes represents a list of distribution IDs that this Linux distribution is similar to or derived from, as defined in os-release ID_LIKE field." + }, + "JavaArchive": { + "properties": { + "virtualPath": { + "type": "string", + "description": "VirtualPath is path within the archive hierarchy, where nested entries are delimited with ':' (for nested JARs)" + }, + "manifest": { + "$ref": "#/$defs/JavaManifest", + "description": "Manifest is parsed META-INF/MANIFEST.MF contents" + }, + "pomProperties": { + "$ref": "#/$defs/JavaPomProperties", + "description": "PomProperties is parsed pom.properties file contents" + }, + "pomProject": { + "$ref": "#/$defs/JavaPomProject", + "description": "PomProject is parsed pom.xml file contents" + }, + "digest": { + "items": { + "$ref": "#/$defs/Digest" + }, + "type": "array", + "description": "ArchiveDigests is cryptographic hashes of the archive file" + } + }, + "type": "object", + "required": [ + "virtualPath" + ], + "description": "JavaArchive encapsulates all Java ecosystem metadata for a package as well as an (optional) parent relationship." + }, + "JavaJvmInstallation": { + "properties": { + "release": { + "$ref": "#/$defs/JavaVMRelease", + "description": "Release is JVM release information and version details" + }, + "files": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Files are the list of files that are part of this JVM installation" + } + }, + "type": "object", + "required": [ + "release", + "files" + ], + "description": "JavaVMInstallation represents a Java Virtual Machine installation discovered on the system with its release information and file list." + }, + "JavaManifest": { + "properties": { + "main": { + "$ref": "#/$defs/KeyValues", + "description": "Main is main manifest attributes as key-value pairs" + }, + "sections": { + "items": { + "$ref": "#/$defs/KeyValues" + }, + "type": "array", + "description": "Sections are the named sections from the manifest (e.g. per-entry attributes)" + } + }, + "type": "object", + "description": "JavaManifest represents the fields of interest extracted from a Java archive's META-INF/MANIFEST.MF file." + }, + "JavaPomParent": { + "properties": { + "groupId": { + "type": "string", + "description": "GroupID is the parent Maven group identifier" + }, + "artifactId": { + "type": "string", + "description": "ArtifactID is the parent Maven artifact identifier" + }, + "version": { + "type": "string", + "description": "Version is the parent version (child inherits configuration from this specific version of parent POM)" + } + }, + "type": "object", + "required": [ + "groupId", + "artifactId", + "version" + ], + "description": "JavaPomParent contains the fields within the \u003cparent\u003e tag in a pom.xml file" + }, + "JavaPomProject": { + "properties": { + "path": { + "type": "string", + "description": "Path is path to the pom.xml file within the archive" + }, + "parent": { + "$ref": "#/$defs/JavaPomParent", + "description": "Parent is the parent POM reference for inheritance (child POMs inherit configuration from parent)" + }, + "groupId": { + "type": "string", + "description": "GroupID is Maven group identifier (reversed domain name like org.apache.maven)" + }, + "artifactId": { + "type": "string", + "description": "ArtifactID is Maven artifact identifier (project name)" + }, + "version": { + "type": "string", + "description": "Version is project version (together with groupId and artifactId forms Maven coordinates groupId:artifactId:version)" + }, + "name": { + "type": "string", + "description": "Name is a human-readable project name (displayed in Maven-generated documentation)" + }, + "description": { + "type": "string", + "description": "Description is detailed project description" + }, + "url": { + "type": "string", + "description": "URL is the project URL (typically project website or repository)" + } + }, + "type": "object", + "required": [ + "path", + "groupId", + "artifactId", + "version", + "name" + ], + "description": "JavaPomProject represents fields of interest extracted from a Java archive's pom.xml file." + }, + "JavaPomProperties": { + "properties": { + "path": { + "type": "string", + "description": "Path is path to the pom.properties file within the archive" + }, + "name": { + "type": "string", + "description": "Name is the project name" + }, + "groupId": { + "type": "string", + "description": "GroupID is Maven group identifier uniquely identifying the project across all projects (follows reversed domain name convention like com.company.project)" + }, + "artifactId": { + "type": "string", + "description": "ArtifactID is Maven artifact identifier, the name of the jar/artifact (unique within the groupId scope)" + }, + "version": { + "type": "string", + "description": "Version is artifact version" + }, + "scope": { + "type": "string", + "description": "Scope is dependency scope determining when dependency is available (compile=default all phases, test=test compilation/execution only, runtime=runtime and test not compile, provided=expected from JDK or container)" + }, + "extraFields": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Extra is additional custom properties not in standard Maven coordinates" + } + }, + "type": "object", + "required": [ + "path", + "name", + "groupId", + "artifactId", + "version" + ], + "description": "JavaPomProperties represents the fields of interest extracted from a Java archive's pom.properties file." + }, + "JavaVMRelease": { + "properties": { + "implementor": { + "type": "string", + "description": "Implementor is extracted with the `java.vendor` JVM property" + }, + "implementorVersion": { + "type": "string", + "description": "ImplementorVersion is extracted with the `java.vendor.version` JVM property" + }, + "javaRuntimeVersion": { + "type": "string", + "description": "JavaRuntimeVersion is extracted from the 'java.runtime.version' JVM property" + }, + "javaVersion": { + "type": "string", + "description": "JavaVersion matches that from `java -version` command output" + }, + "javaVersionDate": { + "type": "string", + "description": "JavaVersionDate is extracted from the 'java.version.date' JVM property" + }, + "libc": { + "type": "string", + "description": "Libc can either be 'glibc' or 'musl'" + }, + "modules": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Modules is a list of JVM modules that are packaged" + }, + "osArch": { + "type": "string", + "description": "OsArch is the target CPU architecture" + }, + "osName": { + "type": "string", + "description": "OsName is the name of the target runtime operating system environment" + }, + "osVersion": { + "type": "string", + "description": "OsVersion is the version of the target runtime operating system environment" + }, + "source": { + "type": "string", + "description": "Source refers to the origin repository of OpenJDK source" + }, + "buildSource": { + "type": "string", + "description": "BuildSource Git SHA of the build repository" + }, + "buildSourceRepo": { + "type": "string", + "description": "BuildSourceRepo refers to rhe repository URL for the build source" + }, + "sourceRepo": { + "type": "string", + "description": "SourceRepo refers to the OpenJDK repository URL" + }, + "fullVersion": { + "type": "string", + "description": "FullVersion is extracted from the 'java.runtime.version' JVM property" + }, + "semanticVersion": { + "type": "string", + "description": "SemanticVersion is derived from the OpenJDK version" + }, + "buildInfo": { + "type": "string", + "description": "BuildInfo contains additional build information" + }, + "jvmVariant": { + "type": "string", + "description": "JvmVariant specifies the JVM variant (e.g., Hotspot or OpenJ9)" + }, + "jvmVersion": { + "type": "string", + "description": "JvmVersion is extracted from the 'java.vm.version' JVM property" + }, + "imageType": { + "type": "string", + "description": "ImageType can be 'JDK' or 'JRE'" + }, + "buildType": { + "type": "string", + "description": "BuildType can be 'commercial' (used in some older oracle JDK distributions)" + } + }, + "type": "object", + "description": "JavaVMRelease represents JVM version and build information extracted from the release file in a Java installation." + }, + "JavascriptNpmPackage": { + "properties": { + "name": { + "type": "string", + "description": "Name is the package name as found in package.json" + }, + "version": { + "type": "string", + "description": "Version is the package version as found in package.json" + }, + "author": { + "type": "string", + "description": "Author is package author name" + }, + "homepage": { + "type": "string", + "description": "Homepage is project homepage URL" + }, + "description": { + "type": "string", + "description": "Description is a human-readable package description" + }, + "url": { + "type": "string", + "description": "URL is repository or project URL" + }, + "private": { + "type": "boolean", + "description": "Private is whether this is a private package" + } + }, + "type": "object", + "required": [ + "name", + "version", + "author", + "homepage", + "description", + "url", + "private" + ], + "description": "NpmPackage represents the contents of a javascript package.json file." + }, + "JavascriptNpmPackageLockEntry": { + "properties": { + "resolved": { + "type": "string", + "description": "Resolved is URL where this package was downloaded from (registry source)" + }, + "integrity": { + "type": "string", + "description": "Integrity is Subresource Integrity hash for verification using standard SRI format (sha512-... or sha1-...). npm changed from SHA-1 to SHA-512 in newer versions. For registry sources this is the integrity from registry, for remote tarballs it's SHA-512 of the file. npm verifies tarball matches this hash before unpacking, throwing EINTEGRITY error if mismatch detected." + }, + "dependencies": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Dependencies is a map of dependencies and their version markers, i.e. \"lodash\": \"^1.0.0\"" + } + }, + "type": "object", + "required": [ + "resolved", + "integrity", + "dependencies" + ], + "description": "NpmPackageLockEntry represents a single entry within the \"packages\" section of a package-lock.json file." + }, + "JavascriptPnpmLockEntry": { + "properties": { + "resolution": { + "$ref": "#/$defs/PnpmLockResolution", + "description": "Resolution is the resolution information for the package" + }, + "dependencies": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Dependencies is a map of dependencies and their versions" + } + }, + "type": "object", + "required": [ + "resolution", + "dependencies" + ], + "description": "PnpmLockEntry represents a single entry in the \"packages\" section of a pnpm-lock.yaml file." + }, + "JavascriptYarnLockEntry": { + "properties": { + "resolved": { + "type": "string", + "description": "Resolved is URL where this package was downloaded from" + }, + "integrity": { + "type": "string", + "description": "Integrity is Subresource Integrity hash for verification (SRI format)" + }, + "dependencies": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Dependencies is a map of dependencies and their versions" + } + }, + "type": "object", + "required": [ + "resolved", + "integrity", + "dependencies" + ], + "description": "YarnLockEntry represents a single entry section of a yarn.lock file." + }, + "KeyValue": { + "properties": { + "key": { + "type": "string", + "description": "Key is the key name" + }, + "value": { + "type": "string", + "description": "Value is the value associated with the key" + } + }, + "type": "object", + "required": [ + "key", + "value" + ], + "description": "KeyValue represents a single key-value pair." + }, + "KeyValues": { + "items": { + "$ref": "#/$defs/KeyValue" + }, + "type": "array", + "description": "KeyValues represents an ordered collection of key-value pairs that preserves insertion order." + }, + "License": { + "properties": { + "value": { + "type": "string", + "description": "Value is the raw license identifier or expression as found." + }, + "spdxExpression": { + "type": "string", + "description": "SPDXExpression is the parsed SPDX license expression." + }, + "type": { + "type": "string", + "description": "Type is the license type classification (e.g., declared, concluded, discovered)." + }, + "urls": { + "items": { + "type": "string" + }, + "type": "array", + "description": "URLs are URLs where license text or information can be found." + }, + "locations": { + "items": { + "$ref": "#/$defs/Location" + }, + "type": "array", + "description": "Locations are file locations where this license was discovered." + }, + "contents": { + "type": "string", + "description": "Contents is the full license text content." + } + }, + "type": "object", + "required": [ + "value", + "spdxExpression", + "type", + "urls", + "locations" + ], + "description": "License represents software license information discovered for a package, including SPDX expressions and supporting evidence locations." + }, + "LinuxKernelArchive": { + "properties": { + "name": { + "type": "string", + "description": "Name is kernel name (typically \"Linux\")" + }, + "architecture": { + "type": "string", + "description": "Architecture is the target CPU architecture" + }, + "version": { + "type": "string", + "description": "Version is kernel version string" + }, + "extendedVersion": { + "type": "string", + "description": "ExtendedVersion is additional version information" + }, + "buildTime": { + "type": "string", + "description": "BuildTime is when the kernel was built" + }, + "author": { + "type": "string", + "description": "Author is who built the kernel" + }, + "format": { + "type": "string", + "description": "Format is kernel image format (e.g. bzImage, zImage)" + }, + "rwRootFS": { + "type": "boolean", + "description": "RWRootFS is whether root filesystem is mounted read-write" + }, + "swapDevice": { + "type": "integer", + "description": "SwapDevice is swap device number" + }, + "rootDevice": { + "type": "integer", + "description": "RootDevice is root device number" + }, + "videoMode": { + "type": "string", + "description": "VideoMode is default video mode setting" + } + }, + "type": "object", + "required": [ + "name", + "architecture", + "version" + ], + "description": "LinuxKernel represents all captured data for a Linux kernel" + }, + "LinuxKernelModule": { + "properties": { + "name": { + "type": "string", + "description": "Name is module name" + }, + "version": { + "type": "string", + "description": "Version is module version string" + }, + "sourceVersion": { + "type": "string", + "description": "SourceVersion is the source code version identifier" + }, + "path": { + "type": "string", + "description": "Path is the filesystem path to the .ko kernel object file (absolute path)" + }, + "description": { + "type": "string", + "description": "Description is a human-readable module description" + }, + "author": { + "type": "string", + "description": "Author is module author name and email" + }, + "license": { + "type": "string", + "description": "License is module license (e.g. GPL, BSD) which must be compatible with kernel" + }, + "kernelVersion": { + "type": "string", + "description": "KernelVersion is kernel version this module was built for" + }, + "versionMagic": { + "type": "string", + "description": "VersionMagic is version magic string for compatibility checking (includes kernel version, SMP status, module loading capabilities like \"3.17.4-302.fc21.x86_64 SMP mod_unload modversions\"). Module will NOT load if vermagic doesn't match running kernel." + }, + "parameters": { + "additionalProperties": { + "$ref": "#/$defs/LinuxKernelModuleParameter" + }, + "type": "object", + "description": "Parameters are the module parameters that can be configured at load time (user-settable values like module options)" + } + }, + "type": "object", + "description": "LinuxKernelModule represents a loadable kernel module (.ko file) with its metadata, parameters, and dependencies." + }, + "LinuxKernelModuleParameter": { + "properties": { + "type": { + "type": "string", + "description": "Type is parameter data type (e.g. int, string, bool, array types)" + }, + "description": { + "type": "string", + "description": "Description is a human-readable parameter description explaining what the parameter controls" + } + }, + "type": "object", + "description": "LinuxKernelModuleParameter represents a configurable parameter for a kernel module with its type and description." + }, + "LinuxRelease": { + "properties": { + "prettyName": { + "type": "string", + "description": "PrettyName is a human-readable operating system name with version." + }, + "name": { + "type": "string", + "description": "Name is the operating system name without version information." + }, + "id": { + "type": "string", + "description": "ID is the lower-case operating system identifier (e.g., \"ubuntu\", \"rhel\")." + }, + "idLike": { + "$ref": "#/$defs/IDLikes", + "description": "IDLike is a list of operating system IDs this distribution is similar to or derived from." + }, + "version": { + "type": "string", + "description": "Version is the operating system version including codename if available." + }, + "versionID": { + "type": "string", + "description": "VersionID is the operating system version number or identifier." + }, + "versionCodename": { + "type": "string", + "description": "VersionCodename is the operating system release codename (e.g., \"jammy\", \"bullseye\")." + }, + "buildID": { + "type": "string", + "description": "BuildID is a build identifier for the operating system." + }, + "imageID": { + "type": "string", + "description": "ImageID is an identifier for container or cloud images." + }, + "imageVersion": { + "type": "string", + "description": "ImageVersion is the version for container or cloud images." + }, + "variant": { + "type": "string", + "description": "Variant is the operating system variant name (e.g., \"Server\", \"Workstation\")." + }, + "variantID": { + "type": "string", + "description": "VariantID is the lower-case operating system variant identifier." + }, + "homeURL": { + "type": "string", + "description": "HomeURL is the homepage URL for the operating system." + }, + "supportURL": { + "type": "string", + "description": "SupportURL is the support or help URL for the operating system." + }, + "bugReportURL": { + "type": "string", + "description": "BugReportURL is the bug reporting URL for the operating system." + }, + "privacyPolicyURL": { + "type": "string", + "description": "PrivacyPolicyURL is the privacy policy URL for the operating system." + }, + "cpeName": { + "type": "string", + "description": "CPEName is the Common Platform Enumeration name for the operating system." + }, + "supportEnd": { + "type": "string", + "description": "SupportEnd is the end of support date or version identifier." + }, + "extendedSupport": { + "type": "boolean", + "description": "ExtendedSupport indicates whether extended security or support is available." + } + }, + "type": "object", + "description": "LinuxRelease contains Linux distribution identification and version information extracted from /etc/os-release or similar system files." + }, + "Location": { + "properties": { + "path": { + "type": "string", + "description": "RealPath is the canonical absolute form of the path accessed (all symbolic links have been followed and relative path components like '.' and '..' have been removed)." + }, + "layerID": { + "type": "string", + "description": "FileSystemID is an ID representing and entire filesystem. For container images, this is a layer digest. For directories or a root filesystem, this is blank." + }, + "accessPath": { + "type": "string", + "description": "AccessPath is the path used to retrieve file contents (which may or may not have hardlinks / symlinks in the path)" + }, + "annotations": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Arbitrary key-value pairs that can be used to annotate a location" + } + }, + "type": "object", + "required": [ + "path", + "accessPath" + ], + "description": "Location represents a path relative to a particular filesystem resolved to a specific file.Reference." + }, + "LuarocksPackage": { + "properties": { + "name": { + "type": "string", + "description": "Name is the package name as found in the .rockspec file" + }, + "version": { + "type": "string", + "description": "Version is the package version as found in the .rockspec file" + }, + "license": { + "type": "string", + "description": "License is license identifier" + }, + "homepage": { + "type": "string", + "description": "Homepage is project homepage URL" + }, + "description": { + "type": "string", + "description": "Description is a human-readable package description" + }, + "url": { + "type": "string", + "description": "URL is the source download URL" + }, + "dependencies": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Dependencies are the map of dependency names to version constraints" + } + }, + "type": "object", + "required": [ + "name", + "version", + "license", + "homepage", + "description", + "url", + "dependencies" + ], + "description": "LuaRocksPackage represents a Lua package managed by the LuaRocks package manager with metadata from .rockspec files." + }, + "MicrosoftKbPatch": { + "properties": { + "product_id": { + "type": "string", + "description": "ProductID is MSRC Product ID (e.g. \"Windows 10 Version 1703 for 32-bit Systems\")" + }, + "kb": { + "type": "string", + "description": "Kb is Knowledge Base article number (e.g. \"5001028\")" + } + }, + "type": "object", + "required": [ + "product_id", + "kb" + ], + "description": "MicrosoftKbPatch represents a Windows Knowledge Base patch identifier associated with a specific Microsoft product from the MSRC (Microsoft Security Response Center)." + }, + "NixDerivation": { + "properties": { + "path": { + "type": "string", + "description": "Path is path to the .drv file in Nix store" + }, + "system": { + "type": "string", + "description": "System is target system string indicating where derivation can be built (e.g. \"x86_64-linux\", \"aarch64-darwin\"). Must match current system for local builds." + }, + "inputDerivations": { + "items": { + "$ref": "#/$defs/NixDerivationReference" + }, + "type": "array", + "description": "InputDerivations are the list of other derivations that were inputs to this build (dependencies)" + }, + "inputSources": { + "items": { + "type": "string" + }, + "type": "array", + "description": "InputSources are the list of source file paths that were inputs to this build" + } + }, + "type": "object", + "description": "NixDerivation represents a Nix .drv file that describes how to build a package including inputs, outputs, and build instructions." + }, + "NixDerivationReference": { + "properties": { + "path": { + "type": "string", + "description": "Path is path to the referenced .drv file" + }, + "outputs": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Outputs are which outputs of the referenced derivation were used (e.g. [\"out\"], [\"bin\", \"dev\"])" + } + }, + "type": "object", + "description": "NixDerivationReference represents a reference to another derivation used as a build input or runtime dependency." + }, + "NixStoreEntry": { + "properties": { + "path": { + "type": "string", + "description": "Path is full store path for this output (e.g. /nix/store/abc123...-package-1.0)" + }, + "output": { + "type": "string", + "description": "Output is the specific output name for multi-output packages (empty string for default \"out\" output, can be \"bin\", \"dev\", \"doc\", etc.)" + }, + "outputHash": { + "type": "string", + "description": "OutputHash is hash prefix of the store path basename (first part before the dash)" + }, + "derivation": { + "$ref": "#/$defs/NixDerivation", + "description": "Derivation is information about the .drv file that describes how this package was built" + }, + "files": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Files are the list of files under the nix/store path for this package" + } + }, + "type": "object", + "required": [ + "outputHash" + ], + "description": "NixStoreEntry represents a package in the Nix store (/nix/store) with its derivation information and metadata." + }, + "OpamPackage": { + "properties": { + "name": { + "type": "string", + "description": "Name is the package name as found in the .opam file" + }, + "version": { + "type": "string", + "description": "Version is the package version as found in the .opam file" + }, + "licenses": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Licenses are the list of applicable licenses" + }, + "url": { + "type": "string", + "description": "URL is download URL for the package source" + }, + "checksum": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Checksums are the list of checksums for verification" + }, + "homepage": { + "type": "string", + "description": "Homepage is project homepage URL" + }, + "dependencies": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Dependencies are the list of required dependencies" + } + }, + "type": "object", + "required": [ + "name", + "version", + "licenses", + "url", + "checksum", + "homepage", + "dependencies" + ], + "description": "OpamPackage represents an OCaml package managed by the OPAM package manager with metadata from .opam files." + }, + "Package": { + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "version": { + "type": "string" + }, + "type": { + "type": "string" + }, + "foundBy": { + "type": "string" + }, + "locations": { + "items": { + "$ref": "#/$defs/Location" + }, + "type": "array" + }, + "licenses": { + "$ref": "#/$defs/licenses" + }, + "language": { + "type": "string" + }, + "cpes": { + "$ref": "#/$defs/cpes" + }, + "purl": { + "type": "string" + }, + "metadataType": { + "type": "string" + }, + "metadata": { + "anyOf": [ + { + "type": "null" + }, + { + "$ref": "#/$defs/AlpmDbEntry" + }, + { + "$ref": "#/$defs/ApkDbEntry" + }, + { + "$ref": "#/$defs/BinarySignature" + }, + { + "$ref": "#/$defs/BitnamiSbomEntry" + }, + { + "$ref": "#/$defs/CConanFileEntry" + }, + { + "$ref": "#/$defs/CConanInfoEntry" + }, + { + "$ref": "#/$defs/CConanLockEntry" + }, + { + "$ref": "#/$defs/CConanLockV2Entry" + }, + { + "$ref": "#/$defs/CocoaPodfileLockEntry" + }, + { + "$ref": "#/$defs/CondaMetadataEntry" + }, + { + "$ref": "#/$defs/DartPubspec" + }, + { + "$ref": "#/$defs/DartPubspecLockEntry" + }, + { + "$ref": "#/$defs/DotnetDepsEntry" + }, + { + "$ref": "#/$defs/DotnetPackagesLockEntry" + }, + { + "$ref": "#/$defs/DotnetPortableExecutableEntry" + }, + { + "$ref": "#/$defs/DpkgArchiveEntry" + }, + { + "$ref": "#/$defs/DpkgDbEntry" + }, + { + "$ref": "#/$defs/ElfBinaryPackageNoteJsonPayload" + }, + { + "$ref": "#/$defs/ElixirMixLockEntry" + }, + { + "$ref": "#/$defs/ErlangRebarLockEntry" + }, + { + "$ref": "#/$defs/GgufFileHeader" + }, + { + "$ref": "#/$defs/GithubActionsUseStatement" + }, + { + "$ref": "#/$defs/GoModuleBuildinfoEntry" + }, + { + "$ref": "#/$defs/GoModuleEntry" + }, + { + "$ref": "#/$defs/GoSourceEntry" + }, + { + "$ref": "#/$defs/HaskellHackageStackEntry" + }, + { + "$ref": "#/$defs/HaskellHackageStackLockEntry" + }, + { + "$ref": "#/$defs/HomebrewFormula" + }, + { + "$ref": "#/$defs/JavaArchive" + }, + { + "$ref": "#/$defs/JavaJvmInstallation" + }, + { + "$ref": "#/$defs/JavascriptNpmPackage" + }, + { + "$ref": "#/$defs/JavascriptNpmPackageLockEntry" + }, + { + "$ref": "#/$defs/JavascriptPnpmLockEntry" + }, + { + "$ref": "#/$defs/JavascriptYarnLockEntry" + }, + { + "$ref": "#/$defs/LinuxKernelArchive" + }, + { + "$ref": "#/$defs/LinuxKernelModule" + }, + { + "$ref": "#/$defs/LuarocksPackage" + }, + { + "$ref": "#/$defs/MicrosoftKbPatch" + }, + { + "$ref": "#/$defs/NixStoreEntry" + }, + { + "$ref": "#/$defs/OpamPackage" + }, + { + "$ref": "#/$defs/PeBinary" + }, + { + "$ref": "#/$defs/PhpComposerInstalledEntry" + }, + { + "$ref": "#/$defs/PhpComposerLockEntry" + }, + { + "$ref": "#/$defs/PhpPearEntry" + }, + { + "$ref": "#/$defs/PhpPeclEntry" + }, + { + "$ref": "#/$defs/PortageDbEntry" + }, + { + "$ref": "#/$defs/PythonPackage" + }, + { + "$ref": "#/$defs/PythonPdmLockEntry" + }, + { + "$ref": "#/$defs/PythonPipRequirementsEntry" + }, + { + "$ref": "#/$defs/PythonPipfileLockEntry" + }, + { + "$ref": "#/$defs/PythonPoetryLockEntry" + }, + { + "$ref": "#/$defs/PythonUvLockEntry" + }, + { + "$ref": "#/$defs/RDescription" + }, + { + "$ref": "#/$defs/RpmArchive" + }, + { + "$ref": "#/$defs/RpmDbEntry" + }, + { + "$ref": "#/$defs/RubyGemspec" + }, + { + "$ref": "#/$defs/RustCargoAuditEntry" + }, + { + "$ref": "#/$defs/RustCargoLockEntry" + }, + { + "$ref": "#/$defs/SnapEntry" + }, + { + "$ref": "#/$defs/SwiftPackageManagerLockEntry" + }, + { + "$ref": "#/$defs/SwiplpackPackage" + }, + { + "$ref": "#/$defs/TerraformLockProviderEntry" + }, + { + "$ref": "#/$defs/WordpressPluginEntry" + } + ] + } + }, + "type": "object", + "required": [ + "id", + "name", + "version", + "type", + "foundBy", + "locations", + "licenses", + "language", + "cpes", + "purl" + ], + "description": "Package represents a pkg.Package object specialized for JSON marshaling and unmarshalling." + }, + "PeBinary": { + "properties": { + "VersionResources": { + "$ref": "#/$defs/KeyValues", + "description": "VersionResources contains key-value pairs extracted from the PE file's version resource section (e.g., FileVersion, ProductName, CompanyName)." + } + }, + "type": "object", + "required": [ + "VersionResources" + ], + "description": "PEBinary represents metadata captured from a Portable Executable formatted binary (dll, exe, etc.)" + }, + "PhpComposerAuthors": { + "properties": { + "name": { + "type": "string", + "description": "Name is author's full name" + }, + "email": { + "type": "string", + "description": "Email is author's email address" + }, + "homepage": { + "type": "string", + "description": "Homepage is author's personal or company website" + } + }, + "type": "object", + "required": [ + "name" + ], + "description": "PhpComposerAuthors represents author information for a PHP Composer package from the authors field in composer.json." + }, + "PhpComposerExternalReference": { + "properties": { + "type": { + "type": "string", + "description": "Type is reference type (git for source VCS, zip/tar for dist archives)" + }, + "url": { + "type": "string", + "description": "URL is the URL to the resource (git repository URL or archive download URL)" + }, + "reference": { + "type": "string", + "description": "Reference is git commit hash or version tag for source, or archive version for dist" + }, + "shasum": { + "type": "string", + "description": "Shasum is SHA hash of the archive file for integrity verification (dist only)" + } + }, + "type": "object", + "required": [ + "type", + "url", + "reference" + ], + "description": "PhpComposerExternalReference represents source or distribution information for a PHP package, indicating where the package code is retrieved from." + }, + "PhpComposerInstalledEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is package name in vendor/package format (e.g. symfony/console)" + }, + "version": { + "type": "string", + "description": "Version is the package version" + }, + "source": { + "$ref": "#/$defs/PhpComposerExternalReference", + "description": "Source is the source repository information for development (typically git repo, used when passing --prefer-source). Originates from source code repository." + }, + "dist": { + "$ref": "#/$defs/PhpComposerExternalReference", + "description": "Dist is distribution archive information for production (typically zip/tar, default install method). Packaged version of released code." + }, + "require": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Require is runtime dependencies with version constraints (package will not install unless these requirements can be met)" + }, + "provide": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Provide is virtual packages/functionality provided by this package (allows other packages to depend on capabilities)" + }, + "require-dev": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "RequireDev is development-only dependencies (not installed in production, only when developing this package or running tests)" + }, + "suggest": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Suggest is optional but recommended dependencies (suggestions for packages that would extend functionality)" + }, + "license": { + "items": { + "type": "string" + }, + "type": "array", + "description": "License is the list of license identifiers (SPDX format)" + }, + "type": { + "type": "string", + "description": "Type is package type indicating purpose (library=reusable code, project=application, metapackage=aggregates dependencies, etc.)" + }, + "notification-url": { + "type": "string", + "description": "NotificationURL is the URL to notify when package is installed (for tracking/statistics)" + }, + "bin": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Bin is the list of binary/executable files that should be added to PATH" + }, + "authors": { + "items": { + "$ref": "#/$defs/PhpComposerAuthors" + }, + "type": "array", + "description": "Authors are the list of package authors with name/email/homepage" + }, + "description": { + "type": "string", + "description": "Description is a human-readable package description" + }, + "homepage": { + "type": "string", + "description": "Homepage is project homepage URL" + }, + "keywords": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Keywords are the list of keywords for package discovery/search" + }, + "time": { + "type": "string", + "description": "Time is timestamp when this package version was released" + } + }, + "type": "object", + "required": [ + "name", + "version", + "source", + "dist" + ], + "description": "PhpComposerInstalledEntry represents a single package entry from a composer v1/v2 \"installed.json\" files (very similar to composer.lock files)." + }, + "PhpComposerLockEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is package name in vendor/package format (e.g. symfony/console)" + }, + "version": { + "type": "string", + "description": "Version is the package version" + }, + "source": { + "$ref": "#/$defs/PhpComposerExternalReference", + "description": "Source is the source repository information for development (typically git repo, used when passing --prefer-source). Originates from source code repository." + }, + "dist": { + "$ref": "#/$defs/PhpComposerExternalReference", + "description": "Dist is distribution archive information for production (typically zip/tar, default install method). Packaged version of released code." + }, + "require": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Require is runtime dependencies with version constraints (package will not install unless these requirements can be met)" + }, + "provide": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Provide is virtual packages/functionality provided by this package (allows other packages to depend on capabilities)" + }, + "require-dev": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "RequireDev is development-only dependencies (not installed in production, only when developing this package or running tests)" + }, + "suggest": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Suggest is optional but recommended dependencies (suggestions for packages that would extend functionality)" + }, + "license": { + "items": { + "type": "string" + }, + "type": "array", + "description": "License is the list of license identifiers (SPDX format)" + }, + "type": { + "type": "string", + "description": "Type is package type indicating purpose (library=reusable code, project=application, metapackage=aggregates dependencies, etc.)" + }, + "notification-url": { + "type": "string", + "description": "NotificationURL is the URL to notify when package is installed (for tracking/statistics)" + }, + "bin": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Bin is the list of binary/executable files that should be added to PATH" + }, + "authors": { + "items": { + "$ref": "#/$defs/PhpComposerAuthors" + }, + "type": "array", + "description": "Authors are the list of package authors with name/email/homepage" + }, + "description": { + "type": "string", + "description": "Description is a human-readable package description" + }, + "homepage": { + "type": "string", + "description": "Homepage is project homepage URL" + }, + "keywords": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Keywords are the list of keywords for package discovery/search" + }, + "time": { + "type": "string", + "description": "Time is timestamp when this package version was released" + } + }, + "type": "object", + "required": [ + "name", + "version", + "source", + "dist" + ], + "description": "PhpComposerLockEntry represents a single package entry found from a composer.lock file." + }, + "PhpPearEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is the package name" + }, + "channel": { + "type": "string", + "description": "Channel is PEAR channel this package is from" + }, + "version": { + "type": "string", + "description": "Version is the package version" + }, + "license": { + "items": { + "type": "string" + }, + "type": "array", + "description": "License is the list of applicable licenses" + } + }, + "type": "object", + "required": [ + "name", + "version" + ], + "description": "PhpPearEntry represents a single package entry found within php pear metadata files." + }, + "PhpPeclEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is the package name" + }, + "channel": { + "type": "string", + "description": "Channel is PEAR channel this package is from" + }, + "version": { + "type": "string", + "description": "Version is the package version" + }, + "license": { + "items": { + "type": "string" + }, + "type": "array", + "description": "License is the list of applicable licenses" + } + }, + "type": "object", + "required": [ + "name", + "version" + ], + "description": "PhpPeclEntry represents a single package entry found within php pecl metadata files." + }, + "PnpmLockResolution": { + "properties": { + "integrity": { + "type": "string", + "description": "Integrity is Subresource Integrity hash for verification (SRI format)" + } + }, + "type": "object", + "required": [ + "integrity" + ], + "description": "PnpmLockResolution contains package resolution metadata from pnpm lockfiles, including the integrity hash used for verification." + }, + "PortageDbEntry": { + "properties": { + "installedSize": { + "type": "integer", + "description": "InstalledSize is total size of installed files in bytes" + }, + "licenses": { + "type": "string", + "description": "Licenses is license string which may be an expression (e.g. \"GPL-2 OR Apache-2.0\")" + }, + "files": { + "items": { + "$ref": "#/$defs/PortageFileRecord" + }, + "type": "array", + "description": "Files are the files installed by this package (tracked in CONTENTS file)" + } + }, + "type": "object", + "required": [ + "installedSize", + "files" + ], + "description": "PortageEntry represents a single package entry in the portage DB flat-file store." + }, + "PortageFileRecord": { + "properties": { + "path": { + "type": "string", + "description": "Path is the file path relative to the filesystem root" + }, + "digest": { + "$ref": "#/$defs/Digest", + "description": "Digest is file content hash (MD5 for regular files in CONTENTS format: \"obj filename md5hash mtime\")" + } + }, + "type": "object", + "required": [ + "path" + ], + "description": "PortageFileRecord represents a single file attributed to a portage package." + }, + "PythonDirectURLOriginInfo": { + "properties": { + "url": { + "type": "string", + "description": "URL is the source URL from which the package was installed." + }, + "commitId": { + "type": "string", + "description": "CommitID is the VCS commit hash if installed from version control." + }, + "vcs": { + "type": "string", + "description": "VCS is the version control system type (e.g., \"git\", \"hg\")." + } + }, + "type": "object", + "required": [ + "url" + ], + "description": "PythonDirectURLOriginInfo represents installation source metadata from direct_url.json for packages installed from VCS or direct URLs." + }, + "PythonFileDigest": { + "properties": { + "algorithm": { + "type": "string", + "description": "Algorithm is the hash algorithm used (e.g., \"sha256\")." + }, + "value": { + "type": "string", + "description": "Value is the hex-encoded hash digest value." + } + }, + "type": "object", + "required": [ + "algorithm", + "value" + ], + "description": "PythonFileDigest represents the file metadata for a single file attributed to a python package." + }, + "PythonFileRecord": { + "properties": { + "path": { + "type": "string", + "description": "Path is the installed file path from the RECORD file." + }, + "digest": { + "$ref": "#/$defs/PythonFileDigest", + "description": "Digest contains the hash algorithm and value for file integrity verification." + }, + "size": { + "type": "string", + "description": "Size is the file size in bytes as a string." + } + }, + "type": "object", + "required": [ + "path" + ], + "description": "PythonFileRecord represents a single entry within a RECORD file for a python wheel or egg package" + }, + "PythonPackage": { + "properties": { + "name": { + "type": "string", + "description": "Name is the package name from the Name field in PKG-INFO or METADATA." + }, + "version": { + "type": "string", + "description": "Version is the package version from the Version field in PKG-INFO or METADATA." + }, + "author": { + "type": "string", + "description": "Author is the package author name from the Author field." + }, + "authorEmail": { + "type": "string", + "description": "AuthorEmail is the package author's email address from the Author-Email field." + }, + "platform": { + "type": "string", + "description": "Platform indicates the target platform for the package (e.g., \"any\", \"linux\", \"win32\")." + }, + "files": { + "items": { + "$ref": "#/$defs/PythonFileRecord" + }, + "type": "array", + "description": "Files are the installed files listed in the RECORD file for wheels or installed-files.txt for eggs." + }, + "sitePackagesRootPath": { + "type": "string", + "description": "SitePackagesRootPath is the root directory path containing the package (e.g., \"/usr/lib/python3.9/site-packages\")." + }, + "topLevelPackages": { + "items": { + "type": "string" + }, + "type": "array", + "description": "TopLevelPackages are the top-level Python module names from top_level.txt file." + }, + "directUrlOrigin": { + "$ref": "#/$defs/PythonDirectURLOriginInfo", + "description": "DirectURLOrigin contains VCS or direct URL installation information from direct_url.json." + }, + "requiresPython": { + "type": "string", + "description": "RequiresPython specifies the Python version requirement (e.g., \"\u003e=3.6\")." + }, + "requiresDist": { + "items": { + "type": "string" + }, + "type": "array", + "description": "RequiresDist lists the package dependencies with version specifiers from Requires-Dist fields." + }, + "providesExtra": { + "items": { + "type": "string" + }, + "type": "array", + "description": "ProvidesExtra lists optional feature names that can be installed via extras (e.g., \"dev\", \"test\")." + } + }, + "type": "object", + "required": [ + "name", + "version", + "author", + "authorEmail", + "platform", + "sitePackagesRootPath" + ], + "description": "PythonPackage represents all captured data for a python egg or wheel package (specifically as outlined in the PyPA core metadata specification https://packaging.python.org/en/latest/specifications/core-metadata/)." + }, + "PythonPdmFileEntry": { + "properties": { + "url": { + "type": "string", + "description": "URL is the file download URL" + }, + "digest": { + "$ref": "#/$defs/PythonFileDigest", + "description": "Digest is the hash digest of the file hosted at the URL" + } + }, + "type": "object", + "required": [ + "url", + "digest" + ] + }, + "PythonPdmLockEntry": { + "properties": { + "summary": { + "type": "string", + "description": "Summary provides a description of the package" + }, + "files": { + "items": { + "$ref": "#/$defs/PythonPdmFileEntry" + }, + "type": "array", + "description": "Files are the package files with their paths and hash digests (for the base package without extras)" + }, + "marker": { + "type": "string", + "description": "Marker is the \"environment\" --conditional expressions that determine whether a package should be installed based on the runtime environment" + }, + "requiresPython": { + "type": "string", + "description": "RequiresPython specifies the Python version requirement (e.g., \"\u003e=3.6\")." + }, + "dependencies": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Dependencies are the dependency specifications for the base package (without extras)" + }, + "extras": { + "items": { + "$ref": "#/$defs/PythonPdmLockExtraVariant" + }, + "type": "array", + "description": "Extras contains variants for different extras combinations (PDM may have multiple entries per package)" + } + }, + "type": "object", + "required": [ + "summary", + "files" + ], + "description": "PythonPdmLockEntry represents a single package entry within a pdm.lock file." + }, + "PythonPdmLockExtraVariant": { + "properties": { + "extras": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Extras are the optional extras enabled for this variant (e.g., [\"toml\"], [\"dev\"], or [\"toml\", \"dev\"])" + }, + "dependencies": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Dependencies are the dependencies specific to this extras variant" + }, + "files": { + "items": { + "$ref": "#/$defs/PythonPdmFileEntry" + }, + "type": "array", + "description": "Files are the package files specific to this variant (only populated if different from base)" + }, + "marker": { + "type": "string", + "description": "Marker is the environment conditional expression for this variant (e.g., \"python_version \u003c \\\"3.11\\\"\")" + } + }, + "type": "object", + "required": [ + "extras" + ], + "description": "PythonPdmLockExtraVariant represents a specific extras combination variant within a PDM lock file." + }, + "PythonPipRequirementsEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is the package name from the requirements file." + }, + "extras": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Extras are the optional features to install from the package (e.g., package[dev,test])." + }, + "versionConstraint": { + "type": "string", + "description": "VersionConstraint specifies version requirements (e.g., \"\u003e=1.0,\u003c2.0\")." + }, + "url": { + "type": "string", + "description": "URL is the direct download URL or VCS URL if specified instead of a PyPI package." + }, + "markers": { + "type": "string", + "description": "Markers are environment marker expressions for conditional installation (e.g., \"python_version \u003e= '3.8'\")." + } + }, + "type": "object", + "required": [ + "name", + "versionConstraint" + ], + "description": "PythonRequirementsEntry represents a single entry within a [*-]requirements.txt file." + }, + "PythonPipfileLockEntry": { + "properties": { + "hashes": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Hashes are the package file hash values in the format \"algorithm:digest\" for integrity verification." + }, + "index": { + "type": "string", + "description": "Index is the PyPI index name where the package should be fetched from." + } + }, + "type": "object", + "required": [ + "hashes", + "index" + ], + "description": "PythonPipfileLockEntry represents a single package entry within a Pipfile.lock file." + }, + "PythonPoetryLockDependencyEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is the dependency package name." + }, + "version": { + "type": "string", + "description": "Version is the locked version or version constraint for the dependency." + }, + "optional": { + "type": "boolean", + "description": "Optional indicates whether this dependency is optional (only needed for certain extras)." + }, + "markers": { + "type": "string", + "description": "Markers are environment marker expressions that conditionally enable the dependency (e.g., \"python_version \u003e= '3.8'\")." + }, + "extras": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Extras are the optional feature names from the dependency that should be installed." + } + }, + "type": "object", + "required": [ + "name", + "version", + "optional" + ], + "description": "PythonPoetryLockDependencyEntry represents a single dependency entry within a Poetry lock file." + }, + "PythonPoetryLockEntry": { + "properties": { + "index": { + "type": "string", + "description": "Index is the package repository name where the package should be fetched from." + }, + "dependencies": { + "items": { + "$ref": "#/$defs/PythonPoetryLockDependencyEntry" + }, + "type": "array", + "description": "Dependencies are the package's runtime dependencies with version constraints." + }, + "extras": { + "items": { + "$ref": "#/$defs/PythonPoetryLockExtraEntry" + }, + "type": "array", + "description": "Extras are optional feature groups that include additional dependencies." + } + }, + "type": "object", + "required": [ + "index", + "dependencies" + ], + "description": "PythonPoetryLockEntry represents a single package entry within a Pipfile.lock file." + }, + "PythonPoetryLockExtraEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is the optional feature name (e.g., \"dev\", \"test\")." + }, + "dependencies": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Dependencies are the package names required when this extra is installed." + } + }, + "type": "object", + "required": [ + "name", + "dependencies" + ], + "description": "PythonPoetryLockExtraEntry represents an optional feature group in a Poetry lock file." + }, + "PythonUvLockDependencyEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is the dependency package name." + }, + "optional": { + "type": "boolean", + "description": "Optional indicates whether this dependency is optional (only needed for certain extras)." + }, + "markers": { + "type": "string", + "description": "Markers are environment marker expressions that conditionally enable the dependency (e.g., \"python_version \u003e= '3.8'\")." + }, + "extras": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Extras are the optional feature names from the dependency that should be installed." + } + }, + "type": "object", + "required": [ + "name", + "optional" + ], + "description": "PythonUvLockDependencyEntry represents a single dependency entry within a uv lock file." + }, + "PythonUvLockEntry": { + "properties": { + "index": { + "type": "string", + "description": "Index is the package repository name where the package should be fetched from." + }, + "dependencies": { + "items": { + "$ref": "#/$defs/PythonUvLockDependencyEntry" + }, + "type": "array", + "description": "Dependencies are the package's runtime dependencies with version constraints." + }, + "extras": { + "items": { + "$ref": "#/$defs/PythonUvLockExtraEntry" + }, + "type": "array", + "description": "Extras are optional feature groups that include additional dependencies." + } + }, + "type": "object", + "required": [ + "index", + "dependencies" + ], + "description": "PythonUvLockEntry represents a single package entry within a uv.lock file." + }, + "PythonUvLockExtraEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is the optional feature name (e.g., \"dev\", \"test\")." + }, + "dependencies": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Dependencies are the package names required when this extra is installed." + } + }, + "type": "object", + "required": [ + "name", + "dependencies" + ], + "description": "PythonUvLockExtraEntry represents an optional feature group in a uv lock file." + }, + "RDescription": { + "properties": { + "title": { + "type": "string", + "description": "Title is short one-line package title" + }, + "description": { + "type": "string", + "description": "Description is detailed package description" + }, + "author": { + "type": "string", + "description": "Author is package author(s)" + }, + "maintainer": { + "type": "string", + "description": "Maintainer is current package maintainer" + }, + "url": { + "items": { + "type": "string" + }, + "type": "array", + "description": "URL is the list of related URLs" + }, + "repository": { + "type": "string", + "description": "Repository is CRAN or other repository name" + }, + "built": { + "type": "string", + "description": "Built is R version and platform this was built with" + }, + "needsCompilation": { + "type": "boolean", + "description": "NeedsCompilation is whether this package requires compilation" + }, + "imports": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Imports are the packages imported in the NAMESPACE" + }, + "depends": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Depends are the packages this package depends on" + }, + "suggests": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Suggests are the optional packages that extend functionality" + } + }, + "type": "object", + "description": "RDescription represents metadata from an R package DESCRIPTION file containing package information, dependencies, and author details." + }, + "Relationship": { + "properties": { + "parent": { + "type": "string", + "description": "Parent is the ID of the parent artifact in this relationship." + }, + "child": { + "type": "string", + "description": "Child is the ID of the child artifact in this relationship." + }, + "type": { + "type": "string", + "description": "Type is the relationship type (e.g., \"contains\", \"dependency-of\", \"ancestor-of\")." + }, + "metadata": { + "description": "Metadata contains additional relationship-specific metadata." + } + }, + "type": "object", + "required": [ + "parent", + "child", + "type" + ], + "description": "Relationship represents a directed relationship between two artifacts in the SBOM, such as package-contains-file or package-depends-on-package." + }, + "RpmArchive": { + "properties": { + "name": { + "type": "string", + "description": "Name is the RPM package name as found in the RPM database." + }, + "version": { + "type": "string", + "description": "Version is the upstream version of the package." + }, + "epoch": { + "oneOf": [ + { + "type": "integer", + "description": "Epoch is the version epoch used to force upgrade ordering (null if not set)." + }, + { + "type": "null" + } + ] + }, + "architecture": { + "type": "string", + "description": "Arch is the target CPU architecture (e.g., \"x86_64\", \"aarch64\", \"noarch\")." + }, + "release": { + "type": "string", + "description": "Release is the package release number or distribution-specific version suffix." + }, + "sourceRpm": { + "type": "string", + "description": "SourceRpm is the source RPM filename that was used to build this package." + }, + "signatures": { + "items": { + "$ref": "#/$defs/RpmSignature" + }, + "type": "array", + "description": "Signatures contains GPG signature metadata for package verification." + }, + "size": { + "type": "integer", + "description": "Size is the total installed size of the package in bytes." + }, + "vendor": { + "type": "string", + "description": "Vendor is the organization that packaged the software." + }, + "modularityLabel": { + "type": "string", + "description": "ModularityLabel identifies the module stream for modular RPM packages (e.g., \"nodejs:12:20200101\")." + }, + "provides": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Provides lists the virtual packages and capabilities this package provides." + }, + "requires": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Requires lists the dependencies required by this package." + }, + "files": { + "items": { + "$ref": "#/$defs/RpmFileRecord" + }, + "type": "array", + "description": "Files are the file records for all files owned by this package." + } + }, + "type": "object", + "required": [ + "name", + "version", + "epoch", + "architecture", + "release", + "sourceRpm", + "size", + "vendor", + "files" + ], + "description": "RpmArchive represents package metadata extracted directly from a .rpm archive file, containing the same information as an RPM database entry." + }, + "RpmDbEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is the RPM package name as found in the RPM database." + }, + "version": { + "type": "string", + "description": "Version is the upstream version of the package." + }, + "epoch": { + "oneOf": [ + { + "type": "integer", + "description": "Epoch is the version epoch used to force upgrade ordering (null if not set)." + }, + { + "type": "null" + } + ] + }, + "architecture": { + "type": "string", + "description": "Arch is the target CPU architecture (e.g., \"x86_64\", \"aarch64\", \"noarch\")." + }, + "release": { + "type": "string", + "description": "Release is the package release number or distribution-specific version suffix." + }, + "sourceRpm": { + "type": "string", + "description": "SourceRpm is the source RPM filename that was used to build this package." + }, + "signatures": { + "items": { + "$ref": "#/$defs/RpmSignature" + }, + "type": "array", + "description": "Signatures contains GPG signature metadata for package verification." + }, + "size": { + "type": "integer", + "description": "Size is the total installed size of the package in bytes." + }, + "vendor": { + "type": "string", + "description": "Vendor is the organization that packaged the software." + }, + "modularityLabel": { + "type": "string", + "description": "ModularityLabel identifies the module stream for modular RPM packages (e.g., \"nodejs:12:20200101\")." + }, + "provides": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Provides lists the virtual packages and capabilities this package provides." + }, + "requires": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Requires lists the dependencies required by this package." + }, + "files": { + "items": { + "$ref": "#/$defs/RpmFileRecord" + }, + "type": "array", + "description": "Files are the file records for all files owned by this package." + } + }, + "type": "object", + "required": [ + "name", + "version", + "epoch", + "architecture", + "release", + "sourceRpm", + "size", + "vendor", + "files" + ], + "description": "RpmDBEntry represents all captured data from a RPM DB package entry." + }, + "RpmFileRecord": { + "properties": { + "path": { + "type": "string", + "description": "Path is the absolute file path where the file is installed." + }, + "mode": { + "type": "integer", + "description": "Mode is the file permission mode bits following Unix stat.h conventions." + }, + "size": { + "type": "integer", + "description": "Size is the file size in bytes." + }, + "digest": { + "$ref": "#/$defs/Digest", + "description": "Digest contains the hash algorithm and value for file integrity verification." + }, + "userName": { + "type": "string", + "description": "UserName is the owner username for the file." + }, + "groupName": { + "type": "string", + "description": "GroupName is the group name for the file." + }, + "flags": { + "type": "string", + "description": "Flags indicates the file type (e.g., \"%config\", \"%doc\", \"%ghost\")." + } + }, + "type": "object", + "required": [ + "path", + "mode", + "size", + "digest", + "userName", + "groupName", + "flags" + ], + "description": "RpmFileRecord represents the file metadata for a single file attributed to a RPM package." + }, + "RpmSignature": { + "properties": { + "algo": { + "type": "string", + "description": "PublicKeyAlgorithm is the public key algorithm used for signing (e.g., \"RSA\")." + }, + "hash": { + "type": "string", + "description": "HashAlgorithm is the hash algorithm used for the signature (e.g., \"SHA256\")." + }, + "created": { + "type": "string", + "description": "Created is the timestamp when the signature was created." + }, + "issuer": { + "type": "string", + "description": "IssuerKeyID is the GPG key ID that created the signature." + } + }, + "type": "object", + "required": [ + "algo", + "hash", + "created", + "issuer" + ], + "description": "RpmSignature represents a GPG signature for an RPM package used for authenticity verification." + }, + "RubyGemspec": { + "properties": { + "name": { + "type": "string", + "description": "Name is gem name as specified in the gemspec" + }, + "version": { + "type": "string", + "description": "Version is gem version as specified in the gemspec" + }, + "files": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Files is logical list of files in the gem (NOT directly usable as filesystem paths. Example: bundler gem lists \"lib/bundler/vendor/uri/lib/uri/ldap.rb\" but actual path is \"/usr/local/lib/ruby/3.2.0/bundler/vendor/uri/lib/uri/ldap.rb\". Would need gem installation path, ruby version, and env vars like GEM_HOME to resolve actual paths.)" + }, + "authors": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Authors are the list of gem authors (stored as array regardless of using `author` or `authors` method in gemspec)" + }, + "homepage": { + "type": "string", + "description": "Homepage is project homepage URL" + } + }, + "type": "object", + "required": [ + "name", + "version" + ], + "description": "RubyGemspec represents all metadata parsed from the *.gemspec file" + }, + "RustCargoAuditEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is crate name as specified in audit section of the build binary" + }, + "version": { + "type": "string", + "description": "Version is crate version as specified in audit section of the build binary" + }, + "source": { + "type": "string", + "description": "Source is the source registry or repository where this crate came from" + } + }, + "type": "object", + "required": [ + "name", + "version", + "source" + ], + "description": "RustBinaryAuditEntry represents Rust crate metadata extracted from a compiled binary using cargo-auditable format." + }, + "RustCargoLockEntry": { + "properties": { + "name": { + "type": "string", + "description": "Name is crate name as specified in Cargo.toml" + }, + "version": { + "type": "string", + "description": "Version is crate version as specified in Cargo.toml" + }, + "source": { + "type": "string", + "description": "Source is the source registry or repository URL in format \"registry+https://github.com/rust-lang/crates.io-index\" for registry packages" + }, + "checksum": { + "type": "string", + "description": "Checksum is content checksum for registry packages only (hexadecimal string). Cargo doesn't require or include checksums for git dependencies. Used to detect MITM attacks by verifying downloaded crate matches lockfile checksum." + }, + "dependencies": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Dependencies are the list of dependencies with version constraints" + } + }, + "type": "object", + "required": [ + "name", + "version", + "source", + "checksum", + "dependencies" + ], + "description": "RustCargoLockEntry represents a locked dependency from a Cargo.lock file with precise version and checksum information." + }, + "Schema": { + "properties": { + "version": { + "type": "string", + "description": "Version is the JSON schema version for this document format." + }, + "url": { + "type": "string", + "description": "URL is the URL to the JSON schema definition document." + } + }, + "type": "object", + "required": [ + "version", + "url" + ], + "description": "Schema specifies the JSON schema version and URL reference that defines the structure and validation rules for this document format." + }, + "SnapEntry": { + "properties": { + "snapType": { + "type": "string", + "description": "SnapType indicates the snap type (base, kernel, app, gadget, or snapd)." + }, + "base": { + "type": "string", + "description": "Base is the base snap name that this snap depends on (e.g., \"core20\", \"core22\")." + }, + "snapName": { + "type": "string", + "description": "SnapName is the snap package name." + }, + "snapVersion": { + "type": "string", + "description": "SnapVersion is the snap package version." + }, + "architecture": { + "type": "string", + "description": "Architecture is the target CPU architecture (e.g., \"amd64\", \"arm64\")." + } + }, + "type": "object", + "required": [ + "snapType", + "base", + "snapName", + "snapVersion", + "architecture" + ], + "description": "SnapEntry represents metadata for a Snap package extracted from snap.yaml or snapcraft.yaml files." + }, + "Source": { + "properties": { + "id": { + "type": "string", + "description": "ID is a unique identifier for the analyzed source artifact." + }, + "name": { + "type": "string", + "description": "Name is the name of the analyzed artifact (e.g., image name, directory path)." + }, + "version": { + "type": "string", + "description": "Version is the version of the analyzed artifact (e.g., image tag)." + }, + "supplier": { + "type": "string", + "description": "Supplier is supplier information, which can be user-provided for NTIA minimum elements compliance." + }, + "type": { + "type": "string", + "description": "Type is the source type (e.g., \"image\", \"directory\", \"file\")." + }, + "metadata": { + "description": "Metadata contains additional source-specific metadata." + } + }, + "type": "object", + "required": [ + "id", + "name", + "version", + "type", + "metadata" + ], + "description": "Source represents the artifact that was analyzed to generate this SBOM, such as a container image, directory, or file archive." + }, + "SwiftPackageManagerLockEntry": { + "properties": { + "revision": { + "type": "string", + "description": "Revision is git commit hash of the resolved package" + } + }, + "type": "object", + "required": [ + "revision" + ], + "description": "SwiftPackageManagerResolvedEntry represents a resolved dependency from a Package.resolved file with its locked version and source location." + }, + "SwiplpackPackage": { + "properties": { + "name": { + "type": "string", + "description": "Name is the package name as found in the .toml file" + }, + "version": { + "type": "string", + "description": "Version is the package version as found in the .toml file" + }, + "author": { + "type": "string", + "description": "Author is author name" + }, + "authorEmail": { + "type": "string", + "description": "AuthorEmail is author email address" + }, + "packager": { + "type": "string", + "description": "Packager is packager name (if different from author)" + }, + "packagerEmail": { + "type": "string", + "description": "PackagerEmail is packager email address" + }, + "homepage": { + "type": "string", + "description": "Homepage is project homepage URL" + }, + "dependencies": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Dependencies are the list of required dependencies" + } + }, + "type": "object", + "required": [ + "name", + "version", + "author", + "authorEmail", + "packager", + "packagerEmail", + "homepage", + "dependencies" + ], + "description": "SwiplPackEntry represents a SWI-Prolog package from the pack system with metadata about the package and its dependencies." + }, + "TerraformLockProviderEntry": { + "properties": { + "url": { + "type": "string", + "description": "URL is the provider source address (e.g., \"registry.terraform.io/hashicorp/aws\")." + }, + "constraints": { + "type": "string", + "description": "Constraints specifies the version constraints for the provider (e.g., \"~\u003e 4.0\")." + }, + "version": { + "type": "string", + "description": "Version is the locked provider version selected during terraform init." + }, + "hashes": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Hashes are cryptographic checksums for the provider plugin archives across different platforms." + } + }, + "type": "object", + "required": [ + "url", + "constraints", + "version", + "hashes" + ], + "description": "TerraformLockProviderEntry represents a single provider entry in a Terraform dependency lock file (.terraform.lock.hcl)." + }, + "WordpressPluginEntry": { + "properties": { + "pluginInstallDirectory": { + "type": "string", + "description": "PluginInstallDirectory is directory name where the plugin is installed" + }, + "author": { + "type": "string", + "description": "Author is plugin author name" + }, + "authorUri": { + "type": "string", + "description": "AuthorURI is author's website URL" + } + }, + "type": "object", + "required": [ + "pluginInstallDirectory" + ], + "description": "WordpressPluginEntry represents all metadata parsed from the wordpress plugin file" + }, + "cpes": { + "items": { + "$ref": "#/$defs/CPE" + }, + "type": "array" + }, + "licenses": { + "items": { + "$ref": "#/$defs/License" + }, + "type": "array" + } + } +} diff --git a/schema/json/schema-latest.json b/schema/json/schema-latest.json index 7f49453fd..125c92005 100644 --- a/schema/json/schema-latest.json +++ b/schema/json/schema-latest.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "anchore.io/schema/syft/json/16.1.2/document", + "$id": "anchore.io/schema/syft/json/16.1.3/document", "$ref": "#/$defs/Document", "$defs": { "AlpmDbEntry": { @@ -1478,6 +1478,13 @@ "metadataHash": { "type": "string", "description": "MetadataKeyValuesHash is a xx64 hash of all key-value pairs from the GGUF header metadata.\nThis hash is computed over the complete header metadata (including the fields extracted\ninto typed fields above) and provides a stable identifier for the model configuration\nacross different file locations or remotes. It allows matching identical models even\nwhen stored in different repositories or with different filenames." + }, + "parts": { + "items": { + "$ref": "#/$defs/GgufFileHeader" + }, + "type": "array", + "description": "Parts contains headers from additional GGUF files that were merged\ninto this package during post-processing (e.g., from OCI layers without model names)." } }, "type": "object", diff --git a/syft/create_sbom_config.go b/syft/create_sbom_config.go index f75113f17..2e737f6f2 100644 --- a/syft/create_sbom_config.go +++ b/syft/create_sbom_config.go @@ -477,7 +477,7 @@ func (c *CreateSBOMConfig) Create(ctx context.Context, src source.Source) (*sbom func findDefaultTags(src source.Description) ([]string, error) { switch m := src.Metadata.(type) { - case source.ImageMetadata: + case source.ImageMetadata, source.OCIModelMetadata: return []string{pkgcataloging.ImageTag, filecataloging.FileTag}, nil case source.FileMetadata, source.DirectoryMetadata: return []string{pkgcataloging.DirectoryTag, filecataloging.FileTag}, nil diff --git a/syft/file/mock_resolver.go b/syft/file/mock_resolver.go index 4a200d011..b9ed38420 100644 --- a/syft/file/mock_resolver.go +++ b/syft/file/mock_resolver.go @@ -13,16 +13,18 @@ import ( ) var _ Resolver = (*MockResolver)(nil) +var _ OCIMediaTypeResolver = (*MockResolver)(nil) // MockResolver implements the FileResolver interface and is intended for use *only in test code*. // It provides an implementation that can resolve local filesystem paths using only a provided discrete list of file // paths, which are typically paths to test fixtures. type MockResolver struct { - locations []Location - metadata map[Coordinates]Metadata - mimeTypeIndex map[string][]Location - extension map[string][]Location - basename map[string][]Location + locations []Location + metadata map[Coordinates]Metadata + mimeTypeIndex map[string][]Location + mediaTypeIndex map[string][]Location + extension map[string][]Location + basename map[string][]Location } // NewMockResolverForPaths creates a new MockResolver, where the only resolvable @@ -72,6 +74,34 @@ func NewMockResolverForPathsWithMetadata(metadata map[Coordinates]Metadata) *Moc } } +// NewMockResolverForMediaTypes creates a MockResolver that can resolve files by media type. +// The mediaTypes map specifies which locations should be returned for each media type. +func NewMockResolverForMediaTypes(mediaTypes map[string][]Location) *MockResolver { + var locations []Location + mediaTypeIndex := make(map[string][]Location) + extension := make(map[string][]Location) + basename := make(map[string][]Location) + + for mediaType, locs := range mediaTypes { + mediaTypeIndex[mediaType] = append(mediaTypeIndex[mediaType], locs...) + for _, l := range locs { + locations = append(locations, l) + ext := path.Ext(l.RealPath) + extension[ext] = append(extension[ext], l) + bn := path.Base(l.RealPath) + basename[bn] = append(basename[bn], l) + } + } + + return &MockResolver{ + locations: locations, + metadata: make(map[Coordinates]Metadata), + mediaTypeIndex: mediaTypeIndex, + extension: extension, + basename: basename, + } +} + // HasPath indicates if the given path exists in the underlying source. func (r MockResolver) HasPath(path string) bool { for _, l := range r.locations { @@ -189,6 +219,14 @@ func (r MockResolver) FilesByMIMEType(types ...string) ([]Location, error) { return locations, nil } +func (r MockResolver) FilesByMediaType(types ...string) ([]Location, error) { + var locations []Location + for _, ty := range types { + locations = append(locations, r.mediaTypeIndex[ty]...) + } + return locations, nil +} + func (r MockResolver) FilesByExtension(extensions ...string) ([]Location, error) { var results []Location for _, ext := range extensions { diff --git a/syft/file/resolver.go b/syft/file/resolver.go index ac4652fcf..24a03e8fb 100644 --- a/syft/file/resolver.go +++ b/syft/file/resolver.go @@ -52,6 +52,17 @@ type PathResolver interface { RelativeFileByPath(_ Location, path string) *Location } +// OCIMediaTypeResolver resolves single files as a layer in an OCI artifact for a given media type. +type OCIMediaTypeResolver interface { + // FilesByMediaType fetches a set of file references which the contents have been classified as one of the given Media Types. + // The implementation for this may vary, however, this was first implemented to classify ai globs stored in OCI images. + // The following considerations should be made when implementing: + // - only return locations to files (NOT directories) + // - locations for the implementer should be "/" and the fsid should be the layer digest the glob was found + // - locations should be used with the FileContents API to return readers to the temporary data + FilesByMediaType(types ...string) ([]Location, error) +} + // LocationResolver provides iteration over all file locations in a source. type LocationResolver interface { // AllLocations returns a channel of all file references from the underlying source. diff --git a/syft/format/common/spdxhelpers/to_format_model.go b/syft/format/common/spdxhelpers/to_format_model.go index c51fc087c..113f5c876 100644 --- a/syft/format/common/spdxhelpers/to_format_model.go +++ b/syft/format/common/spdxhelpers/to_format_model.go @@ -35,6 +35,7 @@ const ( spdxPrimaryPurposeOther = "OTHER" prefixImage = "Image" + prefixOCIModel = "OCIModel" prefixDirectory = "Directory" prefixFile = "File" prefixSnap = "Snap" @@ -215,6 +216,36 @@ func toRootPackage(s source.Description) *spdx.Package { } } + case source.OCIModelMetadata: + prefix = prefixOCIModel + purpose = spdxPrimaryPurposeContainer + + qualifiers := packageurl.Qualifiers{ + { + Key: "arch", + Value: m.Architecture, + }, + } + + ref, _ := reference.Parse(m.UserInput) + if ref, ok := ref.(reference.NamedTagged); ok { + qualifiers = append(qualifiers, packageurl.Qualifier{ + Key: "tag", + Value: ref.Tag(), + }) + } + + c := toChecksum(m.ManifestDigest) + if c != nil { + checksums = append(checksums, *c) + purl = &packageurl.PackageURL{ + Type: "oci", + Name: s.Name, + Version: m.ManifestDigest, + Qualifiers: qualifiers, + } + } + case source.DirectoryMetadata: prefix = prefixDirectory purpose = spdxPrimaryPurposeFile diff --git a/syft/format/common/spdxhelpers/to_format_model_test.go b/syft/format/common/spdxhelpers/to_format_model_test.go index fdc0f096f..57ca27db2 100644 --- a/syft/format/common/spdxhelpers/to_format_model_test.go +++ b/syft/format/common/spdxhelpers/to_format_model_test.go @@ -316,6 +316,81 @@ func Test_toFormatModel(t *testing.T) { }, }, }, + { + name: "oci-model", + in: sbom.SBOM{ + Source: source.Description{ + Name: "llama", + Version: "sha256:d34db33f", + Supplier: "Model Provider", + Metadata: source.OCIModelMetadata{ + UserInput: "model-repo/llama:latest", + ManifestDigest: "sha256:d34db33f", + }, + }, + Artifacts: sbom.Artifacts{ + Packages: pkg.NewCollection(pkg.Package{ + Name: "pkg-1", + Version: "version-1", + }), + }, + }, + expected: &spdx.Document{ + SPDXIdentifier: "DOCUMENT", + SPDXVersion: spdx.Version, + DataLicense: spdx.DataLicense, + DocumentName: "llama", + Packages: []*spdx.Package{ + { + PackageSPDXIdentifier: "Package-pkg-1-pkg-1", + PackageName: "pkg-1", + PackageVersion: "version-1", + PackageSupplier: &spdx.Supplier{ + Supplier: "Model Provider", + SupplierType: "Organization", + }, + }, + { + PackageSPDXIdentifier: "DocumentRoot-OCIModel-llama", + PackageName: "llama", + PackageVersion: "sha256:d34db33f", + PrimaryPackagePurpose: "CONTAINER", + PackageChecksums: []spdx.Checksum{{Algorithm: "SHA256", Value: "d34db33f"}}, + PackageExternalReferences: []*v2_3.PackageExternalReference{ + { + Category: "PACKAGE-MANAGER", + RefType: "purl", + Locator: "pkg:oci/llama@sha256%3Ad34db33f?arch=&tag=latest", + }, + }, + PackageSupplier: &spdx.Supplier{ + Supplier: "Model Provider", + SupplierType: "Organization", + }, + }, + }, + Relationships: []*spdx.Relationship{ + { + RefA: spdx.DocElementID{ + ElementRefID: "DocumentRoot-OCIModel-llama", + }, + RefB: spdx.DocElementID{ + ElementRefID: "Package-pkg-1-pkg-1", + }, + Relationship: spdx.RelationshipContains, + }, + { + RefA: spdx.DocElementID{ + ElementRefID: "DOCUMENT", + }, + RefB: spdx.DocElementID{ + ElementRefID: "DocumentRoot-OCIModel-llama", + }, + Relationship: spdx.RelationshipDescribes, + }, + }, + }, + }, } for _, test := range tests { diff --git a/syft/format/github/internal/model/model.go b/syft/format/github/internal/model/model.go index 0f50dc21d..874bb88a7 100644 --- a/syft/format/github/internal/model/model.go +++ b/syft/format/github/internal/model/model.go @@ -122,6 +122,9 @@ func toPath(s source.Description, p pkg.Package) string { case source.ImageMetadata: image := strings.ReplaceAll(metadata.UserInput, ":/", "//") return fmt.Sprintf("%s:/%s", image, packagePath) + case source.OCIModelMetadata: + image := strings.ReplaceAll(metadata.UserInput, ":/", "//") + return fmt.Sprintf("%s:/%s", image, packagePath) case source.FileMetadata: path := trimRelative(metadata.Path) if isArchive(metadata.Path) { diff --git a/syft/format/github/internal/model/model_test.go b/syft/format/github/internal/model/model_test.go index 308086436..0ea36695c 100644 --- a/syft/format/github/internal/model/model_test.go +++ b/syft/format/github/internal/model/model_test.go @@ -178,6 +178,11 @@ func Test_toGithubModel(t *testing.T) { metadata: source.SnapMetadata{}, testPath: "name:/etc", }, + { + name: "oci-model", + metadata: source.OCIModelMetadata{UserInput: "model-repo/llama:latest"}, + testPath: "model-repo/llama:latest:/etc", + }, } for _, test := range tests { diff --git a/syft/format/internal/spdxutil/helpers/document_name.go b/syft/format/internal/spdxutil/helpers/document_name.go index 5f718765e..b34c7a445 100644 --- a/syft/format/internal/spdxutil/helpers/document_name.go +++ b/syft/format/internal/spdxutil/helpers/document_name.go @@ -12,6 +12,8 @@ func DocumentName(src source.Description) string { switch metadata := src.Metadata.(type) { case source.ImageMetadata: return metadata.UserInput + case source.OCIModelMetadata: + return metadata.UserInput case source.DirectoryMetadata: return metadata.Path case source.FileMetadata: diff --git a/syft/format/internal/spdxutil/helpers/document_name_test.go b/syft/format/internal/spdxutil/helpers/document_name_test.go index d4007fc9d..26dbf1ebf 100644 --- a/syft/format/internal/spdxutil/helpers/document_name_test.go +++ b/syft/format/internal/spdxutil/helpers/document_name_test.go @@ -54,6 +54,17 @@ func Test_DocumentName(t *testing.T) { }, expected: "some/name", }, + { + name: "oci-model", + srcMetadata: source.Description{ + Metadata: source.OCIModelMetadata{ + UserInput: "model-repo/name:tag", + ID: "id", + ManifestDigest: "digest", + }, + }, + expected: "model-repo/name:tag", + }, { name: "named", srcMetadata: source.Description{ diff --git a/syft/format/internal/spdxutil/helpers/document_namespace.go b/syft/format/internal/spdxutil/helpers/document_namespace.go index 7215efebd..c45eb527d 100644 --- a/syft/format/internal/spdxutil/helpers/document_namespace.go +++ b/syft/format/internal/spdxutil/helpers/document_namespace.go @@ -14,6 +14,7 @@ import ( const ( InputImage = "image" + InputOCIModel = "oci-model" InputDirectory = "dir" InputFile = "file" InputSnap = "snap" @@ -30,6 +31,8 @@ func DocumentNamespace(name string, src source.Description, desc sbom.Descriptor switch src.Metadata.(type) { case source.ImageMetadata: input = InputImage + case source.OCIModelMetadata: + input = InputOCIModel case source.DirectoryMetadata: input = InputDirectory case source.FileMetadata: diff --git a/syft/format/internal/spdxutil/helpers/document_namespace_test.go b/syft/format/internal/spdxutil/helpers/document_namespace_test.go index 2db754663..959b5e6a3 100644 --- a/syft/format/internal/spdxutil/helpers/document_namespace_test.go +++ b/syft/format/internal/spdxutil/helpers/document_namespace_test.go @@ -61,6 +61,18 @@ func Test_DocumentNamespace(t *testing.T) { }, expected: "https://anchore.com/syft/snap/my-name-", }, + { + name: "oci-model", + inputName: "my-name", + src: source.Description{ + Metadata: source.OCIModelMetadata{ + UserInput: "model-repo/name:tag", + ID: "id", + ManifestDigest: "digest", + }, + }, + expected: "https://anchore.com/syft/oci-model/my-name-", + }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { diff --git a/syft/format/internal/spdxutil/helpers/source_info.go b/syft/format/internal/spdxutil/helpers/source_info.go index 6729e6d49..a26c1d74b 100644 --- a/syft/format/internal/spdxutil/helpers/source_info.go +++ b/syft/format/internal/spdxutil/helpers/source_info.go @@ -83,7 +83,7 @@ func SourceInfo(p pkg.Package) string { case pkg.TerraformPkg: answer = "acquired package info from Terraform dependency lock file" case pkg.ModelPkg: - answer = "acquired package info from AI artifact (e.g. GGUF File" + answer = "acquired package info from AI artifact (e.g. GGUF File)" default: answer = "acquired package info from the following paths" } diff --git a/syft/format/syftjson/model/source_test.go b/syft/format/syftjson/model/source_test.go index ad8538ffc..68bef2b91 100644 --- a/syft/format/syftjson/model/source_test.go +++ b/syft/format/syftjson/model/source_test.go @@ -190,6 +190,37 @@ func TestSource_UnmarshalJSON(t *testing.T) { }, }, }, + { + name: "oci-model", + input: []byte(`{ + "id": "foobar", + "type": "oci-model", + "metadata": { + "userInput": "model-repo/llama:latest", + "imageID": "sha256:e7b300aee9f9bf3433d32bc9305bfdd22183beb59d933b48d77ab56ba53a197a", + "manifestDigest": "sha256:e515aad2ed234a5072c4d2ef86a1cb77d5bfe4b11aa865d9214875734c4eeb3c", + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "tags": [], + "imageSize": 5576169, + "layers": [], + "repoDigests": [] + } + }`), + expected: &Source{ + ID: "foobar", + Type: "oci-model", + Metadata: source.OCIModelMetadata{ + UserInput: "model-repo/llama:latest", + ID: "sha256:e7b300aee9f9bf3433d32bc9305bfdd22183beb59d933b48d77ab56ba53a197a", + ManifestDigest: "sha256:e515aad2ed234a5072c4d2ef86a1cb77d5bfe4b11aa865d9214875734c4eeb3c", + MediaType: "application/vnd.oci.image.manifest.v1+json", + Tags: []string{}, + Size: 5576169, + Layers: []source.LayerMetadata{}, + RepoDigests: []string{}, + }, + }, + }, { name: "unknown source type", input: []byte(`{ diff --git a/syft/format/syftjson/to_format_model.go b/syft/format/syftjson/to_format_model.go index fa205c5b6..38274b209 100644 --- a/syft/format/syftjson/to_format_model.go +++ b/syft/format/syftjson/to_format_model.go @@ -325,7 +325,17 @@ func toSourceModel(src source.Description) model.Source { Metadata: src.Metadata, } - if metadata, ok := src.Metadata.(source.ImageMetadata); ok { + switch metadata := src.Metadata.(type) { + case source.ImageMetadata: + // ensure that empty collections are not shown as null + if metadata.RepoDigests == nil { + metadata.RepoDigests = []string{} + } + if metadata.Tags == nil { + metadata.Tags = []string{} + } + m.Metadata = metadata + case source.OCIModelMetadata: // ensure that empty collections are not shown as null if metadata.RepoDigests == nil { metadata.RepoDigests = []string{} diff --git a/syft/format/syftjson/to_format_model_test.go b/syft/format/syftjson/to_format_model_test.go index bb493176a..8ff3fdcc5 100644 --- a/syft/format/syftjson/to_format_model_test.go +++ b/syft/format/syftjson/to_format_model_test.go @@ -161,6 +161,34 @@ func Test_toSourceModel(t *testing.T) { }, }, }, + { + name: "oci-model", + src: source.Description{ + ID: "test-id", + Name: "some-name", + Version: "some-version", + Metadata: source.OCIModelMetadata{ + UserInput: "user-input", + ID: "id...", + ManifestDigest: "digest...", + MediaType: "type...", + }, + }, + expected: model.Source{ + ID: "test-id", + Name: "some-name", + Version: "some-version", + Type: "oci-model", + Metadata: source.OCIModelMetadata{ + UserInput: "user-input", + ID: "id...", + ManifestDigest: "digest...", + MediaType: "type...", + RepoDigests: []string{}, + Tags: []string{}, + }, + }, + }, // below are regression tests for when the name/version are not provided // historically we've hoisted up the name/version from the metadata, now it is a simple pass-through { @@ -225,6 +253,30 @@ func Test_toSourceModel(t *testing.T) { }, }, }, + { + name: "oci-model - no name/version", + src: source.Description{ + ID: "test-id", + Metadata: source.OCIModelMetadata{ + UserInput: "user-input", + ID: "id...", + ManifestDigest: "digest...", + MediaType: "type...", + }, + }, + expected: model.Source{ + ID: "test-id", + Type: "oci-model", + Metadata: source.OCIModelMetadata{ + UserInput: "user-input", + ID: "id...", + ManifestDigest: "digest...", + MediaType: "type...", + RepoDigests: []string{}, + Tags: []string{}, + }, + }, + }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { diff --git a/syft/format/syftjson/to_syft_model_test.go b/syft/format/syftjson/to_syft_model_test.go index e0e6d7246..d369f7ed4 100644 --- a/syft/format/syftjson/to_syft_model_test.go +++ b/syft/format/syftjson/to_syft_model_test.go @@ -130,6 +130,32 @@ func Test_toSyftSourceData(t *testing.T) { }, }, }, + { + name: "oci-model", + src: model.Source{ + ID: "the-id", + Name: "some-name", + Version: "some-version", + Type: "oci-model", + Metadata: source.OCIModelMetadata{ + UserInput: "user-input", + ID: "id...", + ManifestDigest: "digest...", + MediaType: "type...", + }, + }, + expected: &source.Description{ + ID: "the-id", + Name: "some-name", + Version: "some-version", + Metadata: source.OCIModelMetadata{ + UserInput: "user-input", + ID: "id...", + ManifestDigest: "digest...", + MediaType: "type...", + }, + }, + }, // below are regression tests for when the name/version are not provided // historically we've hoisted up the name/version from the metadata, now it is a simple pass-through { @@ -192,6 +218,28 @@ func Test_toSyftSourceData(t *testing.T) { }, }, }, + { + name: "oci-model - no name/version", + src: model.Source{ + ID: "the-id", + Type: "oci-model", + Metadata: source.OCIModelMetadata{ + UserInput: "user-input", + ID: "id...", + ManifestDigest: "digest...", + MediaType: "type...", + }, + }, + expected: &source.Description{ + ID: "the-id", + Metadata: source.OCIModelMetadata{ + UserInput: "user-input", + ID: "id...", + ManifestDigest: "digest...", + MediaType: "type...", + }, + }, + }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { diff --git a/syft/get_source.go b/syft/get_source.go index e70f4cfe5..e7c1f2d98 100644 --- a/syft/get_source.go +++ b/syft/get_source.go @@ -65,6 +65,8 @@ func validateSourcePlatform(src source.Source, cfg *GetSourceConfig) error { switch meta.(type) { case *source.ImageMetadata, source.ImageMetadata: return nil + case *source.OCIModelMetadata, source.OCIModelMetadata: + return nil case *source.SnapMetadata, source.SnapMetadata: return nil default: diff --git a/syft/get_source_config_test.go b/syft/get_source_config_test.go index 9d0ad8774..912131494 100644 --- a/syft/get_source_config_test.go +++ b/syft/get_source_config_test.go @@ -31,7 +31,8 @@ func TestGetProviders_Sources(t *testing.T) { t.Errorf("Expected no error for Sources parameter, got: %v", err) } - if len(providers) != 1 { - t.Errorf("Expected 1 providers, got %d", len(providers)) + // Registry tag has two providers: OCIModel and Image + if len(providers) != 2 { + t.Errorf("Expected 2 providers, got %d", len(providers)) } } diff --git a/syft/get_source_test.go b/syft/get_source_test.go index 241854c83..612e5c3a4 100644 --- a/syft/get_source_test.go +++ b/syft/get_source_test.go @@ -111,6 +111,10 @@ func TestValidateSourcePlatform_SupportedMetadataTypes(t *testing.T) { metadata: source.FileMetadata{}, wantErr: require.Error, }, + { + name: "oci-model", + metadata: source.OCIModelMetadata{}, + }, } for _, tt := range tests { diff --git a/syft/internal/fileresolver/container_image_model.go b/syft/internal/fileresolver/container_image_model.go new file mode 100644 index 000000000..51e6736fd --- /dev/null +++ b/syft/internal/fileresolver/container_image_model.go @@ -0,0 +1,141 @@ +package fileresolver + +import ( + "context" + "fmt" + "io" + "os" + "path/filepath" + + "github.com/anchore/syft/syft/file" +) + +var _ file.Resolver = (*ContainerImageModel)(nil) +var _ file.OCIMediaTypeResolver = (*ContainerImageModel)(nil) + +// LayerInfo holds information about an OCI model layer file stored on disk. +type LayerInfo struct { + TempPath string // Path to the temp file on disk + MediaType string // OCI media type of the layer +} + +// ContainerImageModel is a file.Resolver implementation that provides access to +// GGUF header data fetched from OCI model artifacts via range-GET requests. +// This does not fetch the entire model from the registry, only a sliver of it. +type ContainerImageModel struct { + tempDir string // temp directory containing all layer files + layerFiles map[string]LayerInfo // digest -> layer info (temp path + media type) + locations map[string]file.Location // digest -> location +} + +// NewContainerImageModel creates a new resolver with the given temp directory and layer files. +func NewContainerImageModel(tempDir string, layerFiles map[string]LayerInfo) *ContainerImageModel { + // Create locations for all layer files + // Each location has RealPath="/", FileSystemID=digest, AccessPath="/" + locations := make(map[string]file.Location, len(layerFiles)) + for digest := range layerFiles { + // Use NewVirtualLocationFromCoordinates with digest as FileSystemID + coords := file.NewCoordinates("/", digest) + locations[digest] = file.NewVirtualLocationFromCoordinates(coords, "/") + } + + return &ContainerImageModel{ + tempDir: tempDir, + layerFiles: layerFiles, + locations: locations, + } +} + +// FilesByMediaType returns locations for layers matching the given media type patterns. +// Patterns support glob-style matching (e.g., "application/vnd.docker.ai*"). +func (r *ContainerImageModel) FilesByMediaType(types ...string) ([]file.Location, error) { + var matches []file.Location + + for digest, info := range r.layerFiles { + for _, pattern := range types { + matched, err := filepath.Match(pattern, info.MediaType) + if err != nil { + return nil, fmt.Errorf("invalid media type pattern %q: %w", pattern, err) + } + if matched { + if loc, ok := r.locations[digest]; ok { + matches = append(matches, loc) + } + break // Don't add the same location twice + } + } + } + + return matches, nil +} + +// FileContentsByLocation returns the contents of the file at the given location. +// The location's FileSystemID contains the layer digest, which is used to look up the temp file. +// This method is used as part of the content selection in the generic cataloger when locations +// are returned by searching for contents by media type. +func (r *ContainerImageModel) FileContentsByLocation(location file.Location) (io.ReadCloser, error) { + // Look up the temp file path using the digest stored in FileSystemID + digest := location.FileSystemID + info, ok := r.layerFiles[digest] + if !ok { + return nil, fmt.Errorf("no file found for digest %q", digest) + } + return os.Open(info.TempPath) +} + +// FileMetadataByLocation returns metadata for the file at the given location. +func (r *ContainerImageModel) FileMetadataByLocation(_ file.Location) (m file.Metadata, err error) { + return m, nil +} + +// HasPath checks if the given path exists in the resolver. +func (r *ContainerImageModel) HasPath(path string) bool { + // The virtual path is "/" for all files + if path == "/" && len(r.layerFiles) > 0 { + return true + } + return false +} + +// FilesByPath returns locations for files matching the given paths. +func (r *ContainerImageModel) FilesByPath(_ ...string) ([]file.Location, error) { + return nil, nil +} + +// FilesByGlob returns locations for files matching the given glob patterns. +func (r *ContainerImageModel) FilesByGlob(_ ...string) ([]file.Location, error) { + return nil, nil +} + +// FilesByMIMEType returns locations for files with the given MIME types. +// This is not implemented for OCI model artifacts as we don't have MIME type detection. +func (r *ContainerImageModel) FilesByMIMEType(_ ...string) ([]file.Location, error) { + // Not implemented - OCI model artifacts don't have MIME type detection + return nil, nil +} + +// RelativeFileByPath returns a file at the given path relative to the reference location. +// This is not applicable for OCI model artifacts. +func (r *ContainerImageModel) RelativeFileByPath(_ file.Location, _ string) *file.Location { + // Not implemented - no layer hierarchy in OCI model artifacts + return nil +} + +// AllLocations returns all file locations in the resolver. +func (r *ContainerImageModel) AllLocations(ctx context.Context) <-chan file.Location { + ch := make(chan file.Location) + + go func() { + defer close(ch) + + for _, loc := range r.locations { + select { + case <-ctx.Done(): + return + case ch <- loc: + } + } + }() + + return ch +} diff --git a/syft/internal/fileresolver/container_image_model_test.go b/syft/internal/fileresolver/container_image_model_test.go new file mode 100644 index 000000000..bd8c2efb7 --- /dev/null +++ b/syft/internal/fileresolver/container_image_model_test.go @@ -0,0 +1,130 @@ +package fileresolver + +import ( + "io" + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/anchore/syft/syft/file" +) + +const ggufLayerMediaType = "application/vnd.docker.ai.gguf.v3" + +func TestOCIModelResolver_FilesByMediaType(t *testing.T) { + tempDir := t.TempDir() + + tests := []struct { + name string + layerFiles map[string]LayerInfo + patterns []string + expected int + }{ + { + name: "exact match GGUF", + layerFiles: map[string]LayerInfo{ + "sha256:abc123": {TempPath: filepath.Join(tempDir, "f1"), MediaType: ggufLayerMediaType}, + }, + patterns: []string{ggufLayerMediaType}, + expected: 1, + }, + { + name: "glob match docker ai", + layerFiles: map[string]LayerInfo{ + "sha256:abc123": {TempPath: filepath.Join(tempDir, "f1"), MediaType: ggufLayerMediaType}, + }, + patterns: []string{"application/vnd.docker.ai*"}, + expected: 1, + }, + { + name: "no match", + layerFiles: map[string]LayerInfo{ + "sha256:abc123": {TempPath: filepath.Join(tempDir, "f1"), MediaType: ggufLayerMediaType}, + }, + patterns: []string{"application/json"}, + expected: 0, + }, + { + name: "multiple patterns match multiple files", + layerFiles: map[string]LayerInfo{ + "sha256:abc123": {TempPath: filepath.Join(tempDir, "f1"), MediaType: ggufLayerMediaType}, + "sha256:def456": {TempPath: filepath.Join(tempDir, "f2"), MediaType: "application/octet-stream"}, + }, + patterns: []string{ggufLayerMediaType, "application/octet-stream"}, + expected: 2, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + resolver := NewContainerImageModel(tempDir, test.layerFiles) + + locations, err := resolver.FilesByMediaType(test.patterns...) + require.NoError(t, err) + assert.Len(t, locations, test.expected) + }) + } +} + +func TestOCIModelResolver_FileContentsByLocation(t *testing.T) { + tempDir := t.TempDir() + content := []byte("test gguf content") + + tempFile := filepath.Join(tempDir, "test.gguf") + require.NoError(t, os.WriteFile(tempFile, content, 0600)) + + digest := "sha256:abc123" + layerFiles := map[string]LayerInfo{ + digest: {TempPath: tempFile, MediaType: ggufLayerMediaType}, + } + + resolver := NewContainerImageModel(tempDir, layerFiles) + + tests := []struct { + name string + digest string + wantErr bool + wantData []byte + errSubstr string + }{ + { + name: "valid location returns content", + digest: digest, + wantErr: false, + wantData: content, + }, + { + name: "invalid digest returns error", + digest: "sha256:invalid", + wantErr: true, + errSubstr: "no file found for digest", + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + loc := file.NewVirtualLocationFromCoordinates( + file.NewCoordinates("/", test.digest), + "/", + ) + + reader, err := resolver.FileContentsByLocation(loc) + + if test.wantErr { + require.Error(t, err) + assert.Contains(t, err.Error(), test.errSubstr) + return + } + + require.NoError(t, err) + defer reader.Close() + + data, err := io.ReadAll(reader) + require.NoError(t, err) + assert.Equal(t, test.wantData, data) + }) + } +} diff --git a/syft/pkg/cataloger/ai/cataloger.go b/syft/pkg/cataloger/ai/cataloger.go index cca60ac87..d566edba2 100644 --- a/syft/pkg/cataloger/ai/cataloger.go +++ b/syft/pkg/cataloger/ai/cataloger.go @@ -9,8 +9,17 @@ import ( "github.com/anchore/syft/syft/pkg/cataloger/generic" ) +const ( + catalogerName = "gguf-cataloger" + ggufLayerMediaType = "application/vnd.docker.ai*" +) + // NewGGUFCataloger returns a new cataloger instance for GGUF model files. +// It supports both traditional file-based discovery and OCI layer-aware discovery +// when the source for the SBOM is the oci model source func NewGGUFCataloger() pkg.Cataloger { - return generic.NewCataloger("gguf-cataloger"). - WithParserByGlobs(parseGGUFModel, "**/*.gguf") + return generic.NewCataloger(catalogerName). + WithParserByGlobs(parseGGUFModel, "**/*.gguf"). + WithParserByMediaType(parseGGUFModel, ggufLayerMediaType). + WithProcessors(ggufMergeProcessor) } diff --git a/syft/pkg/cataloger/ai/parse_gguf_model.go b/syft/pkg/cataloger/ai/parse_gguf_model.go index 74deb4199..3fe78f658 100644 --- a/syft/pkg/cataloger/ai/parse_gguf_model.go +++ b/syft/pkg/cataloger/ai/parse_gguf_model.go @@ -122,6 +122,10 @@ func extractVersion(kvs gguf_parser.GGUFMetadataKVs) string { // extractModelNameFromPath extracts the model name from the file path func extractModelNameFromPath(path string) string { + // we do not want to return a name from filepath if it's not a distinct gguf file + if !strings.Contains(path, ".gguf") { + return "" + } // Get the base filename base := filepath.Base(path) diff --git a/syft/pkg/cataloger/ai/processor.go b/syft/pkg/cataloger/ai/processor.go new file mode 100644 index 000000000..c3ca8c3e7 --- /dev/null +++ b/syft/pkg/cataloger/ai/processor.go @@ -0,0 +1,59 @@ +package ai + +import ( + "github.com/anchore/syft/syft/artifact" + "github.com/anchore/syft/syft/pkg" +) + +// ggufMergeProcessor consolidates multiple GGUF packages into a single package +// representing the AI model. When scanning OCI images with multiple layers, +// each layer may produce a separate package. This processor finds the package +// with a name and merges metadata from nameless packages into its GGUFFileParts field. +// Only packages with a non-empty name are returned in the final result. +func ggufMergeProcessor(pkgs []pkg.Package, rels []artifact.Relationship, err error) ([]pkg.Package, []artifact.Relationship, error) { + if err != nil { + return pkgs, rels, err + } + + if len(pkgs) == 0 { + return pkgs, rels, err + } + + // Separate packages with names from those without + var namedPkgs []pkg.Package + var namelessHeaders []pkg.GGUFFileHeader + + for _, p := range pkgs { + if p.Name != "" { + namedPkgs = append(namedPkgs, p) + } else { + if header, ok := p.Metadata.(pkg.GGUFFileHeader); ok { + // We do not want a kv hash for nameless headers + header.MetadataKeyValuesHash = "" + namelessHeaders = append(namelessHeaders, header) + } + } + } + + // If there are no named packages, return nothing + if len(namedPkgs) == 0 { + return nil, rels, err + } + + // merge nameless headers into a single named package; + // if there are multiple named packages, return them without trying to merge headers. + // we cannot determine which nameless headers belong to which package + // this is because the order we receive the gguf headers in is not guaranteed + // to match the layer order in the original oci image + if len(namedPkgs) == 1 && len(namelessHeaders) > 0 { + winner := &namedPkgs[0] + if header, ok := winner.Metadata.(pkg.GGUFFileHeader); ok { + header.Parts = namelessHeaders + winner.Metadata = header + } + } + + // Largest number of key value + + return namedPkgs, rels, err +} diff --git a/syft/pkg/cataloger/ai/processor_test.go b/syft/pkg/cataloger/ai/processor_test.go new file mode 100644 index 000000000..6d216ae95 --- /dev/null +++ b/syft/pkg/cataloger/ai/processor_test.go @@ -0,0 +1,63 @@ +package ai + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/anchore/syft/syft/pkg" +) + +func Test_ggufMergeProcessor(t *testing.T) { + tests := []struct { + name string + pkgs []pkg.Package + wantPkgCount int + wantFilePartCount int + }{ + { + name: "single named package merges nameless headers", + pkgs: []pkg.Package{ + {Name: "model", Metadata: pkg.GGUFFileHeader{MetadataKeyValuesHash: "abc"}}, + {Name: "", Metadata: pkg.GGUFFileHeader{MetadataKeyValuesHash: "part1"}}, + {Name: "", Metadata: pkg.GGUFFileHeader{MetadataKeyValuesHash: "part2"}}, + }, + wantPkgCount: 1, + wantFilePartCount: 2, + }, + { + name: "multiple named packages returns all without merging", + pkgs: []pkg.Package{ + {Name: "model1", Metadata: pkg.GGUFFileHeader{}}, + {Name: "model2", Metadata: pkg.GGUFFileHeader{}}, + {Name: "", Metadata: pkg.GGUFFileHeader{}}, + }, + wantPkgCount: 2, + wantFilePartCount: 0, + }, + { + name: "no named packages returns empty result", + pkgs: []pkg.Package{ + {Name: "", Metadata: pkg.GGUFFileHeader{}}, + {Name: "", Metadata: pkg.GGUFFileHeader{}}, + }, + wantPkgCount: 0, + wantFilePartCount: 0, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + got, _, err := ggufMergeProcessor(test.pkgs, nil, nil) + require.NoError(t, err) + assert.Len(t, got, test.wantPkgCount) + + if test.wantPkgCount == 1 && test.wantFilePartCount > 0 { + header, ok := got[0].Metadata.(pkg.GGUFFileHeader) + require.True(t, ok) + assert.Len(t, header.Parts, test.wantFilePartCount) + } + }) + } +} diff --git a/syft/pkg/cataloger/binary/classifier_cataloger_test.go b/syft/pkg/cataloger/binary/classifier_cataloger_test.go index 587eb3efc..ba32f672a 100644 --- a/syft/pkg/cataloger/binary/classifier_cataloger_test.go +++ b/syft/pkg/cataloger/binary/classifier_cataloger_test.go @@ -2164,6 +2164,11 @@ func (p *panicyResolver) FilesByMIMEType(_ ...string) ([]file.Location, error) { return nil, errors.New("not implemented") } +func (p *panicyResolver) FilesByMediaType(_ ...string) ([]file.Location, error) { + p.searchCalled = true + return nil, errors.New("not implemented") +} + func (p *panicyResolver) RelativeFileByPath(_ file.Location, _ string) *file.Location { return nil } diff --git a/syft/pkg/cataloger/generic/cataloger.go b/syft/pkg/cataloger/generic/cataloger.go index abdad6293..d357d0e07 100644 --- a/syft/pkg/cataloger/generic/cataloger.go +++ b/syft/pkg/cataloger/generic/cataloger.go @@ -114,6 +114,26 @@ func (c *Cataloger) WithParserByPath(parser Parser, paths ...string) *Cataloger return c } +func (c *Cataloger) WithParserByMediaType(parser Parser, types ...string) *Cataloger { + c.requesters = append(c.requesters, + func(resolver file.Resolver, _ Environment) []request { + var requests []request + log.WithFields("mediatypes", types).Trace("searching content matching mediatypes") + ociResolver, ok := resolver.(file.OCIMediaTypeResolver) + if !ok { + return nil + } + matches, err := ociResolver.FilesByMediaType(types...) + if err != nil { + return nil + } + requests = append(requests, makeRequests(parser, matches)...) + return requests + }, + ) + return c +} + func (c *Cataloger) WithProcessors(processors ...Processor) *Cataloger { for _, p := range processors { c.processors = append(c.processors, processorWrapper{Processor: p}) diff --git a/syft/pkg/cataloger/generic/cataloger_test.go b/syft/pkg/cataloger/generic/cataloger_test.go index f4e5c4798..46524771f 100644 --- a/syft/pkg/cataloger/generic/cataloger_test.go +++ b/syft/pkg/cataloger/generic/cataloger_test.go @@ -138,6 +138,10 @@ func (m spyReturningFileResolver) FilesByMIMEType(types ...string) ([]file.Locat return m.m.FilesByMIMEType(types...) } +func (m spyReturningFileResolver) FilesByMediaType(types ...string) ([]file.Location, error) { + return m.m.FilesByMediaType(types...) +} + func (m spyReturningFileResolver) RelativeFileByPath(f file.Location, path string) *file.Location { return m.m.RelativeFileByPath(f, path) } @@ -189,6 +193,55 @@ func TestClosesFileOnParserPanic(t *testing.T) { require.True(t, spy.closed) } +func Test_CatalogerWithParserByMediaType(t *testing.T) { + allParsedPaths := make(map[string]bool) + parser := func(_ context.Context, resolver file.Resolver, env *Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) { + allParsedPaths[reader.Path()] = true + contents, err := io.ReadAll(reader) + require.NoError(t, err) + + if len(contents) == 0 { + return nil, nil, nil + } + + p := pkg.Package{ + Name: string(contents), + Locations: file.NewLocationSet(reader.Location), + } + + return []pkg.Package{p}, nil, nil + } + + upstream := "media-type-cataloger" + + // Create locations with test fixtures that exist on disk + loc1 := file.NewLocation("test-fixtures/a-path.txt") + loc2 := file.NewLocation("test-fixtures/another-path.txt") + + // Create a mock resolver that maps media types to locations + resolver := file.NewMockResolverForMediaTypes(map[string][]file.Location{ + "application/vnd.test.model": {loc1, loc2}, + }) + + cataloger := NewCataloger(upstream). + WithParserByMediaType(parser, "application/vnd.test.model") + + actualPkgs, _, err := cataloger.Catalog(context.Background(), resolver) + assert.NoError(t, err) + + // Verify both files were parsed + assert.True(t, allParsedPaths["test-fixtures/a-path.txt"], "expected a-path.txt to be parsed") + assert.True(t, allParsedPaths["test-fixtures/another-path.txt"], "expected another-path.txt to be parsed") + + // Verify packages were created + assert.Len(t, actualPkgs, 2) + + // Verify FoundBy is set correctly + for _, p := range actualPkgs { + assert.Equal(t, upstream, p.FoundBy) + } +} + func Test_genericCatalogerReturnsErrors(t *testing.T) { genericErrorReturning := NewCataloger("error returning").WithParserByGlobs(func(ctx context.Context, resolver file.Resolver, environment *Environment, locationReader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) { return []pkg.Package{ diff --git a/syft/pkg/cataloger/internal/pkgtest/observing_resolver.go b/syft/pkg/cataloger/internal/pkgtest/observing_resolver.go index 49fc9c51f..52eb6e478 100644 --- a/syft/pkg/cataloger/internal/pkgtest/observing_resolver.go +++ b/syft/pkg/cataloger/internal/pkgtest/observing_resolver.go @@ -208,6 +208,11 @@ func (r *ObservingResolver) FilesByMIMEType(types ...string) ([]file.Location, e return locs, err } +// FilesByMediaType returns files matching the given media types. +func (r *ObservingResolver) FilesByMediaType(_ ...string) ([]file.Location, error) { + return nil, nil +} + // RelativeFileByPath returns a file at a path relative to the given location. func (r *ObservingResolver) RelativeFileByPath(location file.Location, path string) *file.Location { const methodName = "RelativeFileByPath" diff --git a/syft/pkg/cataloger/redhat/parse_rpm_db_test.go b/syft/pkg/cataloger/redhat/parse_rpm_db_test.go index 0f0337565..aac34bf59 100644 --- a/syft/pkg/cataloger/redhat/parse_rpm_db_test.go +++ b/syft/pkg/cataloger/redhat/parse_rpm_db_test.go @@ -80,6 +80,10 @@ func (r *rpmdbTestFileResolverMock) FilesByMIMEType(...string) ([]file.Location, return nil, fmt.Errorf("not implemented") } +func (r *rpmdbTestFileResolverMock) FilesByMediaType(...string) ([]file.Location, error) { + return nil, fmt.Errorf("not implemented") +} + func TestParseRpmDB(t *testing.T) { ctx := context.TODO() packagesLocation := file.NewLocation("test-fixtures/Packages") diff --git a/syft/pkg/gguf.go b/syft/pkg/gguf.go index 59c30e075..512c8873c 100644 --- a/syft/pkg/gguf.go +++ b/syft/pkg/gguf.go @@ -34,4 +34,8 @@ type GGUFFileHeader struct { // across different file locations or remotes. It allows matching identical models even // when stored in different repositories or with different filenames. MetadataKeyValuesHash string `json:"metadataHash,omitempty" cyclonedx:"metadataHash"` + + // Parts contains headers from additional GGUF files that were merged + // into this package during post-processing (e.g., from OCI layers without model names). + Parts []GGUFFileHeader `json:"parts,omitempty" cyclonedx:"parts"` } diff --git a/syft/source/image_metadata.go b/syft/source/image_metadata.go index aa4fe60dd..8a2849aea 100644 --- a/syft/source/image_metadata.go +++ b/syft/source/image_metadata.go @@ -17,6 +17,7 @@ type ImageMetadata struct { Variant string `json:"architectureVariant,omitempty"` OS string `json:"os"` Labels map[string]string `json:"labels,omitempty"` + Annotations map[string]string `json:"annotations,omitempty" id:"-"` // critical: do not consider annotations as an identifiable part of the source image } // LayerMetadata represents all static metadata that defines what a container image layer is. diff --git a/syft/source/internal/image_id.go b/syft/source/internal/image_id.go new file mode 100644 index 000000000..a45a474e0 --- /dev/null +++ b/syft/source/internal/image_id.go @@ -0,0 +1,66 @@ +package internal + +import ( + "fmt" + + "github.com/opencontainers/go-digest" + + "github.com/anchore/syft/syft/artifact" + "github.com/anchore/syft/syft/source" +) + +// DeriveImageID derives an artifact ID from the given image metadata. The order of data precedence is: +// 1. prefer a digest of the raw container image manifest +// 2. if no manifest digest is available, calculate a chain ID from the image layer metadata +// 3. if no layer metadata is available, use the user input string +// +// in all cases, if an alias is provided, it is additionally considered in the ID calculation. This allows for the +// same image to be scanned multiple times with different aliases and be considered logically different. +func DeriveImageID(alias source.Alias, metadata source.ImageMetadata) artifact.ID { + var input string + + if len(metadata.RawManifest) > 0 { + input = digest.Canonical.FromBytes(metadata.RawManifest).String() + } else { + // calculate chain ID for image sources where manifestDigest is not available + // https://github.com/opencontainers/image-spec/blob/main/config.md#layer-chainid + input = calculateChainID(metadata.Layers) + if input == "" { + // TODO what happens here if image has no layers? + // is this case possible? + input = digest.Canonical.FromString(metadata.UserInput).String() + } + } + + if !alias.IsEmpty() { + // if the user provided an alias, we want to consider that in the artifact ID. This way if the user + // scans the same item but is considered to be logically different, then ID will express that. + aliasStr := fmt.Sprintf(":%s@%s", alias.Name, alias.Version) + input = digest.Canonical.FromString(input + aliasStr).String() + } + + return ArtifactIDFromDigest(input) +} + +// https://github.com/opencontainers/image-spec/blob/main/config.md#layer-chainid +func calculateChainID(lm []source.LayerMetadata) string { + if len(lm) < 1 { + return "" + } + + // DiffID(L0) = digest of layer 0 + // https://github.com/anchore/stereoscope/blob/1b1b744a919964f38d14e1416fb3f25221b761ce/pkg/image/layer_metadata.go#L19-L32 + chainID := lm[0].Digest + id := chain(chainID, lm[1:]) + + return id +} + +func chain(chainID string, layers []source.LayerMetadata) string { + if len(layers) < 1 { + return chainID + } + + chainID = digest.Canonical.FromString(layers[0].Digest + " " + chainID).String() + return chain(chainID, layers[1:]) +} diff --git a/syft/source/internal/image_id_test.go b/syft/source/internal/image_id_test.go new file mode 100644 index 000000000..278545d26 --- /dev/null +++ b/syft/source/internal/image_id_test.go @@ -0,0 +1,278 @@ +package internal + +import ( + "crypto/sha256" + "fmt" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/anchore/syft/syft/artifact" + "github.com/anchore/syft/syft/source" +) + +func TestDeriveImageID(t *testing.T) { + tests := []struct { + name string + alias source.Alias + metadata source.ImageMetadata + want artifact.ID + }{ + { + name: "use raw manifest over chain ID or user input", + metadata: source.ImageMetadata{ + UserInput: "user-input", + Layers: []source.LayerMetadata{ + { + Digest: "a", + }, + { + Digest: "b", + }, + { + Digest: "c", + }, + }, + RawManifest: []byte("raw-manifest"), + }, + want: func() artifact.ID { + hasher := sha256.New() + hasher.Write([]byte("raw-manifest")) + return artifact.ID(fmt.Sprintf("%x", hasher.Sum(nil))) + }(), + }, + { + name: "use chain ID over user input", + metadata: source.ImageMetadata{ + Layers: []source.LayerMetadata{ + { + Digest: "a", + }, + { + Digest: "b", + }, + { + Digest: "c", + }, + }, + }, + want: func() artifact.ID { + metadata := []source.LayerMetadata{ + { + Digest: "a", + }, + { + Digest: "b", + }, + { + Digest: "c", + }, + } + return artifact.ID(strings.TrimPrefix(calculateChainID(metadata), "sha256:")) + }(), + }, + { + name: "use user input last", + metadata: source.ImageMetadata{ + UserInput: "user-input", + }, + want: func() artifact.ID { + hasher := sha256.New() + hasher.Write([]byte("user-input")) + return artifact.ID(fmt.Sprintf("%x", hasher.Sum(nil))) + }(), + }, + { + name: "without alias (first)", + metadata: source.ImageMetadata{ + UserInput: "user-input", + Layers: []source.LayerMetadata{ + { + Digest: "a", + }, + { + Digest: "b", + }, + { + Digest: "c", + }, + }, + RawManifest: []byte("raw-manifest"), + }, + want: "85298926ecd92ed57688f13039017160cd728f04dd0d2d10a10629007106f107", + }, + { + name: "always consider alias (first)", + alias: source.Alias{ + Name: "alias", + Version: "version", + }, + metadata: source.ImageMetadata{ + UserInput: "user-input", + Layers: []source.LayerMetadata{ + { + Digest: "a", + }, + { + Digest: "b", + }, + { + Digest: "c", + }, + }, + RawManifest: []byte("raw-manifest"), + }, + want: "a8717e42449960c1dd4963f2f22bd69c7c105e7e82445be0a65aa1825d62ff0d", + }, + { + name: "without alias (last)", + metadata: source.ImageMetadata{ + UserInput: "user-input", + }, + want: "ab0dff627d80b9753193d7280bec8f45e8ec6b4cb0912c6fffcf7cd782d9739e", + }, + { + name: "always consider alias (last)", + alias: source.Alias{ + Name: "alias", + Version: "version", + }, + metadata: source.ImageMetadata{ + UserInput: "user-input", + }, + want: "fe86c0eecd5654d3c0c0b2176aa394aef6440347c241aa8d9b628dfdde4287cf", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert.Equal(t, tt.want, DeriveImageID(tt.alias, tt.metadata)) + }) + } +} + +// ensures same metadata produces identical IDs +// regardless of whether the source is stereoscope-based or OCI model-based. Both source types +// use DeriveImageID with ImageMetadata +// this test captures known-good IDs that must remain +// stable across refactors to maintain consistency. +// +// IMPORTANT: If any of these tests fail after a refactor, it means the artifact ID generation +// has changed and will break consistency between stereoscope images and OCI model sources. +func TestDeriveImageID_CrossSourceConsistency(t *testing.T) { + tests := []struct { + name string + alias source.Alias + metadata source.ImageMetadata + wantID artifact.ID + }{ + { + name: "raw manifest with layers - typical container image", + metadata: source.ImageMetadata{ + UserInput: "docker.io/library/alpine:latest", + ManifestDigest: "sha256:abc123", + Layers: []source.LayerMetadata{ + {Digest: "sha256:layer1", MediaType: "application/vnd.oci.image.layer.v1.tar+gzip", Size: 1000}, + {Digest: "sha256:layer2", MediaType: "application/vnd.oci.image.layer.v1.tar+gzip", Size: 2000}, + }, + RawManifest: []byte(`{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json"}`), + }, + // snapshot: this ID must remain stable for stereoscope/oci-model consistency + wantID: "b22c7289dd3b4785a3795c90e15d16bd66bd29b444b8974fe29ed0443ce50405", + }, + { + name: "raw manifest only - minimal image", + metadata: source.ImageMetadata{ + RawManifest: []byte(`{"schemaVersion":2}`), + }, + // snapshot: this ID must remain stable + wantID: "bafebd36189ad3688b7b3915ea55d461e0bfcfbdde11e54b0a123999fb6be50f", + }, + { + name: "chain ID fallback - no raw manifest", + metadata: source.ImageMetadata{ + UserInput: "some-image", + Layers: []source.LayerMetadata{ + {Digest: "sha256:aaa111"}, + {Digest: "sha256:bbb222"}, + }, + }, + // snapshot: chain ID calculation must remain stable + wantID: "0ba9c8d271e6708871505d362e37267c5fb7910066c04d3115b89ba4d34aa180", + }, + { + name: "user input fallback - no manifest or layers", + metadata: source.ImageMetadata{ + UserInput: "registry.example.com/org/model:v1.0", + }, + // snapshot: user input hash must remain stable + wantID: "a5a8733a3ba3eb99a8ebebcd40c4053f9b896ea6e2217ebc6e885573f20baccf", + }, + { + name: "with alias - same image different logical identity", + alias: source.Alias{ + Name: "my-custom-name", + Version: "1.0.0", + }, + metadata: source.ImageMetadata{ + RawManifest: []byte(`{"schemaVersion":2}`), + }, + // snapshot: alias must affect ID deterministically + wantID: "9eae41c0efc30023368c29089bac007f2c9d0b40a0ee034081a17c4c22f55ac6", + }, + { + name: "annotations has no effect on ID", + metadata: source.ImageMetadata{ + UserInput: "registry.example.com/org/model:v1.0", + Annotations: map[string]string{ + "annotation1": "value1", + }, + }, + // snapshot: user input hash must remain stable + wantID: "a5a8733a3ba3eb99a8ebebcd40c4053f9b896ea6e2217ebc6e885573f20baccf", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := DeriveImageID(tt.alias, tt.metadata) + assert.Equal(t, tt.wantID, got, "ID must remain stable for cross-source consistency") + }) + } +} + +func TestCalculateChainID(t *testing.T) { + tests := []struct { + name string + layers []source.LayerMetadata + want string + }{ + { + name: "empty layers returns empty string", + layers: []source.LayerMetadata{}, + want: "", + }, + { + name: "single layer returns digest", + layers: []source.LayerMetadata{ + {Digest: "sha256:abc123"}, + }, + want: "sha256:abc123", + }, + { + name: "multiple layers calculates chain ID", + layers: []source.LayerMetadata{ + {Digest: "a"}, + {Digest: "b"}, + {Digest: "c"}, + }, + // snapshot - this value should not change + want: "sha256:1dfe230e220ef0e6bc0a8978d23d72b95769e76a62879a5f49267d8c007ab43d", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert.Equal(t, tt.want, calculateChainID(tt.layers)) + }) + } +} diff --git a/syft/source/oci_model_metadata.go b/syft/source/oci_model_metadata.go new file mode 100644 index 000000000..317a1cb3c --- /dev/null +++ b/syft/source/oci_model_metadata.go @@ -0,0 +1,4 @@ +package source + +// OCIModelMetadata is an AI model from an OCI registry, which is a specialized form of ImageMetadata. +type OCIModelMetadata ImageMetadata diff --git a/syft/source/ocimodelsource/oci_model_source.go b/syft/source/ocimodelsource/oci_model_source.go new file mode 100644 index 000000000..8fe4aae49 --- /dev/null +++ b/syft/source/ocimodelsource/oci_model_source.go @@ -0,0 +1,245 @@ +package ocimodelsource + +import ( + "context" + "fmt" + "os" + "path/filepath" + "strings" + "sync" + + "github.com/google/go-containerregistry/pkg/name" + v1 "github.com/google/go-containerregistry/pkg/v1" + + "github.com/anchore/stereoscope/pkg/image" + "github.com/anchore/syft/internal/log" + "github.com/anchore/syft/syft/artifact" + "github.com/anchore/syft/syft/file" + "github.com/anchore/syft/syft/internal/fileresolver" + "github.com/anchore/syft/syft/source" + "github.com/anchore/syft/syft/source/internal" +) + +var _ source.Source = (*ociModelSource)(nil) + +// Config holds the input configuration for an OCI model artifact source. +type Config struct { + Reference string + RegistryOptions *image.RegistryOptions + Alias source.Alias +} + +// ociModelSource implements the source.Source interface for OCI model artifacts. +type ociModelSource struct { + id artifact.ID + reference string + alias source.Alias + metadata source.OCIModelMetadata + tempDir string + resolver interface { + file.Resolver + file.OCIMediaTypeResolver + } + mutex *sync.Mutex +} + +// NewFromRegistry creates a new OCI model source by fetching the model artifact from a registry. +func NewFromRegistry(ctx context.Context, cfg Config) (source.Source, error) { + client := newRegistryClient(cfg.RegistryOptions) + art, err := validateAndFetchArtifact(ctx, client, cfg.Reference) + if err != nil { + return nil, err + } + + metadata := buildMetadata(art) + tempDir, resolver, err := fetchAndStoreGGUFHeaders(ctx, client, art) + if err != nil { + return nil, err + } + + id := internal.DeriveImageID(cfg.Alias, source.ImageMetadata(metadata)) + return &ociModelSource{ + id: id, + reference: cfg.Reference, + alias: cfg.Alias, + metadata: metadata, + tempDir: tempDir, + resolver: resolver, + mutex: &sync.Mutex{}, + }, nil +} + +// validateAndFetchArtifact fetches and validates a model artifact in a single registry call. +func validateAndFetchArtifact(ctx context.Context, client *registryClient, reference string) (*modelArtifact, error) { + art, err := client.fetchModelArtifact(ctx, reference) + if err != nil { + // errNotModelArtifact is wrapped, so callers can use errors.Is() to check + return nil, err + } + + if len(art.GGUFLayers) == 0 { + return nil, fmt.Errorf("model artifact has no GGUF layers") + } + + return art, nil +} + +// fetchAndStoreGGUFHeaders fetches GGUF layer headers and stores them in temp files. +func fetchAndStoreGGUFHeaders(ctx context.Context, client *registryClient, artifact *modelArtifact) (string, *fileresolver.ContainerImageModel, error) { + tempDir, err := os.MkdirTemp("", "syft-oci-gguf") + if err != nil { + return "", nil, fmt.Errorf("failed to create temp directory: %w", err) + } + + layerFiles := make(map[string]fileresolver.LayerInfo) + for _, layer := range artifact.GGUFLayers { + li, err := fetchSingleGGUFHeader(ctx, client, artifact.Reference, layer, tempDir) + if err != nil { + osErr := os.RemoveAll(tempDir) + if osErr != nil { + log.Errorf("unable to remove temp directory (%s): %v", tempDir, err) + } + return "", nil, err + } + layerFiles[layer.Digest.String()] = li + } + + resolver := fileresolver.NewContainerImageModel(tempDir, layerFiles) + + return tempDir, resolver, nil +} + +// fetchSingleGGUFHeader fetches a single GGUF layer header and writes it to a temp file. +func fetchSingleGGUFHeader(ctx context.Context, client *registryClient, ref name.Reference, layer v1.Descriptor, tempDir string) (fileresolver.LayerInfo, error) { + headerData, err := client.fetchBlobRange(ctx, ref, layer.Digest, maxHeaderBytes) + if err != nil { + return fileresolver.LayerInfo{}, fmt.Errorf("failed to fetch GGUF layer header: %w", err) + } + + digestStr := layer.Digest.String() + safeDigest := strings.ReplaceAll(digestStr, ":", "-") + tempPath := filepath.Join(tempDir, safeDigest+".gguf") + if err := os.WriteFile(tempPath, headerData, 0600); err != nil { + return fileresolver.LayerInfo{}, fmt.Errorf("failed to write temp file: %w", err) + } + + return fileresolver.LayerInfo{ + TempPath: tempPath, + MediaType: string(layer.MediaType), + }, nil +} + +// buildMetadata constructs OCIModelMetadata from a modelArtifact. +func buildMetadata(artifact *modelArtifact) source.OCIModelMetadata { + // layers + layers := make([]source.LayerMetadata, len(artifact.Manifest.Layers)) + for i, layer := range artifact.Manifest.Layers { + layers[i] = source.LayerMetadata{ + MediaType: string(layer.MediaType), + Digest: layer.Digest.String(), + Size: layer.Size, + } + } + + // tags + var tags []string + if tagged, ok := artifact.Reference.(interface{ TagStr() string }); ok { + if tag := tagged.TagStr(); tag != "" { + tags = []string{tag} + } + } + + // digests + var repoDigests []string + if artifact.ManifestDigest != "" { + repoDigests = []string{artifact.Reference.Context().String() + "@" + artifact.ManifestDigest} + } + + // metadata + return source.OCIModelMetadata{ + UserInput: artifact.Reference.String(), + ID: artifact.ManifestDigest, + ManifestDigest: artifact.ManifestDigest, + MediaType: string(artifact.Manifest.MediaType), + Tags: tags, + Size: calculateTotalSize(layers), + Layers: layers, + RawManifest: artifact.RawManifest, + RawConfig: artifact.RawConfig, + RepoDigests: repoDigests, + Architecture: artifact.Config.Architecture, + Variant: artifact.Config.Variant, + OS: artifact.Config.OS, + Labels: artifact.Config.Config.Labels, + Annotations: extractManifestAnnotations(artifact.Manifest), + } +} + +// extractManifestAnnotations extracts annotations from the manifest. +func extractManifestAnnotations(manifest *v1.Manifest) map[string]string { + if manifest == nil || manifest.Annotations == nil { + return make(map[string]string) + } + return manifest.Annotations +} + +// calculateTotalSize sums up the size of all layers. +func calculateTotalSize(layers []source.LayerMetadata) int64 { + var total int64 + for _, layer := range layers { + total += layer.Size + } + return total +} + +// ID returns the artifact ID. +func (s *ociModelSource) ID() artifact.ID { + return s.id +} + +// Describe returns a description of the source. +func (s *ociModelSource) Describe() source.Description { + name := s.reference + version := "" + supplier := "" + + if !s.alias.IsEmpty() { + if s.alias.Name != "" { + name = s.alias.Name + } + if s.alias.Version != "" { + version = s.alias.Version + } + if s.alias.Supplier != "" { + supplier = s.alias.Supplier + } + } + + return source.Description{ + ID: string(s.id), + Name: name, + Version: version, + Supplier: supplier, + Metadata: s.metadata, + } +} + +// FileResolver returns a file resolver for accessing header of GGUF files. +func (s *ociModelSource) FileResolver(_ source.Scope) (file.Resolver, error) { + return s.resolver, nil +} + +// Close cleans up temporary files. Safe to call multiple times. +func (s *ociModelSource) Close() error { + s.mutex.Lock() + defer s.mutex.Unlock() + + if s.tempDir == "" { + return nil + } + + err := os.RemoveAll(s.tempDir) + s.tempDir = "" + s.resolver = nil + return err +} diff --git a/syft/source/ocimodelsource/oci_model_source_provider.go b/syft/source/ocimodelsource/oci_model_source_provider.go new file mode 100644 index 000000000..86aa43fb3 --- /dev/null +++ b/syft/source/ocimodelsource/oci_model_source_provider.go @@ -0,0 +1,36 @@ +package ocimodelsource + +import ( + "context" + + "github.com/anchore/stereoscope/pkg/image" + "github.com/anchore/syft/syft/source" +) + +type ociModelSourceProvider struct { + reference string + registryOpts *image.RegistryOptions + alias source.Alias +} + +// NewSourceProvider creates a new OCI model artifact source provider. +func NewSourceProvider(reference string, registryOpts *image.RegistryOptions, alias source.Alias) source.Provider { + return &ociModelSourceProvider{ + reference: reference, + registryOpts: registryOpts, + alias: alias, + } +} + +func (p *ociModelSourceProvider) Name() string { + return "oci-model" +} + +func (p *ociModelSourceProvider) Provide(ctx context.Context) (source.Source, error) { + cfg := Config{ + Reference: p.reference, + RegistryOptions: p.registryOpts, + Alias: p.alias, + } + return NewFromRegistry(ctx, cfg) +} diff --git a/syft/source/ocimodelsource/registry_client.go b/syft/source/ocimodelsource/registry_client.go new file mode 100644 index 000000000..7574fda6c --- /dev/null +++ b/syft/source/ocimodelsource/registry_client.go @@ -0,0 +1,217 @@ +package ocimodelsource + +import ( + "context" + "crypto/tls" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "strings" + + "github.com/google/go-containerregistry/pkg/authn" + "github.com/google/go-containerregistry/pkg/name" + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/remote" + + "github.com/anchore/stereoscope/pkg/image" +) + +// errNotModelArtifact is returned when a reference does not point to a model artifact. +var errNotModelArtifact = errors.New("not an OCI model artifact") + +const ( + // Model artifact media types as per Docker's OCI artifacts for AI model packaging + // Reference: https://www.docker.com/blog/oci-artifacts-for-ai-model-packaging/ + modelConfigMediaTypePrefix = "application/vnd.docker.ai.model.config." + ggufLayerMediaType = "application/vnd.docker.ai.gguf.v3" + + // Maximum bytes to read/return for GGUF headers + maxHeaderBytes = 8 * 1024 * 1024 // 8 MB +) + +// registryClient handles OCI registry interactions for model artifacts. +type registryClient struct { + options []remote.Option +} + +// newRegistryClient creates a new registry client with authentication from RegistryOptions. +func newRegistryClient(registryOpts *image.RegistryOptions) *registryClient { + opts := buildRemoteOptions(registryOpts) + + return ®istryClient{ + options: opts, + } +} + +// buildRemoteOptions converts stereoscope RegistryOptions to go-containerregistry remote.Options. +func buildRemoteOptions(registryOpts *image.RegistryOptions) []remote.Option { + var opts []remote.Option + + if registryOpts == nil { + return opts + } + + // Build authenticator + authenticator := buildAuthenticator(registryOpts) + opts = append(opts, remote.WithAuth(authenticator)) + + // Handle TLS settings + if registryOpts.InsecureSkipTLSVerify { + if transport, ok := remote.DefaultTransport.(*http.Transport); ok { + transport = transport.Clone() + if transport.TLSClientConfig == nil { + transport.TLSClientConfig = &tls.Config{ + MinVersion: tls.VersionTLS12, + } + } + transport.TLSClientConfig.InsecureSkipVerify = true //#nosec G402 -- user explicitly requested insecure TLS + opts = append(opts, remote.WithTransport(transport)) + } + } + + // Handle insecure HTTP + if registryOpts.InsecureUseHTTP { + opts = append(opts, remote.WithTransport(http.DefaultTransport)) + } + + return opts +} + +// buildAuthenticator creates an authn.Authenticator from RegistryOptions. +func buildAuthenticator(registryOpts *image.RegistryOptions) authn.Authenticator { + // If credentials are provided, use them + if len(registryOpts.Credentials) > 0 { + // Use the first credential set (we could enhance this to match by authority) + cred := registryOpts.Credentials[0] + + if cred.Token != "" { + return &authn.Bearer{Token: cred.Token} + } + + if cred.Username != "" || cred.Password != "" { + return &authn.Basic{ + Username: cred.Username, + Password: cred.Password, + } + } + } + + // Fall back to anonymous authenticator + return authn.Anonymous +} + +// modelArtifact represents a parsed OCI model artifact. +type modelArtifact struct { + Reference name.Reference + Manifest *v1.Manifest + Config *v1.ConfigFile + RawManifest []byte + RawConfig []byte + ManifestDigest string + GGUFLayers []v1.Descriptor +} + +func (c *registryClient) fetchModelArtifact(ctx context.Context, refStr string) (*modelArtifact, error) { + ref, err := name.ParseReference(refStr) + if err != nil { + return nil, fmt.Errorf("failed to parse reference %q: %w", refStr, err) + } + + opts := c.options + opts = append(opts, remote.WithContext(ctx)) + desc, err := remote.Get(ref, opts...) + if err != nil { + return nil, fmt.Errorf("failed to fetch descriptor: %w", err) + } + + manifest := &v1.Manifest{} + if err := json.Unmarshal(desc.Manifest, manifest); err != nil { + return nil, fmt.Errorf("failed to unmarshal manifest: %w", err) + } + + if !isModelArtifact(manifest) { + return nil, fmt.Errorf("%w (config media type: %s)", errNotModelArtifact, manifest.Config.MediaType) + } + + img, err := desc.Image() + if err != nil { + return nil, fmt.Errorf("failed to get image: %w", err) + } + + configFile, err := img.ConfigFile() + if err != nil { + return nil, fmt.Errorf("failed to get config file: %w", err) + } + + rawConfig, err := img.RawConfigFile() + if err != nil { + return nil, fmt.Errorf("failed to get raw config: %w", err) + } + + ggufLayers := extractGGUFLayers(manifest) + + return &modelArtifact{ + Reference: ref, + Manifest: manifest, + Config: configFile, + RawManifest: desc.Manifest, + RawConfig: rawConfig, + ManifestDigest: desc.Digest.String(), + GGUFLayers: ggufLayers, + }, nil +} + +// isModelArtifact checks if the manifest represents a model artifact. +func isModelArtifact(manifest *v1.Manifest) bool { + return strings.HasPrefix(string(manifest.Config.MediaType), modelConfigMediaTypePrefix) +} + +// extractGGUFLayers extracts GGUF layer descriptors from the manifest. +func extractGGUFLayers(manifest *v1.Manifest) []v1.Descriptor { + var ggufLayers []v1.Descriptor + for _, layer := range manifest.Layers { + if string(layer.MediaType) == ggufLayerMediaType { + ggufLayers = append(ggufLayers, layer) + } + } + return ggufLayers +} + +func (c *registryClient) fetchBlobRange(ctx context.Context, ref name.Reference, digest v1.Hash, maxBytes int64) ([]byte, error) { + repo := ref.Context() + + opts := c.options + opts = append(opts, remote.WithContext(ctx)) + layer, err := remote.Layer(repo.Digest(digest.String()), opts...) + if err != nil { + return nil, fmt.Errorf("failed to fetch layer: %w", err) + } + + reader, err := layer.Compressed() + if err != nil { + return nil, fmt.Errorf("failed to get layer reader: %w", err) + } + // this defer is what causes the download to stop + // 1. io.ReadFull(reader, data) reads exactly 8MB into the buffer + // 2. The function returns with data[:n] + // 3. defer reader.Close() executes, closing the HTTP response body + // 4. Closing the response body closes the underlying TCP connection + // 5. The server receives TCP FIN/RST and stops sending + // note: some data is already in flight when we close so we will see > 8mb over the wire + // the full image will not download given we terminate the reader early here + defer reader.Close() + + // Note: this is not some arbitrary number picked out of the blue. + // This is based on the specification of header data found here: + // https://github.com/ggml-org/ggml/blob/master/docs/gguf.md#file-structure + data := make([]byte, maxBytes) + n, err := io.ReadFull(reader, data) + if err != nil && err != io.ErrUnexpectedEOF { + // ErrUnexpectedEOF is okay - it means the file is smaller than maxBytes + return nil, fmt.Errorf("failed to read layer data: %w", err) + } + + return data[:n], nil +} diff --git a/syft/source/ocimodelsource/registry_client_test.go b/syft/source/ocimodelsource/registry_client_test.go new file mode 100644 index 000000000..c411d489d --- /dev/null +++ b/syft/source/ocimodelsource/registry_client_test.go @@ -0,0 +1,114 @@ +package ocimodelsource + +import ( + "testing" + + v1 "github.com/google/go-containerregistry/pkg/v1" + "github.com/google/go-containerregistry/pkg/v1/types" + "github.com/stretchr/testify/assert" +) + +func TestIsModelArtifact(t *testing.T) { + tests := []struct { + name string + manifest *v1.Manifest + expected bool + }{ + { + name: "valid model artifact", + manifest: &v1.Manifest{ + Config: v1.Descriptor{ + MediaType: modelConfigMediaTypePrefix + "v1+json", + }, + }, + expected: true, + }, + { + name: "container image", + manifest: &v1.Manifest{ + Config: v1.Descriptor{ + MediaType: types.DockerConfigJSON, + }, + }, + expected: false, + }, + { + name: "empty media type", + manifest: &v1.Manifest{ + Config: v1.Descriptor{ + MediaType: "", + }, + }, + expected: false, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + result := isModelArtifact(test.manifest) + assert.Equal(t, test.expected, result) + }) + } +} + +func TestExtractGGUFLayers(t *testing.T) { + tests := []struct { + name string + manifest *v1.Manifest + expected int + }{ + { + name: "single GGUF layer", + manifest: &v1.Manifest{ + Layers: []v1.Descriptor{ + {MediaType: types.MediaType(ggufLayerMediaType), Digest: v1.Hash{Algorithm: "sha256", Hex: "abc"}}, + }, + }, + expected: 1, + }, + { + name: "multiple GGUF layers", + manifest: &v1.Manifest{ + Layers: []v1.Descriptor{ + {MediaType: types.MediaType(ggufLayerMediaType), Digest: v1.Hash{Algorithm: "sha256", Hex: "abc"}}, + {MediaType: types.MediaType(ggufLayerMediaType), Digest: v1.Hash{Algorithm: "sha256", Hex: "def"}}, + }, + }, + expected: 2, + }, + { + name: "mixed layers", + manifest: &v1.Manifest{ + Layers: []v1.Descriptor{ + {MediaType: types.MediaType(ggufLayerMediaType), Digest: v1.Hash{Algorithm: "sha256", Hex: "abc"}}, + {MediaType: types.DockerLayer, Digest: v1.Hash{Algorithm: "sha256", Hex: "def"}}, + {MediaType: types.MediaType(ggufLayerMediaType), Digest: v1.Hash{Algorithm: "sha256", Hex: "ghi"}}, + }, + }, + expected: 2, + }, + { + name: "no GGUF layers", + manifest: &v1.Manifest{ + Layers: []v1.Descriptor{ + {MediaType: types.DockerLayer}, + }, + }, + expected: 0, + }, + { + name: "empty layers", + manifest: &v1.Manifest{ + Layers: []v1.Descriptor{}, + }, + expected: 0, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + result := extractGGUFLayers(test.manifest) + assert.Len(t, result, test.expected) + }) + } +} diff --git a/syft/source/sourceproviders/source_providers.go b/syft/source/sourceproviders/source_providers.go index 6da749bc5..fcaf7e697 100644 --- a/syft/source/sourceproviders/source_providers.go +++ b/syft/source/sourceproviders/source_providers.go @@ -7,6 +7,7 @@ import ( "github.com/anchore/syft/syft/source" "github.com/anchore/syft/syft/source/directorysource" "github.com/anchore/syft/syft/source/filesource" + "github.com/anchore/syft/syft/source/ocimodelsource" "github.com/anchore/syft/syft/source/snapsource" "github.com/anchore/syft/syft/source/stereoscopesource" ) @@ -43,6 +44,14 @@ func All(userInput string, cfg *Config) []collections.TaggedValue[source.Provide // --from docker, registry, etc. Join(stereoscopeProviders.Select(PullTag)...). + // --from oci-model, registry (for select cases only) + // OCI model artifacts with header-only fetching + // note: we don't want to use the "pull" tag since it's not actually pulling the full image, + // instead we want to match on registry since these models are stored in OCI registries. + // This does mean that this must be placed after the pull provider, which is ideal since we don't want to + // unnecessarily pull registry headers first if the more common case is the pull providers. + Join(tagProvider(ocimodelsource.NewSourceProvider(userInput, cfg.RegistryOptions, cfg.Alias), "registry")). + // --from snap (remote only) Join(tagProvider(snapsource.NewRemoteSourceProvider(userInput, cfg.Exclude, cfg.DigestAlgorithms, cfg.Alias), SnapTag)) } diff --git a/syft/source/stereoscopesource/image_source.go b/syft/source/stereoscopesource/image_source.go index f14e311ed..c6dc29390 100644 --- a/syft/source/stereoscopesource/image_source.go +++ b/syft/source/stereoscopesource/image_source.go @@ -5,7 +5,6 @@ import ( "github.com/bmatcuk/doublestar/v4" "github.com/distribution/reference" - "github.com/opencontainers/go-digest" "github.com/anchore/stereoscope/pkg/image" "github.com/anchore/syft/internal/log" @@ -36,7 +35,7 @@ type stereoscopeImageSource struct { func New(img *image.Image, cfg ImageConfig) source.Source { metadata := imageMetadataFromStereoscopeImage(img, cfg.Reference) return &stereoscopeImageSource{ - id: deriveIDFromStereoscopeImage(cfg.Alias, metadata), + id: internal.DeriveImageID(cfg.Alias, metadata), config: cfg, image: img, metadata: metadata, @@ -163,61 +162,6 @@ func imageMetadataFromStereoscopeImage(img *image.Image, reference string) sourc } } -// deriveIDFromStereoscopeImage derives an artifact ID from the given image metadata. The order of data precedence is: -// 1. prefer a digest of the raw container image manifest -// 2. if no manifest digest is available, calculate a chain ID from the image layer metadata -// 3. if no layer metadata is available, use the user input string -// -// in all cases, if an alias is provided, it is additionally considered in the ID calculation. This allows for the -// same image to be scanned multiple times with different aliases and be considered logically different. -func deriveIDFromStereoscopeImage(alias source.Alias, metadata source.ImageMetadata) artifact.ID { - var input string - - if len(metadata.RawManifest) > 0 { - input = digest.Canonical.FromBytes(metadata.RawManifest).String() - } else { - // calculate chain ID for image sources where manifestDigest is not available - // https://github.com/opencontainers/image-spec/blob/main/config.md#layer-chainid - input = calculateChainID(metadata.Layers) - if input == "" { - // TODO what happens here if image has no layers? - // is this case possible? - input = digest.Canonical.FromString(metadata.UserInput).String() - } - } - - if !alias.IsEmpty() { - // if the user provided an alias, we want to consider that in the artifact ID. This way if the user - // scans the same item but is considered to be logically different, then ID will express that. - aliasStr := fmt.Sprintf(":%s@%s", alias.Name, alias.Version) - input = digest.Canonical.FromString(input + aliasStr).String() - } - - return internal.ArtifactIDFromDigest(input) -} - -func calculateChainID(lm []source.LayerMetadata) string { - if len(lm) < 1 { - return "" - } - - // DiffID(L0) = digest of layer 0 - // https://github.com/anchore/stereoscope/blob/1b1b744a919964f38d14e1416fb3f25221b761ce/pkg/image/layer_metadata.go#L19-L32 - chainID := lm[0].Digest - id := chain(chainID, lm[1:]) - - return id -} - -func chain(chainID string, layers []source.LayerMetadata) string { - if len(layers) < 1 { - return chainID - } - - chainID = digest.Canonical.FromString(layers[0].Digest + " " + chainID).String() - return chain(chainID, layers[1:]) -} - func getImageExclusionFunction(exclusions []string) func(string) bool { if len(exclusions) == 0 { return nil diff --git a/syft/source/stereoscopesource/image_source_test.go b/syft/source/stereoscopesource/image_source_test.go index 1af81986c..1faaaa611 100644 --- a/syft/source/stereoscopesource/image_source_test.go +++ b/syft/source/stereoscopesource/image_source_test.go @@ -2,8 +2,6 @@ package stereoscopesource import ( "context" - "crypto/sha256" - "fmt" "strings" "testing" @@ -12,7 +10,6 @@ import ( "github.com/anchore/stereoscope" "github.com/anchore/stereoscope/pkg/imagetest" - "github.com/anchore/syft/syft/artifact" "github.com/anchore/syft/syft/internal/testutil" "github.com/anchore/syft/syft/source" ) @@ -112,146 +109,6 @@ func Test_StereoscopeImage_Exclusions(t *testing.T) { } } -func Test_StereoscopeImageSource_ID(t *testing.T) { - tests := []struct { - name string - alias source.Alias - metadata source.ImageMetadata - want artifact.ID - }{ - { - name: "use raw manifest over chain ID or user input", - metadata: source.ImageMetadata{ - UserInput: "user-input", - Layers: []source.LayerMetadata{ - { - Digest: "a", - }, - { - Digest: "b", - }, - { - Digest: "c", - }, - }, - RawManifest: []byte("raw-manifest"), - }, - want: func() artifact.ID { - hasher := sha256.New() - hasher.Write([]byte("raw-manifest")) - return artifact.ID(fmt.Sprintf("%x", hasher.Sum(nil))) - }(), - }, - { - name: "use chain ID over user input", - metadata: source.ImageMetadata{ - //UserInput: "user-input", - Layers: []source.LayerMetadata{ - { - Digest: "a", - }, - { - Digest: "b", - }, - { - Digest: "c", - }, - }, - }, - want: func() artifact.ID { - metadata := []source.LayerMetadata{ - { - Digest: "a", - }, - { - Digest: "b", - }, - { - Digest: "c", - }, - } - return artifact.ID(strings.TrimPrefix(calculateChainID(metadata), "sha256:")) - }(), - }, - { - name: "use user input last", - metadata: source.ImageMetadata{ - UserInput: "user-input", - }, - want: func() artifact.ID { - hasher := sha256.New() - hasher.Write([]byte("user-input")) - return artifact.ID(fmt.Sprintf("%x", hasher.Sum(nil))) - }(), - }, - { - name: "without alias (first)", - metadata: source.ImageMetadata{ - UserInput: "user-input", - Layers: []source.LayerMetadata{ - { - Digest: "a", - }, - { - Digest: "b", - }, - { - Digest: "c", - }, - }, - RawManifest: []byte("raw-manifest"), - }, - want: "85298926ecd92ed57688f13039017160cd728f04dd0d2d10a10629007106f107", - }, - { - name: "always consider alias (first)", - alias: source.Alias{ - Name: "alias", - Version: "version", - }, - metadata: source.ImageMetadata{ - UserInput: "user-input", - Layers: []source.LayerMetadata{ - { - Digest: "a", - }, - { - Digest: "b", - }, - { - Digest: "c", - }, - }, - RawManifest: []byte("raw-manifest"), - }, - want: "a8717e42449960c1dd4963f2f22bd69c7c105e7e82445be0a65aa1825d62ff0d", - }, - { - name: "without alias (last)", - metadata: source.ImageMetadata{ - UserInput: "user-input", - }, - want: "ab0dff627d80b9753193d7280bec8f45e8ec6b4cb0912c6fffcf7cd782d9739e", - }, - { - name: "always consider alias (last)", - alias: source.Alias{ - Name: "alias", - Version: "version", - }, - metadata: source.ImageMetadata{ - UserInput: "user-input", - }, - want: "fe86c0eecd5654d3c0c0b2176aa394aef6440347c241aa8d9b628dfdde4287cf", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - assert.Equal(t, tt.want, deriveIDFromStereoscopeImage(tt.alias, tt.metadata)) - }) - } -} - func Test_Describe(t *testing.T) { tests := []struct { name string