oficina / mapa Public

Clone
git clone https://amadan.net/oficina/mapa

Plain git — no account needed to clone.

Download

Download this file

1package main
2
3const (
4 graph = "internal/mapa/graph.go"
5 rank = "internal/mapa/rank.go"
6 suggest = "internal/mapa/suggest.go"
7 store = "internal/mapa/store.go"
8 verbs = "internal/mapa/verbs.go"
9 views = "internal/mapa/views.go"
10 aliases = "internal/mapa/aliases.go"
11 around = "internal/mapa/around.go"
12 recent = "internal/mapa/recent.go"
13
14 gateOne = "TestGate1ScopeLeaksNothing"
15 gateFour = "TestNoPlaintextReachesTheDisk"
16 gateEight = "TestGate8EveryWriteLogsAnEvent"
17 staleNot = "TestAStaleDraftIsNotCarried"
18)
19
20// mutations is each scope check, seal and event the gates stand on,
21// removed one at a time.
22var mutations = []mutation{
23 {gate: "1", test: gateOne,
24 name: "backlinks and pending texts read every private partition",
25 edits: []edit{{file: graph,
26 from: "\tif scope.Member != 0 {\n" +
27 "\t\tfor pageID, text := range found.private[scope.Member] {",
28 to: "\tfor _, texts := range found.private {\n" +
29 "\t\tfor pageID, text := range texts {"}}},
30 {gate: "1", test: gateOne,
31 name: "the level-up's scoped accessor ignores its scope",
32 edits: []edit{{file: around,
33 from: "\tif page == nil || !view.scope.sees(page) {",
34 to: "\tif page == nil {"},
35 {file: around,
36 from: "\treturn view.page(view.index.days[view.scope.Member]" +
37 "[date]) != nil\n}",
38 to: "\tfor _, days := range view.index.days {\n" +
39 "\t\tif view.page(days[date]) != nil {\n" +
40 "\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}"}}},
41 {gate: "1", test: "TestTheScopedAccessorGuardsEveryRead",
42 name: "the scoped accessor drops its own guard",
43 edits: []edit{{file: around,
44 from: "\tif page == nil || !view.scope.sees(page) {",
45 to: "\tif page == nil {"}}},
46 {gate: "1", test: gateOne, name: "search reads every person's postings",
47 edits: []edit{{file: rank,
48 from: "\tif own := index.ownTerms[scope.Member]; " +
49 "scope.Member != 0 && own != nil {\n" +
50 "\t\tparts = append(parts, own)\n\t}",
51 to: "\tfor _, own := range index.ownTerms {\n" +
52 "\t\tparts = append(parts, own)\n\t}"}}},
53 {gate: "1", test: gateOne,
54 name: "document frequency counts private pages",
55 edits: []edit{{file: rank,
56 from: "max(stats.index.teamTerms.frequency(term), 1)",
57 to: "max(func() int {\n" +
58 "\t\tcount := stats.index.teamTerms.frequency(term)\n" +
59 "\t\tfor _, own := range stats.index.ownTerms {\n" +
60 "\t\t\tcount += own.frequency(term)\n\t\t}\n" +
61 "\t\treturn count\n\t}(), 1)"}}},
62 {gate: "1", test: gateOne,
63 name: "autocomplete offers everyone's pending texts",
64 edits: []edit{{file: suggest,
65 from: "\tif scope.Member != 0 {\n" +
66 "\t\trows = append(rows[:len(rows):len(rows)],\n" +
67 "\t\t\tindex.pending.own[scope.Member]...)\n\t}",
68 to: "\tfor _, own := range index.pending.own {\n" +
69 "\t\trows = append(rows[:len(rows):len(rows)], own...)\n\t}"}}},
70 {gate: "1", test: gateOne,
71 name: "page links name the sequential row id",
72 edits: []edit{{file: views,
73 from: "\treturn \"/p/\" + publicID(page.nonce)",
74 to: "\treturn \"/p/\" + publicID(page.id)"}}},
75 {gate: "4", test: gateFour, name: "page records are stored in the clear",
76 edits: []edit{{file: store,
77 from: "\treturn store.sealer.Seal(purpose, plain)",
78 to: "\treturn plain, nil"}}},
79 {gate: "4", test: gateFour, name: "old titles are stored in the clear",
80 edits: []edit{{file: verbs,
81 from: "\tsealed, err := tx.store.sealer.Seal(seal.PurposeAlias, " +
82 "[]byte(old))",
83 to: "\tsealed, err := []byte(old), error(nil)\n" +
84 "\t_ = seal.PurposeAlias"},
85 {file: aliases,
86 from: "\t\ttitle, err := store.sealer.Open(" +
87 "seal.PurposeAlias, row.SealedTitle)\n" +
88 "\t\tif err != nil {\n" +
89 "\t\t\treturn nil, err\n\t\t}\n\t\tviews = append",
90 to: "\t\ttitle := row.SealedTitle\n\t\tviews = append"}}},
91 {gate: "8", test: gateEight, name: "freeing an alias logs no event",
92 edits: []edit{{file: verbs,
93 from: "\t\treturn tx.log(actor, ObjectPage, pageID, " +
94 "VerbAliasFreed,\n\t\t\tpage.Revision)",
95 to: "\t\t_ = page\n\t\treturn nil"}}},
96 {gate: "8", test: gateEight,
97 name: "the event rule is off and delete logs nothing",
98 edits: []edit{
99 {file: store, from: "\t\t\tif tx.events == 0 {",
100 to: "\t\t\tif tx.events < 0 {"},
101 {file: verbs,
102 from: "\t\treturn tx.log(actor, ObjectPage, pageID, " +
103 "VerbDeleted, page.Revision)",
104 to: "\t\treturn nil"}}},
105 {gate: "L9", test: staleNot,
106 name: "a rename carries every draft on the page, stale ones too",
107 edits: []edit{{file: verbs,
108 from: "\t\tWhere(\"page_id = ? AND base_revision = ?\", " +
109 "pageID, from).",
110 to: "\t\tWhere(\"page_id = ?\", pageID)."}}},
111 {gate: "80", test: "TestRecentlyEditedOutlastsManyPrivateWrites",
112 name: "Recently edited's query reads private pages too",
113 edits: []edit{{file: recent,
114 from: " WHERE pages.rung = @team AND NOT pages.gone\n)",
115 to: " WHERE NOT pages.gone\n)"}}},
116 {gate: "80", test: "TestRecentlyEditedLeavesOutDeletedPages",
117 name: "Recently edited's query reads deleted pages too",
118 edits: []edit{{file: recent,
119 from: " WHERE pages.rung = @team AND NOT pages.gone\n)",
120 to: " WHERE pages.rung = @team\n)"}}},
121}
122