Skip to content

Commit 9be6c33

Browse files
authored
Disable docker image download (#240)
* Disable docker image download * Add tests and docs * Add image vulnerability scanning * Add grype scanning into workflows * Refactoring * Change nginx version to one with less vurnelabilities * test docker image for jakarta.mail * Change opengauss image and remove ryuk * Replace runtime.exec with ExecOperations and disable Testcontainers test * Comment whole Testcontainers test * Disable testcontainers test * Remove @disabled * Add link to ryuk issue * Replace port number * Fix docs and grammar issues * Enable discard service with inetd * Add discard port to test-changed-metadata workflow
1 parent 9425ee5 commit 9be6c33

File tree

36 files changed

+423
-30
lines changed

36 files changed

+423
-30
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
discard stream tcp nowait root internal
2+
discard dgram udp wait root internal

.github/workflows/dockerd.service

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[Service]
2+
Environment="HTTP_PROXY=http://localhost:9"
3+
Environment="HTTPS_PROXY=https://localhost:9"
4+
Environment="NO_PROXY=localhost,127.0.0.1"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "Scan docker images from the allowed docker images list"
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
scan-images:
7+
name: "🔎 Scan docker images"
8+
runs-on: "ubuntu-20.04"
9+
steps:
10+
- name: "☁️ Checkout repository"
11+
uses: actions/checkout@v3
12+
with:
13+
fetch-depth: 0
14+
- uses: graalvm/setup-graalvm@v1
15+
with:
16+
version: '22.3.1'
17+
java-version: '17'
18+
- name: "🔎 Check docker images"
19+
run: |
20+
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sudo sh -s -- -b /usr/local/bin
21+
sudo apt-get install jq
22+
./gradlew checkAllowedDockerImages

.github/workflows/test-all-metadata.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ jobs:
5252
components: 'native-image'
5353
github-token: ${{ secrets.GITHUB_TOKEN }}
5454
native-image-job-reports: 'true'
55+
- name: "Pull allowed docker images"
56+
run: |
57+
./gradlew pullAllowedDockerImages --coordinates=${{ matrix.coordinates }}
58+
- name: "Disable docker"
59+
run: |
60+
sudo apt-get install openbsd-inetd
61+
sudo bash -c "cat ./.github/workflows/discard-port.conf >> /etc/inetd.conf"
62+
sudo systemctl start inetd
63+
sudo mkdir /etc/systemd/system/docker.service.d
64+
sudo bash -c "cat ./.github/workflows/dockerd.service > /etc/systemd/system/docker.service.d/http-proxy.conf"
65+
sudo systemctl daemon-reload
66+
sudo systemctl restart docker
5567
- name: "🧪 Run '${{ matrix.coordinates }}' tests"
5668
run: |
5769
./gradlew test -Pcoordinates=${{ matrix.coordinates }}

.github/workflows/test-changed-metadata.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ jobs:
5555
components: 'native-image'
5656
github-token: ${{ secrets.GITHUB_TOKEN }}
5757
native-image-job-reports: 'true'
58+
- name: "Pull allowed docker images"
59+
run: |
60+
./gradlew pullAllowedDockerImages --coordinates=${{ matrix.coordinates }}
61+
- name: "Disable docker"
62+
run: |
63+
sudo apt-get install openbsd-inetd
64+
sudo bash -c "cat ./.github/workflows/discard-port.conf >> /etc/inetd.conf"
65+
sudo systemctl start inetd
66+
sudo mkdir /etc/systemd/system/docker.service.d
67+
sudo bash -c "cat ./.github/workflows/dockerd.service > /etc/systemd/system/docker.service.d/http-proxy.conf"
68+
sudo systemctl daemon-reload
69+
sudo systemctl restart docker
5870
- name: "🧪 Run '${{ matrix.coordinates }}' tests"
5971
run: |
6072
./gradlew test -Pcoordinates=${{ matrix.coordinates }}

CONTRIBUTING.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,26 @@ In this example this can be done by invoking following command from the reposito
196196
```bash
197197
./gradlew test -Pcoordinates=org.example:library:0.0.1
198198
```
199+
200+
### Providing the tests that use docker
201+
202+
If your tests use docker (either with explicit docker process invocation or through some library method call), all images
203+
have to be declared in `required-docker-images.txt` file. This file must be placed under `/tests/src/<groupId>/<artifactId>/<versionId>`.
204+
205+
Only docker images that are listed [here](https://github.com/oracle/graalvm-reachability-metadata/blob/master/tests/tck-build-logic/src/main/resources/AllowedDockerImages.txt)
206+
can be executed. If you want to extend this list, please create separate pull request to do that, and post the result of the following command on your pull request:
207+
208+
```shell
209+
grype <dockerImageName>
210+
```
211+
212+
Possible scenarios:
213+
* If your test uses docker image, and you didn't specify it in the `required-docker-images.txt` file, the test will fail.
214+
* If your test uses docker image that is not listed in [allowed docker images list](https://github.com/oracle/graalvm-reachability-metadata/blob/master/tests/tck-build-logic/src/main/resources/AllowedDockerImages.txt),
215+
the test will fail
216+
* Only docker images that are in both `required-docker-images.txt` and in the `allowed docker images list`
217+
can be executed.
218+
199219

200220
## Tested Libraries and Frameworks
201221

metadata/index.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,5 +240,9 @@
240240
{
241241
"directory" : "jakarta.servlet/jakarta.servlet-api",
242242
"module" : "jakarta.servlet:jakarta.servlet-api"
243+
},
244+
{
245+
"directory" : "samples/docker",
246+
"module" : "samples:docker"
243247
}
244248
]

metadata/samples/docker/image-pull/.gitkeep

Whitespace-only changes.

metadata/samples/docker/index.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"latest": true,
4+
"metadata-version": "image-pull",
5+
"module": "samples:docker",
6+
"tested-versions": [
7+
"image-pull"
8+
]
9+
}
10+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mysql/mysql-server:8.0

0 commit comments

Comments
 (0)