Skip to content

fix(import): harden WinSCP password and site import reliability#77

Merged
Orinks merged 2 commits intodevfrom
fix/winscp-importer-reliability
Mar 4, 2026
Merged

fix(import): harden WinSCP password and site import reliability#77
Orinks merged 2 commits intodevfrom
fix/winscp-importer-reliability

Conversation

@Orinks
Copy link
Owner

@Orinks Orinks commented Mar 4, 2026

Summary

Improve WinSCP importer reliability end-to-end (password + site import) with FileZilla importer resilience as the quality bar.

Root-cause gaps addressed

  • WinSCP password decryption did not match upstream algorithm structure (version, length width, and shift handling), causing real-world password imports to fail or decode incorrectly.
  • WinSCP INI parsing assumed UTF-8 only, failing on valid exports with alternate encodings (e.g. UTF-16).
  • URL-encoded WinSCP fields (notably PublicKeyFile, also session/dir values) were not consistently decoded, causing site import fidelity issues.
  • Error/no-results messages in import dialog were generic and not actionable for WinSCP-specific fallback paths.

Design (scoped, low regression risk)

  • Keep importer APIs stable (list[ImportedSite]) and harden internals.
  • Make WinSCP parser tolerant (encoding fallback + strict=False) while preserving skip-invalid-site behavior.
  • Decrypt safely: support WinSCP internal formats; treat unsupported external/master-password encryption as non-fatal empty password.
  • Preserve partial import: malformed password payloads no longer block site import.
  • Add source-specific user guidance in dialog error/no-results messaging.

Before / After

Before

  • Some valid WinSCP passwords failed to import due to incomplete decode logic.
  • Some WinSCP INI exports failed to parse depending on file encoding.
  • URL-encoded key paths could import literally encoded.
  • Users saw generic failure/no-results messages with limited next steps.

After

  • WinSCP password decoding aligns with upstream simple algorithm variants and shift handling.
  • Unsupported external/master-password-encrypted values are safely ignored (password blank), without blocking site import.
  • WinSCP INI encoding fallback supports UTF-8/UTF-16/common legacy encodings.
  • URL-encoded key path/remote dir/session-host fields decode to usable values.
  • Dialog messaging now includes WinSCP-specific troubleshooting and fallback hints.

Testing

  • Added comprehensive WinSCP tests for:
    • internal v0 and internal v2 length formats
    • shift-byte payloads
    • odd-length, truncated, invalid, and key-prefix-mismatch payloads
    • external/master-password-encrypted payload handling
    • UTF-16 INI parsing
    • URL-decoded site fields
  • Added dialog tests validating WinSCP-specific user messaging for parse errors and empty results.

Validation runs

  • pytest -q tests/test_importers_winscp.py tests/test_import_connections_dialog.py tests/test_importers_filezilla.py tests/test_importers_init.py
  • pytest -q
  • ruff check src/portkeydrop/importers/winscp.py src/portkeydrop/dialogs/import_connections.py tests/test_importers_winscp.py tests/test_import_connections_dialog.py
  • ruff format --check src/portkeydrop/importers/winscp.py src/portkeydrop/dialogs/import_connections.py tests/test_importers_winscp.py tests/test_import_connections_dialog.py

@gitguardian
Copy link

gitguardian bot commented Mar 4, 2026

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@Orinks Orinks force-pushed the fix/winscp-importer-reliability branch from 9a563fb to fb7d81b Compare March 4, 2026 15:55
@Orinks Orinks merged commit 3ebf610 into dev Mar 4, 2026
6 checks passed
@Orinks Orinks deleted the fix/winscp-importer-reliability branch March 4, 2026 16:54
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