Overview
Foundry is the dominant smart contract development framework. Teams using Foundry already have test suites that exercise their contracts. ChainProof can provide significantly more value by correlating its static findings with existing Foundry tests — identifying which findings already have test coverage, which are untested, and even suggesting test scaffolds for unexercised vulnerability patterns.
Proposed Integration
Phase 1: Test Coverage Correlation
- Run
forge coverage --report lcov to generate LCOV coverage data
- Parse the LCOV file to determine which lines are covered
- For each ChainProof finding, check if the flagged line is covered by existing tests
- Add
testCoverage: boolean field to Finding — if true, a test exercises this code path (but may not assert the vulnerability)
Phase 2: Foundry Test Scaffolding
For findings with no test coverage, generate a Foundry test stub:
// Auto-generated by ChainProof — test stub for CP-107 finding at Vault.sol:42
contract VaultReentrancyTest is Test {
Vault vault;
AttackContract attacker;
function setUp() public {
vault = new Vault();
attacker = new AttackContract(address(vault));
}
function test_reentrancy_withdraw_line42() public {
// TODO: Fund vault and attacker, then call attacker.attack()
// ChainProof detected: external call before state update in withdraw()
vm.expectRevert(); // placeholder — fill in actual assertion
attacker.attack();
}
}
Phase 3: Foundry Invariant Test Hints
For CP-101 (overflow) findings, suggest property-based invariant test functions using Foundry's vm.assume and assertLe patterns.
CLI Integration
# Run scan and correlate with Foundry coverage
chainproof scan contracts/ --foundry --coverage-report lcov.info
# Generate test stubs for uncovered findings
chainproof scan contracts/ --generate-tests test/chainproof/
Acceptance Criteria
Overview
Foundry is the dominant smart contract development framework. Teams using Foundry already have test suites that exercise their contracts. ChainProof can provide significantly more value by correlating its static findings with existing Foundry tests — identifying which findings already have test coverage, which are untested, and even suggesting test scaffolds for unexercised vulnerability patterns.
Proposed Integration
Phase 1: Test Coverage Correlation
forge coverage --report lcovto generate LCOV coverage datatestCoverage: booleanfield toFinding— iftrue, a test exercises this code path (but may not assert the vulnerability)Phase 2: Foundry Test Scaffolding
For findings with no test coverage, generate a Foundry test stub:
Phase 3: Foundry Invariant Test Hints
For CP-101 (overflow) findings, suggest property-based invariant test functions using Foundry's
vm.assumeandassertLepatterns.CLI Integration
Acceptance Criteria
packages/core/src/integrations/lcov.tstestCoverage: booleanfield added toFinding--foundryCLI flag that auto-detects and runsforge coverage--generate-tests <dir>CLI flag that writes stubs