import { HostConfig } from "../types.js";
import { validateHostname } from "../utils/path-security.js";
import { validateAlphanumeric } from "../utils/validation.js";
/**
* Validate host configuration for SSH
* SECURITY: Validates host before shell interpolation to prevent command injection
*/
export function validateHostForSsh(host: HostConfig): void {
// Validate hostname using centralized validation
validateHostname(host.host);
// Validate SSH user if provided
if (host.sshUser) {
validateAlphanumeric(host.sshUser, "SSH user");
}
// Validate key path if provided
if (host.sshKeyPath) {
validateAlphanumeric(host.sshKeyPath, "SSH key path", { allowSlash: true, allowTilde: true });
}
}
/**
* Host resource stats from SSH
*/
export interface HostResources {
hostname: string;
uptime: string;
loadAverage: [number, number, number];
cpu: {
cores: number;
usagePercent: number;
};
memory: {
totalMB: number;
usedMB: number;
freeMB: number;
usagePercent: number;
};
disk: Array<{
filesystem: string;
mount: string;
totalGB: number;
usedGB: number;
availGB: number;
usagePercent: number;
}>;
}