Skip to content

Conversation

@ansasaki
Copy link
Contributor

@ansasaki ansasaki commented Dec 9, 2024

This moves the code from the main.rs file to a new dedicated module in keylime library, keylime::device_id.

The new module implements the builder pattern in DeviceIDBuilder to setup the arguments and then generate an instance of the DeviceID structure.

This modifies the tests/run.sh script to generate the IAK and IDevID certificates using the TPM state placed in test-data/tpm-state (which is generated if not present) and place the resulting certificates in keylime/test-data/iak-idevid-certs

Move the IAK/IDevID initialization code to the dedicated module
'device_id'.

The module implements the builder pattern to set the parameters set
through configuration.

The goal is to simplify the code in main.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
This makes the tests/run.sh script to generate the IAK and IDevID
certificates if the tpm2-openssl provider is available.

The added test is executed only if both the IAK and IDevID certificates
are available.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
@ansasaki ansasaki force-pushed the modular_idevid branch 5 times, most recently from 72cbe78 to 2f2f4e0 Compare December 9, 2024 14:25
@ansasaki ansasaki marked this pull request as draft December 9, 2024 14:28
@ansasaki ansasaki force-pushed the modular_idevid branch 4 times, most recently from de7c314 to d9b28d4 Compare December 9, 2024 15:52
@codecov
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 79.63526% with 67 lines in your changes missing coverage. Please review.

Project coverage is 60.99%. Comparing base (2f7b3ad) to head (e7ca799).
Report is 84 commits behind head on master.

Files with missing lines Patch % Lines
keylime-agent/src/main.rs 0.00% 29 Missing ⚠️
keylime/src/device_id.rs 89.47% 26 Missing ⚠️
keylime/src/crypto/x509.rs 33.33% 6 Missing ⚠️
keylime-agent/src/config.rs 85.71% 2 Missing ⚠️
keylime/src/crypto.rs 77.77% 2 Missing ⚠️
keylime/src/tpm.rs 86.66% 2 Missing ⚠️
Additional details and impacted files
Flag Coverage Δ
e2e-testsuite 60.99% <79.63%> (+3.40%) ⬆️
upstream-unit-tests 60.99% <79.63%> (+9.98%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
keylime-agent/src/error.rs 10.09% <100.00%> (-5.17%) ⬇️
keylime/src/hostname_parser.rs 50.00% <100.00%> (ø)
keylime/src/ip_parser.rs 79.16% <100.00%> (ø)
keylime-agent/src/config.rs 77.43% <85.71%> (-10.07%) ⬇️
keylime/src/crypto.rs 66.87% <77.77%> (+2.13%) ⬆️
keylime/src/tpm.rs 72.68% <86.66%> (+6.49%) ⬆️
keylime/src/crypto/x509.rs 48.45% <33.33%> (ø)
keylime/src/device_id.rs 89.47% <89.47%> (ø)
keylime-agent/src/main.rs 24.27% <0.00%> (-1.75%) ⬇️

... and 6 files with indirect coverage changes

@ansasaki
Copy link
Contributor Author

Hopefully, the fix in the CI image will be sufficient for the current test failure: keylime/keylime#1699

Instead of invoking docker ourselves, set the github job to run in the
CI container directly.

This also adds a workaround for:
actions/runner#2033

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
@ansasaki
Copy link
Contributor Author

The xxd tool was missing in the CI image and was added via keylime/keylime#1701

@ansasaki ansasaki marked this pull request as ready for review December 10, 2024 16:04
When IAK/IDevID are enabled, but the paths to the certificates are
explicitly configured as the empty string, continue normally and
register without IAK and IDevID certificates.

This is to make it possible to use IAK and IDevID without the
certificates, in case the user does the public key matching check
separately.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Copy link
Contributor

@Isaac-Matthews Isaac-Matthews left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, looks good.

Copy link
Contributor

@sergio-correia sergio-correia left a comment

Choose a reason for hiding this comment

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

LGTM

@ansasaki ansasaki merged commit 223b9ee into keylime:master Dec 12, 2024
17 checks passed
@ansasaki ansasaki deleted the modular_idevid branch December 12, 2024 11:38
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.

7 participants