Repository navigation
feat!: release 2.0.0 — new detections, enforced budgets, docs overhaul #4
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
Closed
Closed
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
bb13367
chore: update safeuploads version to 1.1.1 in uv.lock
joaovitoriasilva e98faec
feat: implement resource monitoring for gzip and zip inspectors, enha…
joaovitoriasilva b19ee7a
feat: Enhance security and performance of compression and XML validators
joaovitoriasilva ae2ae1d
refactor: code structure for improved readability and maintainability
joaovitoriasilva 8383419
feat: enhance audit logging with client IP tracking and refine valida…
joaovitoriasilva ed25b34
refactor: code structure for improved readability and maintainability
joaovitoriasilva e6be664
feat: release version 2.0.0 with breaking changes, enhanced memory ma…
joaovitoriasilva 338ef0a
refactor: remove unused ignore rule for abstract methods in linting c…
joaovitoriasilva 61756be
feat: enhance content analysis and validation error handling in file …
joaovitoriasilva becc8bf
feat: enhance documentation with security policy details and integrat…
joaovitoriasilva 4adf515
feat: standardize heading capitalization in documentation files
joaovitoriasilva 8c657ad
feat: update changelog to remove outdated security workflow details a…
joaovitoriasilva e0467ac
feat: enhance filename sanitization and validation error handling
joaovitoriasilva 4ed094c
feat: enhance ZIP entry rejection logic with configurable threat cate…
joaovitoriasilva a74bd9b
feat: enhance error handling and logging for file uploads, ensuring u…
joaovitoriasilva 2a222ac
feat: update Python version in documentation and enhance gzip analysi…
joaovitoriasilva 98b5003
fix: enhance content analysis to prevent false positives and improve …
joaovitoriasilva c3a1320
feat: enhance filename sanitization to prevent traversal tokens and i…
joaovitoriasilva 02418fd
feat: introduce correlation_scope context manager for managing correl…
joaovitoriasilva 4036c52
feat: remove unused 'strict' parameter from validation methods in Fil…
joaovitoriasilva 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| name: CodeQL | ||
|
|
||
| # `pip-audit` covers known vulnerabilities in our dependencies; ruff's | ||
| # flake8-bandit rules cover single-line patterns in our own code. Neither does | ||
| # interprocedural taint tracking, which is what actually catches an untrusted | ||
| # filename reaching a filesystem or subprocess sink. That is CodeQL's job. | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| schedule: | ||
| # Weekly, so a newly-published query pack is run against unchanged code. | ||
| - cron: '15 4 * * 1' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| analyze: | ||
| name: Analyze Python | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| # Required to upload the SARIF result to the Security tab. | ||
| security-events: write | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| fetch-depth: 1 | ||
| persist-credentials: false | ||
|
|
||
| # `build-mode: none` is the correct setting for an interpreted language: | ||
| # CodeQL reads the sources directly instead of watching a compiler. | ||
| - name: Initialize CodeQL | ||
| uses: github/codeql-action/init@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4.37.7 | ||
| with: | ||
| languages: python | ||
| build-mode: none | ||
| # `security-extended` adds lower-severity and precision queries on top | ||
| # of the default pack. Appropriate for a security library, where a | ||
| # false positive costs far less than a missed sink. | ||
| queries: security-extended | ||
|
|
||
| - name: Perform CodeQL analysis | ||
| uses: github/codeql-action/analyze@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4.37.7 | ||
| with: | ||
| category: /language:python |
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,85 @@ | ||
| name: Mutation testing | ||
|
|
||
| # 98%+ line coverage says every line runs; it does not say anything asserted on | ||
| # the result. Mutation testing perturbs the source and reports which changes the | ||
| # suite fails to notice. Scheduled and non-blocking: a surviving mutant is a | ||
| # lead to investigate, not a build break. | ||
|
|
||
| on: | ||
| schedule: | ||
| # Every Sunday at 05:00 UTC, after the fuzz run. | ||
| - cron: '0 5 * * 0' | ||
| workflow_dispatch: | ||
| inputs: | ||
| filter: | ||
| description: Mutant name glob, e.g. safeuploads.utils.* | ||
| required: false | ||
| default: '' | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| mutate: | ||
| name: Mutate and score | ||
| runs-on: ubuntu-latest | ||
| # The full run is a few thousand mutants; cap it so a pathological | ||
| # mutant that hangs cannot hold a runner all day. | ||
| timeout-minutes: 60 | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| fetch-depth: 1 | ||
| persist-credentials: false | ||
|
|
||
| - name: Install system dependencies | ||
| run: sudo apt-get update && sudo apt-get install -y libmagic1 | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 | ||
| with: | ||
| version-file: pyproject.toml | ||
|
|
||
| - name: Install dependencies | ||
| run: uv sync --frozen --dev --extra fastapi --group mutation | ||
|
|
||
| # A failing suite makes every mutant "killed" and the score meaningless, | ||
| # so establish that the baseline is green before mutating anything. | ||
| - name: Verify the baseline suite passes | ||
| run: uv run pytest -q --no-cov -m "not performance and not fuzz" | ||
|
|
||
| # The filter goes through the environment, never through `${{ }}` | ||
| # interpolation into the script body, which would let anyone able to | ||
| # dispatch the workflow inject shell. | ||
| - name: Run mutation testing | ||
| continue-on-error: true | ||
| env: | ||
| MUTMUT_FILTER: ${{ inputs.filter }} | ||
| run: | | ||
| set -euo pipefail | ||
| if [ -n "${MUTMUT_FILTER}" ]; then | ||
| uv run mutmut run --max-children 4 "${MUTMUT_FILTER}" | ||
| else | ||
| uv run mutmut run --max-children 4 | ||
| fi | ||
|
|
||
| - name: Summarise surviving mutants | ||
| if: always() | ||
| run: | | ||
| set -euo pipefail | ||
| { | ||
| echo '## Surviving mutants' | ||
| echo | ||
| echo 'Each line is a source change the test suite did not notice.' | ||
| echo | ||
| echo '```' | ||
| uv run mutmut results || true | ||
| echo '```' | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
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,65 @@ | ||
| name: OpenSSF Scorecard | ||
|
|
||
| # Scores this repository's *supply-chain posture* rather than its code: are | ||
| # actions pinned to SHAs, are workflow permissions least-privilege, is branch | ||
| # protection on, are releases signed. Those are the properties a consumer of a | ||
| # security library cannot verify from the source alone. | ||
|
|
||
| on: | ||
| branch_protection_rule: | ||
| push: | ||
| branches: | ||
| - main | ||
| schedule: | ||
| # Weekly, offset from the CodeQL run so the two do not contend. | ||
| - cron: '45 4 * * 1' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| analysis: | ||
| name: Scorecard analysis | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| # Upload the SARIF result to the Security tab. | ||
| security-events: write | ||
| # Publish the result to the OpenSSF REST API so the badge resolves. | ||
| id-token: write | ||
| contents: read | ||
| actions: read | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| fetch-depth: 1 | ||
| persist-credentials: false | ||
|
|
||
| - name: Run analysis | ||
| uses: ossf/scorecard-action@2d1146689b8cda280b9bc96326124645441f03bc # v2.4.4 | ||
| with: | ||
| results_file: results.sarif | ||
| results_format: sarif | ||
| # Publishing makes the score readable by anyone evaluating the | ||
| # package, which is the point of running it. Requires a public repo. | ||
| publish_results: true | ||
|
|
||
| # Retained separately from the Security tab so a score regression can be | ||
| # diffed against a specific run. | ||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||
| with: | ||
| name: scorecard-results | ||
| path: results.sarif | ||
| retention-days: 7 | ||
|
|
||
| - name: Upload to code-scanning | ||
| uses: github/codeql-action/upload-sarif@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4.37.7 | ||
| with: | ||
| sarif_file: results.sarif |
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
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.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Report mutation-run failures without failing on surviving mutants.
If
mutmut runexits because of an invalid filter or a tool error,continue-on-error: truelets this job pass. The summary step also suppresses errors, so the scheduled mutation check can appear successful without mutation results. Keep surviving mutants non-blocking, but make a failed mutation command visible as a job failure. (docs.github.com)🤖 Prompt for AI Agents