Skip to content

chore: add slither config#12

Open
igorroncevic wants to merge 4 commits intomainfrom
pr-04-slither
Open

chore: add slither config#12
igorroncevic wants to merge 4 commits intomainfrom
pr-04-slither

Conversation

@igorroncevic
Copy link
Copy Markdown
Contributor

@igorroncevic igorroncevic commented May 6, 2026

Description

Add a minimal Slither config that uses the local Python dependency.

Context

Slither runs against src by default. The solc-version detector is disabled because the template intentionally keeps broad ^0.8 pragmas for easier integration.

Out of Scope

This PR does not add Justfile commands, CI, or hooks.

Testing Instructions

  • Merge chore: add local dependencies #11 first.
  • Run python -m venv dev/.venv.
  • Run dev/.venv/bin/pip install -r dev/requirements.txt.
  • Run dev/.venv/bin/slither src --config-file slither.config.json.

@igorroncevic igorroncevic marked this pull request as ready for review May 6, 2026 15:26
@igorroncevic igorroncevic requested a review from a team as a code owner May 6, 2026 15:26
This was referenced May 6, 2026
Copy link
Copy Markdown
Contributor

@fedgiac fedgiac left a comment

Choose a reason for hiding this comment

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

Looks good! (Waiting for other PRs to be merged before approving.)
In my experience, Slither is very noisy, so I think we'll eventually end up turning off a lot of the checks. But for now it's fine to start with the defaults and then make tweaks once we learn what we need.

Comment thread slither.config.json Outdated
@igorroncevic igorroncevic requested a review from fedgiac May 8, 2026 11:47
@igorroncevic
Copy link
Copy Markdown
Contributor Author

Slither actually reports "^0.8" as "too complex" of a version, so we might need to turn off that rule.

https://github.com/cowprotocol/contracts-template/actions/runs/25554538329/job/75010171728?pr=15#step:5:18

@igorroncevic igorroncevic requested review from anxolin and kaze-cow May 8, 2026 14:11
@fedgiac
Copy link
Copy Markdown
Contributor

fedgiac commented May 8, 2026

(Code is good, just waiting for merging the previous PR.)

Slither actually reports "^0.8" as "too complex" of a version, so we might need to turn off that rule.

While ^0.8.0 is fine. 🤷
I don't mind using ^0.8.0, even if it's a bit silly.

A rule we most likely want to disable is solc-version since it requires the pragma itself to be at least that of a Solidity version with no known vulnerabilities.

Comment thread README.md Outdated

```shell
npm install --prefix dev
python -m venv dev/.venv
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider using uv, i think nowadays is better and more predictable and simple to use.

Comment thread .gitignore
.env

# Local development dependencies
dev/node_modules/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR also has the wrong base branch. This is annoying because every PR we open shows the same changes over and over

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Everything's merging into main, I didn't stack PRs.

Comment thread slither.config.json
@@ -0,0 +1,4 @@
{
"detectors_to_exclude": "solc-version",
"filter_paths": "(lib/|test/|script/)"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will filter out things like src/lib/Foo.sol

Suggested change
"filter_paths": "(lib/|test/|script/)"
"filter_paths": "^(lib|test|script)/"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's necessary. We don't want to check those, as lib will contain dependencies we won't change or format.

Comment thread slither.config.json
@@ -0,0 +1,4 @@
{
"detectors_to_exclude": "solc-version",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fairenough about disabling this, but this also adds the risk of the foundry version being in a vulnerable solidity and no-one noticing

Maybe we could have a check-solc recipe in the Justfile in a follow up PR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe there's better way, but this could work

  # Check that foundry.toml's pinned solc has no known medium/high-severity bugs
  check-solc:
      #!/usr/bin/env bash
      set -euo pipefail
      SOLC=$(awk -F'"' '/^solc *=/ {print $2; exit}' foundry.toml)
      [ -n "$SOLC" ] || { echo "could not read 'solc' from foundry.toml"; exit 1; }
      BUGS=$(curl -sfL https://raw.githubusercontent.com/ethereum/solidity/develop/docs/bugs.json)
      HITS=$(jq -r --arg v "$SOLC" '
        def vparts: split(".") | map(tonumber);
        .[]
        | select(.severity == "high" or .severity == "medium")
        | (.introduced // "0.0.0") as $i
        echo "solc $SOLC matches known bugs:"
        echo "$HITS"
        exit 1
      fi
      echo "solc $SOLC: no known medium/high-severity bugs"


Copy link
Copy Markdown
Contributor Author

@igorroncevic igorroncevic May 11, 2026

Choose a reason for hiding this comment

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

I just don't see an issue there.

The thing with excluding solc-version detector is reducing noise when slither complains about ^0.8 pragma we want to use. That pragma is already old and possibly vulnerable. Contracts that get deployed with that pragma will always stay there and exploitable if we've made them so.

Also all Solidity versions have some known issues, that's why they're soon moving to 1.x versioning.

I don't think this will help.

## Summary

Stack on top of #12. Replaces the `python -m venv` + `pip install -r
dev/requirements.txt` flow with a uv-managed project so slither installs
reproducibly and works on Python versions where `ensurepip` is broken
(e.g. the Homebrew Python 3.14 build).

- `dev/pyproject.toml` declares `slither-analyzer==0.11.5` as the only
dependency (`package = false`, no build).
- `dev/uv.lock` pins the full transitive tree.
- `dev/requirements.txt` is removed — superseded by the lockfile.
- README's local-tooling section collapses to one command: `uv sync
--project dev`.

## Why uv-native instead of `uv pip install -r requirements.txt`

- `requirements.txt` only pinned the top-level dependencies,
while`uv.lock` locks the full graph so every contributor.
- `uv` is faster
- `uv` is more modern and cross platform


https://docs.astral.sh/uv/guides/migration/pip-to-project/#project-environments



## Test plan

```shell
uv sync --project dev
dev/.venv/bin/slither --version 
dev/.venv/bin/slither src --config-file slither.config.json
```

Co-authored-by: Anxo <2352112+anxolin@users.noreply.github.com>
@igorroncevic igorroncevic changed the base branch from main to pr-07-hooks May 11, 2026 08:02
@igorroncevic igorroncevic changed the base branch from pr-07-hooks to main May 11, 2026 08:02
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.

3 participants