Skip to content

Conversation

@kkaarreell
Copy link
Collaborator

@kkaarreell kkaarreell commented Nov 3, 2025

Summary by Sourcery

Support the new push-model attestation agent across the test framework, parameterize tests and services for push vs standard agents, and add dedicated tests for agent resilience, reattestation, and push-attestation scenarios.

New Features:

  • Add push-model attestation agent support in the test library with new helper functions (limeStartPushAgent, limeStopPushAgent, limePushAgentLogfile)
  • Introduce new functional test suites for agent resilience & reattestation and push-attestation on localhost

Enhancements:

  • Parameterize functional tests to support both standard and push-model agents via AGENT_SERVICE and TENANT_ARGS
  • Extend systemd drop-in configurations upstream for keylime_push_model_agent in rust installation and TPM emulator setup
  • Change default IMA appraisal mode from 'fix' to 'log' and copy SSH/resolv.conf into bootc container for IMA

Tests:

  • Update existing measured-boot and container-basic-attestation tests to include push-model tenant args and dynamic agent commands

@kkaarreell kkaarreell self-assigned this Nov 3, 2025
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 3, 2025

Reviewer's Guide

This PR implements support for PUSH-model attestation by extending the test-helper library, adapting existing tests to parameterize agent service types, adding systemd overrides for the push-model agent, updating IMA configuration tests, and introducing new functional suites for agent resilience and push-attestation on localhost.

Sequence diagram for PUSH-model attestation interaction

sequenceDiagram
    actor User
    participant Agent
    participant Verifier
    User->>Agent: Start agent with push-model
    Agent->>Verifier: Send attestation data (push)
    Verifier->>Agent: Acknowledge attestation
    Agent-->>Verifier: Reattest on failure/restart
Loading

Class diagram for test-helper library and agent service parameterization

classDiagram
    class TestHelperLibrary {
      +setupAgent(serviceType)
      +runAttestationTest()
    }
    class AgentService {
      +serviceType: string
      +start()
      +applySystemdOverride()
    }
    TestHelperLibrary --> AgentService : parameterizes
    AgentService <|-- PushModelAgent
    class PushModelAgent {
      +startPushAttestation()
      +reattestOnFailure()
    }
Loading

File-Level Changes

Change Details Files
Extend test-helpers library with push-model agent wrappers and log handling
  • Map push_model_agent to generic agent in log name resolution
  • Add limeStartPushAgent, limeStopPushAgent, limePushAgentLogfile functions
  • Include push-agent logs in common log submission
  • Fix quoting around internal logfile path variables
Library/test-helpers/lib.sh
Parameterize measured-boot tests for agent service type and push args
  • Introduce TENANT_ARGS and dynamic AGENT_SERVICE checks
  • Pass --push-model to keylime_tenant when appropriate
  • Use limeStart${AGENT_SERVICE} and limeStop${AGENT_SERVICE} calls
functional/measured-boot-swtpm-sanity/test.sh
Add systemd drop-in overrides for keylime_push_model_agent
  • Create service.d dirs for push_model_agent
  • Set RUST_LOG and TPM_BINARY_MEASUREMENTS in drop-ins
  • Add coverage stop hook for push_model_agent
setup/install_upstream_rust_keylime/test.sh
Unify agent command and TCTI overrides in container and emulator tests
  • Determine AGENT_CMD and TENANT_ARGS based on AGENT_SERVICE in container tests
  • Loop over both keylime_agent and keylime_push_model_agent in TCTI drop-in setup
container/functional/keylime_agent_container-basic-attestation/test.sh
setup/configure_tpm_emulator/test.sh
Update IMA configuration tests to use log appraisal and include additional files
  • Change default IMA_APPRAISE from 'fix' to 'log'
  • Copy .ssh and resolv.conf into test workspace and Containerfile
  • Run restorecon on copied content
setup/bootc_configure_kernel_ima_module/test.sh
setup/bootc_configure_kernel_ima_module/Containerfile
setup/configure_kernel_ima_module/test.sh
Introduce new functional tests for agent resilience and push-attestation scenarios
  • Add test suite for agent restart, verifier restart, deletion, and policy update resilience
  • Add push-attestation-on-localhost test covering allowed/failing scripts
functional/agent-resilience-and-reattestation/test.sh
functional/push-attestation-on-localhost/test.sh
functional/agent-resilience-and-reattestation/main.fmf
functional/push-attestation-on-localhost/main.fmf

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@@ -0,0 +1,133 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
. /usr/share/beakerlib/beakerlib.sh || exit 1

Check warning

Code scanning / shellcheck

SC1091 Warning test

Not following: /usr/share/beakerlib/beakerlib.sh: openBinaryFile: does not exist (No such file or directory)
rlRun "keylime_tenant -v 127.0.0.1 -t 127.0.0.1 -u $AGENT_ID --runtime-policy policy.json -c add"
rlRun "limeWaitForAgentStatus $AGENT_ID 'Get Quote'"
rlRun -s "keylime_tenant -c cvlist"
rlAssertGrep "{'code': 200, 'status': 'Success', 'results': {'uuids':.*'$AGENT_ID'" $rlRun_LOG -E

Check warning

Code scanning / shellcheck

SC2154 Warning test

rlRun_LOG is referenced but not assigned.
rlRun "keylime_tenant -v 127.0.0.1 -t 127.0.0.1 -u $AGENT_ID --runtime-policy policy.json -c add"
rlRun "limeWaitForAgentStatus $AGENT_ID 'Get Quote'"
rlRun -s "keylime_tenant -c cvlist"
rlAssertGrep "{'code': 200, 'status': 'Success', 'results': {'uuids':.*'$AGENT_ID'" $rlRun_LOG -E

