debugging

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 12 Imported by: 0

README

Debugging Tools (pkg/core/tools/debugging)

The Debugging Module provides a suite of tools to analyze errors, locate faulty code, and propose fixes.

Key Tools

1. analyze_failure

Uses an LLM to interpret detailed error logs and test failure reports to explain why something went wrong.

2. find_handler

Locates the exact file and function in your codebase that handles a specific API endpoint (e.g., finds HandleLogin for POST /login).

3. propose_fix

Generates a code patch to resolve a specific bug or vulnerability found during testing.

Usage

These tools are typically used in response to a failed test or a user report.

Example Prompts

Trigger these tools by asking:

  • "Why did the login test fail?" (analyze_failure)
  • "Find the code responsible for the /orders endpoint." (find_handler)
  • "Propose a fix for the nil pointer exception in auth_service.go." (propose_fix)
  • "Debug the 500 error on the registration page."

Documentation

Overview

Package debugging provides debugging and codebase analysis tools for ZAP.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyzeEndpointParams

type AnalyzeEndpointParams struct {
	EndpointDescription string `json:"endpoint_description"`
	Method              string `json:"method"`
	URL                 string `json:"url"`
	SampleRequest       string `json:"sample_request,omitempty"`
	Context             string `json:"context,omitempty"`
}

AnalyzeEndpointParams defines input for analyze_endpoint

type AnalyzeEndpointTool

type AnalyzeEndpointTool struct {
	// contains filtered or unexported fields
}

AnalyzeEndpointTool uses LLM to analyze API endpoint structure

func NewAnalyzeEndpointTool

func NewAnalyzeEndpointTool(llmClient llm.LLMClient) *AnalyzeEndpointTool

NewAnalyzeEndpointTool creates a new analyze_endpoint tool

func (*AnalyzeEndpointTool) Description

func (t *AnalyzeEndpointTool) Description() string

func (*AnalyzeEndpointTool) Execute

func (t *AnalyzeEndpointTool) Execute(args string) (string, error)

func (*AnalyzeEndpointTool) Name

func (t *AnalyzeEndpointTool) Name() string

func (*AnalyzeEndpointTool) Parameters

func (t *AnalyzeEndpointTool) Parameters() string

type AnalyzeFailureParams

type AnalyzeFailureParams struct {
	TestResult       shared.TestResult `json:"test_result"`
	ResponseBody     string            `json:"response_body"`
	ExpectedBehavior string            `json:"expected_behavior"`
}

AnalyzeFailureParams defines input for analyze_failure

type AnalyzeFailureTool

type AnalyzeFailureTool struct {
	// contains filtered or unexported fields
}

AnalyzeFailureTool uses LLM to explain test failures

func NewAnalyzeFailureTool

func NewAnalyzeFailureTool(llmClient llm.LLMClient) *AnalyzeFailureTool

NewAnalyzeFailureTool creates a new analyze_failure tool

func (*AnalyzeFailureTool) Description

func (t *AnalyzeFailureTool) Description() string

func (*AnalyzeFailureTool) Execute

func (t *AnalyzeFailureTool) Execute(args string) (string, error)

func (*AnalyzeFailureTool) Name

func (t *AnalyzeFailureTool) Name() string

func (*AnalyzeFailureTool) Parameters

func (t *AnalyzeFailureTool) Parameters() string

type AutoFixParams

type AutoFixParams struct {
	Endpoint       string               `json:"endpoint"`                  // e.g. "POST /api/users"
	BaseURL        string               `json:"base_url"`                  // e.g. "http://localhost:8080"
	Scenario       *shared.TestScenario `json:"scenario,omitempty"`        // optional pre-built scenario
	ExpectedStatus int                  `json:"expected_status,omitempty"` // default 200
	MaxAttempts    int                  `json:"max_attempts,omitempty"`    // default 3
}

AutoFixParams defines input for auto_fix.

type AutoFixTool

type AutoFixTool struct {
	// contains filtered or unexported fields
}

AutoFixTool orchestrates the full fix-and-verify loop: run test → analyze failure → find handler → propose fix → write (with confirmation) → re-run test. Retries up to MaxAttempts times if each fix attempt still fails.

func NewAutoFixTool

func NewAutoFixTool(
	findHandler *FindHandlerTool,
	readFile *ReadFileTool,
	proposeFix *ProposeFixTool,
	writeFile *WriteFileTool,
	testExecutor *shared.TestExecutor,
	analyzeFailure *AnalyzeFailureTool,
) *AutoFixTool

NewAutoFixTool creates a new auto_fix orchestrator.

func (*AutoFixTool) Description

func (t *AutoFixTool) Description() string

func (*AutoFixTool) Execute

func (t *AutoFixTool) Execute(args string) (string, error)

func (*AutoFixTool) Name

func (t *AutoFixTool) Name() string

func (*AutoFixTool) Parameters

func (t *AutoFixTool) Parameters() string

func (*AutoFixTool) SetEventCallback

func (t *AutoFixTool) SetEventCallback(callback core.EventCallback)

SetEventCallback implements ConfirmableTool — propagates to WriteFileTool so the TUI confirmation dialog fires correctly when write_file is called internally.

type CreateTestFileParams

type CreateTestFileParams struct {
	HandlerFile   string `json:"handler_file"`
	Vulnerability string `json:"vulnerability"`
	FixApplied    bool   `json:"fix_applied"`
	Framework     string `json:"framework"`
}

type CreateTestFileTool

type CreateTestFileTool struct {
	// contains filtered or unexported fields
}

CreateTestFileTool generates framework-specific test files

func NewCreateTestFileTool

func NewCreateTestFileTool(llmClient llm.LLMClient) *CreateTestFileTool

func (*CreateTestFileTool) Description

func (t *CreateTestFileTool) Description() string

