script

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package script embeds a Lua 5.1 runtime (gopher-lua) so users can write small probes that run against open ports. See scry-plan.md §7 for the design discussion.

A script defines three globals:

description = "one-line summary shown in --help / --list-scripts"
ports       = {80, 443}        -- table of ports; or "any" for every port
function run(host, port)
  ...
  return "finding string"      -- or return nil, "reason"
end

A fresh Lua state is created for each run, so scripts cannot leak state between invocations. The API surface is registered under the global `scry` table; see api*.go for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine runs a collection of scripts against (host, port) pairs.

func NewEngine

func NewEngine(scripts []*Script, timeout time.Duration) *Engine

NewEngine returns an Engine configured with a per-call timeout. timeout<=0 uses a 5s default.

func (*Engine) RunAll

func (e *Engine) RunAll(ctx context.Context, host string, port uint16) []Finding

RunAll invokes every script whose Matches(port) reports true, in order, returning the collected findings. Errors returned by a script are logged into the finding slice as "error: ..." so the caller can surface them in output rather than silently dropping them.

type Finding

type Finding struct {
	Script string // Script.Name
	Output string // what run() returned
}

Finding is the result of one script run.

type Script

type Script struct {
	Name        string   // basename of the file, minus extension
	Path        string   // absolute path used to re-compile
	Description string   // from `description` global
	Ports       []uint16 // from `ports` table; empty + AnyPort false = no ports
	AnyPort     bool     // set when `ports = "any"`
	// contains filtered or unexported fields
}

Script is a compiled, metadata-parsed Lua script ready to run.

func Load

func Load(path string) (*Script, error)

Load reads and compiles a single script file, extracting metadata. It does not run the script's `run` function.

func (*Script) Matches

func (s *Script) Matches(port uint16) bool

Matches reports whether this script should run against port.

Jump to

Keyboard shortcuts

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