Compare commits

...
Author SHA1 Message Date
BaaRai 0116786f02 Fix review: dalfox --rate-limit/--workers, drop passive subfinder -t
Dalfox v3.2.4 (Rust) has no -w and exposes a global --rate-limit plus --workers (docs/content/reference/cli.md). Subfinder -t only bounds concurrent DNS lookups in active mode, so the passive line is removed; the generic fallback covers it.
2026-11-13 12:17:51 +01:00
BaaRai 4595274fd6 Agent: low-and-slow scanner guidance under a noise profile (off by default)
When ARTEX_NOISE_PROFILE is set, the planner, worker, main agent and chat system prompts gain a code-owned block with the profile per-host limits and exact rate/delay flags for the scanners installed in the image. With no profile the block is empty, so every prompt is byte-for-byte unchanged.

README documents the block.
2026-11-13 12:05:14 +01:00
7 changed files with 150 additions and 4 deletions
+2
View File
@@ -274,6 +274,8 @@ Optional: `ARTEX_LLM_PROVIDER` (anthropic | openai | openai-responses | ollama)
**Noise profile (off by default)**: `ARTEX_NOISE_PROFILE` paces the requests ARTEX itself sends to targets (WebFetch, http custom tools, the enrich probe). Unset or `off`, nothing changes: no limit, no cache. Set `quiet` (2 req/s per host, burst 4, 1 in flight), `balanced` (5 req/s, burst 10, 2 in flight) or `aggressive` (20 req/s, burst 40, 4 in flight), e.g. `ARTEX_NOISE_PROFILE=balanced` in `.env` or the environment. A profile also adds a small jitter, backs off on 429/503 (honouring `Retry-After`, bounded retries, GET/HEAD/OPTIONS only), and, for the http custom tools and the enrich probe, merges identical in-flight GETs of one task (per tool) and caches them briefly (60/30/10 s; never POST, PUT, PATCH or DELETE; WebFetch is paced only), and logs a per-host noise line each minute. `ARTEX_TARGET_USER_AGENT` sets a User-Agent on target requests that carry none, under a profile; empty keeps the current one. Tools launched through Bash are not paced yet.
**Low-and-slow agent guidance (off by default)**: when a noise profile is set, the planner, worker, main agent and chat agents receive a code-owned prompt block with the profile's per-host limits and exact rate/delay flags for the scanners installed in the image (`nmap`, `nuclei`, `httpx`, `katana`, `ffuf`, `dalfox`, `sqlmap`). It tells them to test one host at a time, to back off on 429/503 and never to raise the rate to meet a deadline. Unset or `off`, the block is empty and every prompt is unchanged. Commands launched through Bash are not paced by the governor, so these flags are the brake for scanners.
**Run budgets (off by default)**: `ARTEX_TASK_BUDGET_TOKENS` and `ARTEX_TASK_BUDGET_TURNS` cap a task's total spend (its planner rounds and all its workers); `ARTEX_INTENT_BUDGET_TOKENS` and `ARTEX_INTENT_BUDGET_TURNS` cap one worker run. Unset or `0` means unlimited, and nothing changes. A worker is not started when the remaining task budget cannot cover its estimated cost (the average of the task's finished workers, else 50000 tokens and 10 turns). When the remaining budget reaches the wrap-up reserve (the larger of 5% and 20000 tokens, and 2 turns), the task enters a forced wrap-up: the planner writes a summary and the final goal judgment, and workers may only write back (`record_fact`, `insert_assets`, `report_finding`, `update_finding_report`). The task then ends `done` if its goals are met, otherwise `timeout`. Budgets are kept in memory: a restart, or a revive of a finished task, starts a fresh budget. Each planner round logs a `[budget]` line. Practical floor: below 50000 tokens a task gets no worker; from 50000 to about 70000 it typically gets one worker and then the wrap-up. Pick a budget well above 70000 tokens for real exploration.
**Common flags**: `./start.sh -addr :8787 -proxy :8788` (`-addr` frontend+API, `-proxy` traffic recording proxy). The startup script passes arguments through to `artex` verbatim.
+1 -1
View File
@@ -89,7 +89,7 @@ func chatWorkDirSpec(workDir string) string {
func chatSystem(agentKey, dataDir, workDir string) string {
body := renderSystem(agentKey, DefaultAssistantPrompt, chatVars{DataDir: dataDir, Now: nowStr()})
body += untrustedContentTail(body)
return body + chatWorkDirSpec(workDir)
return body + chatWorkDirSpec(workDir) + noiseProfileBlock()
}
// chatVars carries the runtime variables a custom agent's prompt may reference.
+1 -1
View File
@@ -103,7 +103,7 @@ Do not fabricate findings; answer only from real data returned by tools.`
func mainAgentSystem(goal, dataDir, workDir string) string {
body := renderSystem("mainagent", mainAgentDefaultTmpl, MainVars{Goal: goal, DataDir: dataDir, Now: nowStr()})
return body + untrustedContentTail(body) + artifactSpec(workDir)
return body + untrustedContentTail(body) + artifactSpec(workDir) + noiseProfileBlock()
}
// Chat handles one human message and returns the assistant reply. emit, if
+68
View File
@@ -0,0 +1,68 @@
package agent
import (
"fmt"
"strconv"
"strings"
"time"
"github.com/Autumn-27/artex/egress"
)
// noiseProfileHeader starts the code-owned noise block. The block is appended to
// every agent prompt that can launch Bash; with no profile it is empty, so the
// prompts stay byte-for-byte unchanged by default.
const noiseProfileHeader = "[Noise profile: "
// noiseProfileBlock returns the low-and-slow guidance for the active noise
// profile (ARTEX_NOISE_PROFILE), or "" when the profile is off. The text is
// code-owned and carries no target data.
func noiseProfileBlock() string { return renderNoiseProfile(egress.ProfileFromEnv()) }
// renderNoiseProfile renders the block for one profile. It is pure: tests cover
// every profile without touching the environment.
func renderNoiseProfile(p egress.Profile) string {
if p.Name == "" || p.Name == "off" || p.RPS <= 0 {
return ""
}
rps := int(p.RPS + 0.5)
if rps < 1 {
rps = 1
}
conc := p.MaxPerHost
if conc < 1 {
conc = 1
}
// The profile's delay between requests is 1/RPS (500 ms, 200 ms, 50 ms).
delayMS := int((time.Second / time.Duration(rps)) / time.Millisecond)
delaySec := strconv.FormatFloat(1/float64(rps), 'f', -1, 64)
inFlight := fmt.Sprintf("%d requests", conc)
if conc == 1 {
inFlight = "1 request"
}
// nmap and masscan count packets, not requests; the profile's RPS is used as a
// deliberately conservative packet cap.
timing := map[string]string{"quiet": "-T2", "balanced": "-T3", "aggressive": "-T4"}[p.Name]
if timing == "" {
timing = "-T3"
}
retries := "2"
if p.Name == "aggressive" {
retries = "1"
}
var b strings.Builder
fmt.Fprintf(&b, "%s%s. Operator setting, not a target fact.]\n", noiseProfileHeader, p.Name)
b.WriteString("Scan at a reduced rate. When you run one of these scanners, use the flags exactly:\n")
fmt.Fprintf(&b, "- nmap: %s --max-rate %d --max-retries %s\n", timing, rps, retries)
fmt.Fprintf(&b, "- nuclei: -rate-limit %d -c %d\n", rps, conc)
fmt.Fprintf(&b, "- httpx: -rl %d -t %d\n", rps, conc)
fmt.Fprintf(&b, "- katana: -rl %d -c %d\n", rps, conc)
fmt.Fprintf(&b, "- ffuf: -rate %d -t %d\n", rps, conc)
fmt.Fprintf(&b, "- dalfox scan: --rate-limit %d --workers %d\n", rps, conc)
fmt.Fprintf(&b, "- sqlmap: --delay=%s --threads=1\n", delaySec)
fmt.Fprintf(&b, "For any other tool, stay at or below %d requests per second per host, at most %s in flight, and at least %d ms between requests, using the tool's own rate or delay flag. Keep bbot within the same limits with its own rate settings, and do not enable active modules the program policy does not allow.\n", rps, inFlight, delayMS)
b.WriteString("Prefer passive and read-only checks; test one host at a time; do not run two scanners against the same host in parallel; on 429 or 503 stop and back off; never raise the rate to meet a deadline.\n")
b.WriteString("ARTEX paces its own WebFetch, http custom tool and enrich traffic with this profile, but commands launched through Bash are not paced: these flags are the only brake.\n")
return b.String()
}
+76
View File
@@ -0,0 +1,76 @@
package agent
import (
"fmt"
"strings"
"testing"
"github.com/Autumn-27/artex/egress"
)
func TestRenderNoiseProfileOff(t *testing.T) {
for _, p := range []egress.Profile{{}, {Name: "off"}, {Name: "off", RPS: 5}} {
if got := renderNoiseProfile(p); got != "" {
t.Errorf("renderNoiseProfile(%+v) = %q, want empty", p, got)
}
}
}
func TestRenderNoiseProfileTable(t *testing.T) {
for _, c := range []struct {
name string
rps int
conc int
delay int
timing string
retries string
sql string
}{
{"quiet", 2, 1, 500, "-T2", "2", "0.5"},
{"balanced", 5, 2, 200, "-T3", "2", "0.2"},
{"aggressive", 20, 4, 50, "-T4", "1", "0.05"},
} {
got := renderNoiseProfile(egress.Profiles[c.name])
for _, want := range []string{
noiseProfileHeader + c.name,
fmt.Sprintf("- nmap: %s --max-rate %d --max-retries %s", c.timing, c.rps, c.retries),
fmt.Sprintf("- nuclei: -rate-limit %d -c %d", c.rps, c.conc),
fmt.Sprintf("- httpx: -rl %d -t %d", c.rps, c.conc),
fmt.Sprintf("- katana: -rl %d -c %d", c.rps, c.conc),
fmt.Sprintf("- ffuf: -rate %d -t %d", c.rps, c.conc),
fmt.Sprintf("- dalfox scan: --rate-limit %d --workers %d", c.rps, c.conc),
fmt.Sprintf("- sqlmap: --delay=%s --threads=1", c.sql),
fmt.Sprintf("at least %d ms between requests", c.delay),
"commands launched through Bash are not paced",
} {
if !strings.Contains(got, want) {
t.Errorf("%s: missing %q in:\n%s", c.name, want, got)
}
}
}
}
// The default must stay identical: with no profile the block is empty and none of
// the four prompts that can launch Bash gains any text.
func TestPromptBuildersNoiseBlock(t *testing.T) {
builders := map[string]func() string{
"planner": func() string { return plannerSystem("goal", "/data", "/work") },
"worker": func() string { return workerSystem("", "", "/data", "/run") },
"mainagent": func() string { return mainAgentSystem("goal", "/data", "/work") },
"chat": func() string { return chatSystem("auto", "/data", "/work") },
}
for _, env := range []string{"", "off"} {
t.Setenv("ARTEX_NOISE_PROFILE", env)
for name, build := range builders {
if got := build(); strings.Contains(got, noiseProfileHeader) {
t.Errorf("%s with profile %q contains the noise block", name, env)
}
}
}
t.Setenv("ARTEX_NOISE_PROFILE", "quiet")
for name, build := range builders {
if got := build(); !strings.Contains(got, noiseProfileHeader+"quiet") {
t.Errorf("%s with quiet is missing the noise block", name)
}
}
}
+1 -1
View File
@@ -448,7 +448,7 @@ No duplicates, no padding; but when the goal is unmet and there are uncovered, d
func plannerSystem(goal, dataDir, workDir string) string {
body := renderSystem("planner", plannerDefaultTmpl, PlannerVars{Goal: goal, DataDir: dataDir, Now: nowStr()})
return body + untrustedDataRules + artifactSpec(workDir)
return body + untrustedDataRules + artifactSpec(workDir) + noiseProfileBlock()
}
// Plan runs one planning round. emit, if non-nil, receives the planner's execution
+1 -1
View File
@@ -321,7 +321,7 @@ func workerSystem(proxyAddr, caCert, dataDir, runDir string) string {
// caCert is present only when the recording MITM is on, which is exactly when
// the traffic_* tools are registered — so it gates the traffic-tool note.
// Optional finding guidance is added for every role after tool resolution.
return body + untrustedContentTail(body) + workerTrafficBlock(caCert != "") + workerArtifactSpec(runDir)
return body + untrustedContentTail(body) + workerTrafficBlock(caCert != "") + workerArtifactSpec(runDir) + noiseProfileBlock()
}
// renderIntentTask formats the claimed intent for the worker's launch USER message: