safety

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 13 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

View Source
const (
	PolicyFileName   = "safety-policy.json"
	EnvPolicyEnabled = "VOLCENGINE_SAFETY_POLICY_ENABLED"
	EnvPolicyRules   = "VOLCENGINE_SAFETY_POLICY_RULES"
	EnvSkipConfirm   = "VOLCENGINE_SAFETY_SKIP_CONFIRM"
)
View Source
const ConfirmationNeededMessage = "" /* 494-byte string literal not displayed */

ConfirmationNeededMessage is shared by the default and localized CLI/MCP errors.

View Source
const MCPApprovalDescription = "" /* 232-byte string literal not displayed */

MCPApprovalDescription describes the same approval flow for tool discovery, before a confirmation error exists. It is guidance, not a one-use token.

Variables

This section is empty.

Functions

func CheckAndConfirm

func CheckAndConfirm(input io.Reader, output io.Writer, interactive bool, policy *Policy, command CommandInfo, skipConfirm bool, retryInstruction string) error

func CheckAndConfirmWithMessages

func CheckAndConfirmWithMessages(input io.Reader, output io.Writer, interactive bool, policy *Policy, command CommandInfo, skipConfirm bool, retryInstruction string, messages Messages) error

func IsInteractive

func IsInteractive(input io.Reader) bool

func PolicyFilePath

func PolicyFilePath(configDir string) string

func SavePolicy

func SavePolicy(configDir string, policy *Policy) error

func SkipConfirmFromEnvironment

func SkipConfirmFromEnvironment() bool

Types

type Action

type Action string
const (
	ActionAllow   Action = "allow"
	ActionDeny    Action = "deny"
	ActionConfirm Action = "confirm"
)

type CheckResult

type CheckResult struct {
	Action  Action
	Matched bool
	Rule    *Rule
}

type CommandInfo

type CommandInfo struct {
	Product string
	// ProductAliases are other spellings of the same service. A rule written
	// with any of them applies to Product.
	ProductAliases []string
	Action         string
}

type Messages

type Messages struct {
	Denied              string
	ConfirmationNeeded  string
	Prompt              string
	InputUnavailable    string
	ConfirmationReadErr string
	Cancelled           string
}

type Policy

type Policy struct {
	Enabled bool   `json:"enabled"`
	Rules   []Rule `json:"rules"`
}

func DefaultPolicy

func DefaultPolicy() *Policy

func LoadEffectivePolicy

func LoadEffectivePolicy(configDir string) (*Policy, error)

func LoadPolicy

func LoadPolicy(configDir string) (*Policy, error)

func (*Policy) Check

func (p *Policy) Check(command CommandInfo) CheckResult

type Rule

type Rule struct {
	Pattern string `json:"pattern"`
	Action  Action `json:"action"`
}

Jump to

Keyboard shortcuts

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