From 23d6dfb69ab395700267a4fabb73a49f75092588 Mon Sep 17 00:00:00 2001 From: Vishnu Ajith <27vishnu07@gmail.com> Date: Sun, 27 Sep 2026 22:01:25 +0100 Subject: [PATCH] fix(ci): refine learn page script patterns Signed-off-by: Vishnu Ajith <27vishnu07@gmail.com> --- .github/scripts/update_learn_page.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/scripts/update_learn_page.py b/.github/scripts/update_learn_page.py index d7b258b9..747b6d1f 100644 --- a/.github/scripts/update_learn_page.py +++ b/.github/scripts/update_learn_page.py @@ -199,6 +199,23 @@ def render( severity_medium = r'(
)\d+(MEDIUM
)' severity_low = r'(
)\d+(LOW
)' + if not re.search(severity_critical, content): + severity_start = ( + r'(
\n)' + r'(\s*
)' + ) + critical_box = ( + f'
{critical_count}' + "CRITICAL
\n" + ) + content, count = re.subn( + severity_start, + lambda match: match.group(1) + critical_box + match.group(2), + content, + ) + if count == 0: + return content, ["severity box: CRITICAL"] + replacements: Tuple[Tuple[str, str, int], ...] = ( ("headline metric: Azure scan rules", _metric("Azure scan rules"), rule_count), ("headline metric: CLI remediation playbooks", _metric("CLI remediation playbooks"), playbook_count), @@ -371,10 +388,10 @@ def main() -> int: print("Learn page and README statistics already current; nothing to do.") return 0 - sev = severities print( f"Updated {', '.join(changed)} - rules: {rule_count}, playbooks: {playbook_count}, " - f"severity CRITICAL: {sev['CRITICAL']}, HIGH: {sev['HIGH']}, MEDIUM: {sev['MEDIUM']}, LOW: {sev['LOW']}" + f"severity CRITICAL: {severities['CRITICAL']}, HIGH: {severities['HIGH']}, " + f"MEDIUM: {severities['MEDIUM']}, LOW: {severities['LOW']}" ) return 0