Skip to content

Commit 337a09d

Browse files
committed
disable provenance by default if not set
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
1 parent 37abced commit 337a09d

File tree

3 files changed

+45
-34
lines changed

3 files changed

+45
-34
lines changed

.github/workflows/ci.yml

-5
Original file line numberDiff line numberDiff line change
@@ -606,11 +606,6 @@ jobs:
606606
if: matrix.target == 'binary'
607607
run: |
608608
tree /tmp/buildx-build
609-
-
610-
name: Print provenance
611-
if: matrix.target == 'binary'
612-
run: |
613-
cat /tmp/buildx-build/provenance.json | jq
614609
-
615610
name: Print SBOM
616611
if: matrix.target == 'binary'

__tests__/context.test.ts

+38-1
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ nproc=3`],
557557
[
558558
'build',
559559
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
560-
"--provenance", `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`,
560+
"--provenance", 'false',
561561
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
562562
'.'
563563
]
@@ -638,6 +638,43 @@ nproc=3`],
638638
'.'
639639
]
640640
],
641+
[
642+
23,
643+
'0.10.0',
644+
new Map<string, string>([
645+
['context', '.'],
646+
['load', 'false'],
647+
['no-cache', 'false'],
648+
['push', 'false'],
649+
['pull', 'false'],
650+
['outputs', 'type=docker'],
651+
]),
652+
[
653+
'build',
654+
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
655+
"--output", 'type=docker',
656+
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
657+
'.'
658+
]
659+
],
660+
[
661+
24,
662+
'0.10.0',
663+
new Map<string, string>([
664+
['context', '.'],
665+
['load', 'true'],
666+
['no-cache', 'false'],
667+
['push', 'false'],
668+
['pull', 'false'],
669+
]),
670+
[
671+
'build',
672+
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
673+
"--load",
674+
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
675+
'.'
676+
]
677+
],
641678
])(
642679
'[%d] given %p with %p as inputs, returns %p',
643680
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>) => {

src/context.ts

+7-28
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,14 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, context: str
169169
if (inputs.provenance) {
170170
args.push('--provenance', inputs.provenance);
171171
} else if ((await buildx.satisfiesBuildKitVersion(inputs.builder, '>=0.11.0', standalone)) && !hasDockerExport(inputs)) {
172-
// if provenance not specified and BuildKit version compatible for
173-
// attestation, set default provenance. Also needs to make sure user
172+
// If provenance not specified but BuildKit version compatible for
173+
// attestation, disable provenance anyway. Also needs to make sure user
174174
// doesn't want to explicitly load the image to docker.
175-
if (fromPayload('repository.private') !== false) {
176-
// if this is a private repository, we set the default provenance
177-
// attributes being set in buildx: https://github.com/docker/buildx/blob/fb27e3f919dcbf614d7126b10c2bc2d0b1927eb6/build/build.go#L603
178-
args.push('--provenance', getProvenanceAttrs(`mode=min,inline-only=true`));
179-
} else {
180-
// for a public repository, we set max provenance mode.
181-
args.push('--provenance', getProvenanceAttrs(`mode=max`));
182-
}
175+
// While this action successfully pushes OCI compliant images to
176+
// well-known registries, some runtimes (e.g. Google Cloud Run and AWS
177+
// Lambda) are not able to pull resulting image from their own registry...
178+
// See also https://github.com/docker/buildx/issues/1533
179+
args.push('--provenance', 'false');
183180
}
184181
if (inputs.sbom) {
185182
args.push('--sbom', inputs.sbom);
@@ -281,24 +278,6 @@ export const asyncForEach = async (array, callback) => {
281278
}
282279
};
283280

284-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
285-
function fromPayload(path: string): any {
286-
return select(github.context.payload, path);
287-
}
288-
289-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
290-
function select(obj: any, path: string): any {
291-
if (!obj) {
292-
return undefined;
293-
}
294-
const i = path.indexOf('.');
295-
if (i < 0) {
296-
return obj[path];
297-
}
298-
const key = path.slice(0, i);
299-
return select(obj[key], path.slice(i + 1));
300-
}
301-
302281
function getProvenanceInput(name: string): string {
303282
const input = core.getInput(name);
304283
if (!input) {

0 commit comments

Comments
 (0)