Skip to content

feat: add --foundry-deny flag to control forge diagnostic errors#637

Merged
dguido merged 2 commits intocrytic:masterfrom
dguido:feat/foundry-deny-flag
Jan 20, 2026
Merged

feat: add --foundry-deny flag to control forge diagnostic errors#637
dguido merged 2 commits intocrytic:masterfrom
dguido:feat/foundry-deny-flag

Conversation

@dguido
Copy link
Copy Markdown
Member

@dguido dguido commented Jan 19, 2026

Summary

Add --foundry-deny flag to control forge's diagnostic error level.

Problem

Forge's linter returns exit code 1 on warnings, causing crytic-compile to interpret this as a compilation failure even when Solidity compilation succeeded.

This breaks analysis of many Foundry projects that have linter warnings, including large projects like Optimism contracts-bedrock which has 113+ linter warnings.

Solution

  • Add --deny never to forge build command by default
  • Add --foundry-deny flag to allow users to override if needed

The --deny flag controls which forge diagnostics are treated as errors:

  • never (default): No diagnostics cause errors
  • warn: Warnings cause errors
  • all: All diagnostics cause errors

Testing

Tested against Optimism contracts-bedrock which previously failed due to forge linter warnings. After this change, compilation succeeds and slither can analyze the contracts.

Changes

  • crytic_compile/platform/foundry.py: Add --deny flag to forge build command
  • crytic_compile/cryticparser/cryticparser.py: Add --foundry-deny CLI argument
  • crytic_compile/cryticparser/defaults.py: Add default value

🤖 Generated with Claude Code

Comment on lines +69 to +70
"--deny",
deny_level,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see, this is only supported since Foundry 1.4. We need to ensure we don't break support for older versions by using an unsupported CLI flag. I think a good way to go would be to make the current behavior the default (eg foundry_deny could have a None default), and when foundry_deny is None we don't add any extra arguments here. Alternatively, we could keep never as the default if you think that is more user friendly, but offer a way to disable the addition of --deny ... altogether (maybe a magic value such as "disable"?)

dguido and others added 2 commits January 20, 2026 10:41
Forge's linter returns exit code 1 on warnings, causing crytic-compile to
interpret this as a compilation failure even when Solidity compilation
succeeded. This breaks analysis of many Foundry projects that have linter
warnings.

- Add `--deny never` to forge build command by default
- Add `--foundry-deny` flag to allow users to override if needed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The --deny flag is only available in Foundry 1.4+. This change:
- Adds version detection for forge
- Only adds --deny when forge >= 1.4.0
- Changes default from "never" to None (auto-detect)
- Updates help text to reflect auto-detection behavior

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dguido dguido force-pushed the feat/foundry-deny-flag branch from cd3e045 to 9629777 Compare January 20, 2026 15:42
@dguido dguido merged commit 079330f into crytic:master Jan 20, 2026
60 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.

2 participants