Repository navigation
fix: throw FormatException on malformed commit/tree output and add fuzz workflow - #110
Merged
Merged
Conversation
…zz workflow - Throw `FormatException` in `TreeEntry.fromLsTree` when a line does not match `_lsTreeRegEx` instead of `StateError` from `.single`. - Validate required single headers (`tree`, `author`, `committer`, and `commit` in rev-list mode) and trailing newline in `Commit._parse` via `scanner.error` (`FormatException`) instead of throwing null-check `TypeError`, `StateError`, or `AssertionError`. - Pass `--no-sign` in `test/tag_test.dart` lightweight tag test so global `tag.gpgSign=true` does not force an annotated tag editor prompt. - Add unit test regressions in `test/parse_test.dart`, fuzz harness in `test/fuzz/git_parser_fuzz.dart`, and `.github/workflows/fuzz.yaml`.
📊 Cognitive Complexity AnalysisNet Delta: +8 | Added: 1 | Increased: 2 | Improved: 0 | Removed: 0 | Violations: 0
|
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.
Rationale
Coverage-guided fuzzing of
package:gituncovered 4 cases whereTreeEntry.fromLsTree,Commit.parse, andCommit.parseRawRevListthrewStateError, null-checkTypeError,ArgumentError, orAssertionErrorinstead ofFormatExceptionwhen given malformedgit ls-treeorgit rev-list --headeroutput.Summary of Changes
_lsTreeRegEx.allMatches(value).singleinTreeEntry.fromLsTree(lib/src/tree_entry.dart) with_lsTreeRegEx.firstMatch(value)and throwFormatExceptionwhen no match is found.tree,author,committer, andcommitin rev-list mode), SHA-1 header format, and trailing commit message newline inCommit._parse(lib/src/commit.dart) viascanner.error(FormatException) instead of throwing null-checkTypeError,StateError,ArgumentError, orAssertionError.--no-signwhen creating a lightweight tag intest/tag_test.dartso globaltag.gpgSign=trueconfigurations do not prompt for an annotated tag message.test/parse_test.dart, a coverage-guided fuzz target intest/fuzz/git_parser_fuzz.dart, and.github/workflows/fuzz.yaml(instrument-packages: string_scanner,source_span).Verification
dart test(100%pass).--instrument-packages=string_scanner,source_span(149,978executions,~25,000 exec/s,0crashes,71.0%AST coverage oncommit.dartand60.0%ontree_entry.dart).kscripts pr-checkwith 0 issues.