Potential fix for code scanning alert no. 53: Log entries created from user input#80
Potential fix for code scanning alert no. 53: Log entries created from user input#80alessio wants to merge 1 commit into
Conversation
…m user input Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #80 +/- ##
==========================================
- Coverage 40.25% 39.74% -0.52%
==========================================
Files 2 2
Lines 77 78 +1
==========================================
Hits 31 31
- Misses 46 47 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
|
||
| fmt.Printf("%s", shellescape.Quote(line)) | ||
| safeLine := shellescape.StripUnsafe(line) | ||
| fmt.Printf("%s", shellescape.Quote(safeLine)) |
Potential fix for https://github.com/alessio/shellescape/security/code-scanning/53
General fix: sanitize untrusted input before writing it to output that may be interpreted as log/terminal text. For plain-text safety, remove control characters (including CR/LF and terminal escapes) prior to formatting.
Best fix here: in
cmd/escargs/escargs.go, sanitizelinewithshellescape.StripUnsafebefore passing it toshellescape.Quote. This preserves the intended feature (shell-escaping arguments) while preventing control-character-based forging/confusion. No new imports or dependencies are needed becauseStripUnsafealready exists inshellescape.go.Change needed:
cmd/escargs/escargs.gomain()around line 80.fmt.Printf("%s", shellescape.Quote(line))with output based on a sanitized variable, e.g.:safeLine := shellescape.StripUnsafe(line)fmt.Printf("%s", shellescape.Quote(safeLine))Suggested fixes powered by Copilot Autofix. Review carefully before merging.