Skip to content

Commit 0ce122a

Browse files
authored
fix: 500 on bad url (#466)
1 parent 4b034c1 commit 0ce122a

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ COPY --from=build /usr/lib/git-core /usr/lib/git-core
6969
RUN groupadd --system --gid 1000 rails && \
7070
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
7171
chown -R rails:rails db log storage tmp
72+
73+
# Global git safeguards
74+
RUN git config --system http.timeout 30 && \
75+
git config --system http.lowSpeedLimit 1000 && \
76+
git config --system http.lowSpeedTime 10
7277
USER 1000:1000
7378

7479
# Entrypoint prepares the database.

Dockerfile.dev

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ COPY entrypoint.dev.sh /usr/bin/
2626
RUN chmod +x /usr/bin/entrypoint.dev.sh
2727
ENTRYPOINT ["entrypoint.dev.sh"]
2828

29+
# Global git safeguards
30+
RUN git config --system http.timeout 30 && \
31+
git config --system http.lowSpeedLimit 1000 && \
32+
git config --system http.lowSpeedTime 10
2933
EXPOSE 3000
3034

3135
# Start the main process

Dockerfile.production-worker

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ COPY --from=build /usr/lib/git-core /usr/lib/git-core
6767
RUN groupadd --system --gid 1000 rails && \
6868
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
6969
chown -R rails:rails db log storage tmp
70+
71+
# Configure git settings globally
72+
RUN git config --system http.timeout 30 && \
73+
git config --system http.lowSpeedLimit 1000 && \
74+
git config --system http.lowSpeedTime 10
7075
USER 1000:1000
7176

7277
# Entrypoint prepares the database.

lib/git_remote.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def self.check_remote_exists(repo_url)
88
# Only allow safe protocols
99
return false unless repo_url.match?(/\A(https?|git|ssh):\/\//)
1010

11-
safe_repo_url = URI.parse(repo_url).to_s.gsub(" ", "").gsub("'", "")
12-
Open3.capture2e("git", "ls-remote", safe_repo_url).last.success?
11+
safe_repo_url = URI.parse(repo_url).to_s.gsub(" ", "").gsub("'", "") rescue (return false)
12+
Open3.capture2e("git", "ls-remote", "--", safe_repo_url).last.success?
1313
end
1414
end

0 commit comments

Comments
 (0)