Skip to content

Fix Windows SSH key file permissions#1168

Merged
GT-610 merged 2 commits into
mainfrom
fix-windows-ssh-key-permissions
May 12, 2026
Merged

Fix Windows SSH key file permissions#1168
GT-610 merged 2 commits into
mainfrom
fix-windows-ssh-key-permissions

Conversation

@GT-610
Copy link
Copy Markdown
Collaborator

@GT-610 GT-610 commented May 11, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved security for temporary SSH private key files with platform-specific permission hardening on Windows and Unix-like systems.
    • Failures to apply permissions are now surfaced to the user via an error dialog and prevent continuing the SSH launch to avoid using insecure keys.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 977dfed7-3d0b-4c06-b358-70d1bc27fe35

📥 Commits

Reviewing files that changed from the base of the PR and between 390d918 and 817be98.

📒 Files selected for processing (1)
  • lib/view/widget/server_func_btns.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/view/widget/server_func_btns.dart

📝 Walkthrough

Walkthrough

The SSH temporary private key generation flow now includes platform-specific file permission hardening. After writing the key file, a new _restrictPrivateKeyFile helper enforces restrictive permissions: chmod 600 on non-Windows platforms, and Windows ACL restrictions via whoami and icacls to remove inheritance and grant exclusive access to the current user. Failures in restriction are thrown, logged, and surfaced via an error dialog causing an early return.

Possibly related PRs

  • lollipopkit/flutter_server_box#1073: Both PRs modify the SSH private-key write flow in server_func_btns.dart; the earlier PR added newline-padding and basic non-Windows chmod 600, while this PR extends that with cross-platform hardening including Windows ACL restrictions.

Suggested reviewers

  • lollipopkit
🚥 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 'Fix Windows SSH key file permissions' directly addresses the main change: implementing permission enforcement for SSH private keys on Windows through icacls, while also improving non-Windows chmod handling.
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-windows-ssh-key-permissions

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

@coderabbitai coderabbitai Bot requested a review from lollipopkit May 11, 2026 15:09
Copy link
Copy Markdown
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/view/widget/server_func_btns.dart`:
- Line 220: Awaiting _restrictPrivateKeyFile(path) inside _gotoSSH can throw a
ProcessException that currently escapes the async void caller; wrap the await in
a try/catch that specifically catches ProcessException (and optionally other
Exceptions), handle it by logging and surfacing a user-friendly failure message
(e.g., via existing error dialog / _showError or processLogger) and then
return/abort the SSH flow so the exception does not propagate; update the
_gotoSSH method to catch ProcessException around the call to
_restrictPrivateKeyFile(path) and perform the clean failure handling there.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ae6ebdec-8aeb-4c91-9024-ebb82153b17b

📥 Commits

Reviewing files that changed from the base of the PR and between 1e759c2 and 390d918.

📒 Files selected for processing (1)
  • lib/view/widget/server_func_btns.dart

Comment thread lib/view/widget/server_func_btns.dart Outdated
@GT-610 GT-610 merged commit 4a4b166 into main May 12, 2026
3 checks passed
@GT-610 GT-610 deleted the fix-windows-ssh-key-permissions branch May 12, 2026 01:03
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