Skip to content

fix: 500 on bad url #466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile.production-worker
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions lib/git_remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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