feat: add --foundry-deny flag to control forge diagnostic errors#637
Merged
dguido merged 2 commits intocrytic:masterfrom Jan 20, 2026
Merged
feat: add --foundry-deny flag to control forge diagnostic errors#637dguido merged 2 commits intocrytic:masterfrom
dguido merged 2 commits intocrytic:masterfrom
Conversation
elopez
reviewed
Jan 20, 2026
crytic_compile/platform/foundry.py
Outdated
Comment on lines
+69
to
+70
| "--deny", | ||
| deny_level, |
Member
There was a problem hiding this comment.
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"?)
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>
cd3e045 to
9629777
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
--foundry-denyflag 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
--deny neverto forge build command by default--foundry-denyflag to allow users to override if neededThe
--denyflag controls which forge diagnostics are treated as errors:never(default): No diagnostics cause errorswarn: Warnings cause errorsall: All diagnostics cause errorsTesting
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--denyflag to forge build commandcrytic_compile/cryticparser/cryticparser.py: Add--foundry-denyCLI argumentcrytic_compile/cryticparser/defaults.py: Add default value🤖 Generated with Claude Code