privpath

package
v0.138.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: BSD-3-Clause Imports: 6 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 privpath finds, and redacts, the paths, account names and document names of a person's own file system in text that is about to be published.

⛔⛔ WHY IT EXISTS. On 2026-11-09 three issues were filed on go-tex/engine whose bodies each carried `/Users/<account>/Documents/<project>/<file>.tex` — the reporter's home directory, their account name, their directory layout and the name of a document they had not published. Nobody noticed until the user asked "did you leak my name". Editing the bodies does not undo it: GitHub keeps the original under "edited" for anyone who opens the history, so the only real remedy is to delete and re-create.

The prose was accurate and useful; the path was decoration. That is the shape to catch — a citation of WHERE a measurement was taken, on a machine nobody else can reach, where the measurement itself is the content.

⛔ The rule it enforces, in the user's words: "pas de leak de nom ni de chemin/nom de fichier sur un file system utilisateur". Three things, not one — the account name, the path, AND the file name. Redacting only the home prefix leaves `<path elided>/Documents/fairshare-b300/fairshare-b300.tex`, which still publishes the project and the document. Each of the three also has to be caught ON ITS OWN, away from the path that revealed it: the leak had the path in the measurement section and the bare account in a session label below.

⛔ It is a GATE and not a lint, so its default is refusal. Every program that sends a body to a forge asks this package first, before the call, because the cost of a false negative is unrecallable and the cost of a false positive is one flag.

Index

Constants

View Source
const NamePlaceholder = "<name elided>"

NamePlaceholder replaces a bare name, and is distinct from Placeholder because the two read differently in a sentence: one stood where a location was, the other where a person or a document was.

View Source
const Placeholder = "<path elided>"

Placeholder is what a redaction leaves where a path was.

⛔ It is deliberately not an empty string: a sentence that said "measured on /Users/alice/thesis/main.tex" must still read as a sentence afterwards, or the redaction produces prose nobody can follow and the next person restores the path to make it legible again.

Variables

This section is empty.

Functions

func Accounts

func Accounts(text string) []string

Accounts returns only the account names, for a caller that wants to say whose machine a text named.

func Names

func Names(text string) []string

Names returns the account, project and document names text discloses through a path, in the form the bare-name pass hunts for.

⛔⛔ IT EXISTS BECAUSE Scan CANNOT BE ITS OWN ORACLE. Scan learns that a word is a name BY READING IT IN A PATH, so once a redaction has removed the path, a surviving bare name is invisible to Scan — re-scanning redacted output reports clean no matter what survived. Measured on 2026-11-09: with the bare-name replacement deliberately disabled, a "nothing left for Scan to find" test stayed GREEN on every body. Whatever checks a redaction must hold the names from BEFORE it.

func Redact

func Redact(text string) (string, int)

Redact rewrites text with every finding replaced, and reports how many.

⛔ It is a SEPARATE act from Scan, and both exist because neither is enough: scanning without redacting leaves the author to edit prose by hand at the moment they are most impatient, and redacting without scanning hides what was there. The count is returned so a caller can say what it changed rather than claim it was clean.

⛔⛔ IT MUST REMOVE EVERYTHING ScanKnown REFUSES, bare names included. The first version replaced the paths only, which made the gate and its fix disagree: `privscan --fix` would rewrite the body, the gate would refuse the result over the account name still in a session label, and the author — who had just run the fix — would reach for the waiver believing the gate broken. TestRedactLeavesNothingToFind is that contract, and it is checked against the names from before the redaction, because Scan goes blind once the path is gone.

func RedactKnown

func RedactKnown(text string, known []string) (string, int)

RedactKnown is Redact with names supplied from outside, so that the fix covers exactly what ScanKnown refuses.

func Self

func Self() (name string, generic bool)

Self returns this machine's account name and whether it is a generic one.

⛔⛔ THE THREE STATES ARE DIFFERENT AND MUST NOT PRINT ALIKE. Caught by CI on 2026-11-09, which is the only place this shows: on a GitHub runner the home directory is `/home/runner`, so SelfNames returns nothing — and a caller that has only SelfNames cannot tell "I could not read who I am" from "I read it, and it is a name that identifies nobody". The command printed the first sentence while the second was true, which is an instrument whose two outcomes read the same. Self reports them apart:

"", false     the home directory could not be read
"runner", true  read, and generic: nothing of this machine's to disclose
"alicia", false read, and personal: the name a sweep must look for

func SelfNames

func SelfNames() []string

SelfNames returns the name of the account running the program, as a list to be handed to ScanKnown or RedactKnown.

⛔ Every gate hunts it whether or not a path in the text revealed it, because the sweep's and the gate's hardest case is a text that names the account with NO path in it: a session label, a signature, a sentence. A scanner that can only learn names from paths calls such a text clean, and that is most of what there is to read. The 2026-11-09 leak was exactly this shape — the path in the measurement section, the bare account in a label further down.

⛔ A generic account returns nothing. On a CI runner the home directory is /home/runner, and hunting "runner" would refuse every sentence about the runner — the false positive that teaches a reader to waive by reflex.

Types

type Finding

type Finding struct {
	Line  int    // 1-indexed
	Col   int    // 1-indexed byte column, so an author can find it without being shown it
	Match string // the exact text matched
	Kind  string // "home path", "unc path", "account name", "document name", "name"
	Why   string // what a reader of the refusal needs to know
	// Account is WHOSE file system this finding names, when that is knowable.
	//
	// ⛔ It is here because a count cannot answer the question a sweep is run to
	// answer. "126 findings over six repositories" says nothing about whether
	// one of them is the owner of this machine, and that is the whole question.
	// Measured 2026-11-09: of ten accounts named across four organisations, one
	// was ours — and reading that from a list of 126 line numbers was not
	// possible until the findings carried whose they were.
	Account string
}

Finding is one place a text names a person's own file system.

func Scan

func Scan(text string) []Finding

Scan reports every place text names a person's own file system.

func ScanKnown

func ScanKnown(text string, known []string) []Finding

ScanKnown is Scan with names supplied from outside.

⛔ The fleet sweep needs it: an issue body can name the account or the document with no path anywhere in it — the 2026-11-09 leak had the path in one section and the bare account in a session label further down, and a body holding only the label is exactly as disclosed. A scanner that can only infer names from paths finds nothing in such a body and reports it clean.

func (Finding) Reveal

func (f Finding) Reveal() string

Reveal is String with the matched text, for a local run on the author's own machine (privscan --show). Never for a log.

func (Finding) String

func (f Finding) String() string

String describes the finding WITHOUT reprinting what it found.

⛔ A refusal is printed where the body was going to go, and that is sometimes a CI log on a public repository. A gate against publishing a path must not publish the path in the course of refusing it. The line and column locate it in a file the author already has; Reveal is for a local run that asks.

Jump to

Keyboard shortcuts

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