feat!: release 2.0.0 — new detections, enforced budgets, docs overhaul - #4
Open
joaovitoriasilva wants to merge 16 commits into
Open
feat!: release 2.0.0 — new detections, enforced budgets, docs overhaul#4joaovitoriasilva wants to merge 16 commits into
joaovitoriasilva wants to merge 16 commits into
Conversation
…nce image dimension validation, and add tests for resource limits - Introduced ResourceMonitor to enforce time and memory limits during gzip and zip content inspections. - Updated GzipContentInspector and ZipContentInspector to accept an optional ResourceMonitor parameter for real-time checks. - Enhanced validation logic to raise ResourceLimitError when resource limits are exceeded during inspection. - Added tests to ensure that resource limits are enforced correctly in both gzip and zip inspectors. - Implemented image dimension validation to reject images with excessive pixel counts or zero dimensions. - Added tests for image dimension validation, including checks for PNG and JPEG formats. - Updated existing tests to incorporate new validation logic and ensure compatibility with resource monitoring.
- Implement timeout for Gzip inflation to prevent decompression bombs. - Introduce safe_label utility to escape untrusted text for logging. - Improve ZipContentInspector to use safe_label for filenames in threat messages. - Add XML root element validation to ensure compliance with expected formats. - Enforce limits on XML element counts to prevent excessive resource usage. - Update tests to cover new features and ensure robustness against edge cases. - Validate configuration limits for gzip timeout and XML element cap.
…tion error handling
…nagement, and improved security measures
…ion checklist updates
…nd clarify Python version support
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
…ntrusted values are escaped once
…s timeout handling
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.
What does this PR do?
Prepares the 2.0.0 release. Two strands of work:
Validation and security (breaking). Adds image decompression bomb detection (PNG
IHDR/ JPEG SOF headers bounded by the newmax_image_pixels), root-element enforcement for activity XML so arbitrary XML can no longer hide behind a.gpx/.tcxname, amax_xml_elementscap with incremental parsing, agzip_analysis_timeout, and rejection of ZIP entries carrying executable, script, or system-file extensions. The wall-clock budget is now enforced during validation rather than only on completion, so a runaway upload is aborted while it runs.max_validation_memory_mbbecomes telemetry unlessenforce_memory_limit=True, because it samples process-wide peak RSS and misattributes concurrent work. Fixes log injection (CWE-117) by routing every untrusted filename throughsafe_label(). Removes public symbols that no code path could produce. Lowers the minimum supported Python from 3.13 to 3.11.Documentation. Rewrites
SECURITY.mdaround supported versions / scope / reporting / expectations. Bringsmkdocs.ymlin line with the siblingjasilconfig —site_url,site_description, theme features, admonitions, TOC permalinks, and thesearchplugin, which was silently disabled by listing onlymkdocstrings. Turnsdocs/index.mdfrom a near-verbatim copy ofREADME.mdinto a real landing page, moving the configuration, exception-handling, and release-verification material into the integration checklist. Converts every Markdown heading to sentence case to matchjasil. FixesCONTRIBUTING.md, which was titled "Contributing to Endurain" — the wrong project.Full detail, including upgrade notes, is in
CHANGELOG.md.Related issue
None. This is the release branch, prepared directly by the maintainer. Happy to open a tracking issue if you would rather have one on record.
Type of change
Checklist
uv.lockis 545.Notes for the reviewer
Read the upgrade notes at the top of
CHANGELOG.mdfirst. They call out the one change that makes safeuploads accept something it previously rejected — themax_validation_memory_mbdefault — separately from the four that make it reject more.Breaking surface, in rough order of blast radius:
max_validation_memory_mbno longer fails a validation by default. Anyone relying on it must setenforce_memory_limit=True, and only in a process validating one upload at a time. Config validation warns when the budget is customised but enforcement is off.ResourceLimitError.AttributeError: thevalidate()alias on every validator, eight unreachableErrorCodemembers, three unusedZipThreatCategorymembers.Worth a closer look:
safeuploads/utils.pyandsafeuploads/file_validator.pycarry most of the new logic —safe_label(), image dimension parsing, andResourceMonitorthreading.tests/corpus/test_attack_corpus.pyasserts that every threat the threat model claims to stop raises the documented error code. Samples are constructed at test time rather than checked in, so the repo carries nothing an antivirus would quarantine.#anchorstill resolves; the only anchor that moves is theCONTRIBUTING.mdH1.Verified locally:
ruff check,ruff format --check,mypyclean; 749 tests pass at 98.86% coverage;mkdocs build --strictexits 0 with no warnings.