-
Notifications
You must be signed in to change notification settings - Fork 1
generic: add Dependency-Check example from cachi2-generic #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: generic-basic
Are you sure you want to change the base?
Conversation
Migrate the generic fetcher sample from cachito-testing/cachi2-generic (sample-app branch) to doc-examples, adapted for Hermeto output. Signed-off-by: Vladimir Aleksandrov <valeksan@redhat.com>
Summary of ChangesHello @derasdf, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates a new example into the documentation, illustrating the use of Hermeto's generic fetcher to manage and incorporate external tools. The example focuses on packaging the OWASP Dependency-Check tool into a container image, providing a clear, step-by-step guide for users to understand Hermeto's capabilities in fetching and utilizing third-party dependencies within a containerized environment. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds an example for using Hermeto's generic fetcher with OWASP Dependency-Check, including a Containerfile, an artifacts.lock.yaml, and an updated README.md. A security audit identified two medium-severity issues in the Containerfile: the use of a deprecated base image and the lack of a non-root user configuration. Additionally, my review provides suggestions to improve the Containerfile for better security and efficiency, such as running the container as a non-root user and optimizing image layers, and to enhance the portability of commands in the README.md.
| RUN jar -xvf hermeto-output/deps/generic/dependency-check.zip | ||
|
|
||
| RUN chmod +x dependency-check/bin/dependency-check.sh | ||
|
|
||
| ENTRYPOINT ["/tmp/dependency-check/bin/dependency-check.sh", "--version"] No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a couple of suggestions to improve this Containerfile:
- Combine
RUNlayers: To reduce the number of layers in the container image and improve build performance, it's a good practice to chain relatedRUNcommands together. - Run as non-root user: For security reasons, it's a best practice to run containers as a non-root user. You should create a dedicated user and switch to it before setting the
ENTRYPOINT.
Here is a suggestion that applies both improvements:
RUN jar -xvf hermeto-output/deps/generic/dependency-check.zip && \
chmod +x dependency-check/bin/dependency-check.sh
# Create a non-root user and switch to it for security reasons
RUN groupadd -r app && useradd --no-log-init -r -g app app
USER app
ENTRYPOINT ["/tmp/dependency-check/bin/dependency-check.sh", "--version"]
| @@ -0,0 +1,10 @@ | |||
| FROM ibmjava:11-jdk | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Containerfile uses ibmjava:11-jdk as a base image. This image is deprecated by IBM and no longer receives security updates. Using an unmaintained base image exposes the container to known and future vulnerabilities in the operating system and the Java runtime. It is recommended to use a supported base image, such as ibm-semeru-runtimes:open-11-jdk.
| @@ -0,0 +1,10 @@ | |||
| FROM ibmjava:11-jdk | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The container does not specify a non-root user and will run as root by default. Running containers with root privileges increases the risk of container escape and limits the effectiveness of defense-in-depth strategies. If the application within the container is compromised, the attacker will have full administrative access within the container. It is recommended to create a non-privileged user and use the USER instruction to switch to it before the ENTRYPOINT.
|
|
||
| ```shell | ||
| podman build . \ | ||
| --volume "$(realpath ./hermeto-output)":/tmp/hermeto-output \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The realpath command may not be available on all systems by default (e.g., macOS). Using $(pwd) is a more portable way to get the absolute path of the current directory.
| --volume "$(realpath ./hermeto-output)":/tmp/hermeto-output \ | |
| --volume "$(pwd)/hermeto-output":/tmp/hermeto-output \ |
a-ovchinnikov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. While the robot's comments are somewhat valid I'd have focused on migration first and on everything else after that (since there is no guarantee that it won't break things).
Yep, migration first, fixes later OR subsequent commits. |
Migrate the generic fetcher sample from cachito-testing/cachi2-generic (sample-app branch) to doc-examples, adapted for Hermeto output.