Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

v1 source realm

Package bouncer is Bouncer's on-chain registry: scan requests, attestations, disputes and author replies, plus the re...

Overview

Package bouncer is Bouncer's on-chain registry: scan requests, attestations, disputes and author replies, plus the reads other realms use (Check, Score) and the Tavern pages in Render.

One realm holds all state and every write, and every logic-data type is declared here (security guide §3A). Writes are crossing functions that check cur.IsCurrent() and take the caller from cur.Previous(). Reads are plain functions that return values or copies, never pointers into state, and never take callbacks.

Constants 4

const Disclaimer

1const Disclaimer = "A high score means Bouncer found no issues with its current rules. It is not a guarantee of safety."
source

Disclaimer is shown on every Passport.

Functions 31

func AddAttester

crossing Action
1func AddAttester(cur realm, addr address)
source

AddAttester allows addr to post attestations.

func AddDetail

crossing Action
1func AddDetail(cur realm, pkgpath string, id uint64, index int, snippet, attack, exploit, before, after string)
source

AddDetail attaches the vulnerable snippet and, for a PROVEN finding, the exploit and its evidence to finding index of attestation id. Only the attester who posted the attestation may call it, once per finding: the details are as permanent as the attestation itself.

func Attest

crossing Action
1func Attest(cur realm, pkgpath, sourceHash, scannerVersion, rulesetHash, toolchain, reportHash, reportURI, findings string, directAtRisk, indirectAtRisk, unverified int) uint64
source

Attest records a scan result for pkgpath. Attesters only. findings is a ";"-separated list of "RULE,severity,LABEL,file,line[,func]" entries ("" for none), in the report's order. Score, grade and verdict are computed here from the findings and dependency counts.

func Badge

Action
1func Badge(pkgpath string) string
source

Badge returns a Markdown image of pkgpath's live Bouncer badge (grade, score and attestation date), linked to its Passport. A realm shows it by adding one line to its Render:

Example
1out += bouncer.Badge("gno.land/r/<address>/myrealm")

The color follows the verdict, not the grade: a package with a PROVEN High finding is red even at grade B.

func ByAuthor

Action
1func ByAuthor(addr address) []string
source

ByAuthor returns the attested packages in addr's namespace, sorted.

func Check

Action
1func Check(pkgpath string, p Policy) bool
source

Check reports whether the latest attestation of pkgpath satisfies p. An unattested package never passes.

func CloseRequest

crossing Action
1func CloseRequest(cur realm, id uint64, note string)
source

CloseRequest lets an attester close a request it cannot serve, such as a package that does not exist.

func Dispute

crossing Action
1func Dispute(cur realm, pkgpath, reportHash, note string) uint64
source

Dispute files a challenge against the latest attestation of pkgpath, backed by a report with a different hash. One open dispute per filer per package.

func IsAttester

Action
1func IsAttester(addr address) bool
source

IsAttester reports whether addr may post attestations.

func LatestHashes

Action
1func LatestHashes(pkgpath string) string
source

LatestHashes returns "<source hash> <rule-set hash>" of pkgpath's latest attestation, or "" if there is none, so the bot can skip unchanged code.

func OpenRequestsText

Action
1func OpenRequestsText(limit int) string
source

OpenRequestsText is OpenRequests for the scanner bot, as plain text: one "id pkgpath" line per open request, oldest first. Package paths never contain spaces or newlines.

func RemoveAttester

crossing Action
1func RemoveAttester(cur realm, addr address)
source

RemoveAttester revokes addr. Its past attestations stay on record.

func Render

1func Render(path string) string
source

Render serves the Tavern pages:

Example
1""                 Noticeboard
2"realm/<pkgpath>"  Passport

func Reply

crossing Action
1func Reply(cur realm, pkgpath, note, successor string)
source

Reply lets the author of an address-namespace package answer its Passport and, optionally, name the fixed version (successor) in the same namespace.

func RequestScan

crossing Action
1func RequestScan(cur realm, pkgpath string) uint64
source

RequestScan asks the scanner bot to scan pkgpath. Each address may have one open request at a time.

func ResolveDispute

crossing Action
1func ResolveDispute(cur realm, id uint64, resolution string)
source

ResolveDispute closes a dispute with a resolution note. Admin or an attester.

func Score

Action
1func Score(pkgpath string) (int, bool)
source

Score returns the latest score for pkgpath.

func ScoreFor

Action
1func ScoreFor(fs []Finding, d Deps) (score int, grade, verdict string)
source

ScoreFor exposes the formula, so anyone can check an attestation or score a report before attesting it.

func Versions

Action
1func Versions(pkgpath string) []string
source

Versions returns every attested version of pkgpath's package, oldest first. A path without a /vN suffix is its own only version.

func History

Action
1func History(pkgpath string) []Attestation
source

History returns every attestation for pkgpath, oldest first.

func Latest

Action
1func Latest(pkgpath string) (Attestation, bool)
source

Latest returns the newest attestation for pkgpath.

func Replies

Action
1func Replies(pkgpath string) []AuthorReply
source

Replies returns the author's replies on pkgpath, oldest first.

func DisputesFor

Action
1func DisputesFor(pkgpath string) []DisputeRecord
source

