mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-07-27 16:49:51 -07:00
58d54311d8
- merge-catalog: stop dropping anilist_id on every new anime insert (bun:sqlite .get() returns null, so the old !== undefined guard always fired); the guard was dead anyway since a colliding id is caught earlier - sync-command: throw instead of fail() inside runHostSync so the finally block runs and temp dirs holding snapshot data are cleaned up on failure - ssh: shell-quote the user-supplied --remote-cmd in the probe, and reject option-like (-prefixed) SSH hosts that ssh/scp would parse as flags - sync-db: close the remote handle if opening the local DB throws - sync-shared: treat EPERM from process.kill(pid, 0) as alive, not dead - cli-parser: trim the sync host before the mode-exclusivity check - tests: cover anilist_id preservation, anilist-based anime matching, and the SSH host/shell-quote guards
20 lines
826 B
TypeScript
20 lines
826 B
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { assertSafeSshHost, shellQuote } from './ssh.js';
|
|
|
|
test('assertSafeSshHost rejects option-like hosts', () => {
|
|
assert.throws(() => assertSafeSshHost('-oProxyCommand=touch pwned'), /looks like an option/);
|
|
assert.throws(() => assertSafeSshHost('-lroot'), /looks like an option/);
|
|
});
|
|
|
|
test('assertSafeSshHost accepts normal destinations', () => {
|
|
assert.doesNotThrow(() => assertSafeSshHost('macbook'));
|
|
assert.doesNotThrow(() => assertSafeSshHost('user@192.168.1.20'));
|
|
assert.doesNotThrow(() => assertSafeSshHost('ssh-alias'));
|
|
});
|
|
|
|
test('shellQuote escapes single quotes and wraps in quotes', () => {
|
|
assert.equal(shellQuote('subminer'), `'subminer'`);
|
|
assert.equal(shellQuote(`a'; rm -rf ~; '`), `'a'\\''; rm -rf ~; '\\'''`);
|
|
});
|