fix(grpc-data): H2 review2-7a - no aggregates or resolution for a peer without a HistoryRead grant
The history field still marks that the origin has a historian (negotiation rule unchanged), but a principal with no HistoryRead export sees no aggregate names and resolution 0 (undisclosed).
This commit is contained in:
@@ -291,7 +291,7 @@ public sealed record DataLimits(int MaxPageItems, int MaxBatchItems, int MaxMess
|
||||
/// <param name="Processed">HistoryRead-Processed (at least one aggregate served).</param>
|
||||
/// <param name="AtTime">HistoryRead-AtTime.</param>
|
||||
/// <param name="Aggregates">The served aggregates, as stable <c>HistoryAggregateType</c> names.</param>
|
||||
/// <param name="TimestampResolutionTicks">The backend's stored timestamp resolution (QuestDB µs = 10); 1 = 100 ns.</param>
|
||||
/// <param name="TimestampResolutionTicks">The backend's stored timestamp resolution (QuestDB µs = 10); 1 = 100 ns; 0 = undisclosed (no grant).</param>
|
||||
/// <param name="MaxValuesPerPage">The origin's per-node page ceiling for this caller.</param>
|
||||
/// <param name="MaxConcurrentReads">The origin's concurrent history reads admitted per principal.</param>
|
||||
/// <param name="ContinuationIdle">How long an untaken origin continuation lives.</param>
|
||||
@@ -301,7 +301,8 @@ public sealed record DataHistoryCapabilities(bool Raw, bool Processed, bool AtTi
|
||||
public void Validate()
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(Aggregates);
|
||||
if (TimestampResolutionTicks <= 0 || MaxValuesPerPage <= 0 || MaxConcurrentReads <= 0 || ContinuationIdle <= TimeSpan.Zero
|
||||
// Resolution 0 = undisclosed (the caller holds no HistoryRead grant on any export).
|
||||
if (TimestampResolutionTicks < 0 || MaxValuesPerPage <= 0 || MaxConcurrentReads <= 0 || ContinuationIdle <= TimeSpan.Zero
|
||||
|| Aggregates.Any(string.IsNullOrWhiteSpace))
|
||||
throw new ArgumentOutOfRangeException(nameof(MaxValuesPerPage), "History capabilities must be positive.");
|
||||
}
|
||||
|
||||
@@ -63,7 +63,9 @@ public sealed partial class LocalDataServices
|
||||
internal DataHistoryCapabilities? HistoryCapabilitiesFor(LocalExportCatalog? catalog, DataAuthenticatedContext context)
|
||||
{
|
||||
if (HistoryServing is not { } serving) return null;
|
||||
var limits = catalog?.HistoryLimitsFor(context.PrincipalId) ?? (4, 10_000, 4 * 1024 * 1024);
|
||||
// Without a HistoryRead grant on some export the peer learns that history exists here, and nothing about it.
|
||||
if (catalog?.HistoryLimitsFor(context.PrincipalId) is not { } limits)
|
||||
return new DataHistoryCapabilities(false, false, false, [], 0, 10_000, 4, PeerHistoryIdle);
|
||||
return new DataHistoryCapabilities(true, serving.Aggregates.Count > 0, true, serving.Aggregates, serving.TimestampResolutionTicks,
|
||||
limits.ValuesPerPage, limits.ConcurrentReads, PeerHistoryIdle);
|
||||
}
|
||||
|
||||
@@ -287,6 +287,11 @@ public sealed class GrpcDataHistoryWireTests
|
||||
await using var ungranted = new RealOrigin(exportOperations: DataOperationSets.V1, grantHistory: false);
|
||||
var denied = await Should.ThrowAsync<RpcException>(() => ungranted.HistoryAsync(Raw(I("a", RealOriginRequests.Flow)), History));
|
||||
denied.StatusCode.ShouldBe(StatusCode.PermissionDenied);
|
||||
// ...and its probe names no aggregates or resolution: nothing about the historian leaks to an ungranted peer.
|
||||
var bare = W.CapabilitiesResponse.Parser.ParseFrom(Convert.FromHexString(await ungranted.DriveAsync("GetCapabilities", History)));
|
||||
bare.History.ShouldNotBeNull();
|
||||
bare.History.Aggregates.ShouldBeEmpty();
|
||||
bare.History.TimestampResolutionTicks.ShouldBe(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user