[K9VULN-12862] Skip crawling of non-UTF-8 paths#868
Merged
jasonforal merged 4 commits intomainfrom Mar 31, 2026
Merged
Conversation
2 tasks
|
🎯 Code Coverage (details) 🔗 Commit SHA: 47a9544 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a panic that occurs when encountering paths with non-UTF-8 characters during directory crawling. The solution gracefully skips such paths and uses proper error handling patterns (context with the ? operator) instead of expect() or unwrap().
Changes:
- Modified
get_files()to skip non-UTF-8 paths using pattern matching instead of returning errors - Modified
filter_files_by_diff_aware_info()to handle path stripping failures gracefully by returningfalseinstead of panicking - Updated error handling in the binary to use
.context()?.for proper error propagation
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/cli/src/file_utils.rs | Changed error handling to skip non-UTF-8 paths in get_files() and changed path comparison in filter_files_by_diff_aware_info() from string-based to Path-based |
| crates/bins/src/bin/datadog-static-analyzer.rs | Updated error handling from .expect() to .context()?. for better error propagation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
juli1
approved these changes
Mar 31, 2026
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 problem are you trying to solve?
We currently panic when encountering a path with non-UTF-8 characters while crawling the directory for files to scan.
What is your solution?
Alternatives considered
What the reviewer should know
.gitignore&Pathinstead of&str(i.e. don't try to convert to UTF-8), however a non-UTF-8PathBufis impossible because the data is populated from a JSON response from the backend.