Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce better security for buildpacks-phases task #434

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions task/buildpacks-phases/0.1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Buildpacks](https://buildpacks.io). To do that, it uses [builders](https://build

Cloud Native Buildpacks are pluggable, modular tools that transform application source code into OCI images. They replace Dockerfiles in the app development lifecycle, and enable for swift rebasing of images and modular control over images (through the use of builders), among other benefits. This command uses a builder to construct the image, and pushes it to the registry provided.

The lifecycle phases are run in separate containers to enable better security for untrusted builders. Specifically, registry credentials are hidden from the detect and build phases of the lifecycle, and the analyze, restore, and export phases (which require credentials) are run in the lifecycle image published by the [Cloud Native Buildpacks project]( https://hub.docker.com/u/buildpacksio).

See also [`buildpacks`](../buildpacks) for the combined version of this task, which uses the [creator binary](https://github.com/buildpacks/spec/blob/platform/0.3/platform.md#operations), to run all of the [lifecycle phases](https://buildpacks.io/docs/concepts/components/lifecycle/#phases). This task, in contrast, runs all of the phases separately.

## Install the Task
Expand Down
31 changes: 28 additions & 3 deletions task/buildpacks-phases/0.1/buildpacks-phases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ spec:
value: "0.3"

steps:
# Ensure the builder's user has read/write permissions for needed directories.
- name: prepare
image: alpine
imagePullPolicy: Always
Expand All @@ -76,6 +77,19 @@ spec:
securityContext:
privileged: true

# Copy stack.toml so that it will be accessible to the exporter, since the lifecycle image will not contain it.
- name: copy-stack-toml
natalieparellano marked this conversation as resolved.
Show resolved Hide resolved
image: $(params.BUILDER_IMAGE)
imagePullPolicy: Always
command: ["/bin/sh"]
args:
- "-c"
- >
cp /cnb/stack.toml /layers/
volumeMounts:
- name: layers-dir
mountPath: /layers

- name: detect
image: $(params.BUILDER_IMAGE)
imagePullPolicy: Always
Expand All @@ -89,15 +103,19 @@ spec:
mountPath: /layers
- name: $(params.PLATFORM_DIR)
mountPath: /platform
- name: empty-dir
mountPath: /tekton/home

- name: analyze
image: $(params.BUILDER_IMAGE)
image: buildpacksio/lifecycle:0.8.1
imagePullPolicy: Always
command: ["/cnb/lifecycle/analyzer"]
args:
- "-layers=/layers"
- "-group=/layers/group.toml"
- "-cache-dir=/cache"
- "-uid=$(params.USER_ID)"
- "-gid=$(params.GROUP_ID)"
- "$(resources.outputs.image.url)"
volumeMounts:
- name: $(params.CACHE)
Expand All @@ -106,13 +124,15 @@ spec:
mountPath: /layers

- name: restore
image: $(params.BUILDER_IMAGE)
image: buildpacksio/lifecycle:0.8.1
imagePullPolicy: Always
command: ["/cnb/lifecycle/restorer"]
args:
- "-group=/layers/group.toml"
- "-layers=/layers"
- "-cache-dir=/cache"
- "-uid=$(params.USER_ID)"
- "-gid=$(params.GROUP_ID)"
volumeMounts:
- name: $(params.CACHE)
mountPath: /cache
Expand All @@ -133,9 +153,11 @@ spec:
mountPath: /layers
- name: $(params.PLATFORM_DIR)
mountPath: /platform
- name: empty-dir
mountPath: /tekton/home

- name: export
image: $(params.BUILDER_IMAGE)
image: buildpacksio/lifecycle:0.8.1
imagePullPolicy: Always
command: ["/cnb/lifecycle/exporter"]
args:
Expand All @@ -144,6 +166,9 @@ spec:
- "-group=/layers/group.toml"
- "-cache-dir=/cache"
- "-process-type=$(params.PROCESS_TYPE)"
- "-uid=$(params.USER_ID)"
- "-gid=$(params.GROUP_ID)"
- "-stack=/layers/stack.toml"
- "$(resources.outputs.image.url)"
volumeMounts:
- name: layers-dir
Expand Down