Check warning

Code scanning / shellcheck

SC2086 Warning test

Double quote to prevent globbing and word splitting.
rlRun "keylime_tenant -v 127.0.0.1 -t 127.0.0.1 -u $AGENT_ID -c regdelete"
# verify agent is deleted
rlRun -s "keylime_tenant -c reglist"
rlAssertNotGrep "$AGENT_ID" $rlRun_LOG

Check warning

Code scanning / shellcheck

SC2086 Warning test

Double quote to prevent globbing and word splitting.

rlPhaseStartTest "Remove agent and re-add with updated policy"
# create a script that will be allowed
TESTDIR=`limeCreateTestDir`

Check warning

Code scanning / shellcheck

SC2006 Warning test

Use $(...) notation instead of legacy backticks ....
limeSubmitCommonLogs
limeClearData
limeRestoreConfig
limeExtendNextExcludelist $TESTDIR

Check warning

Code scanning / shellcheck

SC2086 Warning test

Double quote to prevent globbing and word splitting.
Copy link

@sourcery-ai sourcery-ai bot left a 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 - here's some feedback:

  • Consider centralizing the push_model_agent service name and TENANT_ARGS logic into a shared helper or variable so you don’t have to sprinkle the same conditional blocks across every test script.
  • The repeated appending of ${TENANT_ARGS} in tenant CLI invocations is error-prone—wrap your keylime_tenant calls in a helper function that automatically includes the correct flags for push mode.
  • The new functional tests are quite long and cover multiple scenarios; splitting them into smaller, FMF-parameterized cases would make them more readable and easier to maintain.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider centralizing the `push_model_agent` service name and TENANT_ARGS logic into a shared helper or variable so you don’t have to sprinkle the same conditional blocks across every test script.
- The repeated appending of `${TENANT_ARGS}` in tenant CLI invocations is error-prone—wrap your keylime_tenant calls in a helper function that automatically includes the correct flags for push mode.
- The new functional tests are quite long and cover multiple scenarios; splitting them into smaller, FMF-parameterized cases would make them more readable and easier to maintain.

## 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.

Explicitly set permissions on the .ssh directory and private keys after copying to prevent unauthorized access.

```suggestion
COPY .ssh /var/roothome/.ssh
RUN chmod 700 /var/roothome/.ssh && \
    find /var/roothome/.ssh -type f -name "id_*" -exec chmod 600 {} \; && \
    chown -R root:root /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"
```
</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.

If you must overwrite resolv.conf, verify its contents are suitable for all deployment environments and do not conflict with container runtime DNS management.
</issue_to_address>

### Comment 3
<location> `setup/bootc_configure_kernel_ima_module/Containerfile:13` </location>
<code_context>
 ARG KEYLIME_BOOTC_INSTALL_PACKAGES="rsync beakerlib selinux-policy-devel swtpm swtpm-tools nmap keylime expect"
 RUN dnf -y install ${KEYLIME_BOOTC_INSTALL_PACKAGES}
 RUN sed -i '/tss/ d' /usr/lib/group; ls -ld /etc/keylime /var/lib/keylime; ls -l /etc/keylime /var/lib/keylime; /bin/true
+RUN restorecon -Rv /usr /etc; /bin/true
</code_context>

<issue_to_address>
**suggestion:** Running restorecon recursively on /usr and /etc may have unintended side effects.

Limit restorecon to only the files or directories changed during the build to avoid unnecessary processing and unintended changes.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines 8 to 10
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 link

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.

Explicitly set permissions on the .ssh directory and private keys after copying to prevent unauthorized access.

Suggested change
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_*" -exec chmod 600 {} \; && \
chown -R root:root /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 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
Copy link

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.

If you must overwrite resolv.conf, verify its contents are suitable for all deployment environments and do not conflict with container runtime DNS management.

ARG KEYLIME_BOOTC_INSTALL_PACKAGES="rsync beakerlib selinux-policy-devel swtpm swtpm-tools nmap keylime expect"
RUN dnf -y install ${KEYLIME_BOOTC_INSTALL_PACKAGES}
RUN sed -i '/tss/ d' /usr/lib/group; ls -ld /etc/keylime /var/lib/keylime; ls -l /etc/keylime /var/lib/keylime; /bin/true
RUN restorecon -Rv /usr /etc; /bin/true
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Running restorecon recursively on /usr and /etc may have unintended side effects.

Limit restorecon to only the files or directories changed during the build to avoid unnecessary processing and unintended changes.

@kkaarreell
Copy link
Collaborator Author

/packit test

@kkaarreell kkaarreell force-pushed the ks_agent_resilience branch 2 times, most recently from 4fdc219 to edd3558 Compare November 4, 2025 09:36
@kkaarreell
Copy link
Collaborator Author

/packit test

@kkaarreell kkaarreell force-pushed the ks_agent_resilience branch 2 times, most recently from 2f26d48 to c44983b Compare November 18, 2025 08:29
@kkaarreell
Copy link
Collaborator Author

/packit test

@kkaarreell kkaarreell merged commit 8bbb68a into main Dec 4, 2025
7 of 10 checks passed
@kkaarreell kkaarreell deleted the ks_agent_resilience branch December 4, 2025 08:18
@kkaarreell kkaarreell changed the title [WIP] /functional/agent-resilience-and-reattestation /functional/agent-resilience-and-reattestation Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants