Make scripts/diff-filter.pl portable to macOS#8839
Make scripts/diff-filter.pl portable to macOS#8839tautschnig wants to merge 1 commit intodiffblue:developfrom
Conversation
This change impact analysis helper used `sed` in ways not portable to macOS.
There was a problem hiding this comment.
Pull request overview
This pull request fixes a macOS portability issue in the diff-filter.pl script by modifying the sed -i command to work on both GNU and BSD (macOS) sed implementations.
Changes:
- Modified
sed -itosed -i.bakwith explicit backup extension for macOS compatibility - Added cleanup step to remove the temporary backup file after editing
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if($edits{$f}{$l} =~ /^[CDcd]$/) | ||
| { | ||
| `sed -i '${l}s/^/$edits{$f}{$l}#/' $f_edit`; | ||
| `sed -i.bak '${l}s/^/$edits{$f}{$l}#/' $f_edit`; |
There was a problem hiding this comment.
The backtick-executed sed command interpolates $f_edit directly into a shell command without quoting or escaping, which allows shell metacharacters in file names from the goto-diff output to break out of the sed invocation and run arbitrary commands. An attacker controlling a file path in the diff (for example via a repository with crafted file names) can trigger command execution when this script is run. Use a safer invocation that avoids the shell (such as Perl’s system in list form or a pure-Perl edit) or ensure $f_edit is safely quoted/escaped so that any metacharacters are treated as literal path characters, not shell syntax.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8839 +/- ##
========================================
Coverage 80.00% 80.00%
========================================
Files 1700 1700
Lines 188252 188252
Branches 73 73
========================================
+ Hits 150613 150616 +3
+ Misses 37639 37636 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This change impact analysis helper used
sedin ways not portable to macOS.