security

package
v1.40.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectLanguage

func DetectLanguage(code string) string

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

func HasTestDeclaration(code, lang string) bool

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

func IsSafePublicURL(raw string) bool

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

func ParseAllows(code string) map[string]bool

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

func RedactRetained(text string) string

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

func RedactSensitive(text string) string

RedactSensitive removes common credential shapes before text is shown, returned to the agent, or sent to optional telemetry.

func ScanCode

func ScanCode(code string) []string

ScanCode checks generated code for dangerous patterns. Returns a list of violations, or empty if code is safe.

func ValidateCommand

func ValidateCommand(cmd string) string

ValidateCommand checks if a shell command is safe to execute. Returns empty string if safe, or reason if blocked.

Types

This section is empty.

Jump to

Keyboard shortcuts

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