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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ignite",
"version": "0.6.1",
"version": "0.7.1",
"private": true,
"description": "Secure JS/TS code execution in Docker with sandboxing for AI agents, untrusted code, and microservices",
"workspaces": [
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ignite/cli",
"version": "0.6.0",
"version": "0.7.1",
"type": "module",
"bin": {
"ignite": "./dist/index.js"
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/run.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import { resolve } from 'node:path';
import { loadService, executeService, runPreflight, createReport, formatReportAsText, getImageName, buildServiceImage, parseAuditFromOutput, formatSecurityAudit, DEFAULT_POLICY, isValidRuntime, loadPolicyFile } from '@ignite/core';
import { logger, ConfigError } from '@ignite/shared';

Expand Down Expand Up @@ -60,7 +60,7 @@ export async function runCommand(servicePath: string, options: RunOptions): Prom
: undefined;

if (options.auditOutput && audit) {
const outputPath = join(process.cwd(), options.auditOutput);
const outputPath = resolve(process.cwd(), options.auditOutput);
await writeFile(outputPath, JSON.stringify(audit, null, 2));
logger.success(`Audit saved to ${outputPath}`);
}
Comment on lines 62 to 66
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add error handling for audit file write operation.

The writeFile call can fail (e.g., permission denied, disk full, invalid path) but errors aren't caught. This could cause the command to fail with an unhandled rejection after successful execution.

🛡️ Proposed fix
     if (options.auditOutput && audit) {
       const outputPath = resolve(process.cwd(), options.auditOutput);
-      await writeFile(outputPath, JSON.stringify(audit, null, 2));
-      logger.success(`Audit saved to ${outputPath}`);
+      try {
+        await writeFile(outputPath, JSON.stringify(audit, null, 2));
+        logger.success(`Audit saved to ${outputPath}`);
+      } catch (writeErr) {
+        logger.warn(`Failed to save audit to ${outputPath}: ${(writeErr as Error).message}`);
+      }
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (options.auditOutput && audit) {
const outputPath = resolve(process.cwd(), options.auditOutput);
await writeFile(outputPath, JSON.stringify(audit, null, 2));
logger.success(`Audit saved to ${outputPath}`);
}
if (options.auditOutput && audit) {
const outputPath = resolve(process.cwd(), options.auditOutput);
try {
await writeFile(outputPath, JSON.stringify(audit, null, 2));
logger.success(`Audit saved to ${outputPath}`);
} catch (writeErr) {
logger.warn(`Failed to save audit to ${outputPath}: ${(writeErr as Error).message}`);
}
}
🤖 Prompt for AI Agents
In `@packages/cli/src/commands/run.ts` around lines 62 - 66, Wrap the audit file
write in a try/catch to handle filesystem errors when calling writeFile with the
resolved outputPath (used when options.auditOutput && audit), so failures
(permission, disk, invalid path) are caught; on error log a clear message via
logger.error including the outputPath and error details and avoid letting the
unhandled rejection propagate (either return a non-fatal error status or rethrow
after logging depending on command semantics). Ensure the success log
(logger.success(`Audit saved to ${outputPath}`)) remains inside the try block
and reference the existing symbols options.auditOutput, audit, outputPath,
writeFile, and logger in your changes.

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const program = new Command();
program
.name('ignite')
.description('Secure sandbox for AI-generated code, untrusted scripts, and JS/TS execution')
.version('0.6.0');
.version('0.7.1');

program
.command('init <name>')
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ignite/core",
"version": "0.6.0",
"version": "0.7.1",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
27 changes: 27 additions & 0 deletions packages/core/src/service/load-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ function validateServiceConfig(config: unknown): ServiceValidation {
failRatio: 'positive',
});

const memoryConfig = pf['memory'] as Record<string, unknown> | undefined;
const warnRatio = memoryConfig?.['warnRatio'];
const failRatio = memoryConfig?.['failRatio'];
if (typeof warnRatio === 'number' && typeof failRatio === 'number') {
if (warnRatio >= failRatio) {
errors.push('preflight.memory.warnRatio must be less than preflight.memory.failRatio');
}
}

validatePreflightSection(pf['dependencies'], 'preflight.dependencies', errors, {
warnCount: 'positive',
infoCount: 'positive',
Expand All @@ -137,11 +146,29 @@ function validateServiceConfig(config: unknown): ServiceValidation {
failMb: 'positive',
});

const imageConfig = pf['image'] as Record<string, unknown> | undefined;
const warnMb = imageConfig?.['warnMb'];
const failMb = imageConfig?.['failMb'];
if (typeof warnMb === 'number' && typeof failMb === 'number') {
if (warnMb >= failMb) {
errors.push('preflight.image.warnMb must be less than preflight.image.failMb');
}
}

validatePreflightSection(pf['timeout'], 'preflight.timeout', errors, {
minMs: 'positive',
maxMs: 'positive',
coldStartBufferMs: 'positive',
});

const timeoutConfig = pf['timeout'] as Record<string, unknown> | undefined;
const minMs = timeoutConfig?.['minMs'];
const maxMs = timeoutConfig?.['maxMs'];
if (typeof minMs === 'number' && typeof maxMs === 'number') {
if (minMs >= maxMs) {
errors.push('preflight.timeout.minMs must be less than preflight.timeout.maxMs');
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ignite/http",
"version": "0.6.0",
"version": "0.7.1",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ignite/shared",
"version": "0.6.0",
"version": "0.7.1",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down