Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 0 additions & 155 deletions src/cli/commands/auth.ts

This file was deleted.

41 changes: 1 addition & 40 deletions src/cli/commands/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ export const detectCommand = new Command('detect')
.description('Detect MDM enrollment, running AI agents, and host security posture')
.option('--json', 'Output as JSON')
.option('-q, --quiet', 'Suppress terminal output')
.option('--upload', 'Upload results to Guard0 platform')
.option('--section <name>', 'Run only a specific section (mdm|agents|host)')
.action(async (options: { json?: boolean; quiet?: boolean; upload?: boolean; section?: string }) => {
.action(async (options: { json?: boolean; quiet?: boolean; section?: string }) => {
const spinner = options.quiet ? null : createSpinner('Detecting environment...');
spinner?.start();

Expand Down Expand Up @@ -35,11 +34,6 @@ export const detectCommand = new Command('detect')
if (agents) output.agents = agents;
if (host) output.host = host;
console.log(JSON.stringify(output, null, 2));

// Upload if requested
if (options.upload) {
await uploadDetectResults(output, options.quiet);
}
return;
}

Expand Down Expand Up @@ -173,15 +167,6 @@ export const detectCommand = new Command('detect')
}

console.log('');

// ── Upload ───────────────────────────────────────────────────────────
if (options.upload) {
const output: Record<string, unknown> = {};
if (mdm) output.mdm = mdm;
if (agents) output.agents = agents;
if (host) output.host = host;
await uploadDetectResults(output, options.quiet);
}
} catch (err) {
spinner?.stop();
const message = err instanceof Error ? err.message : String(err);
Expand All @@ -193,27 +178,3 @@ export const detectCommand = new Command('detect')
}
});

async function uploadDetectResults(data: Record<string, unknown>, quiet?: boolean): Promise<void> {
try {
const { shouldUpload, uploadResults, collectMachineMeta, detectCIMeta } = await import('../../platform/upload.js');
const uploadDecision = await shouldUpload(true);
if (!uploadDecision.upload) {
if (!quiet) {
console.error(' Upload skipped: not authenticated. Run `g0 auth login` first.');
}
return;
}
const response = await uploadResults({
type: 'host-hardening' as const,
machine: collectMachineMeta(),
result: data as unknown as import('../../endpoint/host-hardening.js').HostHardeningResult,
});
if (response && !quiet) {
console.log(`\n Uploaded to: ${response.url}`);
}
} catch (err) {
if (!quiet) {
console.error(` Upload failed: ${err instanceof Error ? err.message : err}`);
}
}
}
19 changes: 1 addition & 18 deletions src/cli/commands/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { Command } from 'commander';
import { loadDaemonConfig } from '../../daemon/config.js';
import { readPid } from '../../daemon/process.js';
import { getMachineId } from '../../platform/machine-id.js';
import { isAuthenticated } from '../../platform/auth.js';
import { collectMachineMeta, shouldUpload, uploadResults } from '../../platform/upload.js';
import { listMCPServers } from '../../mcp/analyzer.js';
import { scanEndpoint } from '../../endpoint/scanner.js';
import { reportEndpointTerminal } from '../../reporters/endpoint-terminal.js';
Expand All @@ -16,7 +14,6 @@ import type { EndpointStatusResult } from '../../types/endpoint.js';

