sourcerule

package
v1.166.3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 7 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 sourcerule is who may run a managed script for which webhook source (#2332). A run reads every event its source stores, so naming a source is reading it: an administrator may name any source, and anyone else only the source made for a form whose script they own.

Index

Constants

This section is empty.

Variables

View Source
var ErrSourceRefused = errors.New("this script cannot run for that webhook source")

ErrSourceRefused is a script naming a webhook source its owner may not run it for.

Functions

func OwnerOf

func OwnerOf(get func(ctx context.Context, id string) (*script.Script, error)) func(ctx context.Context, scriptID string) (string, error)

OwnerOf is Rule.FormOwner over a script read: the owner's email of the script with the id, "" for a script that does not exist, which owns nothing.

Types

type Rule

type Rule struct {
	Sources SourceReader
	// FormOwner is the owner's email of the script a form source was made
	// for.
	FormOwner func(ctx context.Context, scriptID string) (string, error)
}

Rule is who may run a script for which webhook source (#2332). A run reads every event the source stores, so naming a source is reading it: an administrator may name any source, and anyone else only the source made for a form whose script they own, which holds the submissions their own form collected.

func NewRule

func NewRule(db *sql.DB, get func(ctx context.Context, id string) (*script.Script, error)) *Rule

NewRule is the rule over the stored webhook sources and the scripts get reads, nil without a database. A source is read only for its name and its form, so its secrets are not decrypted.

func (*Rule) Check

func (r *Rule) Check(ctx context.Context, source, callerEmail string, admin bool) error

Check reports why a script may not run for source when the caller names it in a webhook handler (#2434), nil when it may. A nil Rule refuses every source: the deployment has none.

type SourceReader

type SourceReader interface {
	Get(ctx context.Context, name string) (whsource.Source, error)
}

SourceReader reads a webhook source by name (whsource.Store).

Jump to

Keyboard shortcuts

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