api

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package api holds the shared types for the vigolium.* JavaScript API surface: the namespace constants, the JSFuncDef declaration + handler factory, the APIOptions dependency bundle, and the APIFunction documentation record.

It is a leaf package: the jsext engine and each per-domain function package (api/parse, …) import it, but it imports nothing from jsext. This lets API domains live in their own subpackages while sharing one source of truth for the registry types.

Index

Constants

View Source
const (
	NsRoot       = "vigolium"
	NsLog        = "vigolium.log"
	NsUtils      = "vigolium.utils"
	NsParse      = "vigolium.parse"
	NsHTTP       = "vigolium.http"
	NsScan       = "vigolium.scan"
	NsIngest     = "vigolium.ingest"
	NsAgent      = "vigolium.agent"
	NsDB         = "vigolium.db"
	NsDBRecords  = "vigolium.db.records"
	NsDBFindings = "vigolium.db.findings"
	NsOAST       = "vigolium.oast"
	NsRecord     = "vigolium.record"
	NsConfig     = "vigolium.config"
	NsMCP        = "vigolium.mcp"
)

Namespace constants for the vigolium.* JS API.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIFunction

type APIFunction struct {
	Category    string // display category, e.g. "Encoding & Decoding"
	Namespace   string // e.g. "vigolium.log"
	Name        string // e.g. "info"
	Signature   string // e.g. ".info(msg: string)"
	Returns     string // e.g. "void"
	Description string // e.g. "Log an informational message."
	Example     string // e.g. `vigolium.log.info("scanning " + ctx.request.url)`
}

APIFunction describes a single JS API function for documentation.

func (APIFunction) FullName

func (f APIFunction) FullName() string

FullName returns the fully-qualified function name (e.g. "vigolium.utils.base64Encode").

type APIOptions

type APIOptions struct {
	ScriptID   string
	HTTPClient *http.Requester
	ConfigVars map[string]string

	// Scanner context (all nil-safe)
	ScopeMatcher *config.ScopeMatcher
	ScopeConfig  *config.ScopeConfig
	ScanUUID     string
	ProjectUUID  string

	// Security controls (from extensions config)
	AllowExec   bool   // gate for exec() and setEnv(); default false
	SandboxDir  string // base path for file ops; empty = cwd
	ExecTimeout int    // max seconds for exec(); default 30, cap 120

	// Finding emitter for hooks that want to create findings
	FindingEmitter func(*output.ResultEvent)

	// Database repository for ingest API (nil = ingest disabled)
	Repository *database.Repository

	// LLMClient enables vigolium.agent.* API (nil = disabled)
	LLMClient llm.Client

	// OASTService enables vigolium.oast.* API (nil = disabled)
	OASTService *oast.Service
}

APIOptions holds all context needed to set up the vigolium.* JS API on a VM.

type HandlerFactory

type HandlerFactory func(vm *sobek.Runtime, opts APIOptions) func(sobek.FunctionCall) sobek.Value

HandlerFactory creates a JS function handler given runtime dependencies. It is called once per VM setup, not per invocation.

type JSFuncDef

type JSFuncDef struct {
	Namespace   string
	Name        string
	Category    string
	Signature   string
	Returns     string
	Description string
	Example     string
	MakeHandler HandlerFactory // nil for metadata-only entries
}

JSFuncDef declares a JS API function with metadata and an optional handler factory. When MakeHandler is nil, the entry is metadata-only (e.g., dynamic config keys, per-request properties like vigolium.record.uuid).

func (JSFuncDef) FullName

func (d JSFuncDef) FullName() string

FullName returns the fully-qualified function name (e.g. "vigolium.utils.sha256").

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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