Publish how old the vulnerability database is - #295
Merged
Conversation
A database that stopped updating does not make anything fail. Scans keep running, keep finding what it knew when it stopped, and report success. One deployment was found 46 days behind with every scan green, and what surfaced it was somebody looking at the disk for an unrelated reason. Three layers could have said so and none did. The bootstrap failed on every start and logged it, but nobody reads worker logs. metadata.json held the date all along. The admin panel reads that file and shows it, but a screen has to be visited, and even then the reader has to subtract two dates themselves. Two gauges: the upstream update time, and the configured refresh interval beside it. Neither answers alone. The timestamp says when the data stopped changing; the interval says how long that is supposed to be able to go on. An air-gapped install mirroring on a slower cadence is not broken, and only the interval separates it from one that is. No staleness verdict is published, and the panel's fresh / stale bucket stays out. That classification exists for a screen; a series carrying it would freeze one judgement into the metric and put it beyond the collector's reach, which is where the decision belongs because the cadence is a local fact. Zero when no database has been downloaded, rather than omitting the series. That is the worst state this can be in, and it is exactly where a series that disappeared would leave a dashboard looking clean. The backend already has a read-only mount of the worker's cache, added when this same file being unreachable made the panel report "unknown", so the metric reads it directly rather than inferring from task history.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
O2. Sits beside the task-run series #291 added.
Why this needs a metric rather than a check
A vulnerability database that stopped updating does not make anything fail. Scans keep running, keep finding what it knew when it stopped, and report success. Nothing in the system objects.
A deployment was found 46 days behind with every scan green. Three layers could have said so:
metadata.jsonWhat actually surfaced it was somebody looking at the disk for an unrelated reason.
Two gauges, no verdict
trusca_vuln_db_last_update_timestamp_secondsandtrusca_vuln_db_refresh_interval_hours.Neither answers alone. The timestamp says when the data stopped changing; the interval says how long that is supposed to be able to go on. An air-gapped install mirroring on a slower cadence is not broken, and only the interval separates it from one that is.
The panel's fresh / stale bucket is deliberately not published. That classification exists for a screen. A series carrying it would freeze one judgement into the metric and put it beyond the collector's reach, and the right threshold depends on a cadence only the deployment knows.
Zero when no database has been downloaded, rather than dropping the series. That is the worst state this can be in, and it is exactly where a disappearing series would leave a dashboard looking clean. Same reasoning as
outcome=runningin #291.Where it reads from
Directly from the file. The backend already carries a read-only mount of the worker's Trivy cache, added when this same file being unreachable made the panel report "unknown", so no inference from task history is needed.
Task history answers a different question anyway (did the refresh run, did it succeed) and #291 already publishes that as
trusca_task_runs_24h{task="...",outcome="failed"}. Reading both together is a runbook matter, not a third series.Verification
5 unit tests, contract fixture updated,
ruffandmypyclean, 239 related tests green. Admin guide in both locales explains why the two series belong together and why no verdict ships with them.One test is worth noting: it asserts that the accessor never reads the snapshot's
freshnessattribute. Two earlier versions matched on the stringsfreshnessandfreshand both failed on names that legitimately contain them (the accessor is named for what it measures, andrefreshcontainsfresh). A test of spelling is not a test of behaviour.