DisputesFor returns copies of every dispute on pkgpath, oldest first.

func RuleGuidance

Action
1func RuleGuidance(rule string) (Guidance, bool)
source

RuleGuidance returns the guidance for rule, and false for a rule this realm has no guidance for yet.

func Custom

Action
1func Custom(minScore int) Policy
source

Custom starts a policy at minScore that is otherwise as strict as the zero value; loosen it with the With methods:

Example
1bouncer.Custom(60).WithProvenOther().WithOpenDisputes()

Other realms must build policies this way: the VM refuses to allocate a Bouncer type in a foreign realm, so a bouncer.Policy{...} literal written in another realm panics.

func Strict

Action
1func Strict() Policy
source

Strict: score 90 or more, no PROVEN findings, every dependency verified, no open disputes.

func OpenRequests

Action
1func OpenRequests(limit int) []Request
source

OpenRequests returns up to limit open requests, oldest first, for the scanner bot.

Types 8

type Attestation

struct
 1type Attestation struct {
 2	ID             uint64
 3	PkgPath        string
 4	SourceHash     string // sha256 of the scanned source, hex
 5	ScannerVersion string
 6	RulesetHash    string // hex
 7	Toolchain      string // gno version the exploits ran on
 8	ReportHash     string // sha256 of the full JSON report, hex
 9	ReportURI      string // where the full report lives (ipfs:// or https://)
10	Findings       []Finding
11	Deps           Deps
12	Score          int
13	Grade          string
14	Verdict        string
15	Attester       address
16	Height         int64
17	Time           int64 // unix seconds, block time
18}
source

Attestation is a scan result posted by an attester.

type AuthorReply

struct
1type AuthorReply struct {
2	Author    address
3	Note      string
4	Successor string // pkgpath of the fixed version, if any
5	Height    int64
6}
source

AuthorReply is an author's response to a Passport.

type Deps

struct
1type Deps struct {
2	DirectAtRisk   int
3	IndirectAtRisk int
4	Unverified     int
5}
source

Deps counts dependency trust for an attestation.

type DisputeRecord

struct
 1type DisputeRecord struct {
 2	ID            uint64
 3	PkgPath       string
 4	AttestationID uint64 // the attestation disputed (the latest at filing time)
 5	ReportHash    string // the disputer's report
 6	Note          string
 7	Filer         address
 8	Height        int64
 9	Resolved      bool
10	Resolution    string
11}
source

DisputeRecord is a challenge to an attestation, backed by a different report.

type Finding

struct
 1type Finding struct {
 2	Rule     string // B01 ...
 3	Severity string // critical, high, medium
 4	Label    string // PROVEN, NOT REPRODUCED, STATIC WARNING
 5	File     string
 6	Line     int
 7	Func     string // enclosing function, if known
 8
 9	Detailed bool   // AddDetail has run for this finding
10	Snippet  string // the vulnerable code
11	Attack   string // what the exploit did, one line (PROVEN only)
12	Exploit  string // the attacker source that ran (PROVEN only)
13	Before   string // evidence before the attack (PROVEN only)
14	After    string // evidence after the attack (PROVEN only)
15}
source

Finding is one attested finding. The detail fields (Snippet onward) are filled once, after Attest, by AddDetail.

type Guidance

struct
1type Guidance struct {
2	Title   string // short name of the bug class
3	Guide   string // security guide sections
4	Meaning string // what the finding means
5	Danger  string // why it is dangerous
6	Fix     string // what to change
7	Example string // the fixed code, Gno
8	Why     string // why the fix works
9}
source

Guidance is the fix guidance for one rule. It is written once per rule, so every Passport says the same thing and it costs nothing per finding.

type Policy

struct
 1type Policy struct {
 2	MinScore int
 3	// AllowProvenCritical and AllowProvenOther permit PROVEN findings of
 4	// critical, or of high and medium, severity.
 5	AllowProvenCritical bool
 6	AllowProvenOther    bool
 7	// RequireVerifiedDeps forbids at-risk and unverified dependencies.
 8	RequireVerifiedDeps bool
 9	AllowOpenDisputes   bool
10}
source

Policy is an integration policy for Check. The zero value is the most conservative: no PROVEN findings, no open disputes, any score.

Methods on Policy

func WithOpenDisputes

method on Policy
1func (p Policy) WithOpenDisputes() Policy
source

WithOpenDisputes allows open disputes.

func WithProvenCritical

method on Policy
1func (p Policy) WithProvenCritical() Policy
source

WithProvenCritical allows PROVEN critical findings.

func WithProvenOther

method on Policy
1func (p Policy) WithProvenOther() Policy
source

WithProvenOther allows PROVEN high and medium findings.

func WithVerifiedDeps

method on Policy
1func (p Policy) WithVerifiedDeps() Policy
source

WithVerifiedDeps requires every dependency to be verified.

type Request

struct
 1type Request struct {
 2	ID        uint64
 3	PkgPath   string
 4	Requester address
 5	Height    int64
 6	// Status is "open", "attested", "cancelled" or "closed".
 7	Status string
 8	// Note explains a closed request.
 9	Note string
10}
source

Request is a scan request, as returned by reads.

Dependencies

Source Files 18