Skip to content

Commit 3dfe98e

Browse files
Copilotpelikhan
andcommitted
Delete tools.json after loading to ensure no secrets remain on disk
Added file deletion in both safe_inputs_mcp_server.cjs and safe_inputs_mcp_server_http.cjs after the configuration is loaded and tools are registered. This guarantees that even though the env field only lists variable names (not secrets), the file is removed immediately after use for maximum security. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent 225e510 commit 3dfe98e

File tree

6 files changed

+96
-0
lines changed

6 files changed

+96
-0
lines changed

.github/workflows/copilot-pr-merged-report.lock.yml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/daily-performance-summary.lock.yml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/dev.lock.yml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/test-python-safe-input.lock.yml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/workflow/js/safe_inputs_mcp_server.cjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ function startSafeInputsServer(configPath, options = {}) {
7171
registerTool(server, tool);
7272
}
7373

74+
// Delete the configuration file after loading to ensure no secrets remain on disk
75+
try {
76+
const fs = require("fs");
77+
if (fs.existsSync(configPath)) {
78+
fs.unlinkSync(configPath);
79+
server.debug(`Deleted configuration file: ${configPath}`);
80+
}
81+
} catch (error) {
82+
server.debugError(`Warning: Could not delete configuration file: `, error);
83+
// Continue anyway - the server is already running
84+
}
85+
7486
// Start the server
7587
start(server);
7688
}

pkg/workflow/js/safe_inputs_mcp_server_http.cjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ function createMCPServer(configPath, options = {}) {
114114
logger.debug(`Tool registration complete: ${registeredCount} registered, ${skippedCount} skipped`);
115115
logger.debug(`=== MCP Server Creation Complete ===`);
116116

117+
// Delete the configuration file after loading to ensure no secrets remain on disk
118+
try {
119+
const fs = require("fs");
120+
if (fs.existsSync(configPath)) {
121+
fs.unlinkSync(configPath);
122+
logger.debug(`Deleted configuration file: ${configPath}`);
123+
}
124+
} catch (error) {
125+
logger.debugError(`Warning: Could not delete configuration file: `, error);
126+
// Continue anyway - the server is already running
127+
}
128+
117129
return { server, config, logger };
118130
}
119131

0 commit comments

Comments
 (0)