Add protocol allowlist to git_remote checker

I wasn't able to replicate CVE-2022-24439 / CVE-2023-40267 after a while of trying to add something malicious but I figure it's a quick and easy check to add just in case
This commit is contained in:
Max Wofford
2025-07-13 11:27:21 -07:00
parent 237724886a
commit 633eb4a5ce

View File

@@ -5,6 +5,9 @@ class GitRemote
# only run check if git is installed and in path
return true unless system("git --version")
# Only allow safe protocols
return false unless repo_url.match?(/\A(https?|git|ssh):\/\//)
safe_repo_url = URI.parse(repo_url).to_s.gsub(" ", "").gsub("'", "")
Open3.capture2e("git", "ls-remote", safe_repo_url).last.success?
end