Skip to content

fix: reject failed SSH configuration captures - #210

Merged
TheWitness merged 2 commits into
developfrom
fix/reject-failed-ssh-captures
Nov 17, 2026
Merged

TheWitness merged 2 commits into
developfrom
fix/reject-failed-ssh-captures

Conversation

@somethingwithproof

Copy link
Copy Markdown
Member

Fixes #209. Follow-up to #207/#208.

SSH capture now drains stdout and stderr together, checks the remote exit status before closing the channel, and rejects failed reads, nonzero status and unavailable status before writing an incoming backup. Successful commands may still emit stderr warnings. The capture deadline, output normalization and atomic file replacement are preserved.

Regression tests cover nonzero/missing status with output above the backup size threshold, stderr draining, read/open failures, delayed output, cleanup, and the full download/archive caller. The caller test verifies that a failed capture neither archives a stale/error file nor advances lastbackup. All four failure assertions fail against the original implementation.

Validation: 337 tests passed on PHP 8.5.12; 336 passed on PHP 8.3.36 with one root-only permission-test skip. The 27 focused capture tests passed, and Xdebug on PHP 8.4.25 exercised all 23 changed executable transport lines. The transport files are now included in the existing coverage filter. PHP syntax and formatter checks passed.

The tests use real local streams with doubles at the SSH extension boundary; no live SSH server or vendor device was exercised. Exit status comes from the ssh2 extension's stream metadata, not from shell-specific command wrapping. Servers that report success for their own error text still require vendor-specific output validation. Deploying this change does not remove previously archived failed captures.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@sonarqubecloud

Copy link
Copy Markdown

@TheWitness
TheWitness merged commit 2209449 into develop Nov 17, 2026
7 checks passed
@TheWitness
TheWitness deleted the fix/reject-failed-ssh-captures branch November 17, 2026 03:35
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.

Failed SSH capture commands can be archived as successful backups

2 participants