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), and a third, at ImagesPath, the images from other sites the user loaded in each document, which load again without asking (see Add).
Index ¶
- Constants
- func DefaultPath() (string, error)
- func ImagesPath() (string, error)
- func OutsidePath() (string, error)
- type Choice
- type Store
- func (st *Store) Add(file, item string) error
- func (st *Store) Allowed() []string
- func (st *Store) Ask(file string, ask func(paths []string) run.Answer) func(paths []string) run.Answer
- func (st *Store) Forget(file string) error
- func (st *Store) Has(file, item string) bool
- func (st *Store) Lookup(file string, sources []string) (allow, ok bool)
- func (st *Store) Remember(file string, sources []string, allow bool) error
Constants ¶
const Max = 500
Max is how many documents' answers are kept; the oldest go first.
const MaxItems = 200
MaxItems is how many items Add keeps for one document; the oldest go first.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
DefaultPath is mdsh/sources.json in the user's config folder.
func ImagesPath ¶ added in v1.7.0
ImagesPath is mdsh/images.json in the user's config folder, where the images from other sites each document's user chose to load are kept.
func OutsidePath ¶
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 OpenDefault ¶
func OpenDefault() *Store
OpenDefault opens the store at DefaultPath, or returns nil, which remembers nothing, if there is no config folder.
func OpenImages ¶ added in v1.7.0
func OpenImages() *Store
OpenImages opens the store at ImagesPath, 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) Add ¶ added in v1.7.0
Add puts item, such as an image's address, in file's list of allowed items, keeping the ones already there. It is for stores that grow an answer at a time, as ImagesPath's does, rather than answer a whole list at once.
func (*Store) Allowed ¶
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.