func (*CreateTestFileTool) Execute

func (t *CreateTestFileTool) Execute(args string) (string, error)

func (*CreateTestFileTool) Name

func (t *CreateTestFileTool) Name() string

func (*CreateTestFileTool) Parameters

func (t *CreateTestFileTool) Parameters() string

type FindHandlerParams

type FindHandlerParams struct {
	Endpoint  string `json:"endpoint"`
	Method    string `json:"method"`
	Path      string `json:"path"`
	Framework string `json:"framework"`
}

FindHandlerParams defines input for find_handler

type FindHandlerTool

type FindHandlerTool struct {
	// contains filtered or unexported fields
}

FindHandlerTool locates endpoint handlers in the codebase

func NewFindHandlerTool

func NewFindHandlerTool(workDir string) *FindHandlerTool

NewFindHandlerTool creates a new find_handler tool It internally creates a SearchCodeTool, which is also in the debugging package.

func (*FindHandlerTool) Description

func (t *FindHandlerTool) Description() string

func (*FindHandlerTool) Execute

func (t *FindHandlerTool) Execute(args string) (string, error)

func (*FindHandlerTool) Name

func (t *FindHandlerTool) Name() string

func (*FindHandlerTool) Parameters

func (t *FindHandlerTool) Parameters() string

type HandlerInfo

type HandlerInfo struct {
	File         string   `json:"file"`
	Line         int      `json:"line"`
	Content      string   `json:"content"`
	RelatedFiles []string `json:"related_files"`
	Analysis     string   `json:"analysis"`
}

HandlerInfo contains details about a discovered handler

type ListFilesTool

type ListFilesTool struct {
	// contains filtered or unexported fields
}

ListFilesTool lists files in a directory with glob patterns

func NewListFilesTool

func NewListFilesTool(workDir string) *ListFilesTool

NewListFilesTool creates a new file listing tool

func (*ListFilesTool) Description

func (t *ListFilesTool) Description() string

func (*ListFilesTool) Execute

func (t *ListFilesTool) Execute(args string) (string, error)

func (*ListFilesTool) Name

func (t *ListFilesTool) Name() string

func (*ListFilesTool) Parameters

func (t *ListFilesTool) Parameters() string

type ProposeFixParams

type ProposeFixParams struct {
	File          string `json:"file"`
	Vulnerability string `json:"vulnerability"`
	CurrentCode   string `json:"current_code"`
	FailedTest    string `json:"failed_test,omitempty"`
}

type ProposeFixTool

type ProposeFixTool struct {
	// contains filtered or unexported fields
}

ProposeFixTool generates and applies code fixes

func NewProposeFixTool

func NewProposeFixTool(llmClient llm.LLMClient, workDir string) *ProposeFixTool

NewProposeFixTool creates a new propose_fix tool

func (*ProposeFixTool) Description

func (t *ProposeFixTool) Description() string

func (*ProposeFixTool) Execute

func (t *ProposeFixTool) Execute(args string) (string, error)

func (*ProposeFixTool) Name

func (t *ProposeFixTool) Name() string

func (*ProposeFixTool) Parameters

func (t *ProposeFixTool) Parameters() string

type ReadFileTool

type ReadFileTool struct {
	// contains filtered or unexported fields
}

ReadFileTool reads file contents

func NewReadFileTool

func NewReadFileTool(workDir string) *ReadFileTool

NewReadFileTool creates a new file reading tool

func (*ReadFileTool) Description

func (t *ReadFileTool) Description() string

func (*ReadFileTool) Execute

func (t *ReadFileTool) Execute(args string) (string, error)

func (*ReadFileTool) Name

func (t *ReadFileTool) Name() string

func (*ReadFileTool) Parameters

func (t *ReadFileTool) Parameters() string

type SearchCodeTool

type SearchCodeTool struct {
	// contains filtered or unexported fields
}

SearchCodeTool searches for patterns in the codebase

func NewSearchCodeTool

func NewSearchCodeTool(workDir string) *SearchCodeTool

NewSearchCodeTool creates a new code search tool

func (*SearchCodeTool) Description

func (t *SearchCodeTool) Description() string

Description returns the tool description

func (*SearchCodeTool) Execute

func (t *SearchCodeTool) Execute(args string) (string, error)

Execute searches for patterns in the codebase

func (*SearchCodeTool) Name

func (t *SearchCodeTool) Name() string

Name returns the tool name

func (*SearchCodeTool) Parameters

func (t *SearchCodeTool) Parameters() string

Parameters returns the tool parameter description

type WriteFileParams

type WriteFileParams struct {
	Path    string `json:"path"`    // File path to write
	Content string `json:"content"` // Content to write
}

WriteFileParams defines the parameters for the write_file tool.

type WriteFileTool

type WriteFileTool struct {
	// contains filtered or unexported fields
}

WriteFileTool writes or modifies files with human-in-the-loop confirmation.

func NewWriteFileTool

func NewWriteFileTool(workDir string, confirmManager *shared.ConfirmationManager) *WriteFileTool

NewWriteFileTool creates a new file writing tool.

func (*WriteFileTool) Description

func (t *WriteFileTool) Description() string

Description returns the tool description.

func (*WriteFileTool) Execute

func (t *WriteFileTool) Execute(args string) (string, error)

Execute writes a file after user confirmation.

func (*WriteFileTool) Name

func (t *WriteFileTool) Name() string

Name returns the tool name.

func (*WriteFileTool) Parameters

func (t *WriteFileTool) Parameters() string

Parameters returns the tool parameter description.

func (*WriteFileTool) SetEventCallback

func (t *WriteFileTool) SetEventCallback(callback core.EventCallback)

SetEventCallback sets the callback for emitting events to the TUI. This implements the ConfirmableTool interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL