-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
BLD: add more static analysis #31661
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
Open
tacaswell
wants to merge
17
commits into
matplotlib:main
Choose a base branch
from
tacaswell:bld/static_analysis
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3ed5b7a
STY: add shellcheck
tacaswell d434453
STY: apply ruff to notebooks we have checked in
tacaswell 1634070
MNT: fix warnings identified by clang-tidy
tacaswell 4bae6f7
BLD: add NOLINT directives to _qhull_wrapper
tacaswell 7b4bce4
MNT: ensure that variables are always initialized
tacaswell b9f9ee9
BLD: add tooling to run clang-tidy on c/c++ code
tacaswell c68ee48
MNT: tweak so that clang-tidy runs on objectiveC code as well
tacaswell 31020b8
BLD: try harder to find clang-tidy
tacaswell bfbbd84
BLD: add zizmor to prek config
tacaswell 235c6ee
CI: add cool-down periods on dependabot
tacaswell a728b5d
CI: add zizmor action to keep us in line
tacaswell fcbb6f5
CI: remove redundancy and leaked credentials in workflow
tacaswell f267ca2
MNT: address issues identified by clang-tidy
tacaswell daf53d7
CI: add static validation of svg
tacaswell a3a474a
CI: simplify clang-tidy testing
tacaswell 95b0283
CI: add missing dep
tacaswell 1c966c2
CI: ensure we have llvm on the GHA job
tacaswell 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
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,34 @@ | ||
| --- | ||
| name: zizmor | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, v*.x] | ||
| pull_request: | ||
| branches: [main] | ||
| schedule: | ||
| - cron: '45 19 * * 1' | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| zizmor: | ||
| name: zizmor | ||
| if: github.repository == 'matplotlib/matplotlib' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| security-events: write | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Run zizmor | ||
| uses: zizmorcore/zizmor-action@b1d7e1fb5de872772f31590499237e7cce841e8e # v0.5.3 | ||
| with: | ||
| advanced-security: true | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,19 @@ | ||
| --- | ||
| rules: | ||
| dangerous-triggers: | ||
| ignore: | ||
| # These workflows use pull_request_target solely to obtain write access | ||
| # for API operations (labeling, commenting) on fork PRs. None of them | ||
| # check out or execute any PR-supplied code. | ||
| - autoclose_comment.yml:11 | ||
| - conflictcheck.yml:3 | ||
| - labeler.yml:3 | ||
| - pr_welcome.yml:4 | ||
| cache-poisoning: | ||
| ignore: | ||
| # cygwin.yml is a test-only workflow; no artifacts are published. | ||
| # The three caches (pip, ccache, matplotlib data) are purely for build | ||
| # acceleration and present no poisoning risk for released artifacts. | ||
| - cygwin.yml:144:9 | ||
| - cygwin.yml:151:9 | ||
| - cygwin.yml:158:9 |
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,56 @@ | ||
| /** @type {import('svglint').Config} */ | ||
| const config = { | ||
| rules: { | ||
| // Ensure all SVGs are valid XML. | ||
| valid: true, | ||
|
|
||
| // Block elements that can execute code or embed arbitrary content. | ||
| // <script> can run arbitrary JavaScript; <foreignObject> and <iframe> | ||
| // can embed arbitrary HTML. Unlike event-handler attributes (which | ||
| // are a legitimate tool for matplotlib's interactive SVG examples), | ||
| // there is no use case in this repository for these elements outside | ||
| // of a <script> already paired with its own exemption. | ||
| elm: { | ||
| "script": false, | ||
| "foreignObject": false, | ||
| "iframe": false, | ||
| }, | ||
|
|
||
| custom: [ | ||
| // Block external URL references in href / xlink:href. | ||
| // Internal fragment references (#id), data: URIs, and relative | ||
| // paths are all fine. http/https/ftp and protocol-relative URLs | ||
| // are blocked because they cause the SVG renderer to make an | ||
| // outbound network request, leaking the viewer's IP and UA to an | ||
| // attacker-controlled server. | ||
| (reporter, $, _ast) => { | ||
| reporter.name = "no-external-references"; | ||
| const externalPattern = /^(https?:|ftp:|\/\/)/i; | ||
| $("[href], [xlink\\:href]").each((_i, el) => { | ||
| if (!el.attribs) { return; } | ||
| const href = | ||
| el.attribs["href"] ?? el.attribs["xlink:href"]; | ||
| if (href && externalPattern.test(href)) { | ||
| reporter.error( | ||
| `Found external reference '${href}' on <${el.name}>. ` + | ||
| "External URL references in SVGs cause the renderer " + | ||
| "to make an outbound request, leaking viewer IP/UA." | ||
| ); | ||
| } | ||
| }); | ||
| }, | ||
| ], | ||
| }, | ||
|
|
||
| // These four files are intentional interactive SVG examples that | ||
| // demonstrate matplotlib's SVG interactivity features. They contain | ||
| // embedded ECMAScript by design and are exempted from the <script> rule. | ||
| ignore: [ | ||
| "doc/_static/svg_histogram.svg", | ||
| "doc/_static/svg_tooltip.svg", | ||
| "galleries/examples/user_interfaces/images/svg_histogram.svg", | ||
| "galleries/examples/user_interfaces/images/svg_tooltip.svg", | ||
| ], | ||
| }; | ||
|
|
||
| export default config; |
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,36 @@ | ||
| --- | ||
| # clang-tidy configuration for matplotlib's src/ directory. | ||
| # | ||
| # Philosophy: enable checks that find real bugs (memory safety, undefined | ||
| # behaviour, security) and suppress checks that are high-noise style rules | ||
| # inappropriate for a C/C++ codebase that interfaces heavily with C APIs | ||
| # (CPython, FreeType, libagg) via pybind11. | ||
| # | ||
| # Run with: | ||
| # clang-tidy -p <build_dir> --config-file=src/.clang-tidy <file> | ||
|
|
||
| Checks: > | ||
| bugprone-*, | ||
| clang-analyzer-*, | ||
| objc-*, | ||
| performance-move-const-arg, | ||
| performance-move-constructor-init, | ||
| performance-no-automatic-move, | ||
| portability-*, | ||
| -bugprone-assignment-in-if-condition, | ||
| -bugprone-easily-swappable-parameters, | ||
| -bugprone-implicit-widening-of-multiplication-result, | ||
| -bugprone-macro-parentheses, | ||
| -bugprone-narrowing-conversions, | ||
| -bugprone-reserved-identifier, | ||
| -bugprone-throwing-static-initialization, | ||
| -clang-analyzer-optin.cplusplus.UninitializedObject, | ||
| -clang-analyzer-optin.performance.Padding, | ||
|
|
||
| # Only report findings in matplotlib's own src/ headers, not in pybind11, | ||
| # Python.h, agg, or other vendored includes. | ||
| HeaderFilterRegex: '.*/matplotlib/src/.*' | ||
|
|
||
| WarningsAsErrors: '' | ||
|
|
||
| CheckOptions: [] |
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.
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.
I'm confused why this is needed; https://github.com/astral-sh/ruff-pre-commit has a note on how not to run on notebooks, so I thought it's enabled by default.
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.
Interesting, that may explain why it found no problems out of the gate.