netube99 (X, 2119721422918742222): masking is switched on in Plugins ›
Built-in, set in Settings › Privacy and seen in Insights › Masking, and
none of the three leads to the others. Web search had the same split.
One pattern for every built-in whose switch, settings and page are apart:
- pluginrt.Manifest.SetAt ("privacy #redactList") says where Settings has
its settings: redact, search, gateway and otel set one. builtins.go
sends setAt and page (its nav.page Part).
- Its Built-in row (featGo): "Settings › <tab>" and, while on, its page
("Masking"). No settings link while off when those settings hide with
the plugin (Observability).
- Its settings, while off (featOff): a first row "Off in Plugins ›
Built-in", what being off means, and Turn on. Privacy and Web search
use it; search's own off row went.
- Insights › Masking's head: "Settings › Privacy", unless Turn off
already goes there. At 600px and under its buttons wrap below the title.
- docs/subsystems/plugin-runtime.md documents SetAt.
Proposal for the owner, not built: give each feature one home with its
switch, settings and page together. This commit only links the three.
Core budget: no raise. +~1.9KB of code is paid for by shortening six
app.js comments (logo mask shelf, copy, sidebar, account models,
fitSend, the hold room).
Run on mote at fe672ce69's tree (origin/main 2b22425b4 + these two):
- go vet ./internal/gui ./internal/pluginrt ./plugins/...;
GOOS=linux -tags nogui and GOOS=windows vet of gui and plugins: clean.
gofmt -l: clean.
- go test -run 'TestBuiltin|TestCoreScriptBudget|Translated'
./internal/gui ./internal/pluginrt: ok (budget passes after the cuts).
- node --test builtin-places, websearch-places, builtins, i18n-keys,
i18n-en-no-cjk: 235 pass, 1 fail. The fail is i18n-keys "a plugin's
words are its own" on plugins/usage "View routing", red on origin/main
too (#5332, #5426, #5482).
builtin-places and websearch-places cover en, zh, zh-TW, ja and de in
Chromium and WebKit, at 1100 and 420 wide, nothing past the edge.
Broken by hand: featGo and featOff made to return at once, and 40
builtin-places subtests went red (42 fails with their parents). Round 1's
files reverted made websearch-places 102 of 142 red.
Queued, not waited for (owner: push each verified fix at once): the full
`go test -timeout 45m ./...` then `make test-ui` on mote behind
~/suite.lock; log at
~/workspace/projects/magpie-wt/websearch-surfaces-scratch/full.log. Any
red gets an issue.
Not tried: the real app on Linux/Windows; warm-ups have no SetAt (their
settings moved into the provider editor).
48 lines
1.7 KiB
Go
48 lines
1.7 KiB
Go
// Package redact is Settings → Privacy's masking: secrets, personal data
|
||
// and the user's own words go to a vendor as placeholders, and come back
|
||
// as they were. While the settings ask for any of it, it stays on.
|
||
//
|
||
// It is the masker of the gateway's middleware point (P3 of
|
||
// docs/subsystems/plugin-runtime.md): Apply serves masking.Masker, and the point
|
||
// fails closed: a request the settings say to mask is not sent while no
|
||
// masker serves it. The logs' and archives' scrubbing (redact.Scrub) is
|
||
// the core's, whatever the settings say.
|
||
package redact
|
||
|
||
import (
|
||
"github.com/yetone/magpie/internal/gwmw"
|
||
"github.com/yetone/magpie/internal/masking"
|
||
"github.com/yetone/magpie/internal/pluginrt"
|
||
"github.com/yetone/magpie/internal/settings"
|
||
)
|
||
|
||
func init() {
|
||
pluginrt.Register(pluginrt.Manifest{
|
||
ID: "redact", API: "^1", Requires: []string{"settings", "gateway"}, Essential: true,
|
||
Name: "Privacy masking", Sub: "Secrets, personal data and your own words go to vendors as placeholders, and come back as they were",
|
||
One: "Masking is on", Many: "Masking is on",
|
||
InUse: InUse,
|
||
SetAt: "privacy #redactList",
|
||
// Insights › Masking: what masking did, request by request
|
||
Parts: []pluginrt.Part{{Slot: "nav.page", Key: "masking"}},
|
||
Client: []string{"i18n.js", "redact.css", "client.js", "page.js"},
|
||
Apply: func(c *pluginrt.Ctx) error {
|
||
c.OnDispose(gwmw.Mask(masking.Masker{}))
|
||
return nil
|
||
},
|
||
})
|
||
}
|
||
|
||
// InUse is 1 while the settings ask for anything to be masked; settings
|
||
// that can't be read are not known, so it stays on.
|
||
func InUse() (int, error) {
|
||
st, err := settings.LoadChecked()
|
||
if err != nil {
|
||
return 0, err
|
||
}
|
||
if masking.Wanted(st) {
|
||
return 1, nil
|
||
}
|
||
return 0, nil
|
||
}
|