abuse

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 15 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 abuse is a web node's abuse reporting and enforcement, as an operator runs it on its own: signed reports arrive at the node, a report from a reporter the operator recognizes is applied to the deny list at once and any other waits for the operator, and every change to the list is appended to a log signed by the operator's key, naming the report it answers. Policy stays with each operator: nothing here binds another.

A report's fields are those the long-term report record carries (1bsv-ops docs/apps/bweb/abuse-plan.md section 3), so the same document rides a report channel on the plane when one exists.

Index

Constants

View Source
const MaxReport = 16 << 10

MaxReport bounds a report on the wire.

Variables

View Source
var Categories = []string{"phishing", "malware", "csam", "copyright", "fraud", "harassment", "spam", "other"}

Categories a report may name.

View Source
var ErrQueueFull = errors.New("the report queue is full: try again later")

ErrQueueFull refuses a report from a reporter not recognized while the queue is at its bound.

View Source
var Kinds = []string{"site", "owner", "host", "root", "sha256"}

Kinds are the targets a report or a deny entry names, as the deny list spells them: a site by its id, every site of an owner key, a host name, an object by its closure root or its content hash.

Functions

func Hashed

func Hashed(kind, value string) string

Hashed is the h: form of an entry.

func ParseEntry

func ParseEntry(e string) (kind, value string, err error)

ParseEntry reads kind:value, as a deny entry and a report's target spell it, and returns them lower case. A hashed entry is h:<64 hex>, the SHA-256 of another entry, so a list of the worst content can be shared without being a directory of it.

Types

type Action

type Action struct {
	Time      int64  `json:"time"`
	Decision  string `json:"decision"` // "refuse" or "decline"
	Entry     string `json:"entry,omitempty"`
	Report    string `json:"report"`
	Reporter  string `json:"reporter"`
	Category  string `json:"category"`
	How       string `json:"how"` // "recognized reporter" or "operator"
	Note      string `json:"note,omitempty"`
	Policy    string `json:"policy,omitempty"`
	Operator  string `json:"operator"`
	Signature string `json:"signature"`
}

Action is one decision, as the log keeps it.

func (*Action) Preimage

func (a *Action) Preimage() []byte

Preimage is what the operator signs for an action.

func (*Action) Verify

func (a *Action) Verify() bool

Verify checks an action's signature under its operator key.

type Desk

type Desk struct {
	Dir        string
	DenyFile   string
	Key        *ec.PrivateKey  // the operator's key: it signs each action
	Recognized map[string]bool // reporter keys whose reports apply at once
	Policy     string          // the operator's policy, named in each action
	Now        func() time.Time
	// MaxQueue bounds the reports waiting from reporters not recognized
	// (default 1,000): past it they are refused until the operator acts.
	MaxQueue int
	// contains filtered or unexported fields
}

Desk is an operator's handling of reports on one node: reports are kept under Dir/queue until decided and Dir/done after; the deny list at DenyFile is what the node refuses; Dir/actions.log is the signed record of every decision.

func (*Desk) Act

func (d *Desk) Act(id string, decline bool, note string) (*Action, error)

Act is the operator's decision on a queued report: refuse its target, or decline it, with a note.

func (*Desk) Log

func (d *Desk) Log() ([]Action, error)

Log is the actions taken, in order.

func (*Desk) Queue

func (d *Desk) Queue() ([]Report, error)

Queue is the reports waiting for the operator, oldest first.

func (*Desk) Take

func (d *Desk) Take(raw []byte) (status, id string, err error)

Take is a report as it arrives: checked, kept, and applied at once when its reporter is recognized. It answers "applied", "queued" or, for one seen before, "known".

type Report

type Report struct {
	Version      int    `json:"version"`
	Reporter     string `json:"reporter"` // a compressed key, 66 hex digits
	Target       string `json:"target"`   // kind:value, as a deny entry
	Category     string `json:"category"`
	Evidence     string `json:"evidence,omitempty"` // a reference: a URL, a case number
	Jurisdiction string `json:"jurisdiction,omitempty"`
	Action       string `json:"action"` // "refuse"
	Created      int64  `json:"created"`
	Signature    string `json:"signature"`
}

Report is one report of abuse. Signature is the reporter's, over Preimage, in DER and hex.

func (*Report) Check

func (r *Report) Check(now time.Time) error

Check holds a report to its rules and its signature, at now.

func (*Report) ID

func (r *Report) ID() string

ID is the report's name: the SHA-256 of its preimage, hex. The signature is left out, so the same report signed again, or its signature re-encoded (an ECDSA signature has two valid forms), is the same report.

func (*Report) Preimage

func (r *Report) Preimage() []byte

Preimage is what a reporter signs: its fields one a line, in order, under a fixed first line, so any language makes the same bytes. The evidence is carried by its SHA-256.

func (*Report) Sign

func (r *Report) Sign(key *ec.PrivateKey) error

Sign fills Reporter and Signature with key.

Jump to

Keyboard shortcuts

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