Skip to content

Fix #277, #276, #275: Hardcoded contract addresses, glob validation, and config path fallback - #335

Merged
unrealtim-tech merged 4 commits into
SorobanGuard:mainfrom
Bruno755:fix/issues-277-276-275
Jul 30, 2026
Merged

Fix #277, #276, #275: Hardcoded contract addresses, glob validation, and config path fallback#335
unrealtim-tech merged 4 commits into
SorobanGuard:mainfrom
Bruno755:fix/issues-277-276-275

Conversation

@Bruno755

Copy link
Copy Markdown

Summary

This PR addresses three related issues in the Guard-CLI analyzer and CLI:

  1. hardcoded-address check only detects G-prefixed keys, misses C-prefixed Soroban contract addresses #277: Extend hardcoded-address check to detect C-prefixed Soroban contract addresses
  2. Invalid --include / --exclude glob patterns are silently ignored #276: Report errors for invalid --include/--exclude glob patterns instead of silently ignoring them
  3. ScanConfig.path is parsed from soroban-guard.toml but never applied #275: Implement scan path fallback from soroban-guard.toml config

Changes

Issue #277: C-prefixed Contract Address Detection

  • Modified find_candidate_keys() in hardcoded_address.rs to check for both 'G' (account) and 'C' (contract) prefixes
  • Added unit test for C-prefixed contract address detection
  • Confirmed G.../C... short strings are still properly ignored
  • Updated test fixture to include both G and C prefixed examples
  • Updated docs/checks.md to document both prefix types

Issue #276: Invalid Glob Pattern Validation

  • Added InvalidGlobPattern variant to ScanError enum
  • Updated collect_rust_paths() to validate glob patterns and return error on failure
  • Updated scan_files() to validate glob patterns and return error on failure
  • Added tests to verify invalid exclude and include patterns are properly rejected with clear error messages

Issue #275: Config Path Fallback

  • Made CLI scan path argument optional
  • Implemented precedence logic: CLI arg > config path > error
  • Load config from current directory to check for default scan path
  • Added test to verify config path fallback behavior

Testing

All changes include comprehensive tests:

  • Hardcoded address: test for C-prefixed detection + test for short strings ignored
  • Glob patterns: tests for invalid exclude and include patterns
  • Config path: test verifying config fallback works correctly

Closes #277
Closes #276
Closes #275

Bruno755 and others added 3 commits July 29, 2026 12:52
Extend the hardcoded-address check to also detect C-prefixed 56-character StrKey strings
(Soroban contract addresses) in addition to the existing G-prefixed Ed25519 account keys.
This addresses contract addresses being hardcoded (e.g. token contract addresses) which
are arguably more common in Soroban contracts than hardcoded account keys.

Changes:
- Update find_candidate_keys() to check for both 'G' and 'C' prefixes
- Add unit test for hardcoded C-prefixed contract address (positive case)
- Confirm G.../C... short strings are still ignored (negative case)
- Update hardcoded-address-vulnerable fixture to include C-prefixed example
- Update docs/checks.md to mention both G and C prefixes

Closes SorobanGuard#277

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Instead of silently dropping malformed glob patterns, the analyzer now
returns a clear error message naming the bad pattern and exits with code 2
(consistent with other CLI input-validation failures).

Changes:
- Add InvalidGlobPattern variant to ScanError enum
- Update collect_rust_paths() to report glob parsing errors
- Update scan_files() to report glob parsing errors
- Add tests for invalid exclude and include glob patterns

Closes SorobanGuard#276
Make the CLI scan path argument optional and implement fallback logic:
- CLI positional argument takes precedence if provided
- If not provided, fall back to [scan] path from soroban-guard.toml
- If neither is provided, exit with error

This enables users to set a default scan path in their config file,
making the CLI more convenient for repeated scans of the same target.

Changes:
- Changed Scan command path from required to optional
- Added path resolution logic with proper precedence
- Load config from current directory to check for default path
- Updated documentation to mention config fallback
- Added test to verify config path fallback behavior

Closes SorobanGuard#275
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Bruno755 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@unrealtim-tech
unrealtim-tech merged commit 255c1bd into SorobanGuard:main Jul 30, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants