1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
.{
.{
.name = "account default permits management",
.file = "src/internal/oauth/permissions.zig",
.old = ".action = account_action orelse .read,",
.new = ".action = account_action orelse .manage,",
},
.{
.name = "double wildcard becomes an RPC permission",
.file = "src/internal/oauth/permissions.zig",
.old = "if (methods == .all) return error.InvalidScope;",
.new = "if (methods == .all) break :blk .{ .rpc = .{ .any_audience = &.{\"app.example.getPost\"} } };",
},
.{
.name = "an unrecognized attenuator is discarded",
.file = "src/internal/oauth/permissions.zig",
.old = "account_action = std.meta.stringToEnum(AccountAction, value) orelse return error.InvalidScope;\n } else {\n return error.InvalidScope;",
.new = "account_action = std.meta.stringToEnum(AccountAction, value) orelse return error.InvalidScope;\n } else {\n continue;",
},
.{
.name = "an escaped scope component is decoded twice",
.file = "src/internal/oauth/permissions.zig",
.old = "return decoded;\n}",
.new = "return percent.decodeAlloc(allocator, decoded) catch error.InvalidScope;\n}",
},
.{
.name = "repo matching loses the collection selector",
.file = "src/internal/oauth/permissions.zig",
.old = "grant.actions.contains(request.action) and matchesName(grant.collections, request.collection)",
.new = "grant.actions.contains(request.action)",
},
.{
.name = "wildcard audience requires a fragment on the request",
.file = "src/internal/oauth/permissions.zig",
.old = "validAudience(request.audience, .did_or_service)",
.new = "validAudience(request.audience, .service)",
},
.{
.name = "wildcard audience skips request validation",
.file = "src/internal/oauth/permissions.zig",
.old = "containsSorted(methods, request.method) and validAudience(request.audience, .did_or_service)",
.new = "containsSorted(methods, request.method)",
},
.{
.name = "a service grant compares only the request DID",
.file = "src/internal/oauth/permissions.zig",
.old = "eql(service.audience, request.audience) and matchesName(service.methods, request.method)",
.new = "eql(std.mem.sliceTo(service.audience, '#'), std.mem.sliceTo(request.audience, '#')) and matchesName(service.methods, request.method)",
},
.{
.name = "a duplicate audience overwrites the first",
.file = "src/internal/oauth/permissions.zig",
.old = "if (audience != null) return error.InvalidScope;",
.new = "",
},
.{
.name = "a named selector can widen a positional selector",
.file = "src/internal/oauth/permissions.zig",
.old = "if (positional) return error.InvalidScope;",
.new = "",
},
.{
.name = "a decoded delimiter hides an action suffix",
.file = "src/internal/oauth/permissions.zig",
.old = "std.meta.stringToEnum(RepoAction, value)",
.new = "std.meta.stringToEnum(RepoAction, std.mem.sliceTo(value, '&'))",
},
.{
.name = "malformed escapes discard optional restrictions",
.file = "src/internal/oauth/permissions.zig",
.old = "const value = try decode(allocator, param[equals + 1 ..]);",
.new = "const value = decode(allocator, param[equals + 1 ..]) catch |err| { if (err == error.InvalidScope and resource == .repo) continue; return err; };",
},
.{
.name = "a wildcard discards invalid companion selectors",
.file = "src/internal/oauth/permissions.zig",
.old = "if (eql(value, \"*\")) {\n for (values) |candidate| {\n if (!eql(candidate, \"*\") and Nsid.parse(candidate) == null) return error.InvalidScope;\n }\n return .all;\n }",
.new = "if (eql(value, \"*\")) return .all;",
},
.{
.name = "an explicit scope audience accepts a bare DID",
.file = "src/internal/oauth/permissions.zig",
.old = "validAudience(audience, .service)",
.new = "validAudience(audience, .did_or_service)",
},
}