OPEN-12's option (b) — share the block list and shorten the TTL — was not a deployment decision, it was a rebuild: EdgeStateStore.RefreshTtl was a property initialised to 30 s with no configuration binding anywhere in the tree. The measurement in research/2026-10-01-multi-instance/ showed why that matters: the TTL is not a tuning knob, it is the propagation delay between edges (23.7 s under ~36 req/s, 1.7 s on an idle one), so an operator who runs more than one instance is choosing a staleness bound they cannot set and cannot see. The key is OpenWaf:State:RefreshTtlSeconds, default 30, and the default is unchanged so nothing moves for anyone who does not touch it. A value outside 1-300 aborts startup instead of falling back silently, because a typo in the staleness bound is a security setting failing quietly. /healthz now reports snapshotTtlSeconds, so an operator can read the TTL they actually got. Verified on this commit: 49 unit and 23 integration tests pass (13 new unit cases on the parser; 3 new integration tests that write a ban the way another instance would — straight into the database, no InvalidateAsync — and show a 1 s TTL closing the window inside 5 s while a 300 s TTL keeps serving a source the database has already banned); scripts/smoke.sh 19/19; scripts/compose-smoke.sh 27/27 against the rebuilt image; in a container RefreshTtlSeconds=5 reports snapshotTtlSeconds:5 on /healthz, and =0 aborts the process with the key named in the log. One thing the check taught and the README now says instead of hiding: when startup aborts inside the image, the container stays Up with nothing listening until the HEALTHCHECK goes unhealthy. That is how every startup failure in this image looks, not something this change introduces.
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using OpenWaf.Infrastructure.Persistence;
|
|
|
|
namespace OpenWaf.Tests.Unit;
|
|
|
|
/// <summary>
|
|
/// The snapshot TTL is the bound on how stale an enforced block list may be,
|
|
/// which makes it a security setting rather than a tuning knob. The parsing is
|
|
/// therefore the gate: a typo has to stop the process, not become a silent
|
|
/// thirty seconds.
|
|
/// </summary>
|
|
public sealed class SnapshotRefreshTtlTests
|
|
{
|
|
[Theory]
|
|
[InlineData(null, 30)]
|
|
[InlineData("", 30)]
|
|
[InlineData(" ", 30)]
|
|
[InlineData("5", 5)]
|
|
[InlineData(" 7 ", 7)]
|
|
[InlineData("1", 1)]
|
|
[InlineData("300", 300)]
|
|
public void Unset_means_thirty_and_a_whole_number_means_what_it_says(string? configured, int expected)
|
|
=> Assert.Equal(expected, EdgeStateStore.ParseRefreshTtl(configured).TotalSeconds);
|
|
|
|
[Theory]
|
|
[InlineData("0")]
|
|
[InlineData("-1")]
|
|
[InlineData("301")]
|
|
[InlineData("abc")]
|
|
[InlineData("5.5")]
|
|
[InlineData("30s")]
|
|
public void Anything_else_names_the_key_and_refuses_to_start(string configured)
|
|
{
|
|
var ex = Assert.Throws<InvalidOperationException>(() => EdgeStateStore.ParseRefreshTtl(configured));
|
|
Assert.Contains("OpenWaf:State:RefreshTtlSeconds", ex.Message);
|
|
Assert.Contains(configured, ex.Message);
|
|
}
|
|
}
|