scriptlex

package
v1.135.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package scriptlex holds the lexical checks a managed script's source is put through before it is parsed: the Python instincts an agent brings to a Starlark file, answered with what to write instead, and the credential-shaped strings that must never be stored in one.

It reads text and nothing else. The checks that need the parse tree -- what a script reaches, the reserved words, the destinations -- stay with the validator in internal/platform/scriptrun, which folds these findings into its report.

Index

Constants

View Source
const (
	SeverityError   = "error"
	SeverityWarning = "warning"
)

Finding severities. An error means the script cannot run as written; a warning means it will run but somebody should look.

Variables

This section is empty.

Functions

func CodeOnly

func CodeOnly(source string) string

CodeOnly returns source with the contents of every string literal and every comment replaced by spaces, keeping the quotes, the newlines and every byte offset. The author-facing lexical checks read it instead of the raw text, so a string whose content is `f`, or a SQL column named datetime, is not taken for code (#1853). An unterminated literal is masked to the end of its line (or of the source, for a triple-quoted one); the parser reports it.

Types

type Finding

type Finding struct {
	Severity string `json:"severity"`
	Line     int    `json:"line,omitempty"`
	Message  string `json:"message"`
	Hint     string `json:"hint,omitempty"`
}

Finding is one thing a lexical check noticed, with the corrective action.

func Scan

func Scan(source string) []Finding

Scan runs the lexical checks. The author-facing ones read the code alone (CodeOnly); the secret ones read the raw source, because a pasted credential is inside a string literal.

Jump to

Keyboard shortcuts

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