Skip to content

Conversation

@lxdklp
Copy link
Contributor

@lxdklp lxdklp commented Nov 24, 2025

修复了 #965 的问题

截屏2025-11-25 03 16 09

Summary by CodeRabbit

  • New Features
    • SFTP connections now support SSH known host fingerprints for host verification during secure file transfers.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 24, 2025

Walkthrough

SSH known host fingerprints support is added to the SFTP client. A new optional field stores known host fingerprints in the request model, initialized from settings with error handling. This fingerprint data is then passed to the SSH client during connection setup.

Changes

Cohort / File(s) Summary
SFTP Request Model Enhancement
lib/data/model/sftp/req.dart
Added knownHostFingerprints: Map<String, String>? field to SftpReq. Constructor initializes the field by converting Stores.setting.sshKnownHostFingerprints.get() with try-catch error handling, defaulting to null on failure.
SFTP Worker Data Threading
lib/data/model/sftp/worker.dart
Updated _download and _upload methods to pass knownHostFingerprints: req.knownHostFingerprints to genClient calls, enabling SSH client to use known host fingerprints during handshake.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify try-catch error handling in SftpReq constructor is appropriate for the settings retrieval
  • Confirm knownHostFingerprints parameter matches expected SSH client interface requirements
  • Check that both _download and _upload methods are consistently updated with the new parameter

Poem

🐰 A map of fingerprints so fine,
Through SFTP's layers they entwine,
SSH handshakes now secure and tight,
With known hosts verified just right! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix: #965' is vague and non-descriptive, using only an issue number without explaining the actual change being made. Replace the title with a descriptive summary of the actual change, such as 'Add SSH known host fingerprints support to SFTP requests' to clearly convey the main modification.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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

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

Copy link

@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

🧹 Nitpick comments (1)
lib/data/model/sftp/req.dart (1)

22-26: Consider logging initialization failures for better observability.

The broad exception catch silently swallows all errors when loading known host fingerprints. While the fallback to null is safe, logging the failure would help diagnose configuration issues, type mismatches, or store access problems during development and debugging.

Consider applying this diff to improve observability:

     try {
       knownHostFingerprints = Map<String, String>.from(Stores.setting.sshKnownHostFingerprints.get());
-    } catch (_) {
+    } catch (e) {
+      Loggers.app.warning('Failed to load SSH known host fingerprints: $e');
       knownHostFingerprints = null;
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 75d1a59 and 4ebdbe6.

📒 Files selected for processing (2)
  • lib/data/model/sftp/req.dart (2 hunks)
  • lib/data/model/sftp/worker.dart (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
lib/data/model/**/*.dart

📄 CodeRabbit inference engine (CLAUDE.md)

After modifying annotated model files, run: dart run build_runner build --delete-conflicting-outputs

Files:

  • lib/data/model/sftp/worker.dart
  • lib/data/model/sftp/req.dart
lib/data/model/sftp/**/*.dart

📄 CodeRabbit inference engine (CLAUDE.md)

Place SFTP models under lib/data/model/sftp/

Files:

  • lib/data/model/sftp/worker.dart
  • lib/data/model/sftp/req.dart
🧠 Learnings (2)
📚 Learning: 2025-10-08T09:36:41.682Z
Learnt from: CR
Repo: lollipopkit/flutter_server_box PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-08T09:36:41.682Z
Learning: Applies to lib/data/model/sftp/**/*.dart : Place SFTP models under lib/data/model/sftp/

Applied to files:

  • lib/data/model/sftp/worker.dart
  • lib/data/model/sftp/req.dart
📚 Learning: 2025-10-08T09:36:41.682Z
Learnt from: CR
Repo: lollipopkit/flutter_server_box PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-08T09:36:41.682Z
Learning: Applies to lib/data/model/ssh/**/*.dart : Place SSH models under lib/data/model/ssh/

Applied to files:

  • lib/data/model/sftp/worker.dart
  • lib/data/model/sftp/req.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: check
🔇 Additional comments (2)
lib/data/model/sftp/worker.dart (1)

68-68: LGTM! Known host fingerprints correctly passed to SSH client.

The changes consistently pass the known host fingerprints to genClient in both download and upload operations, enabling SSH known host verification.

Also applies to: 125-125

lib/data/model/sftp/req.dart (1)

11-11: LGTM! Field declaration is appropriate.

The optional knownHostFingerprints field correctly models SSH known host fingerprint data with an appropriate type.

@lollipopkit lollipopkit merged commit 141519d into lollipopkit:main Nov 25, 2025
4 checks passed
@lollipopkit
Copy link
Owner

Thanks

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