| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
WalkthroughAdds Hypothesis-based fuzz tests for manifest handling, introduces a SAFE_STR regex to forbid NULL/control characters in manifest string fields, adds Hypothesis as a dev dependency, updates documentation and changelog, and adds .hypothesis to .gitignore. Changes
Sequence DiagramsequenceDiagram
actor Hypothesis
participant Strategy as Manifest Strategy
participant Validator as StrictYAML Validator
participant Manifest as Manifest Model
participant CLI as dfetch Commands
Hypothesis->>Strategy: generate manifest-like data
Strategy-->>Hypothesis: return candidate data
Hypothesis->>Validator: serialize/validate against schema
alt Valid
Validator-->>Hypothesis: validation passed
Hypothesis->>Manifest: instantiate Manifest (may raise KeyError)
alt Instantiation success
Manifest-->>Hypothesis: instance created
Hypothesis->>CLI: run check/update (in temp dir)
CLI-->>Hypothesis: success or DfetchFatalException (caught)
else KeyError
Hypothesis-->>Hypothesis: tolerate/ignore KeyError
end
else Invalid
Validator-->>Hypothesis: fail -> trigger shrinking
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labelsdevelopment, enhancement 🚥 Pre-merge checks | ✅ 3 ✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review details Configuration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📥 CommitsReviewing files that changed from the base of the PR and between 3915afe and 6ccc317. 📒 Files selected for processing (2)
dfetch/manifest/schema.py (2)tests/test_fuzzing.py (10) Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. ❤️ ShareComment @coderabbitai help to get the list of available commands and usage tips. |
Sorry, something went wrong.
fix typo
ignore list should never be empty
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agentsIn @dfetch/manifest/schema.py: - Around line 7-8: The SAFE_STR regex currently only blocks NUL but the comment claims it blocks all control chars; update the SAFE_STR pattern so it also rejects ASCII control ranges 0x00–0x1F and 0x7F–0x9F (i.e., disallow bytes with hex values 00..1F and 7F..9F) and adjust the comment to match, or if the intended behavior is to only block NUL, change the comment to state that only NUL bytes are disallowed. In @tests/test_fuzzing.py: - Line 79: The generated ignore_list is always present because it's defined as st.lists(..., min_size=1); make it optional by allowing None like the other optional fields: replace the current ignore_list assignment with st.one_of(st.none(), st.lists(SAFE_TEXT, min_size=1, max_size=5)) so the dict comprehension can filter out None and omit the ignore key; apply the same change for the other occurrence of ignore_list referenced in the comment.
tests/test_fuzzing.py (1)📜 Review details146-152: Consider broadening exception handling for robustness.
The test only catches KeyError, but other exceptions like ValueError, TypeError, or strictyaml validation errors may be raised during Manifest construction. If these are expected failures for invalid fuzzed input, they should also be suppressed.
Suggested improvement@given(manifest_strategy) def test_manifest_can_be_created(data): """Validate by attempting to construct a Manifest.""" - try: - Manifest(data) - except KeyError: - pass + with suppress(KeyError, ValueError, TypeError): + Manifest(data)
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 CommitsReviewing files that changed from the base of the PR and between 8ac79aa and 3915afe.
📒 Files selected for processing (6)dfetch/__main__.py (1)⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)dfetch/manifest/manifest.py (3)
- DfetchFatalException (25-26)
dfetch/util/util.py (1)
- Manifest (103-356)
- remotes (281-283)
- projects (260-262)
dfetch/manifest/remote.py (1)
- in_directory (66-75)
dfetch/manifest/project.py (1)
- url (78-80)
- vcs (432-434)
.gitignore (1)CHANGELOG.rst (1)17-17: LGTM!
The .hypothesis directory is correctly ignored. This is a standard practice for projects using Hypothesis, as it stores test data and examples that should not be committed to version control.
dfetch/manifest/schema.py (2)7-8: LGTM!
The changelog entries clearly document the new fuzzing capability and the stricter manifest validation. The issue references (#819, #114) provide good traceability.
doc/manifest.rst (1)10-33: Systematic replacement approach is good.
The replacement of Str() with SAFE_STR across all string fields in both REMOTE_SCHEMA and PROJECT_SCHEMA is thorough and consistent. This provides centralized validation once the regex pattern is corrected.
3-3: LGTM!
The import changes correctly reflect the shift from Str() to Regex-based validation.
pyproject.toml (1)20-22: Documentation is correct, but implementation is incomplete.
The documentation correctly states that strings should not contain NULL or control characters. However, the current SAFE_STR regex in dfetch/manifest/schema.py only blocks NULL bytes, not control characters. The implementation must be updated to match this documentation (see comment on schema.py).
tests/test_fuzzing.py (6)89-89: No action required—Hypothesis 6.150.0 is the current stable release and has no known security vulnerabilities.
Version 6.150.0 is the latest release on PyPI (released January 6, 2026) with no public security advisories or high-severity CVEs. The pinned version is current and secure.
1-18: LGTM!
The imports are well-organized and appropriate for the fuzzing test suite.
20-39: LGTM!
The Hypothesis profile configuration is well-structured for different environments. The deadline=None setting is appropriate given the filesystem and subprocess operations in these tests.
117-128: LGTM!
The manifest strategy structure aligns well with the expected manifest schema format.
131-136: LGTM!
Clean helper function that leverages StrictYAML's validation.
155-174: LGTM!
Both test functions follow a consistent and appropriate pattern for fuzzing CLI commands with generated manifests. The use of suppress(DfetchFatalException) correctly handles expected failures from invalid manifest configurations.
177-194: LGTM!
The main block provides useful utilities for manual testing and debugging. The round-trip demonstration validates the strategy produces valid data.
One minor note: manifest_strategy.example() (line 181) bypasses Hypothesis's shrinking and database, but this is acceptable here for demonstration purposes.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary by CodeRabbit
Bug Fixes
Documentation
Tests
Chores
Changelog
✏️ Tip: You can customize this high-level summary in your review settings.