SLSA 定義 (供應鏈層級安全保證定義)
BuildKit 支援為其執行的建置建立 SLSA 出處證明。
BuildKit 產生的出處證明格式由 SLSA 出處證明格式
BuildKit 支援為其執行的建置建立 SLSA 出處證明。
BuildKit 產生的出處證明格式由 SLSA 出處證明格式
buildConfig
對應於 SLSA buildConfig
inputs
欄位中找到。
"buildConfig": {
"llbDefinition": [
{
"id": "step0",
"op": {
"Op": {
"exec": {
"meta": {
"args": [
"/bin/sh",
"-c",
"go build ."
],
"env": [
"PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOPATH=/go",
"GOFLAGS=-mod=vendor",
],
"cwd": "/src",
},
"mounts": [...]
}
},
"platform": {...},
},
"inputs": [
"step8:0",
"step2:0",
]
},
...
]
},
metadata.buildInvocationId
metadata.buildStartedOn
對應於 SLSA 對應於 SLSA 對應於 SLSA 包含在 `mode=min` 和 `mode=max` 中。 定義來源資訊是否完整。 如果所有建置參數都包含在 對於 BuildKit 建置, 如果 對應於 SLSA 定義建置結果是否應逐位元組可重現。使用者可以使用 包含在 `mode=min` 和 `mode=max` 中。 如果建置是封閉的且未存取網路,則此擴充欄位會設定為 true。在 Dockerfile 中,如果建置未使用 部分包含在 `mode=min` 中。 此擴充欄位定義了不屬於 SLSA 來源規範的 BuildKit 特定額外中繼資料。 僅在 定義 LLB 建置步驟的來源映射,定義於 僅在 定義在 包含在 `mode=min` 和 `mode=max` 中。 定義用於建置的版本控制系統的選用中繼資料。如果建置使用來自 Git 儲存庫的遠端上下文,BuildKit 會自動提取版本控制系統的詳細資訊,並將其顯示在 要檢查已產生並附加到容器映像檔的來源,您可以使用 例如,檢查基於 對於類似的建置,但使用 metadata.buildStartedOn
"metadata": {
"buildStartedOn": "2021-11-17T15:00:00Z",
...
},
metadata.buildFinishedOn
metadata.buildFinishedOn
"metadata": {
"buildFinishedOn": "2021-11-17T15:01:00Z",
...
},
metadata.completeness
metadata.completeness
invocation.parameters
欄位中,則 completeness.parameters
為 true。使用 min
模式建置時,建置參數不會包含在來源資訊中,且參數不完整。在沒有使用前端的直接 LLB 建置中,參數也不完整。completeness.environment
始終為 true。materials
欄位包含建置的所有相依性,則 completeness.materials
為 true。從本地目錄中未追蹤的來源建置時,素材不完整;而從遠端 Git 儲存庫建置時,所有素材都可以由 BuildKit 追蹤,且 completeness.materials
為 true。 "metadata": {
"completeness": {
"parameters": true,
"environment": true,
"materials": true
},
...
},
metadata.reproducible
metadata.reproducible
reproducible=true
證明參數來設定此值。 "metadata": {
"reproducible": false,
...
},
metadata.https://mobyproject.org/buildkit@v1#hermetic
RUN
命令或使用 --network=none
旗標停用網路,則建置是封閉的。 "metadata": {
"https://mobyproject.org/buildkit@v1#hermetic": true,
...
},
metadata.https://mobyproject.org/buildkit@v1#metadata
"metadata": {
"https://mobyproject.org/buildkit@v1#metadata": {
"source": {...},
"layers": {...},
"vcs": {...},
},
...
},
source
mode=max
時包含。buildConfig.llbDefinition
欄位中,映射到其原始程式碼(例如,Dockerfile 命令)。source.locations
欄位包含在 LLB 步驟中執行的所有 Dockerfile 命令的範圍。source.infos
陣列包含程式碼本身。如果 BuildKit 前端在建立 LLB 定義時提供了此映射,則此映射會存在。layers
mode=max
時包含。buildConfig.llbDefinition
中定義的 LLB 建置步驟掛載的層映射到等效層的 OCI 描述元。如果層資料可用,則此映射會存在,通常在證明是針對映像檔或建置步驟將映像檔資料提取為建置一部分時。vcs
invocation.configSource
欄位中。但是,如果建置使用來自本地目錄的來源,即使目錄包含 Git 儲存庫,VCS 資訊也會遺失。在這種情況下,建置用戶端可以傳送額外的 vcs:source
和 vcs:revision
建置選項,BuildKit 會將它們作為額外中繼資料新增到來源證明中。請注意,與 invocation.configSource
欄位相反,BuildKit 不會驗證 vcs
值,因此它們不可信任,只能用作中繼資料提示。輸出
docker buildx imagetools
命令來檢查登錄中的映像檔。檢查證明會顯示 證明儲存規範 中描述的格式。alpine:latest
的簡單 Docker 映像檔會產生類似以下的來源證明,適用於 mode=min
建置{
"_type": "https://in-toto.io/Statement/v0.1",
"predicateType": "https://slsa.dev/provenance/v0.2",
"subject": [
{
"name": "pkg:docker/<registry>/<image>@<tag/digest>?platform=<platform>",
"digest": {
"sha256": "e8275b2b76280af67e26f068e5d585eb905f8dfd2f1918b3229db98133cb4862"
}
}
],
"predicate": {
"builder": {
"id": ""
},
"buildType": "https://mobyproject.org/buildkit@v1",
"materials": [
{
"uri": "pkg:docker/alpine@latest?platform=linux%2Famd64",
"digest": {
"sha256": "8914eb54f968791faf6a8638949e480fef81e697984fba772b3976835194c6d4"
}
}
],
"invocation": {
"configSource": {
"entryPoint": "Dockerfile"
},
"parameters": {
"frontend": "dockerfile.v0",
"args": {},
"locals": [
{
"name": "context"
},
{
"name": "dockerfile"
}
]
},
"environment": {
"platform": "linux/amd64"
}
},
"metadata": {
"buildInvocationID": "yirbp1aosi1vqjmi3z6bc75nb",
"buildStartedOn": "2022-12-08T11:48:59.466513707Z",
"buildFinishedOn": "2022-12-08T11:49:01.256820297Z",
"reproducible": false,
"completeness": {
"parameters": true,
"environment": true,
"materials": false
},
"https://mobyproject.org/buildkit@v1#metadata": {}
}
}
}
mode=max
{
"_type": "https://in-toto.io/Statement/v0.1",
"predicateType": "https://slsa.dev/provenance/v0.2",
"subject": [
{
"name": "pkg:docker/<registry>/<image>@<tag/digest>?platform=<platform>",
"digest": {
"sha256": "e8275b2b76280af67e26f068e5d585eb905f8dfd2f1918b3229db98133cb4862"
}
}
],
"predicate": {
"builder": {
"id": ""
},
"buildType": "https://mobyproject.org/buildkit@v1",
"materials": [
{
"uri": "pkg:docker/alpine@latest?platform=linux%2Famd64",
"digest": {
"sha256": "8914eb54f968791faf6a8638949e480fef81e697984fba772b3976835194c6d4"
}
}
],
"invocation": {
"configSource": {
"entryPoint": "Dockerfile"
},
"parameters": {
"frontend": "dockerfile.v0",
"args": {},
"locals": [
{
"name": "context"
},
{
"name": "dockerfile"
}
]
},
"environment": {
"platform": "linux/amd64"
}
},
"buildConfig": {
"llbDefinition": [
{
"id": "step0",
"op": {
"Op": {
"source": {
"identifier": "docker-image://docker.io/library/alpine:latest@sha256:8914eb54f968791faf6a8638949e480fef81e697984fba772b3976835194c6d4"
}
},
"platform": {
"Architecture": "amd64",
"OS": "linux"
},
"constraints": {}
}
},
{
"id": "step1",
"op": {
"Op": null
},
"inputs": ["step0:0"]
}
]
},
"metadata": {
"buildInvocationID": "46ue2x93k3xj5l463dektwldw",
"buildStartedOn": "2022-12-08T11:50:54.953375437Z",
"buildFinishedOn": "2022-12-08T11:50:55.447841328Z",
"reproducible": false,
"completeness": {
"parameters": true,
"environment": true,
"materials": false
},
"https://mobyproject.org/buildkit@v1#metadata": {
"source": {
"locations": {
"step0": {
"locations": [
{
"ranges": [
{
"start": {
"line": 1
},
"end": {
"line": 1
}
}
]
}
]
}
},
"infos": [
{
"filename": "Dockerfile",
"data": "RlJPTSBhbHBpbmU6bGF0ZXN0Cg==",
"llbDefinition": [
{
"id": "step0",
"op": {
"Op": {
"source": {
"identifier": "local://dockerfile",
"attrs": {
"local.differ": "none",
"local.followpaths": "[\"Dockerfile\",\"Dockerfile.dockerignore\",\"dockerfile\"]",
"local.session": "q2jnwdkas0i0iu4knchd92jaz",
"local.sharedkeyhint": "dockerfile"
}
}
},
"constraints": {}
}
},
{
"id": "step1",
"op": {
"Op": null
},
"inputs": ["step0:0"]
}
]
}
]
},
"layers": {
"step0:0": [
[
{
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
"digest": "sha256:c158987b05517b6f2c5913f3acef1f2182a32345a304fe357e3ace5fadcad715",
"size": 3370706
}
]
]
}
}
}
}
}