~ knotless Search/
↑↓ move↵ open⇧↵ all results

zat.dev/zat

atproto utils for zig · mirror of https://tangled.org/zat.dev/zat

0
0
128 lines · 5.6 KB Raw History
.{
    .{
        .name = "finding: generated TIDs above 6 << 50 are rejected",
        .file = "src/internal/syntax/tid.zig",
        .old = "if (high > std.math.maxInt(u3)) return null;",
        .new = "if (high > 5) return null;",
    },
    .{
        .name = "finding: DPoP nonce loses JSON special characters",
        .file = "src/internal/oauth/primitives.zig",
        .old = "try aw.writer.print(\",\\\"nonce\\\":{f}\", .{std.json.fmt(n, .{})});",
        .new = "try aw.writer.print(\",\\\"nonce\\\":\\\"{s}\\\"\", .{n});",
    },
    .{
        .name = "finding: firehose CAR is not rooted at the commit CID",
        .file = "src/internal/streaming/firehose.zig",
        .old = "if (commit.commit) |commit_cid| try root_cids.append(allocator, commit_cid);",
        .new = "",
    },
    .{
        .name = "finding: Retry-After HTTP-date is ignored",
        .file = "src/internal/xrpc/xrpc.zig",
        .old = "if (self.millisUntil(at, now)) |milliseconds| return milliseconds;",
        .new = "_ = at;",
    },
    .{
        .name = "Retry-After delta seconds is ignored",
        .file = "src/internal/xrpc/xrpc.zig",
        .old = "if (headers.retry_after) |seconds| {",
        .new = "if (@as(?u64, null)) |seconds| {",
    },
    .{
        .name = "exponential backoff starts one doubling late",
        .file = "src/internal/xrpc/xrpc.zig",
        .old = "const shift: u6 = @intCast(@min(attempt, 16));",
        .new = "const shift: u6 = @intCast(@min(@as(u16, attempt) + 1, 16));",
    },
    .{
        .name = "a POST is retried after a 5xx",
        .file = "src/internal/xrpc/xrpc.zig",
        .old = "if (method == .POST and status != .too_many_requests) return false;",
        .new = "if (method == .PUT and status != .too_many_requests) return false;",
    },
    .{
        .name = "one retry past max_attempts",
        .file = "src/internal/xrpc/xrpc.zig",
        .old = "if (attempt + 1 < attempts and retry_policy.isRetryableStatusForMethod(",
        .new = "if (attempt < attempts and retry_policy.isRetryableStatusForMethod(",
    },
    .{
        .name = "transport errors retried with retry_transient_errors off",
        .file = "src/internal/xrpc/xrpc.zig",
        .old = "if (attempt + 1 >= attempts or !retry_policy.retry_transient_errors or !isRetryableTransportErrorForMethod(method, err)) {",
        .new = "if (attempt + 1 >= attempts or !isRetryableTransportErrorForMethod(method, err)) {",
    },
    .{
        .name = "query values keep spaces unescaped",
        .file = "src/internal/xrpc/xrpc.zig",
        .old = "if (std.ascii.isAlphanumeric(c) or c == '-' or c == '_' or c == '.' or c == '~') {",
        .new = "if (std.ascii.isAlphanumeric(c) or c == '-' or c == '_' or c == '.' or c == '~' or c == ' ') {",
    },
    .{
        .name = "a procedure drops the bearer token",
        .file = "src/internal/xrpc/xrpc.zig",
        .old = ".authorization = auth_value,",
        .new = ".authorization = if (method == .GET) auth_value else null,",
    },
    .{
        .name = "finding: a DID document for another DID is accepted",
        .file = "src/internal/identity/did_resolver.zig",
        .old = "if (!std.mem.eql(u8, doc.id, did.raw)) return error.DidDocumentIdMismatch;",
        .new = "_ = did;",
    },
    .{
        .name = "finding: a non-literal A answer becomes the dial host",
        .file = "src/internal/identity/network_safety.zig",
        .old = "_ = std.Io.net.Ip4Address.parse(data, 0) catch return error.IdentityDnsResolutionFailed;",
        .new = "",
    },
    .{
        .name = "finding: 3fff::/20 passes as routable",
        .file = "src/internal/identity/network_safety.zig",
        .old = "if (matchesIp6(ip, .{ 0x3f, 0xff } ++ @as([14]u8, @splat(0)), 20)) return true;",
        .new = "",
    },
    .{
        .name = "link-local IPv4 passes as routable",
        .file = "src/internal/identity/network_safety.zig",
        .old = ".{ .network = .{ 169, 254, 0, 0 }, .prefix = 16 },",
        .new = "",
    },
    .{
        .name = "a second did= TXT record is ignored",
        .file = "src/internal/identity/handle_resolver.zig",
        .old = "if (found_count != 1) {",
        .new = "if (found_count == 0) {",
    },
    .{
        .name = "a nonce retry signs with the nonce it was challenged on",
        .file = "src/internal/oauth/client.zig",
        .old = "            nonce = retry_nonce;",
        .new = "            nonce = if (retry_nonce != null) params.dpop_nonce else null;",
    },
    .{
        .name = "a resource proof omits ath",
        .file = "src/internal/oauth/client.zig",
        .old = "        .access_token_hash = ath,",
        .new = "        .access_token_hash = null,",
    },
    .{
        .name = "a block reader error leaves the stub marked dirty",
        .file = "src/internal/repo/mst.zig",
        .old = "        const block_data = (try reader.get(cid.raw)) orelse return error.PartialTree;",
        .new = "        const block_data = (reader.get(cid.raw) catch |err| {\n            node.dirty = true;\n            return err;\n        }) orelse return error.PartialTree;",
    },
    .{
        .name = "every DPoP proof carries the same jti",
        .file = "src/internal/oauth/primitives.zig",
        .old = ", .{ jti, std.json.fmt(htm, .{}), std.json.fmt(htu, .{}), now });",
        .new = ", .{ \"fixed\", std.json.fmt(htm, .{}), std.json.fmt(htu, .{}), now });",
    },
    .{
        .name = "did:web fetch drops the preflight's pinned address",
        .file = "src/internal/identity/did_resolver.zig",
        .old = "return try self.fetchDidDocument(did, url, checked_url.resolvedConnection());",
        .new = "return try self.fetchDidDocument(did, url, null);",
    },
}