This commit captures uncommitted modifications that accumulated in the working tree across multiple in-progress workstreams. It is a snapshot to clear the deck before sf v3 work begins; individual workstreams should land separately on top of this. Notable additions: - trace-collector.ts, traces.ts, src/tests/trace-export.test.ts — trace export plumbing - biome.json — Biome linter configuration - .gitignore — exclude native/npm/**/*.node compiled binaries The bulk of the diff is across src/resources/extensions/sf/ (301 files) and src/resources/extensions/sf/tests/ (277 files), reflecting the ongoing sf extension work. Specific feature commits should follow this snapshot rather than being archaeology'd out of it. The 76MB native/npm/linux-x64-gnu/forge_engine.node compiled binary was left out of the commit — it's now gitignored and built locally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
/**
|
|
* Apply user-configured security overrides from global settings.json and env vars.
|
|
*
|
|
* Both overrides are global-only (not project-level) because the threat model is
|
|
* malicious project-level config in cloned repos. Global settings and env vars
|
|
* represent the user's own authority on their machine.
|
|
*
|
|
* Precedence: env var > settings.json > built-in defaults
|
|
*/
|
|
|
|
import {
|
|
type SettingsManager,
|
|
setAllowedCommandPrefixes,
|
|
} from "@singularity-forge/pi-coding-agent";
|
|
import { setFetchAllowedUrls } from "./resources/extensions/search-the-web/url-utils.js";
|
|
|
|
export function applySecurityOverrides(settingsManager: SettingsManager): void {
|
|
// --- Command prefix allowlist ---
|
|
const envPrefixes = process.env.SF_ALLOWED_COMMAND_PREFIXES;
|
|
if (envPrefixes) {
|
|
const prefixes = envPrefixes
|
|
.split(",")
|
|
.map((s) => s.trim())
|
|
.filter(Boolean);
|
|
if (prefixes.length > 0) {
|
|
setAllowedCommandPrefixes(prefixes);
|
|
}
|
|
} else {
|
|
const settingsPrefixes = settingsManager.getAllowedCommandPrefixes();
|
|
if (settingsPrefixes && settingsPrefixes.length > 0) {
|
|
setAllowedCommandPrefixes(settingsPrefixes);
|
|
}
|
|
}
|
|
|
|
// --- Fetch URL allowlist (SSRF exemptions) ---
|
|
const envUrls = process.env.SF_FETCH_ALLOWED_URLS;
|
|
if (envUrls) {
|
|
const urls = envUrls
|
|
.split(",")
|
|
.map((s) => s.trim())
|
|
.filter(Boolean);
|
|
if (urls.length > 0) {
|
|
setFetchAllowedUrls(urls);
|
|
}
|
|
} else {
|
|
const settingsUrls = settingsManager.getFetchAllowedUrls();
|
|
if (settingsUrls && settingsUrls.length > 0) {
|
|
setFetchAllowedUrls(settingsUrls);
|
|
}
|
|
}
|
|
}
|