-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(capabilities): add e2e tests and example pipeline
Signed-off-by: Massimiliano Giovagnoli <[email protected]>
- Loading branch information
Showing
3 changed files
with
91 additions
and
0 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 |