Documentation
¶
Overview ¶
Package oxcodes provides an HTTP client for the ox-codes search service.
Package oxcodes — dataflow analysis types and client methods.
Index ¶
- type Client
- func (c *Client) DataflowAnalyze(ctx context.Context, input DataflowInput) (*DataflowResponse, error)
- func (c *Client) DataflowTaint(ctx context.Context, input TaintInput) (*TaintResponse, error)
- func (c *Client) Rewrite(ctx context.Context, input RewriteInput) (*RewriteResponse, error)
- func (c *Client) Search(ctx context.Context, input SearchInput) (*SearchResponse, error)
- func (c *Client) SearchScoped(ctx context.Context, input ScopedSearchInput) (*SearchResponse, error)
- func (c *Client) SearchStructural(ctx context.Context, input StructuralSearchInput) (*SearchResponse, error)
- type DataflowFinding
- type DataflowInput
- type DataflowResponse
- type DataflowSpan
- type ExpandedBlock
- type RewriteFileResult
- type RewriteInput
- type RewriteResponse
- type Sanitizer
- type ScopedSearchInput
- type SearchInput
- type SearchMatch
- type SearchResponse
- type StructuralSearchInput
- type TaintFinding
- type TaintInput
- type TaintResponse
- type TaintRule
- type TaintSink
- type TaintSinkInfo
- type TaintSource
- type TaintSourceInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls ox-codes HTTP API.
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"`
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 RewriteResponse ¶
type RewriteResponse struct {
Files []RewriteFileResult `json:"files"`
TotalMatches int `json:"total_matches"`
TotalFiles int `json:"total_files"`
DurationMS int64 `json:"duration_ms"`
}
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"`
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 ¶
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.