Warn during build if overflow-checks are off in Cargo.toml.#2360
Merged
Warn during build if overflow-checks are off in Cargo.toml.#2360
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a build-time warning when overflow-checks is not enabled in the Cargo.toml profile, helping developers avoid silent integer overflow vulnerabilities in smart contracts. The warning is displayed during stellar contract build and provides clear guidance on how to fix the configuration.
Changes:
- Added overflow-checks validation logic that inspects Cargo.toml and follows profile inheritance chains
- Integrated warning display into the build process (only when actually building, not with --print-commands-only)
- Added comprehensive test coverage for various scenarios including missing checks, enabled checks, profile inheritance, and edge cases
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cmd/soroban-cli/src/commands/contract/build.rs | Implements overflow-checks validation with run_checks() and check_overflow_checks() functions that parse Cargo.toml, follow profile inheritance, and emit warnings when overflow-checks is not enabled |
| cmd/crates/soroban-test/tests/it/build.rs | Adds 5 comprehensive test cases covering warning presence/absence scenarios, profile inheritance behavior, and --print-commands-only flag behavior |
mootz12
approved these changes
Jan 21, 2026
Contributor
mootz12
left a comment
There was a problem hiding this comment.
LG2M - manually tested with workspaces and direct cargo packages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a warning during
stellar contract buildwhenoverflow-checksis not enabled in the Cargo.toml profile.Why
Close #2281
Known limitations
N/A