Skip to content

fix: ufw OpenSSH profile usage and enhance dry-run logic in git-ssh - #4

Merged
Colin23 merged 3 commits into
mainfrom
fix-ufw-arch
May 3, 2026
Merged

Colin23 merged 3 commits into
mainfrom
fix-ufw-arch

Conversation

@Colin23

@Colin23 Colin23 commented May 3, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

Release Notes

  • Documentation

    • Streamlined setup command syntax in machine setup guide for improved clarity
    • Enhanced firewall tool verification command to provide more detailed status reporting
  • Bug Fixes

    • Improved dry-run mode handling in initialization scripts
    • Refined firewall configuration initialization logic for better reliability

@coderabbitai

coderabbitai Bot commented May 3, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Colin23 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 43 minutes and 50 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2dcf2625-b304-48a7-8617-b85312383ed8

📥 Commits

Reviewing files that changed from the base of the PR and between c46c0fd and 9e71b29.

📒 Files selected for processing (6)
  • README.md
  • docs/new-machine-setup.md
  • runs/30-git-ssh
  • runs/80-dotfiles
  • runs/99-manual
  • tests/README.md
📝 Walkthrough

Walkthrough

Machine setup documentation and bootstrap scripts are updated: command examples are simplified to remove bash prefixes, the ufw verification command is made more verbose, DRY_RUN condition logic is refactored from checking for "true" string to checking for "1" value, and firewall setup logic removes pre-enable SSH allowance in favor of manual configuration notes.

Changes

Bootstrap System Setup & Documentation

Layer / File(s) Summary
DRY_RUN Logic Refactor
runs/30-git-ssh
Three DRY_RUN conditionals change from [[ "${DRY_RUN:-}" == "true" ]] to [[ "${DRY_RUN:-0}" == "1" ]] in SSH key generation, SSH agent, and GitHub connectivity test blocks.
Firewall Configuration Simplification
runs/40-firewall
SSH pre-enable allowance logic is removed; Arch-specific ufw enablement is changed from conditional run_cmd wrapper to direct sudo systemctl enable ufw --now when not already enabled.
Documentation Examples
docs/new-machine-setup.md
Four command invocation examples updated from bash ./run ... to ./run ... across SSH setup, dotfiles apply, full convergence, and idempotency verification steps.
Tool Inventory Update
docs/tool-inventory.md
ufw verification command updated from ufw status to sudo ufw status verbose for more detailed output.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A bunny hops through setup scripts with glee,
Dry runs now check for "1" not "true", you see,
Firewall rules simplified, docs made more clear,
./run is all needed, no bash need appear,
Bootstrap systems purring, all tidied with care!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title mentions two distinct changes: ufw OpenSSH profile usage and dry-run logic in git-ssh. However, the changeset includes four files with updates to documentation, dry-run handling, and firewall configuration, making the title only partially capture the scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-ufw-arch

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 43 minutes and 50 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
runs/40-firewall (1)

26-35: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Potential SSH lockout if the script is ever run over an SSH session.

Removing the pre-enable SSH allowance is the right fix for systems where the OpenSSH ufw application profile doesn't exist (e.g., Arch). However, the script now runs ufw default deny incoming + ufw --force enable with zero inbound rules. If someone runs this remotely (e.g., initial provisioning of a headless machine), their SSH session will drop the moment UFW is enabled.

A simple $SSH_CONNECTION guard before the enable step costs one line and prevents a frustrating lockout:

🛡️ Proposed safeguard
+# Guard: if connected over SSH, allow port 22 to prevent lockout
+if [[ -n "${SSH_CONNECTION:-}" ]]; then
+    log_warn "Detected active SSH session — adding temporary allow 22/tcp to prevent lockout"
+    run_cmd sudo ufw allow 22/tcp
+fi
+
 # Enable if not already active
 ufw_status="$(sudo ufw status 2>/dev/null || echo "inactive")"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@runs/40-firewall` around lines 26 - 35, The script enables UFW
unconditionally which can drop remote SSH sessions; before calling run_cmd sudo
ufw --force enable (and before setting default deny incoming if present
elsewhere), check the SSH connection environment (e.g. test $SSH_CONNECTION or
$SSH_CLIENT) and if non-empty add a temporary allow for SSH (using the same ufw
profile name detection logic or a fallback port 22) or skip enabling until run
locally; update the ufw_status/enable block (references: ufw_status variable,
log_info, and run_cmd sudo ufw --force enable) to perform this guard so remote
runs don’t lock out the operator.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@runs/40-firewall`:
- Around line 26-35: The script enables UFW unconditionally which can drop
remote SSH sessions; before calling run_cmd sudo ufw --force enable (and before
setting default deny incoming if present elsewhere), check the SSH connection
environment (e.g. test $SSH_CONNECTION or $SSH_CLIENT) and if non-empty add a
temporary allow for SSH (using the same ufw profile name detection logic or a
fallback port 22) or skip enabling until run locally; update the
ufw_status/enable block (references: ufw_status variable, log_info, and run_cmd
sudo ufw --force enable) to perform this guard so remote runs don’t lock out the
operator.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bf159012-d2d4-41e7-82e6-bc218a309210

📥 Commits

Reviewing files that changed from the base of the PR and between b2af84b and c46c0fd.

📒 Files selected for processing (4)
  • docs/new-machine-setup.md
  • docs/tool-inventory.md
  • runs/30-git-ssh
  • runs/40-firewall

@Colin23
Colin23 merged commit 143e70b into main May 3, 2026
1 check passed
@Colin23
Colin23 deleted the fix-ufw-arch branch May 3, 2026 15:59
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.

1 participant