-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Refactor Dockerfile validation code to handle here-documents (#3774)
* Refactor Dockerfile validation code to handle here-documents Refactors the `validateDockerfileInsecureDownloads` function to handle Dockerfiles that contain here-documents. This implementation handles the basic use-case, namely shell commands. It does not manage other interpreters that are specified through a she-bang, such as python. Fixes #3335 Signed-off-by: Jürgen Kreileder <jk@blackdown.de> * Add test for empty run command case in validateDockerfileInsecureDownloads() Signed-off-by: Jürgen Kreileder <jk@blackdown.de> * Simplify end line calculation in validateDockerfileInsecureDownloads() Signed-off-by: Jürgen Kreileder <jk@blackdown.de> * Document why we have a python test case here Signed-off-by: Jürgen Kreileder <jk@blackdown.de> --------- Signed-off-by: Jürgen Kreileder <jk@blackdown.de>
- Loading branch information
1 parent
6c345f1
commit e15264d
Showing
4 changed files
with
277 additions
and
14 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
# Copyright 2024 OpenSSF Scorecard Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Add tab | ||
FROM python:3.7 | ||
|
||
RUN <<-EOT | ||
pip install --no-deps -e git+https://github.com/username/repo.git@v1.0#egg=package | ||
EOT | ||
|
||
RUN <<EOT | ||
pip install --no-deps -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567 | ||
EOT | ||
|
||
RUN <<"EOT" | ||
curl bla | bash | ||
EOT | ||
|
||
RUN <<EOT1 bash | ||
pip install --no-deps -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567 | ||
EOT1 | ||
|
||
RUN <<EOT1 <<EOT2 | ||
pip install --no-deps -e git+https://github.com/username/repo.git@v1.0#egg=package | ||
EOT1 | ||
curl bla | bash | ||
EOT2 | ||
|
||
RUN <<EOT1 <<EOT2 | ||
pip install --no-deps -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567 | ||
pip install --no-deps -e git+https://github.com/username/repo.git@v1.0#egg=package | ||
EOT1 | ||
curl bla | bash | ||
EOT2 | ||
|
||
RUN <<EOT | ||
#!/bin/sh | ||
pip install --no-deps -e git+https://github.com/username/repo.git@0123456789abcdef0123456789abcdef01234567 | ||
curl bla | bash | ||
EOT | ||
|
||
# Here-documents can specify interpreters with shebang headers. This shouldn't cause a fatal error. | ||
# Example from https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md | ||
RUN <<EOT | ||
#!/usr/bin/env python | ||
print("hello world") | ||
EOT |
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,18 @@ | ||
# Copyright 2024 OpenSSF Scorecard Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# Note: taken from https://github.com/pushiqiang/utils/blob/master/docker/Dockerfile_template | ||
|
||
FROM scratch | ||
|
||
RUN [] |