trust

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 9 Imported by: ? 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 trust remembers, for each document, whether its user let mdsh read the files the front matter's env.source names into its shells, so that mdsh, mdsh -i and mdsh-gui ask once per file, and again only when the list of files changes. The answers live in one JSON file, shared by every front end. A second store, at OutsidePath, keeps in the same way whether a document's includes and out= files may reach outside its folder, or hidden in it (see run.Outside).

Index

Constants

View Source
const Max = 500

Max is how many documents' answers are kept; the oldest go first.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath is mdsh/sources.json in the user's config folder.

func OutsidePath

func OutsidePath() (string, error)

OutsidePath is mdsh/outside.json in the user's config folder, where the answers to whether a document may reach outside its root live.

Types

type Choice

type Choice struct {
	// File is the document's absolute path.
	File string `json:"file"`
	// Sources are the files approved or refused, as run.SourcePaths
	// gives them. A document that names other files is asked again.
	Sources []string `json:"sources"`
	// Allow is whether they may be read.
	Allow bool `json:"allow"`
	// At is when the answer was given.
	At time.Time `json:"at"`
}

Choice is the answer for one document.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store keeps the answers in a JSON file. It reads the file on each lookup, so an answer given in one front end holds in the others.

func Open

func Open(path string) *Store

Open returns the store kept in path. The file is made on the first answer.

func OpenDefault

func OpenDefault() *Store

OpenDefault opens the store at DefaultPath, or returns nil, which remembers nothing, if there is no config folder.

func OpenOutside

func OpenOutside() *Store

OpenOutside opens the store at OutsidePath, or returns nil, which remembers nothing, if there is no config folder.

func (*Store) Allowed

func (st *Store) Allowed() []string

Allowed lists the documents whose last answer allowed them, whatever their lists were then.

func (*Store) Ask

func (st *Store) Ask(file string, ask func(paths []string) run.Answer) func(paths []string) run.Answer

Ask returns a run.Options.ApproveSources for the document at file that answers from the store when it can and otherwise asks ask, which may be nil when nobody can be asked. A Go or Skip answer from ask is remembered; Stop isn't, so the next run asks again.

func (*Store) Forget

func (st *Store) Forget(file string) error

Forget drops the answer for file, so it is asked again.

func (*Store) Lookup

func (st *Store) Lookup(file string, sources []string) (allow, ok bool)

Lookup returns the answer given for file when it named sources, if there is one.

func (*Store) Remember

func (st *Store) Remember(file string, sources []string, allow bool) error

Remember keeps allow as the answer for file naming sources, in place of any earlier answer for file.

Jump to

Keyboard shortcuts

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