Skip to content

Potential fix for code scanning alert no. 1: Unsafe shell command constructed from library input#3

Draft
n-rodriguez wants to merge 1 commit into
masterfrom
alert-autofix-1
Draft

Potential fix for code scanning alert no. 1: Unsafe shell command constructed from library input#3
n-rodriguez wants to merge 1 commit into
masterfrom
alert-autofix-1

Conversation

@n-rodriguez
Copy link
Copy Markdown

Potential fix for https://github.com/redmine-git-hosting/grack/security/code-scanning/1

To fix this without changing intended functionality, validate/allowlist the dynamic config key input before it is passed into git execution.

Best approach in this file:

  • In config_setting(service_name), normalize as today, then enforce service_name to be only known safe values used by this code (uploadpack, receivepack).
  • In config(config_name), enforce a strict format for config keys accepted by this class (here, http.uploadpack / http.receivepack), and reject anything else with ArgumentError.
  • Keep using array-based IO.popen as-is.

This addresses all alert variants because both taint sources (service_name, config_name) are constrained before reaching execute/command.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…structed from library input

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant