I have been experimenting with syft
output today and I have a question…
To start, I ran the following:
syft scan nginx:latest -o spdx-json | jq > nginx-latest.spdx.json
Looking through the output, I find this containing the pkg:oci
value:
{
"name": "nginx",
"SPDXID": "SPDXRef-DocumentRoot-Image-nginx",
"versionInfo": "sha256:edf555d07d2ddbe6b616d90ee444e2faec1a219310c9a156fa6f6cd0c602881a",
"supplier": "NOASSERTION",
"downloadLocation": "NOASSERTION",
"filesAnalyzed": false,
"checksums": [
{
"algorithm": "SHA256",
"checksumValue": "edf555d07d2ddbe6b616d90ee444e2faec1a219310c9a156fa6f6cd0c602881a"
}
],
"licenseConcluded": "NOASSERTION",
"licenseDeclared": "NOASSERTION",
"externalRefs": [
{
"referenceCategory": "PACKAGE-MANAGER",
"referenceType": "purl",
"referenceLocator": "pkg:oci/nginx@sha256:edf555d07d2ddbe6b616d90ee444e2faec1a219310c9a156fa6f6cd0c602881a?arch=amd64&tag=latest"
}
],
"primaryPackagePurpose": "CONTAINER"
}
At first, I was assuming that the sha256 value on the referenceLocator
line would be the the sha256 of the image’s digest but I am not finding a match there. If I run this:
docker inspect nginx:latest
This is what I see:
[
{
"Id": "sha256:39286ab8a5e14aeaf5fdd6e2fac76e0c8d31a0c07224f0ee5e6be502f12e93f3",
"RepoTags": [
"nginx:latest"
],
"RepoDigests": [
"nginx@sha256:04ba374043ccd2fc5c593885c0eacddebabd5ca375f9323666f28dfd5a9710e3"
],
"Parent": "",
"Comment": "buildkit.dockerfile.v0",
"Created": "2024-08-14T21:31:12Z",
"DockerVersion": "",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"NGINX_VERSION=1.27.1",
"NJS_VERSION=0.8.5",
"NJS_RELEASE=1~bookworm",
"PKG_RELEASE=1~bookworm",
"DYNPKG_RELEASE=2~bookworm"
],
"Cmd": [
"nginx",
"-g",
"daemon off;"
],
"ArgsEscaped": true,
"Image": "",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"/docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {
"maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
},
"StopSignal": "SIGQUIT"
},
"Architecture": "amd64",
"Os": "linux",
"Size": 187706879,
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/0c990431620dfdf6f603066e30825b6a1f6d2a67f9175feffd0473a0bc013c6e/diff:/var/lib/docker/overlay2/c6b29ad8645786a168929f4dc84c19d554bc6a926c3f0944c272109ab98f18ad/diff:/var/lib/docker/overlay2/59f5264666519bef102c481f6969a64f6d25e089f32dbb74baaa2583e70460a4/diff:/var/lib/docker/overlay2/8fb654941d0127046f9c8b564630e3bb3f2a98ff430d75c9db63df8b5fbb567e/diff:/var/lib/docker/overlay2/fe30b3093b0d5fc7b361249e92e8533d6ee0e763e5ad1ab240b11bb7cd2125cc/diff:/var/lib/docker/overlay2/53a025185df15b864d7018af627a9cc5810a252c7f4ca81f5b0e68f283c8f5b1/diff",
"MergedDir": "/var/lib/docker/overlay2/9cfd98a325fc769383e5ed59d04e2f7d636bcf8bd028e73609f123b82891b2df/merged",
"UpperDir": "/var/lib/docker/overlay2/9cfd98a325fc769383e5ed59d04e2f7d636bcf8bd028e73609f123b82891b2df/diff",
"WorkDir": "/var/lib/docker/overlay2/9cfd98a325fc769383e5ed59d04e2f7d636bcf8bd028e73609f123b82891b2df/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:8e2ab394fabf557b00041a8f080b10b4e91c7027b7c174f095332c7ebb6501cb",
"sha256:67796e30ff042303e3c8cbd8478e4f4f6377fd1754a168704f829c4e8a128f40",
"sha256:eda13eb24d4c7b2c4cf60fbef992e18936613ad9067421ae1b59a413f3393267",
"sha256:0fc6bb94eec5602c08d4261eedf9f122af7d122983c5ad8d8cf9ab108d9fd7bd",
"sha256:2bdf51597158f7b0335cb1c082f8449a7ba1af678876158a05747eecca9b7604",
"sha256:16907864a2d01d70c5c1e740085ace628f9d85b9eb38ced8c623e2c3ae36734d",
"sha256:11de3d47036d69ed34dcf240a2d82e0ffc8a9dc8b77deeed65fb6380fbc84c8d"
]
},
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"
}
}
]
Now the repo digest is what I see currently for the “index digest” on Docker Hub:
The sha256 from the SPDX output doesn’t match the “manifest digest” either.
Can someone help explain what the sha256 in the referenceLocator
represents?
Thanks in advance for the help…
Dwayne