Skip to content
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

Add end-to-end tests for reusable monitoring workflow #472

Merged
merged 2 commits into from
Oct 10, 2024

Conversation

linus-sun
Copy link
Collaborator

@linus-sun linus-sun commented Oct 4, 2024

Summary

This test adds an end-to-end test checking the functionality of rekor-monitor's reusable monitoring workflow. It spins up a local instance of Rekor, adds 3 log entries, and then verifies that rekor-monitor is able to successfully verify the consistency proof of the tree hash and finds the given monitored identities and writes it to disk. This test is currently skipped by the rekor-monitor PR CI, and is runnable locally from the e2e_test.sh shell script. Future PRs will, in the process of overall refactoring the monitoring workflow into separate components, add this test to the PR CI as well as relocate it from the cmd/verifier pkg into the corresponding package as its components after the refactor. For now, this PR exists to add an e2e test that is able to verify the consistent functionality of rekor-monitor as future improvements are made in refactoring the monitoring workflow.

Additionally, this test updates the name of the monitoring workflow to prepare it for future exports/refactors, and removes the stable parameter from GetLogInfo so that rekor-monitor fetches the up-to-date tree head and checkpoints when it fetches log info using its rekor client instance.

Release Note

NONE

Documentation

Future PRs will update documentation as the monitoring workflow is refactored- for now, this PR does not require documentation updates.

Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 72.94%. Comparing base (d271ec7) to head (31560d7).
Report is 122 commits behind head on main.

Files with missing lines Patch % Lines
cmd/verifier/main.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #472      +/-   ##
==========================================
+ Coverage   64.02%   72.94%   +8.91%     
==========================================
  Files           4       13       +9     
  Lines         303      765     +462     
==========================================
+ Hits          194      558     +364     
- Misses         78      154      +76     
- Partials       31       53      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@linus-sun linus-sun changed the title test e2e functionality of rekor-monitor Add end-to-end tests for reusable monitoring workflow Oct 7, 2024
Signed-off-by: linus-sun <linussun@google.com>
@linus-sun linus-sun force-pushed the linussun/e2e-test branch 2 times, most recently from d820b24 to 411275c Compare October 7, 2024 20:52
@linus-sun linus-sun marked this pull request as ready for review October 7, 2024 22:00
cmd/verifier/e2e_test.go Outdated Show resolved Hide resolved
cmd/verifier/e2e_test.go Outdated Show resolved Hide resolved
cmd/verifier/e2e_test.sh Outdated Show resolved Hide resolved
pkg/rekor/client.go Show resolved Hide resolved
@linus-sun linus-sun force-pushed the linussun/e2e-test branch 2 times, most recently from ebe4ea1 to 8237e89 Compare October 8, 2024 16:07
Copy link
Contributor

@haydentherapper haydentherapper left a comment

Choose a reason for hiding this comment

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

Great work on this!

pkg/rekor/client.go Show resolved Hide resolved
cmd/verifier/e2e_test.go Outdated Show resolved Hide resolved
cmd/verifier/e2e_test.go Outdated Show resolved Hide resolved
cmd/verifier/e2e_test.go Show resolved Hide resolved
if !strings.Contains(tempOutputIdentitiesString, subject) {
t.Errorf("expected to find %s, did not", subject)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for thoroughness, should we check issuer as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

MatchedIndices will only add the matching identity it's monitoring to its output (see here, where it is only appending the subject)- then, WriteIdentity only writes the subject, so the issuer won't be present here. If we would prefer to include the entire identity, I'm happy to add that functionality into MatchedIndices

Copy link
Contributor

Choose a reason for hiding this comment

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

For identities in certificates, the issuer should be included -

Issuer: iss,

The Subjects field is somewhat confusingly named - this includes references to identifiers found in everything but certificates, like how PGP keys have emails.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I think this would be a good thing to test for as well - record a key and check for its fingerprint, check only a subject, check a subject+issuer, and check for an OID match.

Signed-off-by: linus-sun <linussun@google.com>
Copy link
Contributor

@haydentherapper haydentherapper left a comment

Choose a reason for hiding this comment

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

Great work on this!

@haydentherapper haydentherapper merged commit 7222625 into sigstore:main Oct 10, 2024
7 checks passed
@haydentherapper
Copy link
Contributor

One other comment, we will also need to hook this up in the GitHub action that runs tests.

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.

3 participants