mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-20 07:04:53 +00:00
* chore(deps): bump fast-xml-parser and @aws-sdk/xml-builder Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) and [@aws-sdk/xml-builder](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/packages-internal/xml-builder). These dependencies needed to be updated together. Updates `fast-xml-parser` from 5.3.4 to 5.5.8 - [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases) - [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md) - [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/compare/v5.3.4...v5.5.8) Updates `@aws-sdk/xml-builder` from 3.972.4 to 3.972.18 - [Release notes](https://github.com/aws/aws-sdk-js-v3/releases) - [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/packages-internal/xml-builder/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-js-v3/commits/HEAD/packages-internal/xml-builder) --- updated-dependencies: - dependency-name: fast-xml-parser dependency-version: 5.5.8 dependency-type: indirect - dependency-name: "@aws-sdk/xml-builder" dependency-version: 3.972.18 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump follow-redirects from 1.15.11 to 1.16.0 Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.11 to 1.16.0. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.11...v1.16.0) --- updated-dependencies: - dependency-name: follow-redirects dependency-version: 1.16.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps): bump hono from 4.12.7 to 4.12.14 Bumps [hono](https://github.com/honojs/hono) from 4.12.7 to 4.12.14. - [Release notes](https://github.com/honojs/hono/releases) - [Commits](https://github.com/honojs/hono/compare/v4.12.7...v4.12.14) --- updated-dependencies: - dependency-name: hono dependency-version: 4.12.14 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump vite from 7.3.1 to 7.3.2 Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 7.3.1 to 7.3.2. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v7.3.2/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v7.3.2/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 7.3.2 dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump flatted from 3.3.3 to 3.4.2 Bumps [flatted](https://github.com/WebReflection/flatted) from 3.3.3 to 3.4.2. - [Commits](https://github.com/WebReflection/flatted/compare/v3.3.3...v3.4.2) --- updated-dependencies: - dependency-name: flatted dependency-version: 3.4.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump minimatch from 3.1.2 to 3.1.5 Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.1.2 to 3.1.5. - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](https://github.com/isaacs/minimatch/compare/v3.1.2...v3.1.5) --- updated-dependencies: - dependency-name: minimatch dependency-version: 3.1.5 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump lodash from 4.17.23 to 4.18.1 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.23 to 4.18.1. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.23...4.18.1) --- updated-dependencies: - dependency-name: lodash dependency-version: 4.18.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps): bump @hono/node-server from 1.19.11 to 1.19.14 Bumps [@hono/node-server](https://github.com/honojs/node-server) from 1.19.11 to 1.19.14. - [Release notes](https://github.com/honojs/node-server/releases) - [Commits](https://github.com/honojs/node-server/compare/v1.19.11...v1.19.14) --- updated-dependencies: - dependency-name: "@hono/node-server" dependency-version: 1.19.14 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps): bump rollup from 4.57.1 to 4.60.2 Bumps [rollup](https://github.com/rollup/rollup) from 4.57.1 to 4.60.2. - [Release notes](https://github.com/rollup/rollup/releases) - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md) - [Commits](https://github.com/rollup/rollup/compare/v4.57.1...v4.60.2) --- updated-dependencies: - dependency-name: rollup dependency-version: 4.60.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump electron from 40.1.0 to 40.8.5 Bumps [electron](https://github.com/electron/electron) from 40.1.0 to 40.8.5. - [Release notes](https://github.com/electron/electron/releases) - [Commits](https://github.com/electron/electron/compare/v40.1.0...v40.8.5) --- updated-dependencies: - dependency-name: electron dependency-version: 40.8.5 dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps): bump path-to-regexp from 8.3.0 to 8.4.2 Bumps [path-to-regexp](https://github.com/pillarjs/path-to-regexp) from 8.3.0 to 8.4.2. - [Release notes](https://github.com/pillarjs/path-to-regexp/releases) - [Changelog](https://github.com/pillarjs/path-to-regexp/blob/master/History.md) - [Commits](https://github.com/pillarjs/path-to-regexp/compare/v8.3.0...v8.4.2) --- updated-dependencies: - dependency-name: path-to-regexp dependency-version: 8.4.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump picomatch from 2.3.1 to 2.3.2 Bumps [picomatch](https://github.com/micromatch/picomatch) from 2.3.1 to 2.3.2. - [Release notes](https://github.com/micromatch/picomatch/releases) - [Changelog](https://github.com/micromatch/picomatch/blob/master/CHANGELOG.md) - [Commits](https://github.com/micromatch/picomatch/compare/2.3.1...2.3.2) --- updated-dependencies: - dependency-name: picomatch dependency-version: 2.3.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps): bump yaml from 2.8.2 to 2.8.3 Bumps [yaml](https://github.com/eemeli/yaml) from 2.8.2 to 2.8.3. - [Release notes](https://github.com/eemeli/yaml/releases) - [Commits](https://github.com/eemeli/yaml/compare/v2.8.2...v2.8.3) --- updated-dependencies: - dependency-name: yaml dependency-version: 2.8.3 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump @xmldom/xmldom from 0.8.11 to 0.8.13 Bumps [@xmldom/xmldom](https://github.com/xmldom/xmldom) from 0.8.11 to 0.8.13. - [Release notes](https://github.com/xmldom/xmldom/releases) - [Changelog](https://github.com/xmldom/xmldom/blob/master/CHANGELOG.md) - [Commits](https://github.com/xmldom/xmldom/compare/0.8.11...0.8.13) --- updated-dependencies: - dependency-name: "@xmldom/xmldom" dependency-version: 0.8.13 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump brace-expansion from 1.1.12 to 1.1.14 Bumps [brace-expansion](https://github.com/juliangruber/brace-expansion) from 1.1.12 to 1.1.14. - [Release notes](https://github.com/juliangruber/brace-expansion/releases) - [Commits](https://github.com/juliangruber/brace-expansion/compare/v1.1.12...v1.1.14) --- updated-dependencies: - dependency-name: brace-expansion dependency-version: 1.1.14 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps-dev): bump tar from 7.5.7 to 7.5.13 Bumps [tar](https://github.com/isaacs/node-tar) from 7.5.7 to 7.5.13. - [Release notes](https://github.com/isaacs/node-tar/releases) - [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md) - [Commits](https://github.com/isaacs/node-tar/compare/v7.5.7...v7.5.13) --- updated-dependencies: - dependency-name: tar dependency-version: 7.5.13 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Security Fixes Security fixes: Added input validation for uncontrolled command lines. Added Proper Shell Escaping for useTerminalAutocomplete Fixed 4 race condition alerts by atomic stat+read(s) without following symlinks. Misc: Use Crypto randomness instead of Math.random() (Not a security issue but convenient) * Fix OS quirk fallbacks * Review fix - use lstat before open to skip FIFO/devices early to prevent blocks - SFTP skip UUID tag could be dubiously long * allow symlinks alongside regular files. * Use acutal target size for reading * Fix Destructed import / fix to use full shellEscape charset - Destructed import - Guard now matches full shellEscape charset * Supress Codex complaints Replaced manual fd.read with fs.promises.readFile(fd) to ensure complete file reads to EOF. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
144 lines
4.1 KiB
JavaScript
144 lines
4.1 KiB
JavaScript
/**
|
|
* Passphrase Handler - Handles passphrase requests for encrypted SSH keys
|
|
* This module provides a mechanism to request passphrase input from the user
|
|
* when encountering encrypted default SSH keys in ~/.ssh
|
|
*/
|
|
|
|
// Passphrase request pending map
|
|
// Map of requestId -> { resolveCallback, rejectCallback, webContentsId, keyPath, createdAt, timeoutId }
|
|
const { randomUUID } = require("node:crypto");
|
|
|
|
const passphraseRequests = new Map();
|
|
|
|
// TTL for abandoned requests (2 minutes)
|
|
const REQUEST_TTL_MS = 2 * 60 * 1000;
|
|
|
|
/**
|
|
* Generate a unique request ID for passphrase requests
|
|
*/
|
|
function generateRequestId(prefix = 'pp') {
|
|
return `${prefix}-${randomUUID()}`;
|
|
}
|
|
|
|
/**
|
|
* Request passphrase from user via IPC
|
|
* @param {Object} sender - Electron webContents sender
|
|
* @param {string} keyPath - Path to the encrypted key
|
|
* @param {string} keyName - Name of the key (e.g., id_rsa)
|
|
* @param {string} [hostname] - Optional hostname for context
|
|
* @returns {Promise<{ passphrase?: string, cancelled?: boolean, skipped?: boolean } | null>}
|
|
*/
|
|
function requestPassphrase(sender, keyPath, keyName, hostname) {
|
|
return new Promise((resolve) => {
|
|
if (!sender || sender.isDestroyed()) {
|
|
console.warn('[Passphrase] Sender is destroyed, cannot request passphrase');
|
|
resolve(null);
|
|
return;
|
|
}
|
|
|
|
const requestId = generateRequestId();
|
|
|
|
// Set up TTL timeout to clean up abandoned requests
|
|
const timeoutId = setTimeout(() => {
|
|
const pending = passphraseRequests.get(requestId);
|
|
if (pending) {
|
|
console.warn(`[Passphrase] Request ${requestId} timed out after ${REQUEST_TTL_MS / 1000}s`);
|
|
passphraseRequests.delete(requestId);
|
|
|
|
// Notify renderer to close the modal
|
|
try {
|
|
if (!sender.isDestroyed()) {
|
|
sender.send('netcatty:passphrase-timeout', { requestId });
|
|
}
|
|
} catch (err) {
|
|
console.warn('[Passphrase] Failed to send timeout notification:', err.message);
|
|
}
|
|
|
|
resolve(null);
|
|
}
|
|
}, REQUEST_TTL_MS);
|
|
|
|
passphraseRequests.set(requestId, {
|
|
resolveCallback: resolve,
|
|
webContentsId: sender.id,
|
|
keyPath,
|
|
keyName,
|
|
createdAt: Date.now(),
|
|
timeoutId,
|
|
});
|
|
|
|
console.log(`[Passphrase] Requesting passphrase for ${keyName} (${requestId})`);
|
|
|
|
try {
|
|
sender.send('netcatty:passphrase-request', {
|
|
requestId,
|
|
keyPath,
|
|
keyName,
|
|
hostname,
|
|
});
|
|
} catch (err) {
|
|
console.error('[Passphrase] Failed to send passphrase request:', err);
|
|
passphraseRequests.delete(requestId);
|
|
clearTimeout(timeoutId);
|
|
resolve(null);
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Handle passphrase response from renderer
|
|
*/
|
|
function handleResponse(_event, payload) {
|
|
const { requestId, passphrase, cancelled, skipped } = payload;
|
|
const pending = passphraseRequests.get(requestId);
|
|
|
|
if (!pending) {
|
|
console.warn(`[Passphrase] No pending request for ${requestId}`);
|
|
return { success: false, error: 'Request not found' };
|
|
}
|
|
|
|
// Clear the TTL timeout
|
|
if (pending.timeoutId) {
|
|
clearTimeout(pending.timeoutId);
|
|
}
|
|
|
|
passphraseRequests.delete(requestId);
|
|
|
|
if (cancelled) {
|
|
// User clicked Cancel - stop the entire passphrase flow
|
|
console.log(`[Passphrase] Request ${requestId} cancelled by user`);
|
|
pending.resolveCallback({ cancelled: true });
|
|
} else if (skipped) {
|
|
// User clicked Skip - skip this key but continue with others
|
|
console.log(`[Passphrase] Request ${requestId} skipped by user`);
|
|
pending.resolveCallback({ skipped: true });
|
|
} else {
|
|
console.log(`[Passphrase] Received passphrase for ${requestId}`);
|
|
pending.resolveCallback({ passphrase: passphrase || null });
|
|
}
|
|
|
|
return { success: true };
|
|
}
|
|
|
|
/**
|
|
* Register IPC handler for passphrase responses
|
|
*/
|
|
function registerHandler(ipcMain) {
|
|
ipcMain.handle('netcatty:passphrase:respond', handleResponse);
|
|
}
|
|
|
|
/**
|
|
* Get pending requests (for debugging)
|
|
*/
|
|
function getRequests() {
|
|
return passphraseRequests;
|
|
}
|
|
|
|
module.exports = {
|
|
generateRequestId,
|
|
requestPassphrase,
|
|
handleResponse,
|
|
registerHandler,
|
|
getRequests,
|
|
};
|