async function runEndpointScan(options: {
json?: boolean;
upload?: boolean;
banner?: boolean;
network?: boolean;
artifacts?: boolean;
Expand All @@ -41,25 +38,13 @@ async function runEndpointScan(options: {
} else {
reportEndpointTerminal(result);
}

// Upload
const { upload } = await shouldUpload(options.upload);
if (upload) {
const machine = collectMachineMeta();
await uploadResults({ type: 'endpoint', machine, result });
if (!options.json) {
console.log(chalk.dim(' Results uploaded to Guard0 platform.\n'));
}
}
}

// ─── Shared options ─────────────────────────────────────────────────────────

function addScanOptions(cmd: Command): Command {
return cmd
.option('--json', 'Output as JSON')
.option('--upload', 'Upload results to Guard0 platform')
.option('--no-upload', 'Disable upload')
.option('--no-banner', 'Suppress the g0 banner')
.option('--no-network', 'Skip network port scanning')
.option('--no-artifacts', 'Skip credential and data store scanning')
Expand All @@ -76,7 +61,6 @@ export const endpointCommand = new Command('endpoint')
addScanOptions(endpointCommand)
.action(async (options: {
json?: boolean;
upload?: boolean;
banner?: boolean;
network?: boolean;
artifacts?: boolean;
Expand All @@ -95,7 +79,6 @@ const scanSubcommand = new Command('scan')
addScanOptions(scanSubcommand)
.action(async (options: {
json?: boolean;
upload?: boolean;
banner?: boolean;
network?: boolean;
artifacts?: boolean;
Expand All @@ -116,7 +99,7 @@ const statusSubcommand = new Command('status')
const machineId = getMachineId();
const config = loadDaemonConfig();
const pid = readPid(config.pidFile);
const authed = isAuthenticated();
const authed = false;

let mcpServerCount = 0;
try {
Expand Down
25 changes: 0 additions & 25 deletions src/cli/commands/flows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ export const flowsCommand = new Command('flows')
.option('--json', 'Output as JSON')
.option('-o, --output <file>', 'Write output to file')
.option('--config <file>', 'Path to config file (default: .g0.yaml)')
.option('--upload', 'Upload results to Guard0 platform')
.option('--no-banner', 'Suppress the g0 banner')
.action(async (targetPath: string, options: {
json?: boolean;
output?: string;
config?: string;
upload?: boolean;
banner?: boolean;
}) => {
let resolvedPath: string;
Expand Down Expand Up @@ -83,29 +81,6 @@ export const flowsCommand = new Command('flows')
console.log(`JSON flow analysis also written to: ${options.output}`);
}
}
// Upload to platform
const { shouldUpload } = await import('../../platform/upload.js');
const uploadDecision = await shouldUpload(options.upload);
if (uploadDecision.upload) {
try {
if (uploadDecision.isAuto) {
console.log('\n Auto-uploading (authenticated)...');
}
const { uploadResults, collectProjectMeta, collectMachineMeta, detectCIMeta } = await import('../../platform/upload.js');
const response = await uploadResults({
type: 'flows',
project: collectProjectMeta(resolvedPath),
machine: collectMachineMeta(),
ci: detectCIMeta(),
result,
});
if (response) {
console.log(`\n Uploaded to: ${response.url}`);
}
} catch (err) {
console.error(` Upload failed: ${err instanceof Error ? err.message : err}`);
}
}
} catch (error) {
spinner.stop();
console.error('Flow analysis failed:', error instanceof Error ? error.message : error);
Expand Down
25 changes: 0 additions & 25 deletions src/cli/commands/inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const inventoryCommand = new Command('inventory')
.option('--diff <baseline>', 'Diff against a baseline inventory JSON')
.option('-o, --output <file>', 'Write output to file')
.option('--config <file>', 'Path to config file (default: .g0.yaml)')
.option('--upload', 'Upload results to Guard0 platform')
.option('--no-banner', 'Suppress the g0 banner')
.action(async (targetPath: string, options: {
json?: boolean;
Expand All @@ -33,7 +32,6 @@ export const inventoryCommand = new Command('inventory')
diff?: string;
output?: string;
config?: string;
upload?: boolean;
banner?: boolean;
}) => {
let resolvedPath: string;
Expand Down Expand Up @@ -143,29 +141,6 @@ export const inventoryCommand = new Command('inventory')
}
}

// Upload to platform
const { shouldUpload } = await import('../../platform/upload.js');
const uploadDecision = await shouldUpload(options.upload);
if (uploadDecision.upload) {
try {
if (uploadDecision.isAuto) {
console.log('\n Auto-uploading (authenticated)...');
}
const { uploadResults, collectProjectMeta, collectMachineMeta, detectCIMeta } = await import('../../platform/upload.js');
const response = await uploadResults({
type: 'inventory',
project: collectProjectMeta(resolvedPath),
machine: collectMachineMeta(),
ci: detectCIMeta(),
result: inventory,
});
if (response) {
console.log(`\n Uploaded to: ${response.url}`);
}
} catch (err) {
console.error(` Upload failed: ${err instanceof Error ? err.message : err}`);
}
}
} catch (error) {
spinner.stop();
console.error('Inventory failed:', error instanceof Error ? error.message : error);
Expand Down
Loading
Loading