feat(core): add event cast narrowing detector - #859
Open
anidroid1184 wants to merge 9 commits into
Open
Conversation
Contributor
|
@anidroid1184 , ci pipeline fails, pull from upstream and resolve pipeline failures |
Author
Contributor
|
Please pull from upstream @anidroid1184 and resolve conflicts, also ensure all ci passes |
Author
|
@Gbangbolaoluwagbemiga sure |
Contributor
|
But this still has conflict and the ci fails, please fix before i merge it @anidroid1184 ...Looking forward to the fix |
Author
|
@Gbangbolaoluwagbemiga sorry for be late. I'm still working on the ci pipeline. But still on my local enviroment. Can I send the new PR tomorrow? |
Contributor
|
Yes please, looking forward to that @anidroid1184....well done |
anidroid1184
marked this pull request as draft
July 27, 2026 03:07
added 2 commits
July 27, 2026 16:10
…or codes, and differential corpus
anidroid1184
marked this pull request as ready for review
July 27, 2026 21:20
Contributor
|
@anidroid1184, ci still fails on this |
Author
|
@Gbangbolaoluwagbemiga I'm sorry, I'll review again today, before end to campaign |
The merge with upstream/main accidentally dropped the module declaration and registry.register call for EventDataCastRule, causing CI to fail on the no_orphan_detector_pages test. Also add the missing golden snapshot test function that had an unreferenced snapshot file.
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.
Summary of the change
Adds a static-analysis detector (
event_data_cast) that flags narrowing integer casts insideenv.events().publish()call payloads. When a wider integer (e.g.i128,i64) is cast to a narrower type (e.g.u32) or changes signedness (i64 as u64) inside event emission, indexers receive truncated data silently.The detector scans function bodies, tracks parameter types through the visitor, and recurses into tuples, method calls, and binary expressions within event payloads to catch lossy casts.
Fixes / Closes
Closes #804
Motivation and context
Event data is consumed off-chain by indexers and monitoring tools. A narrowing cast at the point of emission permanently loses information with no compiler warning — indexers see a truncated value and have no way to recover the original. This detector surfaces those casts during static analysis so developers can emit the full-width value or explicitly document the truncation.
Dependencies
Type of change
How Has This Been Tested?
Unit tests — 6 tests in
event_data_cast.rscovering:i128 as u32)u32 as u64)i64 as u64)Golden snapshot —
instasnapshot viadetector_snapshots.rswith a dedicated fixture exercising 4 violations across 3 functions and 3 safe patterns.Command:
Checklist: