the lock records what the source could be read as, and check audits it
Access is verified once, at fetch, and the copy is durable — so whether an adoption is still legitimate rests on the relative visibility of two repositories, which somebody can change with a checkbox a year later without ever seeing the adoption. The lock gains an optional fourth field and check turns that from a silent permanent hazard into something that runs. It costs nothing at add time, because the anonymous request already happened to decide whether to warn and the answer was being thrown away, and one request per run at check time rather than one per document, because only our own visibility has to be current. The stored value decays in both directions, so a source recorded not-public is re-probed only when the alarm would fire, and a source that has since gone public updates the lock and says nothing. Fixes a bug found while testing the alarm rather than after shipping it. sourceVisibility returned public whenever no credential was configured, which is sound at add time — the fetch had just succeeded anonymously — and wrong in the audit, where it is a probe and not a fetch: it would have silently cleared real alarms. Probing is now its own function that always asks with no credential, because what matters is what a stranger can read and not what we can. The value is recorded as public or not-public and never private: an anonymous request tells those apart and nothing finer, so it cannot see two repositories private to different people, which is the case that genuinely widens access. Three-field locks still load, and unknown visibility round-trips as absent rather than as a value. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018UTxuSizozEA8yDitPuris
This commit is contained in:
Vendored
+68
@@ -0,0 +1,68 @@
|
||||
package external
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"git.hypertheory-labs.dev/loom/loom-cli/internal/lock"
|
||||
)
|
||||
|
||||
// auditExposure reports documents adopted from a source that could not be read
|
||||
// anonymously, into a repository that now can.
|
||||
//
|
||||
// Access is verified once, at fetch, and the copy is durable. Whether the
|
||||
// adoption is still legitimate rests on the relative visibility of two
|
||||
// repositories — a fact somebody can change with a checkbox a year later,
|
||||
// without ever seeing the adoption. This is what turns that from a silent
|
||||
// permanent hazard into something that runs.
|
||||
func auditExposure(root string, locks *lock.Set, out io.Writer) (changed bool) {
|
||||
var suspect []lock.Record
|
||||
for _, r := range locks.All() {
|
||||
if r.Visibility == lock.NotPublic {
|
||||
suspect = append(suspect, r)
|
||||
}
|
||||
}
|
||||
if len(suspect) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
// Only our own visibility has to be current, and it is one request for the
|
||||
// whole run rather than one per document.
|
||||
public, known := selfVisibility(root)
|
||||
if known && !public {
|
||||
return false // adopted private into private; nothing has widened
|
||||
}
|
||||
if !known {
|
||||
fmt.Fprintf(out, "\n%d document(s) came from a source that needed a credential, and I cannot\n", len(suspect))
|
||||
fmt.Fprintf(out, "tell who may read this repository — no usable origin.\n")
|
||||
return false
|
||||
}
|
||||
|
||||
// The stored value decays in both directions. A source that has since gone
|
||||
// public would otherwise raise this alarm forever, so re-check — but only
|
||||
// the suspects, and only when the alarm would actually fire.
|
||||
var still []lock.Record
|
||||
for _, r := range suspect {
|
||||
// Probe with no credential: what matters is what a stranger can read,
|
||||
// not what we can.
|
||||
if probeAnonymous(r.URL) == lock.Public {
|
||||
r.Visibility = lock.Public
|
||||
locks.Put(r)
|
||||
changed = true
|
||||
continue
|
||||
}
|
||||
still = append(still, r)
|
||||
}
|
||||
if len(still) == 0 {
|
||||
return changed
|
||||
}
|
||||
|
||||
fmt.Fprintf(out, "\nEXPOSURE this repository is public and holds %d document(s) adopted from\n", len(still))
|
||||
fmt.Fprintf(out, " sources that are not:\n")
|
||||
for _, r := range still {
|
||||
fmt.Fprintf(out, " %s\n", r.Path)
|
||||
}
|
||||
fmt.Fprintf(out, " Confidentiality does not travel with the copy. This was legitimate\n")
|
||||
fmt.Fprintf(out, " when adopted if this repository was not public then.\n")
|
||||
return changed
|
||||
}
|
||||
Reference in New Issue
Block a user