-
Notifications
You must be signed in to change notification settings - Fork 19
Preserve ssh keys and resolv.conf #916
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
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates the test harness and container build to preserve SSH keys and DNS resolver configuration by copying them into the build context and adding matching COPY directives in the Containerfile. Class diagram for updated Containerfile build stepsclassDiagram
class Containerfile {
+COPY 10-ima_kargs.toml /usr/lib/bootc/kargs.d/10-ima_kargs.toml
+COPY ima-policy /etc/ima/ima-policy
+COPY yum.repos.d/* /etc/yum.repos.d/
+COPY .ssh /var/roothome/.ssh
+COPY resolv.conf /etc/resolv.conf
+RUN dnf -y install KEYLIME_BOOTC_INSTALL_PACKAGES
+RUN sed -i '/tss/ d' /usr/lib/group
}
class BuildContext {
+.ssh
+resolv.conf
+yum.repos.d/*
+ima-policy
+10-ima_kargs.toml
}
BuildContext <|-- Containerfile
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `setup/bootc_configure_kernel_ima_module/Containerfile:8-10` </location>
<code_context>
COPY 10-ima_kargs.toml /usr/lib/bootc/kargs.d/10-ima_kargs.toml
COPY ima-policy /etc/ima/ima-policy
COPY yum.repos.d/* /etc/yum.repos.d/
+COPY .ssh /var/roothome/.ssh
+COPY resolv.conf /etc/resolv.conf
ARG KEYLIME_BOOTC_INSTALL_PACKAGES="rsync beakerlib selinux-policy-devel swtpm swtpm-tools nmap keylime expect"
</code_context>
<issue_to_address>
**🚨 suggestion (security):** Consider restricting permissions on the copied .ssh directory for security.
Set directory permissions to 700 and private key files to 600 after copying to prevent unauthorized access to SSH keys.
```suggestion
COPY .ssh /var/roothome/.ssh
RUN chmod 700 /var/roothome/.ssh && \
find /var/roothome/.ssh -type f \( -name "id_*" -o -name "*_key" \) -exec chmod 600 {} +
COPY resolv.conf /etc/resolv.conf
ARG KEYLIME_BOOTC_INSTALL_PACKAGES="rsync beakerlib selinux-policy-devel swtpm swtpm-tools nmap keylime expect"
```
</issue_to_address>
### Comment 2
<location> `setup/bootc_configure_kernel_ima_module/Containerfile:9` </location>
<code_context>
COPY ima-policy /etc/ima/ima-policy
COPY yum.repos.d/* /etc/yum.repos.d/
+COPY .ssh /var/roothome/.ssh
+COPY resolv.conf /etc/resolv.conf
ARG KEYLIME_BOOTC_INSTALL_PACKAGES="rsync beakerlib selinux-policy-devel swtpm swtpm-tools nmap keylime expect"
RUN dnf -y install ${KEYLIME_BOOTC_INSTALL_PACKAGES}
</code_context>
<issue_to_address>
**question (bug_risk):** Overwriting /etc/resolv.conf may interfere with container DNS resolution.
This may disrupt DNS configuration set by the container runtime. Only copy resolv.conf if required, and verify its suitability for the container.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
COPY .ssh /var/roothome/.ssh | ||
COPY resolv.conf /etc/resolv.conf | ||
ARG KEYLIME_BOOTC_INSTALL_PACKAGES="rsync beakerlib selinux-policy-devel swtpm swtpm-tools nmap keylime expect" |
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.
🚨 suggestion (security): Consider restricting permissions on the copied .ssh directory for security.
Set directory permissions to 700 and private key files to 600 after copying to prevent unauthorized access to SSH keys.
COPY .ssh /var/roothome/.ssh | |
COPY resolv.conf /etc/resolv.conf | |
ARG KEYLIME_BOOTC_INSTALL_PACKAGES="rsync beakerlib selinux-policy-devel swtpm swtpm-tools nmap keylime expect" | |
COPY .ssh /var/roothome/.ssh | |
RUN chmod 700 /var/roothome/.ssh && \ | |
find /var/roothome/.ssh -type f \( -name "id_*" -o -name "*_key" \) -exec chmod 600 {} + | |
COPY resolv.conf /etc/resolv.conf | |
ARG KEYLIME_BOOTC_INSTALL_PACKAGES="rsync beakerlib selinux-policy-devel swtpm swtpm-tools nmap keylime expect" |
COPY ima-policy /etc/ima/ima-policy | ||
COPY yum.repos.d/* /etc/yum.repos.d/ | ||
COPY .ssh /var/roothome/.ssh | ||
COPY resolv.conf /etc/resolv.conf |
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.
question (bug_risk): Overwriting /etc/resolv.conf may interfere with container DNS resolution.
This may disrupt DNS configuration set by the container runtime. Only copy resolv.conf if required, and verify its suitability for the container.
Summary by Sourcery
Preserve SSH keys and DNS resolution by copying the host’s /root/.ssh directory and /etc/resolv.conf into the test image context and including them in the container build
Enhancements: