|
11 | 11 | from pytest_container import get_extra_run_args
|
12 | 12 | from pytest_container import MultiStageBuild
|
13 | 13 | from pytest_container.container import ContainerData
|
| 14 | +from pytest_container.runtime import LOCALHOST |
14 | 15 |
|
15 | 16 | from bci_tester.data import ALL_CONTAINERS
|
16 | 17 | from bci_tester.data import BUSYBOX_CONTAINER
|
|
20 | 21 | from bci_tester.data import OS_VERSION
|
21 | 22 | from bci_tester.data import PCP_CONTAINER
|
22 | 23 | from bci_tester.data import POSTGRESQL_CONTAINERS
|
| 24 | +from bci_tester.runtime_choice import DOCKER_SELECTED |
23 | 25 |
|
24 | 26 | CONTAINER_IMAGES = ALL_CONTAINERS
|
25 | 27 |
|
@@ -170,6 +172,33 @@ def test_zypper_verify_passes(container_per_test: ContainerData) -> None:
|
170 | 172 | )
|
171 | 173 |
|
172 | 174 |
|
| 175 | +@pytest.mark.skipif( |
| 176 | + DOCKER_SELECTED, reason="Trivy-Scan images only with podman" |
| 177 | +) |
| 178 | +@pytest.mark.skipif( |
| 179 | + LOCALHOST.system_info.arch not in ("x86_64",), |
| 180 | + reason=f"{LOCALHOST.system_info.arch} is not supported to run trivy", |
| 181 | +) |
| 182 | +def test_trivy_image_scan(host, auto_container: ContainerData) -> None: |
| 183 | + """Check that trivy image is able to scan the container.""" |
| 184 | + |
| 185 | + trivy_container = "docker.io/aquasec/trivy:latest" |
| 186 | + baseurl = auto_container.container.baseurl |
| 187 | + if not baseurl: |
| 188 | + pytest.skip( |
| 189 | + reason=f"container {auto_container.container} has no baseurl" |
| 190 | + ) |
| 191 | + |
| 192 | + host.run_expect( |
| 193 | + [0], |
| 194 | + ( |
| 195 | + f"podman run -v trivy:/root {trivy_container} image {baseurl} " |
| 196 | + "--exit-code 1 --exit-on-eol 2 -f template " |
| 197 | + "--template '@contrib/sarif.tpl'" |
| 198 | + ), |
| 199 | + ) |
| 200 | + |
| 201 | + |
173 | 202 | @pytest.mark.parametrize(
|
174 | 203 | "container",
|
175 | 204 | [
|
|
0 commit comments