chore: refuse native Windows, point to WSL2 setup guide (#467)

This commit is contained in:
ezl-keygraph
2026-09-21 18:16:22 +05:30
committed by GitHub
parent 22b093aac5
commit 327c10fd90
4 changed files with 20 additions and 13 deletions
+6 -9
View File
@@ -96,15 +96,12 @@ function loadTOML(): TOMLConfig | null {
if (!fs.existsSync(configPath)) return null;
// Config contains secrets — refuse to read if group or others have any access.
// Skip on Windows where POSIX permissions are not supported.
if (process.platform !== 'win32') {
const mode = fs.statSync(configPath).mode;
if (mode & 0o077) {
const actual = (mode & 0o777).toString(8).padStart(3, '0');
fail(
`Your config file is readable by other users on this machine (${actual}). Lock it down: chmod 600 ${configPath}`,
);
}
const mode = fs.statSync(configPath).mode;
if (mode & 0o077) {
const actual = (mode & 0o777).toString(8).padStart(3, '0');
fail(
`Your config file is readable by other users on this machine (${actual}). Lock it down: chmod 600 ${configPath}`,
);
}
try {
-3
View File
@@ -360,7 +360,6 @@ function shouldSkipHostsName(name: string, hostname: string): boolean {
*/
function forwardEtcHostsFlags(): string[] {
if (!envBool('SHANNON_FORWARD_HOSTS', true)) return [];
if (os.platform() === 'win32') return [];
let content: string;
try {
@@ -517,8 +516,6 @@ export function spawnWorker(opts: WorkerOptions): ChildProcess {
// ignore stdin/stdout (the container ID is noise).
return spawn('docker', args, {
stdio: ['ignore', 'ignore', 'inherit'],
// Prevent MSYS/Git Bash from converting Unix paths on Windows
...(os.platform() === 'win32' && { env: { ...process.env, MSYS_NO_PATHCONV: '1' } }),
});
}
+13
View File
@@ -61,6 +61,18 @@ function blockSudo(): void {
);
}
/** Refuse to run on native Windows. WSL2 reports `linux`, so it is unaffected. */
function blockNativeWindows(): void {
if (process.platform !== 'win32') return;
failWith(
'CLI_PRECONDITION_FAILED',
'Shannon does not run on native Windows.',
'Run Shannon inside WSL2. Setup instructions:',
'https://github.com/KeygraphHQ/shannon/blob/main/docs/platforms.md',
);
}
/** Commands whose `--json` output contract extends to failures. */
const JSON_CAPABLE_COMMANDS = new Set(['status', 'scans', 'version', '--version', '-v']);
@@ -262,6 +274,7 @@ async function main(): Promise<void> {
enableJsonErrors();
}
blockNativeWindows();
blockSudo();
const args = process.argv.slice(2);