refactor: ask the mode module instead of retyping it

Four sites still compared the verification mode to a literal after the
module owning that policy existed. One of them mattered: an unrecognised
mode fell through to MD5 verification while compute_severity was scoring
it as existence, so a typo in a platform YAML produced a report whose
checks and severities described different platforms.

The mode is normalized once per run and the consumers ask for what they
need. A test reads the sources and fails on a literal comparison, so the
next consumer cannot quietly grow a fifth copy.
This commit is contained in:
Abdessamad Derraz committed 2026-08-12 07:36:29 +02:00
1 parent b11c8b0638
commit 5e168b86c8
4 files changed
+74 -12

No files matched your search

+2 -1
View File
@@ -42,6 +42,7 @@ from common import (
write_if_changed,
yaml_load,
)
from nativemode import reads_file_contents
yaml = require_yaml()
from generate_readme import compute_coverage, manifest_totals
@@ -1603,7 +1604,7 @@ def generate_platform_page(
pct_val = cov["present"] / cov["total"] * 100 if cov["total"] else 0
mode_badge = (
"rb-badge-success" if mode in ("md5", "sha1") else "rb-badge-info"
"rb-badge-success" if reads_file_contents(mode) else "rb-badge-info"
)
lines = [