Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions backend/pkg/templates/prompts/pentester.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@ Check tool availability with 'which [tool]' before use. Install missing tools if
{{end}}
</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. For XSStrike, do not use `xsstrike -c` or `xsstrike -o` unless the installed `xsstrike --help` explicitly documents those options.
- If output needs to be saved or reduced, prefer shell redirection or the tool's documented logging option instead of inventing unsupported output flags.
</cli_argument_protocol>

<msf_workflow_protocol>
Standalone (recommended): All operations in one command
`msfconsole -q -x "use exploit/...; set LPORT [allocated]; exploit; sleep 20; sessions -l; sessions -i 1 -c 'sysinfo'; exit"`
Expand Down
36 changes: 36 additions & 0 deletions backend/pkg/templates/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,42 @@ func TestQuestionTaskPlannerPrompt(t *testing.T) {
}
}

// TestPentesterPromptXSStrikeArgumentGuidance keeps the pentester prompt from
// recommending unsupported XSStrike flags when composing terminal commands.
func TestPentesterPromptXSStrikeArgumentGuidance(t *testing.T) {
defaultPrompts, err := templates.GetDefaultPrompts()
if err != nil {
t.Fatalf("Failed to load default prompts: %v", err)
}

dummyData := validator.CreateDummyTemplateData()
template := defaultPrompts.AgentsPrompts.Pentester.System.Template

rendered, err := templates.RenderPrompt(
string(templates.PromptTypePentester),
template,
dummyData,
)
if err != nil {
t.Fatalf("Failed to render pentester template: %v", err)
}

requiredGuidance := []string{
"cli_argument_protocol",
"XSStrike",
"xsstrike --help",
"xsstrike -c",
"xsstrike -o",
"inventing unsupported output flags",
}

for _, guidance := range requiredGuidance {
if !strings.Contains(rendered, guidance) {
t.Errorf("Rendered pentester template missing XSStrike argument guidance: %s", guidance)
}
}
}

// TestTaskAssignmentWrapperPrompt tests the task_assignment_wrapper template
func TestTaskAssignmentWrapperPrompt(t *testing.T) {
defaultPrompts, err := templates.GetDefaultPrompts()
Expand Down