untrusted

package
v0.206.0 Latest Latest
Warning

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

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

Overview

Package untrusted handles text that came from someone else's page: the web_fetch and browse tools hand it to a model inside a fence, and offload_research hands a seat's digest of it to the caller (register SF-45, security standard gate G13). The same rules apply on both paths, so they live here once.

Index

Constants

This section is empty.

Variables

View Source
var Markers = []string{
	"<|im_start|>", "<|im_end|>", "<|system|>", "<|user|>", "<|assistant|>",
	"</system>", "<system>", "[INST]", "[/INST]", "### Instruction", "### System",
	"UNTRUSTED_WEB_CONTENT",
}

Markers are chat-template and instruction-header strings a page can plant to impersonate a role or the operator. Neutralizing them is belt-and-suspenders; the primary defense on every path is structural (the text travels as a JSON string value, so it cannot close a fence or a field).

Functions

func Bound

func Bound(s string, max int) string

Bound caps s at max characters (runes), never splitting one, and says how much it cut. max <= 0 leaves s whole.

func Sanitize

func Sanitize(s string) string

Sanitize drops zero-width, format and line-separator runes (used to hide a payload or break naive concatenation) and replaces every marker with "[neutralized]". Code points are tested numerically so the source stays ASCII.

func Value

func Value(v any, max int) (any, error)

Value sanitizes and bounds every string inside a JSON-shaped value (object keys included) and returns the result as plain JSON values. It round-trips through encoding/json with UseNumber, so numbers keep their exact text.

Types

This section is empty.

Jump to

Keyboard shortcuts

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