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

[refactor] - return privatekey verification errors #3164

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ahrav
Copy link
Collaborator

@ahrav ahrav commented Aug 2, 2024

Description:

This PR logs any errors encountered during private key verification, ensuring the errors are both available in the result and recorded in the engine.

Screenshot 2024-08-02 at 2 44 52 PM

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@ahrav ahrav changed the base branch from main to bug-new-ctx-per-request August 2, 2024 21:46
Base automatically changed from bug-new-ctx-per-request to main August 2, 2024 21:46
@ahrav ahrav marked this pull request as ready for review August 2, 2024 21:46
@ahrav ahrav requested review from a team as code owners August 2, 2024 21:46
@ahrav ahrav changed the title [refactor] - return errors [refactor] - return privatekey verification errors Aug 2, 2024
@ahrav ahrav marked this pull request as draft August 2, 2024 22:04
@rgmz
Copy link
Contributor

rgmz commented Aug 3, 2024

Why both verificationErrors and verificationErrs? Doesn't the existing code do this, minus returning it with FromData?

@ahrav
Copy link
Collaborator Author

ahrav commented Aug 3, 2024

Why both verificationErrors and verificationErrs? Doesn't the existing code do this, minus returning it with FromData?

I didn't want to change the existing behavior where the error appears in the result. However, we still need the error returned from FromData. Otherwise, the only place to identify these errors would be in the results. This issue should be visible during the scan as early as possible. Additionally, if errors occur only on non-verified results and the scan is run with --only-verified, these errors will be completely missed.

@rgmz
Copy link
Contributor

rgmz commented Aug 4, 2024

I see. It seems like a big code smell to have two different ways of aggregating errors, and the intention behind the code isn't clear.

It would be clearer to use the same method throughout. e.g., having allErrs outside the loop and resultErrs inside the verify block.

			for err := range errChan {
				allErrs = errors.Join(allErrs, err)
				resultErrs = errors.Join(resultErrs, err)
			}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants