oxcodes

package
v1.37.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package oxcodes provides an HTTP client for the ox-codes search service.

Package oxcodes — dataflow analysis types and client methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheStats added in v1.34.0

type CacheStats struct {
	Hits       int `json:"hits"`
	Misses     int `json:"misses"`
	EntryCount int `json:"entry_count"`
}

CacheStats holds hit/miss counters for a cache.

type CacheStatsResponse added in v1.34.0

type CacheStatsResponse struct {
	Scope    CacheStats `json:"scope"`
	Dataflow CacheStats `json:"dataflow"`
	Walks    WalkStats  `json:"walks"`
}

CacheStatsResponse mirrors ox-codes GET /cache/stats response.

type Client

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

Client calls ox-codes HTTP API.

func NewClient

func NewClient(baseURL string) *Client

NewClient creates an ox-codes client.

func (*Client) CacheStats added in v1.34.0

func (c *Client) CacheStats(ctx context.Context) (*CacheStatsResponse, error)

CacheStats calls GET /cache/stats.

func (*Client) DataflowAnalyze

func (c *Client) DataflowAnalyze(ctx context.Context, input DataflowInput) (*DataflowResponse, error)

DataflowAnalyze calls POST /dataflow/analyze.

func (*Client) DataflowTaint

func (c *Client) DataflowTaint(ctx context.Context, input TaintInput) (*TaintResponse, error)

DataflowTaint calls POST /dataflow/taint.

func (*Client) Rewrite

func (c *Client) Rewrite(ctx context.Context, input RewriteInput) (*RewriteResponse, error)

Rewrite calls POST /rewrite.

func (*Client) Search

func (c *Client) Search(ctx context.Context, input SearchInput) (*SearchResponse, error)

Search calls POST /search.

func (*Client) SearchScoped

func (c *Client) SearchScoped(ctx context.Context, input ScopedSearchInput) (*SearchResponse, error)

SearchScoped calls POST /search/scoped.

func (*Client) SearchStructural

func (c *Client) SearchStructural(ctx context.Context, input StructuralSearchInput) (*SearchResponse, error)

SearchStructural calls POST /search/structural.

type DataflowFinding

type DataflowFinding struct {
	Kind     string       `json:"kind"`
	Severity string       `json:"severity"`
	Message  string       `json:"message"`
	File     string       `json:"file"`
	Span     DataflowSpan `json:"span"`
	Variable string       `json:"variable"`
}

DataflowFinding represents a single quality finding (dead store, unused var, etc.).

type DataflowInput

type DataflowInput struct {
	Root        string `json:"root"`
	Language    string `json:"language"`
	MaxResults  int    `json:"max_results"`
	FileGlob    string `json:"file_glob,omitempty"`
	ExcludeGlob string `json:"exclude_glob,omitempty"`
}

DataflowInput is the request for POST /dataflow/analyze.

type DataflowResponse

type DataflowResponse struct {
	Findings      []DataflowFinding `json:"findings"`
	TotalFindings int               `json:"total_findings"`
	FilesAnalyzed int               `json:"files_analyzed"`
	Truncated     bool              `json:"truncated"`
	DurationMS    int64             `json:"duration_ms"`
}

DataflowResponse is the response from POST /dataflow/analyze.

type DataflowSpan

type DataflowSpan struct {
	StartByte int `json:"start_byte"`
	EndByte   int `json:"end_byte"`
	StartLine int `json:"start_line"`
	EndLine   int `json:"end_line"`
}

DataflowSpan represents a byte/line range in source code.

type ExpandedBlock

type ExpandedBlock struct {
	SymbolName string `json:"symbol_name"`
	SymbolKind string `json:"symbol_kind"`
	LineStart  int    `json:"line_start"`
	LineEnd    int    `json:"line_end"`
	Body       string `json:"body"`
}

ExpandedBlock holds the expanded AST context for a match.

type RewriteFileResult

type RewriteFileResult struct {
	File    string `json:"file"`
	Matches int    `json:"matches"`
	Diff    string `json:"diff"`
}

RewriteFileResult holds the per-file rewrite result.

type RewriteInput

type RewriteInput struct {
	Root        string `json:"root"`
	Pattern     string `json:"pattern"`
	Rewrite     string `json:"rewrite"`
	Language    string `json:"language,omitempty"` // omit when empty; server rejects "" anyway
	MaxResults  int    `json:"max_results"`
	FileGlob    string `json:"file_glob,omitempty"`
	ExcludeGlob string `json:"exclude_glob,omitempty"`
	Apply       bool   `json:"apply,omitempty"`
}

RewriteInput mirrors ox-codes /rewrite request.

type RewriteRejection added in v1.34.0

type RewriteRejection struct {
	File   string `json:"file"`
	Reason string `json:"reason"`
}

RewriteRejection holds a file whose re-parse invariant failed and was NOT persisted. The batch continues past these so valid files still land.

type RewriteResponse

type RewriteResponse struct {
	Files        []RewriteFileResult `json:"files"`
	TotalMatches int                 `json:"total_matches"`
	TotalSkipped int                 `json:"total_skipped,omitempty"`
	TotalFiles   int                 `json:"total_files"`
	DurationMS   int64               `json:"duration_ms"`
	Rejected     []RewriteRejection  `json:"rejected,omitempty"`
}

RewriteResponse mirrors ox-codes /rewrite response.

type Sanitizer

type Sanitizer struct {
	Pattern string `json:"pattern"`
}

Sanitizer defines a function that neutralizes tainted data.

type ScopedSearchInput

