Skip to content
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

Enable using read-only HTTPS repositories #2171

Merged
merged 2 commits into from
Dec 3, 2024
Merged

Conversation

mogul
Copy link
Contributor

@mogul mogul commented Dec 3, 2024

If someone wants to clone read-only from an https://github.com/... URL, that should be permitted, and in that case they shouldn't be required to provide an SSH key. (Without this, if you provide neither the path nor the key, then you see ERR /app/bin/clone_process_models: line 39: SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH: unbound variable in the logs and the clone on the penultimate line never happens.)

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of SSH private key for Git operations to prevent errors during cloning.
  • Refactor

    • Enhanced clarity in the assignment and export process of the SSH private key path.
    • Streamlined the conditional export of the SSH command based on the availability of the private key.

If someone wants to clone read-only from an `https://github.com/...` URL, that should be permitted, and in that case they shouldn't be required to provide an SSH key.
Copy link
Contributor

coderabbitai bot commented Dec 3, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in the pull request focus on the clone_process_models script within the spiffworkflow-backend directory. Key modifications include restructuring the export process for the SSH private key path for clarity and adding a conditional check to ensure that the GIT_SSH_COMMAND is only set if the private key path is defined. Additionally, a redundant export statement for GIT_SSH_COMMAND has been removed to streamline the script's logic.

Changes

File Path Change Summary
spiffworkflow-backend/bin/clone_process_models - Updated variable assignment for SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH to use a local variable before exporting.
- Added conditional export for GIT_SSH_COMMAND based on the existence of the SSH private key path.
- Removed redundant export of GIT_SSH_COMMAND within directory check.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d35ec0c and f05522e.

📒 Files selected for processing (1)
  • spiffworkflow-backend/bin/clone_process_models (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • spiffworkflow-backend/bin/clone_process_models

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
spiffworkflow-backend/bin/clone_process_models (1)

33-35: LGTM! Conditional SSH configuration enables HTTPS support

This change correctly makes SSH configuration optional, allowing for both SSH and HTTPS repository access. Consider adding a comment to explain this dual-mode support:

+# Only configure SSH if a private key is provided, otherwise allow HTTPS access
 if [[ -n "${SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH}" ]]; then
   export GIT_SSH_COMMAND="ssh -F /dev/null -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH}"
 fi
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 995a980 and d35ec0c.

📒 Files selected for processing (1)
  • spiffworkflow-backend/bin/clone_process_models (1 hunks)
🔇 Additional comments (2)
spiffworkflow-backend/bin/clone_process_models (2)

27-28: LGTM! Improved variable assignment clarity

The separation of variable assignment and export improves code readability while maintaining the same functionality.


41-41: Verify HTTPS cloning functionality

The implementation looks correct, but let's verify there are no hardcoded SSH URLs or forced SSH configurations in the codebase that might prevent HTTPS cloning.

✅ Verification successful

HTTPS cloning is properly supported

The implementation correctly handles both SSH and HTTPS cloning:

  • SSH configuration (GIT_SSH_COMMAND) is only set when an SSH key is provided
  • The clone URL is controlled by SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL environment variable
  • No forced SSH configurations that would prevent HTTPS cloning
  • The hardcoded SSH URLs found are only in development-related files (package-lock.json and deployment scripts) and don't affect the cloning functionality
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potential hardcoded git URLs or SSH configurations that might interfere with HTTPS cloning

echo "Checking for hardcoded git URLs:"
rg -i "git@github|ssh://git@" --type bash --type python

echo "Checking for forced SSH configurations:"
rg -i "GIT_SSH_COMMAND|StrictHostKeyChecking" --type bash --type python

Length of output: 353


Script:

#!/bin/bash
# Search for potential hardcoded git URLs or SSH configurations that might interfere with HTTPS cloning
# Using more generic file type options

echo "Checking for hardcoded git URLs:"
rg -i "git@github|ssh://git@"

echo "Checking for forced SSH configurations:"
rg -i "GIT_SSH_COMMAND|StrictHostKeyChecking"

# Also check the specific clone script for any git clone related commands
echo "Checking clone script implementation:"
cat spiffworkflow-backend/bin/clone_process_models

Length of output: 3397

@@ -24,18 +24,23 @@ fi

if [[ -z "${SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH:-}" ]]; then
if [[ -n "${SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY:-}" ]]; then
export SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH=$(mktemp /tmp/ssh_private_key.XXXXXX)
SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH=$(mktemp /tmp/ssh_private_key.XXXXXX)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeRabbit is missing a subtlety here that shellcheck.net caught: If you export on the same line that you run a subshell, you might mask an error in the execution of the subshell. Not likely here with mktemp, but good BASH style says the export should happen on a separate line from the assignment for that reason.

@burnettk burnettk merged commit a3c5219 into main Dec 3, 2024
23 checks passed
@burnettk burnettk deleted the enable-readonly-https-repos branch December 3, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants