Fully autonomous AI Agents system capable of performing complex penetration testing tasks
Go ai-agentsai-security-toolanthropicautonomous-agentsgolanggptgraphqlmulti-agent-systemoffensive-securityopen-sourceopenaipenetration-testingpenetration-testing-toolsreactsecurity-automationsecurity-testingsecurity-toolsself-hosted
refactor(tests): update pentester prompt tests for tool-agnostic guidance
Dmitry Ngb8c1b7d9a671
diff --git a/backend/pkg/templates/prompts/pentester.tmpl b/backend/pkg/templates/prompts/pentester.tmplindex db441257..12e85c64 100644--- a/backend/pkg/templates/prompts/pentester.tmpl+++ b/backend/pkg/templates/prompts/pentester.tmpl@@ -330,10 +330,12 @@ Check tool availability with 'which [tool]' before use. Install missing tools if</usage_notes><cli_argument_protocol>-- Verify command-specific flags with `[tool] -h` or `[tool] --help` before first use when the exact syntax is uncertain.-- Do not copy flags between different tools, and do not invent output flags: do not pass `-c`, `-o`, or `-o /dev/null` to a tool unless that tool's own `--help` documents them.-- For XSStrike specifically, do not use `xsstrike -c` or `xsstrike -o` (including `xsstrike -o /dev/null`); XSStrike does not accept these arguments. Confirm the exact flags with `xsstrike --help`.-- If output needs to be saved, reduced, or discarded, use shell redirection (for example, `> results.txt` or `> /dev/null`) or the tool's documented logging option instead of inventing unsupported output flags.+Common AI-agent mistakes with CLI security tools, and how to avoid them:+- Hallucinated flags: verify uncertain syntax with `[tool] -h` or `[tool] --help` before first use, and re-check after any failure suggesting memorized syntax is stale (renamed flag, changed default, different installed version).+- Cross-tool flag assumptions: the same letter or word means different things per tool (`-p` is port in nmap, password in hydra, proxy elsewhere). Never copy a flag from one tool to another, and never invent an output flag (`-o`, `-c`, `-o /dev/null`, etc.) that the target tool's own `--help` does not document.+- Output handling: to save, filter, or discard output, use shell redirection (`> results.txt`, `> /dev/null`, `2>&1`) or the tool's documented logging option instead of guessing an unsupported flag.+- Machine-readable output: when output must be parsed or piped into another tool, request the tool's structured format explicitly (e.g. nmap `-oX`/`-oG`, or a `-json`/`-jsonl` flag many scanners expose) instead of parsing its default free-text output.+- Argument quoting: quote or escape payload strings containing shell metacharacters (semicolons, pipes, ampersands, `$`, quotes, backticks, or glob characters like `*`/`?`) — otherwise the shell, not the target tool, interprets them; this most often corrupts XSS/SQLi payloads and URLs with query parameters.</cli_argument_protocol><msf_workflow_protocol>diff --git a/backend/pkg/templates/templates_test.go b/backend/pkg/templates/templates_test.goindex 1d49b98f..1606e6dd 100644--- a/backend/pkg/templates/templates_test.go+++ b/backend/pkg/templates/templates_test.go@@ -1013,9 +1013,12 @@ func TestQuestionTaskPlannerPrompt(t *testing.T) {}}-// TestPentesterPromptXSStrikeArgumentGuidance keeps the pentester prompt from-// recommending unsupported XSStrike flags when composing terminal commands.-func TestPentesterPromptXSStrikeArgumentGuidance(t *testing.T) {+// TestPentesterPromptCLIArgumentGuidance keeps the pentester prompt's CLI+// argument guidance generic (tool-agnostic) rather than hardcoding advice for+// a single utility, while still covering the common AI-agent mistake classes:+// hallucinated flags, cross-tool flag assumptions, output redirection,+// machine-readable output, and shell-metacharacter quoting.+func TestPentesterPromptCLIArgumentGuidance(t *testing.T) {defaultPrompts, err := templates.GetDefaultPrompts()if err != nil {t.Fatalf("Failed to load default prompts: %v", err)@@ -1035,18 +1038,31 @@ func TestPentesterPromptXSStrikeArgumentGuidance(t *testing.T) {requiredGuidance := []string{"cli_argument_protocol",- "XSStrike",- "xsstrike --help",- "xsstrike -c",- "xsstrike -o",- "xsstrike -o /dev/null",+ "Hallucinated flags",+ "--help",+ "Cross-tool flag assumptions",+ "Never copy a flag from one tool to another","shell redirection",- "inventing unsupported output flags",+ "Machine-readable output",+ "Argument quoting",}for _, guidance := range requiredGuidance {if !strings.Contains(rendered, guidance) {- t.Errorf("Rendered pentester template missing XSStrike argument guidance: %s", guidance)+ t.Errorf("Rendered pentester template missing CLI argument guidance: %s", guidance)+ }+ }++ // The guidance must stay tool-agnostic: no single utility should be+ // singled out by name, or the section would drift back into wasting+ // context tokens on one tool instead of generalizing across Kali tools.+ forbiddenGuidance := []string{+ "XSStrike",+ "xsstrike",+ }+ for _, forbidden := range forbiddenGuidance {+ if strings.Contains(rendered, forbidden) {+ t.Errorf("Rendered pentester template should not single out a specific tool by name: %s", forbidden)}}}