checks: `missing-input-length-bound` accepts any `.len()` call as a bound (#702 regression)

Open
#1,069 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
tooling

Research direction

Start in crates/checks/src/missing_input_length_bound.rs, around line 94, where has_length_check matches any param.len() or param.is_empty() call in the function body. The fix is to count only length calls that sit in an upper-bound comparison inside a diverging if, assert!, require! or panic_with_error!. Done when unit tests show that an unused len() and an is_empty()-only body still raise the finding, while assert!(data.len() <= MAX) suppresses it.

Written by the indexing model from the issue text.

Description

bug checks-crate

Problem

has_length_check returns true if <param>.len() or <param>.is_empty() appears anywhere in the body, whether or not it is compared against a bound. Examples: let n = data.len(); used only as a loop bound, log!(.., data.len()), or an is_empty() check (which bounds nothing from above). Each of these suppresses the finding. #702 described exactly this and was closed, but the visitor is unchanged.

Evidence (main @ 418f39e)

Expected behaviour

Only count param.len() used in a comparison with an upper bound (<, <=, >, >= against a literal / const / storage-read config value) inside an if that diverges, assert!, require!, or panic_with_error!. is_empty() alone does not count.

Acceptance criteria

  • Predicate tightened.
  • Unit tests: unused len() and is_empty()-only do not suppress; assert!(data.len() <= MAX) does.
Dominant language
Rust
Stars
2
Forks
120
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SorobanGuard/Guard-CLI

All issues in SorobanGuard/Guard-CLI

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.