fix: 500 on bad url (#466)

This commit is contained in:
Parth
2025-08-19 08:22:16 +05:30
committed by GitHub
parent 4b034c1246
commit 0ce122ab9d
4 changed files with 16 additions and 2 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -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.

View File

@@ -8,7 +8,7 @@ class GitRemote
# 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