Skip to content

Add runtime egress enforcement and audit logging#9

Merged
initializ-mk merged 1 commit intomainfrom
core/runtime-security
Feb 27, 2026
Merged

Add runtime egress enforcement and audit logging#9
initializ-mk merged 1 commit intomainfrom
core/runtime-security

Conversation

@initializ-mk
Copy link
Contributor

Summary

  • Runtime egress enforcement via EgressEnforcer — an http.RoundTripper that validates every outbound HTTP request against the resolved domain allowlist before forwarding. Supports exact match, wildcard domains (*.github.com), and always-allowed localhost. Three modes: deny-all, allowlist, dev-open.
  • Structured audit logging with NDJSON events (session_start, session_end, tool_exec, egress_allowed, egress_blocked, llm_call) and correlation IDs for end-to-end request tracing.
  • Context-threaded correlationTaskID and CorrelationID propagated through context and HookContext, attached to all audit events including egress callbacks.
  • Tool wiring — all HTTP-making tools (http_request, mcp_call, webhook_call, web_search_tavily, web_search_perplexity) now use the egress-enforced transport/client from context.
  • Comprehensive README rewrite covering fallback chains, OAuth, memory, runtime security, guardrails, context budgeting, config reference, and environment variables.

Files changed

File Change
forge-core/security/egress_enforcer.go NEW — http.RoundTripper wrapper + context helpers
forge-core/security/egress_enforcer_test.go NEW — unit tests
forge-core/security/egress_integration_test.go NEW — end-to-end tests with httptest
forge-core/runtime/audit.go NEW — NDJSON audit logger + context helpers
forge-core/runtime/audit_test.go NEW — unit tests
forge-core/runtime/audit_integration_test.go NEW — event sequence tests
forge-core/runtime/hooks.go MODIFY — add TaskID/CorrelationID to HookContext
forge-core/runtime/loop.go MODIFY — populate IDs in all 5 Fire() calls
forge-core/tools/builtins/http_request.go MODIFY — use egress transport
forge-core/tools/builtins/web_search_tavily.go MODIFY — use egress client
forge-core/tools/builtins/web_search_perplexity.go MODIFY — use egress client
forge-core/tools/adapters/mcp_call.go MODIFY — use egress transport
forge-core/tools/adapters/webhook_call.go MODIFY — use egress transport
forge-cli/runtime/runner.go MODIFY — resolve egress, build enforcer, inject context, register audit hooks
README.md REWRITE — comprehensive documentation

Test plan

  • forge-core/security — all egress enforcer tests pass (allowlist, deny-all, dev-open, wildcards, localhost, callbacks, context helpers, integration)
  • forge-core/runtime — all audit logger tests pass (emit, concurrent safety, context round-trips, event sequence)
  • forge-core/tools — existing tool tests pass unchanged (backward compatible when no egress client in context)
  • forge-cli/runtime — runner tests pass with updated registerHandlers signature
  • golangci-lint clean on both forge-core and forge-cli

- Add EgressEnforcer (http.RoundTripper) that validates outbound requests
  against domain allowlist with wildcard support and localhost bypass
- Add structured NDJSON audit logger with correlation IDs and task IDs
  for end-to-end request tracing
- Extend HookContext with TaskID/CorrelationID, populate in all Fire() calls
- Wire egress transport into all HTTP-making tools (http_request, mcp_call,
  webhook_call, web_search_tavily, web_search_perplexity)
- Resolve egress config in runner, inject enforcer and audit logger into
  handler context, register audit hooks for tool/LLM/egress events
- Rewrite README with full coverage of fallback chains, OAuth, memory,
  runtime security, guardrails, context budgeting, and config reference
@initializ-mk initializ-mk merged commit 494a5cf into main Feb 27, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant