-
Notifications
You must be signed in to change notification settings - Fork 190
(docs): guard unsafe int/uint conversions flagged by gosec #2679
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
Conversation
Signed-off-by: Sachin Sampras M <[email protected]>
Signed-off-by: Sachin Sampras M <[email protected]>
Signed-off-by: Sachin Sampras M <[email protected]>
Signed-off-by: Sachin Sampras M <[email protected]>
ab54b84 to
dedebbd
Compare
haydentherapper
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is necessary. 2^63 is a massive number and realistically there will be no logs with that many entries.
@haydentherapper Thanks for the feedback, totally fair point, and I agree that reaching 2^63 entries is practically impossible. The intent of this change wasn’t to handle a realistic overflow scenario, but to make the code explicitly safe and pass gosec’s G115 check (which flags unchecked uint64 → int64 conversions and vice versa). Adding the bounds check prevents a potential overflow and helps our security linting CI pass cleanly without having to suppress the warning. I’m happy to drop or adjust the change if you prefer to handle this via a lint exclusion instead, just wanted to ensure we stay compliant with the static analysis rules. |
|
Since we've moved development to sigstore/rekor-tiles, we're trying to minimize unnecessary changes to sigstore/rekor. Could you instead add |
Perfect, I will do the same. Thanks |
Signed-off-by: Sachin Sampras M <[email protected]>
Signed-off-by: Sachin Sampras M <[email protected]>
|
@haydentherapper Necessary |
haydentherapper
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
pkg/verify/verify.go
Outdated
|
|
||
| // ProveConsistency verifies consistency between an initial, trusted STH | ||
| // and a second new STH. Callers MUST verify signature on the STHs'. | ||
| // nolint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you comment the specific lines rather than the function so the func still linted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done @haydentherapper
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2679 +/- ##
===========================================
- Coverage 66.46% 26.15% -40.31%
===========================================
Files 92 191 +99
Lines 9258 20126 +10868
===========================================
- Hits 6153 5264 -889
- Misses 2359 14033 +11674
- Partials 746 829 +83
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Sachin Sampras M <[email protected]>
haydentherapper
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
Summary
This PR fixes several gosec G115 findings across Rekor’s verification and Trillian client code. The core issue was unsafe, direct conversions between uint64 & int64 and vice versa on values coming from checkpoints or log roots.
Even though these values are expected to be small in practice, gosec flags them because of a possibility of converting a large uint64 to int64 can overflow and produce incorrect or negative values.
To make these conversions safe and reusable, a small utility was introduced to perform bounds-checked conversions, and the affected call sites were updated to use it. Additional tests were added to cover the new failure paths.
Issues raised:
Below are the HIGH Severity issues flagged by gosec
Summary of Changes Made
pkg/util/safe_convertors.gopkg/api/api.gopkg/api/entries.gopkg/api/tlog.gopkg/sharding/ranges.gopkg/trillianclient/trillian_client.gopkg/verify/verify.goWhy
codes.OutOfRangeat relevant areas.Release Note
NONE
Documentation
NONE