Skip to content

policy: Implement Clone() for the PolicyCalculator#434

Open
Foxboron wants to merge 1 commit into
google:mainfrom
Foxboron:morten/clone-calc
Open

policy: Implement Clone() for the PolicyCalculator#434
Foxboron wants to merge 1 commit into
google:mainfrom
Foxboron:morten/clone-calc

Conversation

@Foxboron

Copy link
Copy Markdown
Contributor

When implementing nested policies, like systemd-pcrlock, it's practical to clone the current PolicyCalculator to transfer the state of the previous policy without mutation.

@Foxboron Foxboron requested review from a team, alexmwu and jkl73 as code owners May 20, 2026 15:02

@josephlr josephlr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like this change, thank you.

Could we add a small test to tpm2/test/policy_test.go to check that Clone works as expected? I can be a very simple test-case.

Comment thread tpm2/policy.go Outdated
@Foxboron

Foxboron commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Could we add a small test to tpm2/test/policy_test.go to check that Clone works as expected? I can be a very simple test-case.

Of course. I didn't spend time on a test because the change was simple and I was not completely sure if this was a good idea to begin with :)

When implementing nested policies, like systemd-pcrlock, it's practical
to clone the current PolicyCalculator to transfer the state of the
previous policy without mutation.

Signed-off-by: Morten Linderud <morten@linderud.pw>
@Foxboron Foxboron force-pushed the morten/clone-calc branch from 2d09d02 to 3883d14 Compare June 3, 2026 22:17
@Foxboron Foxboron requested a review from josephlr June 4, 2026 09:24
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