diff --git a/Dockerfile b/Dockerfile index 2f13b5e5..12a31c6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -69,6 +69,11 @@ COPY --from=build /usr/lib/git-core /usr/lib/git-core RUN groupadd --system --gid 1000 rails && \ useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \ chown -R rails:rails db log storage tmp + +# Global git safeguards +RUN git config --system http.timeout 30 && \ + git config --system http.lowSpeedLimit 1000 && \ + git config --system http.lowSpeedTime 10 USER 1000:1000 # Entrypoint prepares the database. diff --git a/Dockerfile.dev b/Dockerfile.dev index 2e3897e6..c966e9a3 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -26,6 +26,10 @@ COPY entrypoint.dev.sh /usr/bin/ RUN chmod +x /usr/bin/entrypoint.dev.sh ENTRYPOINT ["entrypoint.dev.sh"] +# Global git safeguards +RUN git config --system http.timeout 30 && \ + git config --system http.lowSpeedLimit 1000 && \ + git config --system http.lowSpeedTime 10 EXPOSE 3000 # Start the main process diff --git a/Dockerfile.production-worker b/Dockerfile.production-worker index 561782e0..87c91dcf 100644 --- a/Dockerfile.production-worker +++ b/Dockerfile.production-worker @@ -67,6 +67,11 @@ COPY --from=build /usr/lib/git-core /usr/lib/git-core RUN groupadd --system --gid 1000 rails && \ useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \ chown -R rails:rails db log storage tmp + +# Configure git settings globally +RUN git config --system http.timeout 30 && \ + git config --system http.lowSpeedLimit 1000 && \ + git config --system http.lowSpeedTime 10 USER 1000:1000 # Entrypoint prepares the database. diff --git a/lib/git_remote.rb b/lib/git_remote.rb index 71ca9d97..2418762a 100644 --- a/lib/git_remote.rb +++ b/lib/git_remote.rb @@ -8,7 +8,7 @@ def self.check_remote_exists(repo_url) # 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? + safe_repo_url = URI.parse(repo_url).to_s.gsub(" ", "").gsub("'", "") rescue (return false) + Open3.capture2e("git", "ls-remote", "--", safe_repo_url).last.success? end end