13 Commits

Author SHA1 Message Date
0xJacky
32ba740bc1 refactor(host): report setup handler failures through scoped Cosy errors
Replace the raw errors.New private key path failures, the duplicated
algorithm mismatch gin.H response and the ad hoc 500 for a failed key
removal with scoped errors (ErrPrivateKeyPathRequired,
ErrPrivateKeyPathNotAbsolute, ErrKeyfileDelete in host_setup;
ErrHostKeyAlgorithmMismatch in host_ssh). Validation failures keep their
400 status via abortBadRequest, the remove failure goes through
cosy.ErrHandler.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-02 21:16:00 +08:00
0xJacky
58de54733d refactor(host): drop dead host key helpers and the legacy known-host route
POST host/setup/known-host and hostSetup.trustHostKey had no UI callers
and were a weaker duplicate of host-key/trust, which checks the algorithm
and requires explicit confirmation. hostssh.ScanHostKeys had no callers
and ClassifyHostKeys was only used by tests; the tests now exercise
ClassifyScannedHostKeys like production code does. forgetDetected in the
wizard composable was exported but unused.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-02 21:09:24 +08:00
0xJacky
5b32c0dbfa refactor(host): reuse the known_hosts default and persistence rule
Use settings.DefaultHostKnownHostsPath instead of repeating the literal,
and add setup.IsPersistedDataPath so the verify pipeline and the host key
scan handler share one definition of the persisted data directory.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-02 18:35:21 +08:00
0xJacky
275094fd09 fix(host): harden the host setup API surface
- Reject the whole host/setup group in demo mode.
- Require a verified two-factor session (or a proxied node principal) for
  every endpoint that writes SSH material or opens an outbound connection,
  sharing the guard with POST settings/nginx/control via internal/middleware.
- Validate host_address before it reaches known_hosts, where a comma,
  wildcard or newline would trust a key for other hosts.
- Only read the public key of an unmanaged private key path for a verified
  session, so the endpoint stops being a container-wide file oracle.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-02 18:15:53 +08:00
Hintay
6f16d392fe feat(nginx): add SSH file access modes 2026-07-30 08:29:35 +09:00
Hintay
1be0f99e04 fix(api): surface a failed key read and align the settings echo 2026-07-30 03:46:47 +09:00
Hintay
003ad10bb4 feat(api/host): expose target detection and grouped checks 2026-07-30 03:46:45 +09:00
Hintay
2b7dbf0610 fix(host/ssh): reset client after host key changes 2026-07-30 03:46:43 +09:00
Hintay
a1a7b150e3 feat(host/setup): support Homebrew nginx on macOS 2026-07-30 03:46:43 +09:00
Hintay
432c4088a0 fix(host/setup): address host key trust review
Align known_hosts defaults across setup and runtime, require explicit host key confirmation from the UI, and persist the host SSH wizard settings needed by verification and runner flows.
2026-07-30 03:46:42 +09:00
Hintay
3f8d5bec36 feat(host/setup): add host key management APIs 2026-07-30 03:46:41 +09:00
Hintay
918ccdacf7 fix(host): verify fingerprint and use distinct error for key parsing
- Adds ErrPublicKeyParse (510010) so TrustHostKey returns a semantically
  correct error instead of reusing ErrHostKeyMismatch's expected/got template.
- The TrustHostKey HTTP handler now recomputes the SHA256 fingerprint of
  the submitted public key and rejects requests where the client-confirmed
  fingerprint does not match. Closes a security gap where a tampered
  request body could install an unverified key in known_hosts.
2026-07-30 03:46:39 +09:00
Hintay
6e582d9e1a feat(api/host): expose host-setup endpoints and finish CLI test action
Adds /api/host/setup/{preview,keypair,publickey,verify,known-host} and
wires the CLI 'host-setup test' subcommand through the shared
setup.NewClientFromSettings + setup.Verify helpers introduced in this
commit. Mounted under the authenticated router group.
2026-07-30 03:46:38 +09:00