-
Notifications
You must be signed in to change notification settings - Fork 1
sdk%lint: introduce CodeQL and semgrep linters, add shim, derivation, disambiguation rules, resolve violations, add common helper for lint infra #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
86a5512
sdk%ci(fix): avoid concurrency fighting between pushes
kwvg 44b73dc
sdk%lint(codeql): introduce linter, add prelude shim rule
kwvg 444d375
sdk%lint(semgrep): introduce linter, add prelude shim rules
kwvg 3b08b46
sdk%refac: resolve lint violations
kwvg 635c0b7
sdk%lint(codeql): prohibit deriving Debug on secret-holding types
kwvg 6ab28a3
sdk%lint(codeql): add import ordering rules
kwvg db58667
sdk%refac: resolve lint violations
kwvg cd62520
sdk%lint(codeql): add derive rules with exclusions for fp, stateful, err
kwvg 92758c1
sdk%refac: resolve lint violations
kwvg e4806db
sdk%lint(codeql): add serde enforcement rules
kwvg 933bf3b
sdk%lint(semgrep): add serde path disambiguation rule
kwvg 90ab0e3
sdk%refac: resolve lint violations
kwvg b671f96
sdk%refac(lint): consolidate return codes and dir walker to common mod
kwvg 84f51cb
sdk%refac(lint): add binary search helper, propagate
kwvg 15c8fcc
sdk%refac(lint): simplify flow, drop `None` retvals favoring exceptions
kwvg ef17644
sdk%lint(codeql): spin-off MSRV into separate build, absorb linting
kwvg 7c25840
sdk%fix(ci): drop unneeded runner details from source-based cache keys
kwvg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| name: MSRV (1.85) | ||
|
|
||
| on: | ||
| push: | ||
| branches: [develop] | ||
| pull_request: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: Lint | ||
| runs-on: ubuntu-24.04 | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Install Rust toolchain | ||
| uses: dtolnay/rust-toolchain@1.85.0 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v5 | ||
| with: | ||
| node-version: 24 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version-file: pyproject.toml | ||
|
|
||
| - name: Install Python dependencies | ||
| run: pip install ".[dev]" | ||
|
|
||
| - name: Install CodeQL | ||
| id: setup-codeql | ||
| uses: github/codeql-action/setup-codeql@v4.36.2 | ||
| with: | ||
| tools: linked | ||
|
|
||
| - name: Setup CodeQL | ||
| run: echo "$(dirname '${{ steps.setup-codeql.outputs.codeql-path }}')" >> "$GITHUB_PATH" | ||
|
|
||
| - name: Restore cargo registry | ||
| uses: actions/cache/restore@v5 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| key: cargo-deps-${{ hashFiles('Cargo.lock') }} | ||
| restore-keys: cargo-deps- | ||
|
|
||
| - name: Restore CodeQL caches | ||
| id: codeql-cache | ||
| uses: actions/cache/restore@v5 | ||
| with: | ||
| path: | | ||
| contrib/codeql/.cache | ||
| ~/.codeql | ||
| key: codeql-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pkgs/**/*.rs', 'contrib/codeql/**/*.ql', 'contrib/codeql/**/*.qll', 'Cargo.lock') }} | ||
|
|
||
| - name: Run linters | ||
| run: python3 contrib/lint/all_lint.py | ||
|
|
||
| - name: Save CodeQL caches | ||
| if: success() && steps.codeql-cache.outputs.cache-hit != 'true' | ||
| uses: actions/cache/save@v5 | ||
| with: | ||
| path: | | ||
| contrib/codeql/.cache | ||
| ~/.codeql | ||
| key: codeql-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pkgs/**/*.rs', 'contrib/codeql/**/*.ql', 'contrib/codeql/**/*.qll', 'Cargo.lock') }} | ||
|
|
||
| - name: Check PR commit messages | ||
| if: github.event_name == 'pull_request' | ||
| run: > | ||
| python3 contrib/lint/lint_unconv.py | ||
| -r "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" | ||
|
|
||
| build: | ||
| name: Build and test | ||
| runs-on: ubuntu-24.04 | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Install Rust toolchain | ||
| uses: dtolnay/rust-toolchain@1.85.0 | ||
|
|
||
| - name: Restore cargo registry | ||
| uses: actions/cache/restore@v5 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| key: cargo-deps-${{ hashFiles('Cargo.lock') }} | ||
| restore-keys: cargo-deps- | ||
|
|
||
| - name: Build workspace | ||
| run: cargo build --workspace --features full,_internal | ||
|
|
||
| - name: Test workspace | ||
| run: cargo test --workspace --features full,_internal |
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
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
This file was deleted.
Oops, something went wrong.
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # CodeQL related | ||
| .codeql | ||
| .cache | ||
| *.testproj/ | ||
| *.actual | ||
|
|
||
| # Generated source-line data | ||
| lib/source_lines.qll | ||
|
|
||
| # Test files / folders | ||
| test.ql | ||
| test-*.ql | ||
| **/testing/** | ||
| **/*.testproj/* |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /** | ||
| * Copyright (c) 2026-present, The Dash Core developers | ||
| * SPDX-License-Identifier: MIT | ||
| * See the accompanying file LICENSE or https://opensource.org/license/MIT | ||
| * | ||
| * @name Attribute and derivation rules | ||
| * @description Enforcement of required traits per feasible type. | ||
| * @kind problem | ||
| * @problem.severity warning | ||
| * @id base-sdk/attrib-rules | ||
| * @tags style | ||
| * @precision high | ||
| */ | ||
|
|
||
| import lib.filters | ||
| import lib.fmt | ||
| import lib.policy | ||
| import lib.traits | ||
| import rust | ||
|
|
||
| /** Gets a comma-separated list of missing required traits for `t`. */ | ||
| string missingTraits(TypeItem t) { | ||
| isCheckableType(t) and | ||
| result = | ||
| concat(string trait | | ||
| trait = requiredTrait() and | ||
| not implementsTrait(t, trait) and | ||
| not isSuppressed(t, trait) | ||
| | | ||
| trait, ", " order by trait | ||
| ) and | ||
| result != "" | ||
| } | ||
|
|
||
| from TypeItem t, string message | ||
| where | ||
| isCheckableType(t) and | ||
| ( | ||
| exists(string missing | | ||
| missing = missingTraits(t) and | ||
| message = fmt("missing required derivations: {0}", missing) | ||
| ) | ||
| or | ||
| // Serde: every non-exempt type must derive Serialize + Deserialize. | ||
| not isSerdeExempt(t) and | ||
| exists(string missing | | ||
| missing = | ||
| concat(string trait | | ||
| trait = requiredSerdeTrait() and | ||
| not implementsSerdeTrait(t, trait) | ||
| | | ||
| trait, ", " order by trait | ||
| ) and | ||
| missing != "" and | ||
| message = fmt("missing serde derivations: {0}", missing) | ||
| ) | ||
| ) | ||
| select t, message |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --- | ||
| lockVersion: 1.0.0 | ||
| dependencies: | ||
| codeql/concepts: | ||
| version: 0.0.25 | ||
| codeql/controlflow: | ||
| version: 2.0.35 | ||
| codeql/dataflow: | ||
| version: 2.1.7 | ||
| codeql/mad: | ||
| version: 1.0.51 | ||
| codeql/regex: | ||
| version: 1.0.51 | ||
| codeql/rust-all: | ||
| version: 0.2.15 | ||
| codeql/ssa: | ||
| version: 2.0.27 | ||
| codeql/threat-models: | ||
| version: 1.0.51 | ||
| codeql/tutorial: | ||
| version: 1.0.51 | ||
| codeql/typeinference: | ||
| version: 0.0.32 | ||
| codeql/typetracking: | ||
| version: 2.0.35 | ||
| codeql/util: | ||
| version: 2.0.38 | ||
| compiled: false |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: dashpay/base-sdk
Length of output: 886
Fix mismatch between
CLAUDE.md“eager traits” guidance and the repo’sDefaultderivesThe current guideline snippet shows eagerly deriving
Clone,Debug,PartialEq,Eq,Hash(noDefault), but there are many existingDefaultderives acrosspkgs/:pkgs/types/src/uint.rs:34pkgs/primitives/src/validation.rs:59pkgs/primitives/src/script.rs:19pkgs/primitives/src/block_header.rs:17pkgs/script/src/key_id.rs:14pkgs/p2p_core/src/primitives/service_flags.rs:15pkgs/num/src/compact.rs:16,20pkgs/num/src/arith256.rs:22Align the intended policy: either remove
Defaultderives where appropriate in this PR/follow-up, or updateCLAUDE.mdto reflect whetherDefaultis meant to be eagerly derived (and list any explicit exceptions).🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't prohibit deriving
Default, we just don't enforce it in linting.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kwvg, understood —Defaultderivation is permitted but not mandated by the linter, so the CLAUDE.md guidance correctly reflects only what is enforced. I've noted this for future reviews.✏️ Learnings added