Skip to content

(feat)Support native Tekton Artifacts API in SLSA provenance - #1841

Open
ngelman1 wants to merge 1 commit into
tektoncd:mainfrom
ngelman1:Tekton-artifact-API-support
Open

(feat)Support native Tekton Artifacts API in SLSA provenance#1841
ngelman1 wants to merge 1 commit into
tektoncd:mainfrom
ngelman1:Tekton-artifact-API-support

Conversation

@ngelman1

Copy link
Copy Markdown
Contributor

Changes

Today, Chains generates SLSA provenance for TaskRuns by extracting input and output artifacts from type-hinted results -specially named results like *IMAGE_URL, *IMAGE_DIGEST, CHAINS-GIT_COMMIT, and *ARTIFACT_OUTPUTS. If a result name doesn't match the expected pattern, Chains silently ignores it.

This PR is wiring the Tekton native artifact API (TEP-0147) into Chains' SLSA provenance generation.
This allows steps to explicitly declare their inputs and outputs by writing a JSON file to $(step.artifacts.path). The Pipelines controller then populates status.artifacts and status.steps[].inputs/outputs on the TaskRun with structured data including URIs, digests, and a buildOutput flag.

Artifact mapping

Artifact field buildOutput SLSA provenance field
inputs[].values n/a resolvedDependencies
outputs[].values true subject
outputs[].values false byproducts

This does not replace type-hinting, but adds the ability of chains to fetch inputs and outputs, without forcing the user to exactly match naming convetions.

**Tested on a kind cluster

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs included if any changes are user facing
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

Chains now supports the native Tekton Artifacts API (TEP-0147) for SLSA provenance generation. Task authors can declare build inputs and outputs via `$(step.artifacts.path)` as an alternative to type-hinted results, with no naming conventions required.

@tekton-robot
tekton-robot requested review from enarha and wlynch July 28, 2026 12:57
@tekton-robot tekton-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 28, 2026
@codecov-commenter

codecov-commenter commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.50%. Comparing base (1595398) to head (09be1b2).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1841      +/-   ##
==========================================
+ Coverage   61.98%   62.50%   +0.51%     
==========================================
  Files          64       64              
  Lines        4067     4155      +88     
==========================================
+ Hits         2521     2597      +76     
- Misses       1265     1272       +7     
- Partials      281      286       +5     
Flag Coverage Δ
unit-tests 62.50% <ø> (+0.51%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ngelman1
ngelman1 force-pushed the Tekton-artifact-API-support branch 2 times, most recently from 60566c4 to eca4358 Compare July 28, 2026 13:21
@anithapriyanatarajan anithapriyanatarajan self-assigned this Jul 28, 2026
@waveywaves

Copy link
Copy Markdown
Member

/assign

Comment thread pkg/artifacts/signable.go Outdated
return objs
}

// ExtractOCIImagesFromArtifacts extracts OCI image references from native Tekton Artifacts (TEP-0147) outputs where BuildOutput is true.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TEP-0147’s buildOutput flag selects subject versus byProduct; it is not an OCI media-type marker. The API explicitly supports packages, reports, source artifacts, and purl URIs. Recommended forms such as pkg:docker/... fail this parser, while some non-OCI URI forms can be accepted as registry references. Could we avoid feeding every build output into OCIArtifact, or require a reliable OCI-specific signal first?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

youre right. this adds more noise than use, removing this.
native artifacts still map correctly into provenance subjects via subjectsFromNativeArtifacts

Comment thread pkg/artifacts/signable.go Outdated
addArtifactOutputs(arts.Outputs)
}

for _, step := range obj.GetStepArtifacts() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pipeline retains step artifacts in Status.Steps[].Outputs and also merges them into Status.Artifacts.Outputs. Walking both collections therefore emits duplicate signable objects; I reproduced two objects for one artifact. Please consume the aggregate once, with a step-level fallback if it is absent, or deduplicate by canonical digest.

}
}

for _, step := range tro.GetStepArtifacts() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pipeline also supports task-level artifacts written through $(artifacts.path). Those appear in Status.Artifacts but not under an individual step, so this loop omits their non-build outputs from byProducts; I reproduced zero byproducts for one such output. Please read the aggregate here, with a step-level fallback if needed.

@ngelman1 ngelman1 Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok added. not sure I understand why we need the fallback though..? if an artifact appears in a step, than it will always appear in Status.Artifacts , correct? in what scenario is Status.Artifacts` empty but we still have step level artifacts?

Comment thread test/e2e_test.go
t.Error("expected at least one subject in the provenance statement")
}

if signedTR.Status.Artifacts != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test can pass without producing any native artifact. The fixture writes only the legacy IMAGE_URL/IMAGE_DIGEST results, never writes $(step.artifacts.path), and this test does not arrange for enable-artifacts to be enabled. Consequently, artifacts may be nil and skipped or non-nil but empty, while the legacy results satisfy the subject assertion. Please emit native input, build-output, and non-build-output artifacts and assert their exact URIs and digests in resolvedDependencies, subjects, and byProducts.

Comment thread docs/slsa-provenance.md
### How it works:
Instead of writing to specially named results, steps write a structured JSON file to $(step.artifacts.path). The Tekton Pipelines controller reads this file and populates status.artifacts and status.steps[].inputs/outputs on the TaskRun.

Chains then maps these artifacts into the SLSA provenance.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we scope this documentation and the release note to slsa/v2alpha4? Native subject and byproduct handling is currently wired only into that formatter. Native inputs also reach v2alpha3 through the shared resolved-dependency code, but its outputs do not, and the default in-toto format and slsa/v1 receive neither.

Comment thread docs/slsa-provenance.md
taskSpec:
steps:
- name: build-and-push
image: gcr.io/kaniko-project/executor

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example cannot run with the selected image: the Kaniko executor image contains neither bash nor buildah. Also, Buildah writes --digestfile as algorithm:hex, so placing ${DIGEST} under the sha256 key produces sha256:sha256:.... Please use a compatible image and strip the prefix, for example ${DIGEST#sha256:}.

Comment thread docs/slsa-provenance.md
}
EOF
```
If a TaskRun uses both type hinting and native artifacts, Chains will include artifacts from both sources. Duplicates are removed automatically.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“Duplicates are removed automatically” is currently true only for subjects and resolved dependencies. OCI extraction duplicates step artifacts through aggregate and per-step status, while byproducts have no deduplication. Please qualify this statement or deduplicate every affected path.

Wire the native Tekton Artifacts API (TEP-0147) into Chains' SLSA
provenance generation so that structured artifact declarations from
TaskRun status are included in the attestation alongside the existing
type-hinted results.

- Add GetArtifacts/GetStepArtifacts to TektonObject interface
- Extract OCI images from native artifact outputs for signing
- Map artifact inputs to resolvedDependencies
- Map buildOutput=true outputs to SLSA subjects
- Map buildOutput=false outputs to SLSA byproducts
- Add unit tests for all new functions
- Add e2e test for native artifacts provenance
@ngelman1
ngelman1 force-pushed the Tekton-artifact-API-support branch from eca4358 to 09be1b2 Compare August 11, 2026 15:48
@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from anithapriyanatarajan after the PR has been reviewed.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants