-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support to add and drop linux capabilities (#1702)
* feat: add support to add and drop linux capabilities This commit adds the configuration to add and drop Linux capabilies to the container for bubblewrap and docker runners, enabling a declarative way to do least privilege at both build and test time. Furthermore, the minimum set of process capabilities in Bubblewrap container is now the same of Docker default capabilities. * chore(pkg/container/config): rename capabilities config fields * test(capabilities): add e2e tests and example pipeline --------- Signed-off-by: Massimiliano Giovagnoli <[email protected]>
- Loading branch information
Showing
11 changed files
with
152 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package: | ||
name: busybox | ||
description: Capabilities add-drop feature test | ||
version: 0.1.0 | ||
epoch: 0 | ||
|
||
capabilities: | ||
add: | ||
- CAP_NET_ADMIN | ||
drop: | ||
- CAP_SYS_ADMIN | ||
- CAP_SYS_CHROOT | ||
|
||
environment: | ||
contents: | ||
packages: | ||
- busybox | ||
- cmd:capsh | ||
|
||
pipeline: | ||
- name: Test default effective capability | ||
runs: | | ||
capsh --decode=$(grep CapEff /proc/self/status | cut -d ':' -f2 | xargs) | grep -i cap_dac_override | ||
- name: Test added non-default effective capability | ||
runs: | | ||
capsh --decode=$(grep CapEff /proc/self/status | cut -d ':' -f2 | xargs) | grep -i cap_net_admin | ||
- name: Test dropped default effective capability | ||
runs: | | ||
capsh --decode=$(grep CapEff /proc/self/status | cut -d ':' -f2 | xargs) | grep -vi cap_sys_chroot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package: | ||
name: busybox | ||
description: Capabilities add-drop feature test | ||
version: 0.1.0 | ||
epoch: 0 | ||
|
||
capabilities: | ||
add: | ||
- CAP_NET_ADMIN | ||
drop: | ||
- CAP_SYS_ADMIN | ||
- CAP_SYS_CHROOT | ||
|
||
pipeline: | ||
|
||
test: | ||
environment: | ||
contents: | ||
packages: | ||
- busybox | ||
- cmd:capsh | ||
pipeline: | ||
- name: Test default effective capability | ||
runs: | | ||
capsh --decode=$(grep CapEff /proc/self/status | cut -d ':' -f2 | xargs) | grep -i cap_dac_override | ||
- name: Test added non-default effective capability | ||
runs: | | ||
capsh --decode=$(grep CapEff /proc/self/status | cut -d ':' -f2 | xargs) | grep -i cap_net_admin | ||
- name: Test dropped default effective capability | ||
runs: | | ||
capsh --decode=$(grep CapEff /proc/self/status | cut -d ':' -f2 | xargs) | grep -vi cap_sys_chroot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package: | ||
name: busybox | ||
version: 0.1.0 | ||
epoch: 0 | ||
|
||
capabilities: | ||
add: | ||
- CAP_NET_ADMIN | ||
drop: | ||
- CAP_SYS_ADMIN | ||
|
||
pipeline: | ||
# Here your build pipeline. | ||
# Capabilities are added/dropped to both build and test pipelines. | ||
|
||
test: | ||
environment: | ||
contents: | ||
packages: | ||
- busybox | ||
- iproute2 | ||
pipeline: | ||
# Note: you can't do it with bubblewrap runner, | ||
# as it shares the host network namespace. | ||
- name: Simulate a test attempting to create network interfaces | ||
runs: | | ||
ip link add dev myinterface type dummy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters