Skip to content

feat: Implement per-line and per-function inline suppression comments #19

Description

@Nanle-code

Overview

Developers sometimes need to suppress a specific ChainProof finding on a known-safe code path without suppressing the entire rule globally. Inline suppression comments (similar to eslint-disable) provide fine-grained control without polluting a baseline file or disabling rules project-wide.

Proposed Syntax

Single-line suppression

(bool ok,) = msg.sender.call{value: amount}(""); // chainproof-disable-next-line CP-107

Block suppression

// chainproof-disable CP-107
function knownSafeWithdraw() external {
    // ... reentrancy guard applied via mutex, not CEI pattern
    (bool ok,) = msg.sender.call{value: amount}("");
}
// chainproof-enable CP-107

Suppress all rules on a line

someRiskyCall(); // chainproof-disable-line

Require a reason (optional enforcement)

// chainproof-disable-next-line CP-107 -- mutex pattern applied, see AuditReport-2025.pdf

Implementation Plan

  1. After parsing, extract all comment nodes from the AST
  2. Build a suppression map: Map<lineNumber, ruleId[]>
  3. After rule execution, filter findings against the suppression map
  4. Suppressed findings are included in JSON output with suppressed: true for auditability
  5. Report how many findings were suppressed in the summary line
  6. Add a --no-inline-suppression flag to disable this feature for strict CI modes

Acceptance Criteria

  • Comment extraction from Solidity AST
  • Suppression map construction for chainproof-disable-next-line, chainproof-disable/enable blocks
  • Findings filtered against suppression map before reporting
  • Suppressed findings appear in JSON output with suppressed: true
  • Summary line shows: "X findings suppressed by inline comments"
  • --no-inline-suppression CLI flag
  • VS Code extension respects suppressions (finding removed from Problems panel)
  • Warning emitted for suppression comments that do not match any finding (unused suppression)

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignenhancementNew feature or request

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions