Documentation
¶
Index ¶
- func DetectLanguage(code string) string
- func HasTestDeclaration(code, lang string) bool
- func IsSafePublicURL(raw string) bool
- func ParseAllows(code string) map[string]bool
- func RedactRetained(text string) string
- func RedactSensitive(text string) string
- func ScanCode(code string) []string
- func ValidateCommand(cmd string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectLanguage ¶
DetectLanguage returns one of "js" (Playwright/Jest/Cypress), "go", "rust", "python", or "" for an unrecognized shape. We need this because the "is this a test file" and "what's dangerous" checks are language-specific — `TestFoo(t *testing.T)` is valid Go testing but doesn't contain `test(`, so a Playwright-only scanner rejects it.
func HasTestDeclaration ¶
HasTestDeclaration returns true if the code contains an idiomatic test declaration for its detected language. Used as the "this looks like a test file, not arbitrary code" gate.
func IsSafePublicURL ¶
IsSafePublicURL reports whether raw is an http(s) URL pointing at a public hostname. It rejects:
- non-http(s) schemes (file:, javascript:, data:, gopher:, …)
- localhost, *.localhost, *.local, and the empty host
- every IPv6 literal ([::1], fd00::, …)
- every IPv4 literal in any resolver-accepted notation (dotted decimal/octal/ hex and the short a / a.b / a.b.c forms, plus a bare 32-bit integer)
A non-IP public hostname (example.com, mcp.linear.app, …) is allowed.
func ParseAllows ¶
ParseAllows extracts the set of rule names the file opts into via `// qmax:allow=...` markers. Returned as a set keyed by the exact rule name (e.g. `os/exec`, `exec.Command`). Missing markers => empty set => default-deny stays in effect.
func RedactRetained ¶
RedactRetained removes unambiguous credentials from content that is being persisted to a session file or transferred to another provider. It is deliberately narrower than RedactSensitive: retained content is replayed as the conversation itself, so over-matching destroys context that cannot be recovered.
func RedactSensitive ¶
RedactSensitive removes common credential shapes before text is shown, returned to the agent, or sent to optional telemetry.
func ScanCode ¶
ScanCode checks generated code for dangerous patterns. Returns a list of violations, or empty if code is safe.
func ValidateCommand ¶
ValidateCommand checks if a shell command is safe to execute. Returns empty string if safe, or reason if blocked.
Types ¶
This section is empty.