type ScopedSearchInput struct {
	Root          string `json:"root"`
	Pattern       string `json:"pattern"`
	Scope         string `json:"scope"`
	Language      string `json:"language,omitempty"` // omitempty: empty language omitted; ox-codes /search/scoped rejects ""
	IsRegex       bool   `json:"is_regex"`
	MaxResults    int    `json:"max_results"`
	CaseSensitive bool   `json:"case_sensitive"`
	FileGlob      string `json:"file_glob,omitempty"`
	ExcludeGlob   string `json:"exclude_glob,omitempty"`
	Expand        string `json:"expand,omitempty"`
	MaxTokens     int    `json:"max_tokens,omitempty"`
	Format        string `json:"format,omitempty"` // "markdown" wraps expanded bodies in “`lang fences
}

ScopedSearchInput mirrors ox-codes /search/scoped request.

type SearchInput

type SearchInput struct {
	Root          string `json:"root"`
	Pattern       string `json:"pattern"`
	IsRegex       bool   `json:"is_regex"`
	FileGlob      string `json:"file_glob,omitempty"`
	ExcludeGlob   string `json:"exclude_glob,omitempty"`
	ContextLines  int    `json:"context_lines"`
	MaxResults    int    `json:"max_results"`
	CaseSensitive bool   `json:"case_sensitive"`
	Language      string `json:"language,omitempty"`
	Expand        string `json:"expand,omitempty"`
	MaxTokens     int    `json:"max_tokens,omitempty"`
	Format        string `json:"format,omitempty"` // "markdown" wraps expanded bodies in “`lang fences
}

SearchInput mirrors ox-codes /search request.

type SearchMatch

type SearchMatch struct {
	File     string         `json:"file"`
	Line     int            `json:"line"`
	Text     string         `json:"text"`
	Context  []string       `json:"context,omitempty"`
	Expanded *ExpandedBlock `json:"expanded,omitempty"`
}

SearchMatch mirrors ox-codes match.

type SearchResponse

type SearchResponse struct {
	Matches      []SearchMatch `json:"matches"`
	TotalMatches int           `json:"total_matches"`
	Truncated    bool          `json:"truncated"`
	DurationMS   int64         `json:"duration_ms"`
}

SearchResponse mirrors ox-codes response.

type StructuralSearchInput

type StructuralSearchInput struct {
	Root        string `json:"root"`
	Pattern     string `json:"pattern"`
	Language    string `json:"language,omitempty"` // omit when empty; server rejects "" anyway
	MaxResults  int    `json:"max_results"`
	ExcludeGlob string `json:"exclude_glob,omitempty"`
	Expand      string `json:"expand,omitempty"`
	MaxTokens   int    `json:"max_tokens,omitempty"`
	Format      string `json:"format,omitempty"` // "markdown" wraps expanded bodies in “`lang fences
}

StructuralSearchInput mirrors ox-codes /search/structural request.

type TaintFinding

type TaintFinding struct {
	RuleID   string          `json:"rule_id"`
	Source   TaintSourceInfo `json:"source"`
	Sink     TaintSinkInfo   `json:"sink"`
	Severity string          `json:"severity"`
	Message  string          `json:"message"`
	File     string          `json:"file"`
}

TaintFinding represents a single taint-tracking finding.

type TaintInput

type TaintInput struct {
	Root        string      `json:"root"`
	Language    string      `json:"language"`
	Rules       []TaintRule `json:"rules,omitempty"`
	MaxResults  int         `json:"max_results"`
	FileGlob    string      `json:"file_glob,omitempty"`
	ExcludeGlob string      `json:"exclude_glob,omitempty"`
}

TaintInput is the request for POST /dataflow/taint.

type TaintResponse

type TaintResponse struct {
	Findings      []TaintFinding `json:"findings"`
	TotalFindings int            `json:"total_findings"`
	FilesAnalyzed int            `json:"files_analyzed"`
	Truncated     bool           `json:"truncated"`
	DurationMS    int64          `json:"duration_ms"`
}

TaintResponse is the response from POST /dataflow/taint.

type TaintRule

type TaintRule struct {
	ID         string        `json:"id"`
	Sources    []TaintSource `json:"sources"`
	Sinks      []TaintSink   `json:"sinks"`
	Sanitizers []Sanitizer   `json:"sanitizers,omitempty"`
	Severity   string        `json:"severity"`
}

TaintRule defines a custom taint-tracking rule.

type TaintSink

type TaintSink struct {
	Pattern     string `json:"pattern"`
	ArgIndex    int    `json:"arg_index"`
	CWE         string `json:"cwe"`
	Description string `json:"description"`
}

TaintSink defines where tainted data must not flow.

type TaintSinkInfo

type TaintSinkInfo struct {
	Function string       `json:"function"`
	Span     DataflowSpan `json:"span"`
	ArgIndex int          `json:"arg_index"`
	CWE      string       `json:"cwe"`
}

TaintSinkInfo describes the sink location in a taint finding.

type TaintSource

type TaintSource struct {
	Pattern string `json:"pattern"`
	Tag     string `json:"tag"`
}

TaintSource defines where tainted data originates.

type TaintSourceInfo

type TaintSourceInfo struct {
	Function string       `json:"function"`
	Span     DataflowSpan `json:"span"`
}

TaintSourceInfo describes the source location in a taint finding.

type WalkStats added in v1.34.0

type WalkStats struct {
	InFlight      int   `json:"in_flight"`
	OldestStartMS int64 `json:"oldest_start_ms"`
}

WalkStats holds walk-pool statistics.

Jump to

Keyboard shortcuts

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