mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-02 12:01:50 +08:00
feat(traffic,sandbox): add TUN/netstack transparent gateway, egress controls, CAP_NET_RAW hardening, and i18n fixes
- Implement full-traffic transparent gateway (cmd/artex-gateway, traffic/netstack.go, traffic/transparent.go) using Linux TUN + gVisor netstack deferred TCP handshakes (eliminating nmap/nc false-positive open ports), real ICMPv4 Echo proxying, UDP/DNS interception, and per-container upstream proxy overrides. - Add egress blacklist + asset-intercept sync, non-HTTP flow/DNS SQLite persistence and APIs, and /system/proxy & /function/traffic TCP/UDP/DNS UI panels. - Fix sandbox Playwright MCP browser loopback --proxy-server rewrite and NODE_EXTRA_CA_CERTS override in server/mcpstdio.go. - Strip all SUID/SGID binaries in Dockerfile.sandbox, grant minimal cap_net_raw+ep to nmap/nping/ping with ARTEX_SANDBOX_ALLOW_NET_RAW toggle, and enforce IPv4/IPv6 anti-spoofing in iptables and netstack. - Remove hardcoded Chinese "(全局)" from GET /api/proxy/routes, localize ContainerRoutesTab / NonHTTPTrafficPanel labels, and expose reactive locale/isEn from useLiveTranslation for React Compiler compatibility.
This commit is contained in:
1 parent
9c43e694a3
commit
d786de90af
69 files changed
+13082
-1433
No files matched your search
+17
-4
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/Autumn-27/artex/guard"
|
||||
"github.com/Autumn-27/artex/intercept"
|
||||
"github.com/Autumn-27/artex/internal/sandbox"
|
||||
"github.com/Autumn-27/artex/traffic"
|
||||
"github.com/Autumn-27/norma/agentcore"
|
||||
"github.com/Autumn-27/norma/llm"
|
||||
"github.com/Autumn-27/norma/permission"
|
||||
@@ -153,9 +154,22 @@ func (c *ChatAgent) Chat(ctx context.Context, agentKey, sessionID, message strin
|
||||
if c.proxyAddrFn != nil {
|
||||
proxyAddr = c.proxyAddrFn()
|
||||
}
|
||||
bashEnv := proxyEnv(proxyAddr, c.proxyCACert)
|
||||
srcID := traffic.SourceIdentity{
|
||||
Scope: string(sbTarget.Scope),
|
||||
OwnerID: sbTarget.OwnerID,
|
||||
SessionID: sessionID,
|
||||
}
|
||||
webFetchProxy := proxyAddr
|
||||
if c.proxyCACert != "" && proxyAddr != "" {
|
||||
webFetchProxy = traffic.FormatProxyContextURL(proxyAddr, srcID)
|
||||
}
|
||||
bashEnv := proxyEnv(webFetchProxy, c.proxyCACert)
|
||||
if sandboxActive {
|
||||
bashEnv = sbMgr.ProxyEnv(proxyAddr != "")
|
||||
if proxyAddr != "" && c.proxyCACert != "" && sbMgr.Config().ProxyURL != "" {
|
||||
bashEnv = sbMgr.ProxyEnvWithURL(traffic.FormatProxyContextURL(sbMgr.Config().ProxyURL, srcID))
|
||||
} else {
|
||||
bashEnv = sbMgr.ProxyEnv(proxyAddr != "")
|
||||
}
|
||||
}
|
||||
opts := agentcore.Options{
|
||||
Provider: c.prov,
|
||||
@@ -166,9 +180,8 @@ func (c *ChatAgent) Chat(ctx context.Context, agentKey, sessionID, message strin
|
||||
UnlockSet: def.Unlock,
|
||||
PermissionMode: permission.ModeBypass,
|
||||
EnableWebFetch: true, // 走记录代理留痕;载入代理 CA 验证 MITM 重签的 HTTPS 证书
|
||||
WebFetchProxy: proxyAddr,
|
||||
WebFetchProxy: webFetchProxy,
|
||||
WebFetchCACert: c.proxyCACert,
|
||||
// 联网搜索(可选)。ddgs 无需 key;brave-free 需 BraveKey;tavily 需 TavilyKey。
|
||||
// WebSearchProxy 是独立出口代理(http/https/socks5),与记录流量的 MITM 代理无关;空则直连。
|
||||
EnableWebSearch: ws.Enabled && ws.Backend != "deepseek",
|
||||
WebSearchBackend: ws.Backend,
|
||||
|
||||
+16
-4
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/Autumn-27/artex/db"
|
||||
"github.com/Autumn-27/artex/intercept"
|
||||
"github.com/Autumn-27/artex/internal/sandbox"
|
||||
"github.com/Autumn-27/artex/traffic"
|
||||
"github.com/Autumn-27/norma/agentcore"
|
||||
"github.com/Autumn-27/norma/llm"
|
||||
"github.com/Autumn-27/norma/permission"
|
||||
@@ -155,9 +156,21 @@ func (m *MainAgent) Chat(ctx context.Context, taskID int64, mainSeg int, as *db.
|
||||
if m.proxyAddrFn != nil {
|
||||
proxyAddr = m.proxyAddrFn()
|
||||
}
|
||||
bashEnv := proxyEnv(proxyAddr, m.proxyCACert)
|
||||
srcID := traffic.SourceIdentity{
|
||||
Scope: "task",
|
||||
OwnerID: strconv.FormatInt(taskID, 10),
|
||||
}
|
||||
webFetchProxy := proxyAddr
|
||||
if m.proxyCACert != "" && proxyAddr != "" && taskID > 0 {
|
||||
webFetchProxy = traffic.FormatProxyContextURL(proxyAddr, srcID)
|
||||
}
|
||||
bashEnv := proxyEnv(webFetchProxy, m.proxyCACert)
|
||||
if sandboxActive {
|
||||
bashEnv = sbMgr.ProxyEnv(proxyAddr != "")
|
||||
if proxyAddr != "" && m.proxyCACert != "" && sbMgr.Config().ProxyURL != "" {
|
||||
bashEnv = sbMgr.ProxyEnvWithURL(traffic.FormatProxyContextURL(sbMgr.Config().ProxyURL, srcID))
|
||||
} else {
|
||||
bashEnv = sbMgr.ProxyEnv(proxyAddr != "")
|
||||
}
|
||||
}
|
||||
opts := agentcore.Options{
|
||||
Provider: m.prov,
|
||||
@@ -168,9 +181,8 @@ func (m *MainAgent) Chat(ctx context.Context, taskID int64, mainSeg int, as *db.
|
||||
UnlockSet: def.Unlock,
|
||||
PermissionMode: permission.ModeBypass,
|
||||
EnableWebFetch: true, // 走记录代理留痕;载入代理 CA 验证 MITM 重签的 HTTPS 证书
|
||||
WebFetchProxy: proxyAddr,
|
||||
WebFetchProxy: webFetchProxy,
|
||||
WebFetchCACert: m.proxyCACert,
|
||||
// 联网搜索(可选)。ddgs 无需 key;brave-free 需 BraveKey;tavily 需 TavilyKey。
|
||||
// WebSearchProxy 是独立出口代理(http/https/socks5),与记录流量的 MITM 代理无关;空则直连。
|
||||
EnableWebSearch: m.webSearch.Enabled && m.webSearch.Backend != "deepseek",
|
||||
WebSearchBackend: m.webSearch.Backend,
|
||||
|
||||
+13
-5
@@ -4,11 +4,13 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/Autumn-27/artex/db"
|
||||
"github.com/Autumn-27/artex/intercept"
|
||||
"github.com/Autumn-27/artex/traffic"
|
||||
"github.com/Autumn-27/norma/agentcore"
|
||||
"github.com/Autumn-27/norma/llm"
|
||||
"github.com/Autumn-27/norma/permission"
|
||||
@@ -408,6 +410,13 @@ func (p *Planner) Plan(ctx context.Context, taskID int64, as *db.AssetStore, ts
|
||||
if p.proxyAddrFn != nil {
|
||||
proxyAddr = p.proxyAddrFn()
|
||||
}
|
||||
webFetchProxy := proxyAddr
|
||||
if p.proxyCACert != "" && proxyAddr != "" && taskID > 0 {
|
||||
webFetchProxy = traffic.FormatProxyContextURL(proxyAddr, traffic.SourceIdentity{
|
||||
Scope: "task",
|
||||
OwnerID: strconv.FormatInt(taskID, 10),
|
||||
})
|
||||
}
|
||||
opts := agentcore.Options{
|
||||
Provider: p.prov,
|
||||
SystemPrompt: system,
|
||||
@@ -417,18 +426,17 @@ func (p *Planner) Plan(ctx context.Context, taskID int64, as *db.AssetStore, ts
|
||||
UnlockSet: def.Unlock,
|
||||
PermissionMode: permission.ModeBypass,
|
||||
EnableWebFetch: true, // 走记录代理留痕;载入代理 CA 验证 MITM 重签的 HTTPS 证书
|
||||
WebFetchProxy: proxyAddr,
|
||||
WebFetchProxy: webFetchProxy,
|
||||
WebFetchCACert: p.proxyCACert,
|
||||
// 联网搜索(可选)。ddgs 无需 key;brave-free 需 BraveKey;tavily 需 TavilyKey。
|
||||
// WebSearchProxy 是独立出口代理(http/https/socks5),与记录流量的 MITM 代理无关;空则直连。
|
||||
// WebSearchProxy 是独立的出口代理(http/https/socks5),与记录流量的 MITM 代理无关;空则直连。
|
||||
EnableWebSearch: p.webSearch.Enabled && p.webSearch.Backend != "deepseek",
|
||||
WebSearchBackend: p.webSearch.Backend,
|
||||
BraveSearchAPIKey: p.webSearch.BraveKey,
|
||||
TavilySearchAPIKey: p.webSearch.TavilyKey,
|
||||
WebSearchProxy: p.webSearch.Proxy,
|
||||
BashEnv: proxyEnv(proxyAddr, p.proxyCACert), // Bash 子命令默认走代理+信任 CA
|
||||
WorkingDir: taskDir, // 本任务工作目录 <workDir>/tasks/<taskID>
|
||||
ToolOutputDir: cmdOutDir(taskDir),
|
||||
BashEnv: proxyEnv(webFetchProxy, p.proxyCACert), // Bash 子命令默认走代理+信任 CA
|
||||
WorkingDir: taskDir, // 本任务工作目录 <workDir>/tasks/<taskID>
|
||||
MaxTurns: p.maxTurns, // 0 = unlimited (configurable in agent management)
|
||||
MaxDuration: maxDur, // 0=不限;有 deadline 时=距 deadline 剩余
|
||||
Compaction: compactionConfig(p.compactionWindow()),
|
||||
|
||||
+17
-4
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/Autumn-27/artex/db"
|
||||
"github.com/Autumn-27/artex/intercept"
|
||||
"github.com/Autumn-27/artex/internal/sandbox"
|
||||
"github.com/Autumn-27/artex/traffic"
|
||||
"github.com/Autumn-27/norma/agentcore"
|
||||
"github.com/Autumn-27/norma/harness"
|
||||
"github.com/Autumn-27/norma/llm"
|
||||
@@ -398,14 +399,27 @@ func (w *Worker) execute(ctx context.Context, name string, taskID int64, as *db.
|
||||
proxyAddr = w.proxyAddrFn()
|
||||
}
|
||||
sysProxyAddr, sysCACert, sysDataDir := proxyAddr, w.proxyCACert, w.workDir
|
||||
bashEnv := proxyEnv(proxyAddr, w.proxyCACert)
|
||||
srcID := traffic.SourceIdentity{
|
||||
Scope: "task",
|
||||
OwnerID: strconv.FormatInt(taskID, 10),
|
||||
IntentID: intent.ID,
|
||||
}
|
||||
webFetchProxy := proxyAddr
|
||||
if w.proxyCACert != "" && proxyAddr != "" {
|
||||
webFetchProxy = traffic.FormatProxyContextURL(proxyAddr, srcID)
|
||||
}
|
||||
bashEnv := proxyEnv(webFetchProxy, w.proxyCACert)
|
||||
if sandboxActive {
|
||||
if proxyAddr != "" && sbMgr.Config().ProxyURL != "" {
|
||||
sysProxyAddr = sbMgr.Config().ProxyURL
|
||||
sysCACert = sandbox.ContainerCACertPath
|
||||
}
|
||||
sysDataDir = sandbox.ContainerWorkDir
|
||||
bashEnv = sbMgr.ProxyEnv(proxyAddr != "")
|
||||
if proxyAddr != "" && w.proxyCACert != "" && sbMgr.Config().ProxyURL != "" {
|
||||
bashEnv = sbMgr.ProxyEnvWithURL(traffic.FormatProxyContextURL(sbMgr.Config().ProxyURL, srcID))
|
||||
} else {
|
||||
bashEnv = sbMgr.ProxyEnv(proxyAddr != "")
|
||||
}
|
||||
}
|
||||
sysBody := workerSystem(sysProxyAddr, sysCACert, sysDataDir, displayRunDir)
|
||||
if w.wantConstraints() {
|
||||
@@ -450,9 +464,8 @@ func (w *Worker) execute(ctx context.Context, name string, taskID int64, as *db.
|
||||
// WebFetch 走记录代理,其 HTTP 与 curl 一样被留痕;载入代理 CA 让经 MITM
|
||||
// 重签的 HTTPS 证书能【正常校验通过】(而非关掉校验)。proxy 空则直连。
|
||||
EnableWebFetch: true,
|
||||
WebFetchProxy: proxyAddr,
|
||||
WebFetchProxy: webFetchProxy,
|
||||
WebFetchCACert: w.proxyCACert,
|
||||
// 联网搜索(可选)。ddgs 无需 key;brave-free 需 BraveKey;tavily 需 TavilyKey。
|
||||
// WebSearchProxy 是独立的出口代理(http/https/socks5),与记录流量的 MITM 代理无关;空则直连。
|
||||
EnableWebSearch: w.webSearch.Enabled && w.webSearch.Backend != "deepseek",
|
||||
WebSearchBackend: w.webSearch.Backend,
|
||||
|
||||
Reference in new issue
Block a user