Skip to content

feat: implement #307 excessive contract size detection and #310 hardc…#425

Merged
mijinummi merged 1 commit into
MDTechLabs:mainfrom
Cybermaxi7:feat/issue-307-310-detect-contract-size-and-hardcoded-addresses
May 31, 2026
Merged

feat: implement #307 excessive contract size detection and #310 hardc…#425
mijinummi merged 1 commit into
MDTechLabs:mainfrom
Cybermaxi7:feat/issue-307-310-detect-contract-size-and-hardcoded-addresses

Conversation

@Cybermaxi7
Copy link
Copy Markdown
Contributor

…oded address detection

Issue #307 - Detect Excessive Contract Size

  • Add packages/rules/src/optimization/deployment/excessive_contract_size.rs
    • ExcessiveContractSizeRule implements the Rule trait
    • Estimates bytecode size via AST token count heuristic (2 bytes/token)
    • Warns at 75% of EVM EIP-170 limit (24,576 bytes) with ViolationSeverity::Warning
    • Flags at 100% with ViolationSeverity::Critical
    • Exposes estimate_bytecode_size() helper for dashboards/callers
    • Full unit test coverage: small contract, size growth, threshold ordering, critical violation on oversized contract
  • Add packages/rules/src/optimization/deployment/mod.rs (module + re-exports)
  • Update packages/rules/src/optimization/mod.rs to declare and re-export the new deployment sub-module

Issue #310 - Detect Hardcoded Addresses

  • Add packages/rules/src/security/configuration/hardcoded_addresses.rs
    • HardcodedAddressesRule implements the Rule trait
    • Detects 20-byte Ethereum-style addresses (0x + 40 hex chars) via regex
    • Negative lookahead prevents false-positive matches on longer hashes
    • Deduplicates repeated occurrences of the same address across items
    • Suggests moving addresses to constructor args or config registry
    • Full unit test coverage: const, let binding, function body, short hex, long hash, deduplication, multiple distinct addresses, severity check
  • Add packages/rules/src/security/configuration/mod.rs
  • Add packages/rules/src/security/mod.rs (new top-level security module)
  • Update packages/rules/src/lib.rs to declare pub mod security and re-export ExcessiveContractSizeRule and HardcodedAddressesRule

Closes #307
Closes #310

…DTechLabs#310 hardcoded address detection

Issue MDTechLabs#307 - Detect Excessive Contract Size
- Add packages/rules/src/optimization/deployment/excessive_contract_size.rs
  - ExcessiveContractSizeRule implements the Rule trait
  - Estimates bytecode size via AST token count heuristic (2 bytes/token)
  - Warns at 75% of EVM EIP-170 limit (24,576 bytes) with ViolationSeverity::Warning
  - Flags at 100% with ViolationSeverity::Critical
  - Exposes estimate_bytecode_size() helper for dashboards/callers
  - Full unit test coverage: small contract, size growth, threshold ordering,
    critical violation on oversized contract
- Add packages/rules/src/optimization/deployment/mod.rs (module + re-exports)
- Update packages/rules/src/optimization/mod.rs to declare and re-export the
  new deployment sub-module

Issue MDTechLabs#310 - Detect Hardcoded Addresses
- Add packages/rules/src/security/configuration/hardcoded_addresses.rs
  - HardcodedAddressesRule implements the Rule trait
  - Detects 20-byte Ethereum-style addresses (0x + 40 hex chars) via regex
  - Negative lookahead prevents false-positive matches on longer hashes
  - Deduplicates repeated occurrences of the same address across items
  - Suggests moving addresses to constructor args or config registry
  - Full unit test coverage: const, let binding, function body, short hex,
    long hash, deduplication, multiple distinct addresses, severity check
- Add packages/rules/src/security/configuration/mod.rs
- Add packages/rules/src/security/mod.rs (new top-level security module)
- Update packages/rules/src/lib.rs to declare pub mod security and
  re-export ExcessiveContractSizeRule and HardcodedAddressesRule

Closes MDTechLabs#307
Closes MDTechLabs#310
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 31, 2026

@Cybermaxi7 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

@mijinummi mijinummi merged commit 111d5be into MDTechLabs:main May 31, 2026
1 of 6 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

Development

Successfully merging this pull request may close these issues.

Detect Hardcoded Addresses Detect Excessive Contract Size

2 participants