the retention window is a config key now, and both tables say what it is
Retention was a constant on the policy record: 7 days for observations, 7 for bans and alerts, read from nothing and shown nowhere (OPEN-19). Two keys now, OpenWaf:Policy:ObservationRetentionDays and OpenWaf:Policy:BanRetentionDays, 1..365 whole days, and an out-of-range value aborts startup naming the key rather than falling back to 7 — the same shape OPEN-13 chose for the refresh TTL, because a silently widened window keeps rows longer than the deployment asked for and nothing on any surface would say so. Split into two keys: the two windows answer different questions and their sharing 7 days was coincidence. The window is printed where the rows it governs are printed: /admin-api/state and /admin-api/policy answer observationRetentionDays and banRetentionDays, the observation table appends "rows are pruned after Nd" and the alert table "alerts are pruned after Nd". Measured on this tree: build 0 warnings / 0 errors, unit 132/132, integration 181/181 in 20 s (8 new: 5 startup-refusal and bound cases, a 1-day window pruning a 3-day-old observation, a 30-day window keeping a ban ten days past expiry, both surfaces reporting 30 and 2, and the two defaults), smoke 28/0, console 76 assertions 0 failed. The console gate needed two of its own assertions rewritten, not relaxed: they compared the note text for equality and the sentence grew. Run against the real binary: ObservationRetentionDays=30 BanRetentionDays=2 reports 30 and 2 on both surfaces; ObservationRetentionDays=0 exits with "OpenWaf:Policy:ObservationRetentionDays must be a whole number of days between 1 and 365; got 0".
This commit is contained in:
@@ -117,7 +117,7 @@ const rgb = (s) => s.match(/\d+/g).slice(0, 3).map(Number);
|
||||
// 1000 rows back, no total and no flag.
|
||||
const obsNote = (await page.textContent('#obsnote')).replace(/\s+/g, ' ').trim();
|
||||
check('the observation table states how many sources were recorded, not only the rows it shows',
|
||||
/^\d+ sources? the edge has recorded$/.test(obsNote) || /^newest \d+ of \d+ recorded sources/.test(obsNote),
|
||||
/^\d+ sources? the edge has recorded( \u00b7 rows are pruned after \d+d)?$/.test(obsNote) || /^newest \d+ of \d+ recorded sources/.test(obsNote),
|
||||
obsNote);
|
||||
const streakNote = (await page.textContent('#streaknote')).replace(/\s+/g, ' ').trim();
|
||||
const standing = streakNote.match(/(\d+) of (\d+) standing streaks listed/);
|
||||
@@ -162,6 +162,13 @@ const rgb = (s) => s.match(/\d+/g).slice(0, 3).map(Number);
|
||||
const alertnote = (await page.textContent('#alertnote')).replace(/\s+/g, ' ').trim();
|
||||
check('the page says a server error is never a reason to ban',
|
||||
/will not ban/.test(alertnote), alertnote);
|
||||
// The window the rows age out at, printed on the tables it governs
|
||||
// (OPEN-19). "3 sources recorded" reads the same whether this edge keeps them
|
||||
// a week or a year, and the window is the answer to "how far back can this
|
||||
// incident still be explained" — so it is asserted, not just printed.
|
||||
check('both tables state the retention window they age out at',
|
||||
/rows are pruned after \d+d/.test(obsNote) && /alerts are pruned after \d+d/.test(alertnote),
|
||||
JSON.stringify([obsNote, alertnote]));
|
||||
const warnCells = await page.$$eval('#alerts tbody tr .warn', (els) => els.map((e) => e.textContent));
|
||||
check('the kind an operator has to act on is marked, not only printed',
|
||||
warnCells.includes('server_error_streak'), JSON.stringify(warnCells));
|
||||
@@ -757,7 +764,7 @@ const rgb = (s) => s.match(/\d+/g).slice(0, 3).map(Number);
|
||||
const emptyObsRow = await srcCells();
|
||||
const emptyStreakNote = await noteOf('#streaknote');
|
||||
check('a source with nothing recorded is named in words, with a total of zero',
|
||||
emptyObsNote === 'no recorded observations for ' + NO_MATCH
|
||||
emptyObsNote === 'no recorded observations for ' + NO_MATCH + ' · rows are pruned after 7d'
|
||||
&& emptyObsRow.length === 1 && emptyObsRow[0] === 'nothing recorded for ' + NO_MATCH,
|
||||
`${JSON.stringify(emptyObsNote)} row=${JSON.stringify(emptyObsRow)}`);
|
||||
check('and the streak line says nothing is standing for that source',
|
||||
@@ -779,7 +786,7 @@ const rgb = (s) => s.match(/\d+/g).slice(0, 3).map(Number);
|
||||
const markupTitle = await page.title();
|
||||
check('a filter value containing markup is printed as text and creates no element',
|
||||
markupInjected === 0 && markupTitle.indexOf('XSS3') === -1
|
||||
&& markupNote === 'no recorded observations for ' + MARKUP_KEY,
|
||||
&& markupNote === 'no recorded observations for ' + MARKUP_KEY + ' · rows are pruned after 7d',
|
||||
`${markupInjected} injected elements, title ${JSON.stringify(markupTitle)}, note ${JSON.stringify(markupNote)}`);
|
||||
|
||||
// And back out. Clearing has to restore the unfiltered totals, not leave a
|
||||
|
||||
Reference in New Issue
Block a user