mirror of
https://github.com/SrIzan10/hc-harbor.git
synced 2026-05-01 10:45:21 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user