-
Notifications
You must be signed in to change notification settings - Fork 15
Fix warnings #1002
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
base: main
Are you sure you want to change the base?
Fix warnings #1002
Conversation
Our prost generated code was generating unused warnings because we're
not using all of the generated structs. This change adds an attribute:
`prost_build.type_attribute(".", "#[allow(dead_code)]");`
to each struct in order to suppress those warnings.
This will fix the following warning: ``` warning: the following packages contain code that will be rejected by a future version of Rust: num-bigint-dig v0.8.4 ``` We have `num-bigint-dig` as an indirect dependency from the `rsa` crate, upgrading the `rsa` crate to the latest version gets rid of this warning.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: omertuc The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
WalkthroughThis PR updates multiple Rust dependencies and refactors vendored code. Key changes include: upgrading the Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@vendor/num-bigint/src/bigint/division.rs`:
- Around line 466-469: The checked_div_rem_euclid implementation lacks a
zero-divisor check and will panic when v is zero; update checked_div_rem_euclid
to mirror checked_div_euclid/checked_rem_euclid by returning None if
v.is_zero(), otherwise return Some(self.div_rem_euclid(v)); refer to the
checked_div_rem_euclid and div_rem_euclid functions and reuse the same zero
check pattern as in checked_div_euclid/checked_rem_euclid.
In `@vendor/rsa/src/algorithms/rsa.rs`:
- Around line 286-287: Fix the typo in the documentation comment that reads
"totiem" — replace it with "totient" in the comment starting "FIPS 186-4
**requires** the private exponent to be less than λ(n), which would make Euler's
totiem unreliable." in vendor/rsa/src/algorithms/rsa.rs so the sentence reads
"...which would make Euler's totient unreliable."
🧹 Nitpick comments (4)
src/cluster_crypto/json_crawl.rs (1)
292-299: Consider using.ok()instead of suppressing the lint.The
#[allow(clippy::manual_ok_err)]suppression works, but the clippy suggestion would actually simplify this code while preserving the comment context.♻️ Optional refactor
- #[allow(clippy::manual_ok_err)] - if let Ok(decoded) = String::from_utf8(decoded) { - Some(decoded) - } else { - // We don't search for crypto objects inside binaries - None - } + // We don't search for crypto objects inside binaries, so non-UTF8 returns None + String::from_utf8(decoded).ok()vendor/num-bigint/src/bigrand.rs (1)
52-87: Approve with note on unsafe code complexity.The
cfg_digit!macro dispatches between two implementations based on the target's native digit size. The 64-bit path usesunsafepointer casting fromVec<u64>to a&mut [u32]slice forgen_bits, which is sound because:
- Memory alignment is satisfied (u64 alignment ≥ u32 alignment)
- The
debug_assert!(native_len * 2 >= len)ensures the buffer is large enough- Big-endian targets correctly swap the u32 halves within each u64 (line 83)
The implementation is correct but subtle. Consider adding a brief inline comment explaining why the endian swap is needed (i.e.,
gen_bitsfills u32 slots in logical order, but on big-endian the memory layout of u64 requires swapping the halves).src/protobuf_gen/k8s.io.api.core.v1.rs (1)
7-7510: Consider a module-leveldead_codeallow to reduce regen diff churn (if possible).If your codegen setup allows it, a single
#![allow(dead_code)]at the module/file level (or in themod protobuf_gen { ... }wrapper) can avoid touching every generated type and keep future regen diffs smaller. If not feasible with your currentprost_buildpipeline, this per-type approach is still fine.vendor/num-bigint/src/biguint/iter.rs (1)
321-340: Testtest_iter_u32_digits_bedoesn't actually test big-endian iteration.This test is identical to
test_iter_u32_digits(lines 279-298) and only usesnext(), notnext_back(). Compare withtest_iter_u64_digits_be(lines 342-361) which correctly testsnext_back()for reverse iteration.Since this is vendored code from an upstream library, this is likely an upstream issue. If you're maintaining this vendored copy, consider fixing the test to actually verify big-endian (reverse) iteration using
next_back().
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
Cargo.lockis excluded by!**/*.lockvendor/num-bigint-dig/Cargo.lockis excluded by!**/*.lockvendor/rsa/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (131)
Cargo.tomlbuild.rssrc/cluster_crypto.rssrc/cluster_crypto/crypto_objects.rssrc/cluster_crypto/json_crawl.rssrc/ocp_postprocess/ip_rename/etcd_rename.rssrc/protobuf_gen/github.com.openshift.api.oauth.v1.rssrc/protobuf_gen/github.com.openshift.api.route.v1.rssrc/protobuf_gen/k8s.io.api.admissionregistration.v1.rssrc/protobuf_gen/k8s.io.api.apps.v1.rssrc/protobuf_gen/k8s.io.api.batch.v1.rssrc/protobuf_gen/k8s.io.api.core.v1.rssrc/protobuf_gen/k8s.io.apimachinery.pkg.api.resource.rssrc/protobuf_gen/k8s.io.apimachinery.pkg.apis.meta.v1.rssrc/protobuf_gen/k8s.io.apimachinery.pkg.runtime.rssrc/protobuf_gen/k8s.io.apimachinery.pkg.util.intstr.rsvendor/byteorder/.cargo-checksum.jsonvendor/byteorder/.cargo_vcs_info.jsonvendor/byteorder/.github/workflows/ci.ymlvendor/byteorder/CHANGELOG.mdvendor/byteorder/COPYINGvendor/byteorder/Cargo.tomlvendor/byteorder/Cargo.toml.origvendor/byteorder/LICENSE-MITvendor/byteorder/README.mdvendor/byteorder/UNLICENSEvendor/byteorder/benches/bench.rsvendor/byteorder/rustfmt.tomlvendor/byteorder/src/io.rsvendor/byteorder/src/lib.rsvendor/num-bigint-dig/.cargo-checksum.jsonvendor/num-bigint-dig/.cargo_vcs_info.jsonvendor/num-bigint-dig/Cargo.tomlvendor/num-bigint-dig/Cargo.toml.origvendor/num-bigint-dig/src/algorithms/mod_inverse.rsvendor/num-bigint-dig/src/bigrand.rsvendor/num-bigint-dig/src/biguint.rsvendor/num-bigint-dig/src/prime.rsvendor/num-bigint-dig/tests/torture.rsvendor/num-bigint/.cargo-checksum.jsonvendor/num-bigint/.cargo_vcs_info.jsonvendor/num-bigint/Cargo.tomlvendor/num-bigint/Cargo.toml.origvendor/num-bigint/README.mdvendor/num-bigint/RELEASES.mdvendor/num-bigint/benches/bigint.rsvendor/num-bigint/build.rsvendor/num-bigint/src/bigint.rsvendor/num-bigint/src/bigint/addition.rsvendor/num-bigint/src/bigint/arbitrary.rsvendor/num-bigint/src/bigint/bits.rsvendor/num-bigint/src/bigint/convert.rsvendor/num-bigint/src/bigint/division.rsvendor/num-bigint/src/bigint/power.rsvendor/num-bigint/src/bigint/serde.rsvendor/num-bigint/src/bigint/subtraction.rsvendor/num-bigint/src/bigrand.rsvendor/num-bigint/src/biguint.rsvendor/num-bigint/src/biguint/addition.rsvendor/num-bigint/src/biguint/arbitrary.rsvendor/num-bigint/src/biguint/convert.rsvendor/num-bigint/src/biguint/division.rsvendor/num-bigint/src/biguint/iter.rsvendor/num-bigint/src/biguint/monty.rsvendor/num-bigint/src/biguint/multiplication.rsvendor/num-bigint/src/biguint/power.rsvendor/num-bigint/src/biguint/serde.rsvendor/num-bigint/src/biguint/shift.rsvendor/num-bigint/src/biguint/subtraction.rsvendor/num-bigint/src/lib.rsvendor/num-bigint/src/macros.rsvendor/num-bigint/tests/bigint.rsvendor/num-bigint/tests/bigint_bitwise.rsvendor/num-bigint/tests/biguint.rsvendor/num-bigint/tests/consts/mod.rsvendor/num-bigint/tests/roots.rsvendor/num-integer/.cargo-checksum.jsonvendor/num-integer/.cargo_vcs_info.jsonvendor/num-integer/Cargo.tomlvendor/num-integer/Cargo.toml.origvendor/num-integer/README.mdvendor/num-integer/RELEASES.mdvendor/num-integer/benches/average.rsvendor/num-integer/benches/gcd.rsvendor/num-integer/benches/roots.rsvendor/num-integer/build.rsvendor/num-integer/src/average.rsvendor/num-integer/src/lib.rsvendor/num-integer/src/roots.rsvendor/num-integer/tests/average.rsvendor/num-integer/tests/roots.rsvendor/num-traits/.cargo-checksum.jsonvendor/num-traits/.cargo_vcs_info.jsonvendor/num-traits/Cargo.tomlvendor/num-traits/Cargo.toml.origvendor/num-traits/README.mdvendor/num-traits/RELEASES.mdvendor/num-traits/build.rsvendor/num-traits/src/cast.rsvendor/num-traits/src/float.rsvendor/num-traits/src/identities.rsvendor/num-traits/src/int.rsvendor/num-traits/src/lib.rsvendor/num-traits/src/ops/bytes.rsvendor/num-traits/src/ops/euclid.rsvendor/num-traits/src/real.rsvendor/rsa/.cargo-checksum.jsonvendor/rsa/.cargo_vcs_info.jsonvendor/rsa/CHANGELOG.mdvendor/rsa/Cargo.tomlvendor/rsa/Cargo.toml.origvendor/rsa/README.mdvendor/rsa/src/algorithms/generate.rsvendor/rsa/src/algorithms/pkcs1v15.rsvendor/rsa/src/algorithms/rsa.rsvendor/rsa/src/errors.rsvendor/rsa/src/key.rsvendor/rsa/src/lib.rsvendor/rsa/src/oaep.rsvendor/rsa/src/pkcs1v15.rsvendor/rsa/src/pkcs1v15/signature.rsvendor/rsa/src/pss.rsvendor/rsa/src/pss/signature.rsvendor/rsa/tests/examples/pkcs8/rsa2048-sp800-56b-priv.dervendor/spki/.cargo-checksum.jsonvendor/spki/.cargo_vcs_info.jsonvendor/spki/CHANGELOG.mdvendor/spki/Cargo.tomlvendor/spki/Cargo.toml.origvendor/spki/src/spki.rsvendor/spki/tests/spki.rs
💤 Files with no reviewable changes (23)
- vendor/num-bigint/tests/biguint.rs
- vendor/byteorder/CHANGELOG.md
- vendor/num-bigint/build.rs
- vendor/byteorder/COPYING
- vendor/byteorder/README.md
- vendor/byteorder/.cargo-checksum.json
- vendor/byteorder/Cargo.toml.orig
- vendor/num-traits/src/cast.rs
- vendor/num-traits/src/int.rs
- vendor/num-bigint/tests/roots.rs
- vendor/byteorder/.github/workflows/ci.yml
- vendor/num-bigint/tests/bigint.rs
- vendor/num-integer/benches/gcd.rs
- vendor/byteorder/benches/bench.rs
- vendor/num-integer/build.rs
- vendor/byteorder/src/io.rs
- vendor/byteorder/UNLICENSE
- vendor/byteorder/LICENSE-MIT
- vendor/byteorder/rustfmt.toml
- vendor/num-bigint/tests/bigint_bitwise.rs
- vendor/num-traits/src/ops/bytes.rs
- vendor/byteorder/.cargo_vcs_info.json
- vendor/byteorder/Cargo.toml
🧰 Additional context used
🧬 Code graph analysis (12)
vendor/num-bigint/benches/bigint.rs (1)
vendor/num-integer/benches/roots.rs (1)
bench(16-46)
vendor/rsa/src/algorithms/generate.rs (1)
vendor/rsa/src/algorithms/rsa.rs (2)
compute_modulus(249-251)compute_private_exponent_euler_totient(256-278)
vendor/num-bigint/src/biguint/serde.rs (1)
vendor/num-bigint/src/biguint.rs (1)
biguint_from_vec(526-528)
vendor/num-bigint/src/biguint/arbitrary.rs (1)
vendor/num-bigint/src/biguint.rs (1)
biguint_from_vec(526-528)
vendor/num-bigint/src/bigrand.rs (1)
vendor/num-bigint/src/biguint.rs (1)
biguint_from_vec(526-528)
vendor/num-bigint/src/biguint/addition.rs (2)
vendor/num-bigint/src/lib.rs (1)
from_doublebigdigit(259-261)vendor/num-bigint-dig/src/biguint.rs (1)
u32_from_u128(2530-2537)
vendor/rsa/src/key.rs (1)
vendor/rsa/src/algorithms/rsa.rs (4)
compute_modulus(249-251)compute_private_exponent_carmicheal(289-304)compute_private_exponent_euler_totient(256-278)recover_primes(202-246)
vendor/num-bigint/src/biguint/convert.rs (2)
vendor/num-bigint/src/biguint/division.rs (1)
div_rem_digit(85-107)vendor/num-bigint/src/biguint/multiplication.rs (1)
mac_with_carry(15-26)
vendor/num-bigint/src/biguint/multiplication.rs (2)
vendor/num-bigint/src/lib.rs (1)
from_doublebigdigit(259-261)vendor/num-bigint-dig/src/biguint.rs (1)
u32_from_u128(2530-2537)
vendor/num-bigint/src/biguint/subtraction.rs (2)
vendor/num-bigint/src/lib.rs (1)
from_doublebigdigit(259-261)vendor/num-bigint-dig/src/biguint.rs (1)
u32_from_u128(2530-2537)
vendor/num-bigint/src/biguint.rs (1)
vendor/num-bigint-dig/src/biguint.rs (2)
u32_to_u128(2522-2524)u32_from_u128(2530-2537)
vendor/num-bigint/src/biguint/division.rs (2)
vendor/num-bigint/src/lib.rs (1)
to_doublebigdigit(265-267)vendor/num-bigint-dig/src/biguint.rs (1)
u32_to_u128(2522-2524)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Red Hat Konflux / recert-4-22-on-pull-request
- GitHub Check: build
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
|
|
||
| fn checked_div_rem_euclid(&self, v: &Self) -> Option<(Self, Self)> { | ||
| Some(self.div_rem_euclid(v)) | ||
| } |
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.
Missing zero-divisor check in checked_div_rem_euclid.
This implementation should return None when v is zero, consistent with checked_div_euclid and checked_rem_euclid above (lines 452-456, 460-464). Currently, it will panic on division by zero instead of returning None, defeating the purpose of the "checked" variant.
🐛 Proposed fix
fn checked_div_rem_euclid(&self, v: &Self) -> Option<(Self, Self)> {
+ if v.is_zero() {
+ return None;
+ }
Some(self.div_rem_euclid(v))
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| fn checked_div_rem_euclid(&self, v: &Self) -> Option<(Self, Self)> { | |
| Some(self.div_rem_euclid(v)) | |
| } | |
| fn checked_div_rem_euclid(&self, v: &Self) -> Option<(Self, Self)> { | |
| if v.is_zero() { | |
| return None; | |
| } | |
| Some(self.div_rem_euclid(v)) | |
| } |
🤖 Prompt for AI Agents
In `@vendor/num-bigint/src/bigint/division.rs` around lines 466 - 469, The
checked_div_rem_euclid implementation lacks a zero-divisor check and will panic
when v is zero; update checked_div_rem_euclid to mirror
checked_div_euclid/checked_rem_euclid by returning None if v.is_zero(),
otherwise return Some(self.div_rem_euclid(v)); refer to the
checked_div_rem_euclid and div_rem_euclid functions and reuse the same zero
check pattern as in checked_div_euclid/checked_rem_euclid.
| /// FIPS 186-4 **requires** the private exponent to be less than λ(n), which would | ||
| /// make Euler's totiem unreliable. |
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.
Typo in documentation comment.
"totiem" should be "totient".
📝 Proposed fix
-/// FIPS 186-4 **requires** the private exponent to be less than λ(n), which would
-/// make Euler's totiem unreliable.
+/// FIPS 186-4 **requires** the private exponent to be less than λ(n), which would
+/// make Euler's totient unreliable.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /// FIPS 186-4 **requires** the private exponent to be less than λ(n), which would | |
| /// make Euler's totiem unreliable. | |
| /// FIPS 186-4 **requires** the private exponent to be less than λ(n), which would | |
| /// make Euler's totient unreliable. |
🤖 Prompt for AI Agents
In `@vendor/rsa/src/algorithms/rsa.rs` around lines 286 - 287, Fix the typo in the
documentation comment that reads "totiem" — replace it with "totient" in the
comment starting "FIPS 186-4 **requires** the private exponent to be less than
λ(n), which would make Euler's totiem unreliable." in
vendor/rsa/src/algorithms/rsa.rs so the sentence reads "...which would make
Euler's totient unreliable."
|
@omertuc: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
See commit messages
Summary by CodeRabbit
New Features
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.