Skip to content

docs: update learn page statistics and add CI/CD workflow - #230

Open
parthrohit22 wants to merge 1 commit into
openshield-org:devfrom
parthrohit22:docs/update-learn-page-and-add-cicd
Open

docs: update learn page statistics and add CI/CD workflow#230
parthrohit22 wants to merge 1 commit into
openshield-org:devfrom
parthrohit22:docs/update-learn-page-and-add-cicd

Conversation

@parthrohit22

@parthrohit22 parthrohit22 commented Aug 5, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Closes out the remaining drift documented in #228. Fixes every stale count on the Learn page
(not just the five the first pass covered), fixes the four stale counts in README.md, and
extends .github/scripts/update_learn_page.py / .github/workflows/update-learn-page.yml so
both files are regenerated from the codebase on every push to dev and can no longer drift.

Type of change

  • New scan rule
  • Remediation playbook
  • Bug fix
  • Dashboard/front-end work
  • API endpoint
  • Documentation
  • Compliance mapping

Rule details (if applicable)

Not applicable — this PR adds no scanner rule. It only reads rule metadata to produce counts.

Testing

  • Tested against a real Azure free trial subscription — not applicable, no Azure API calls
  • Returns correct JSON output — not applicable, no scanner or API output
  • All seven CI checks pass
  • No hardcoded credentials or secrets

Verification actually performed:

  • ruff check . and ruff format --check . — clean repo-wide.
  • python -m bandit -r .github/scripts/ — no issues.
  • python -c "import yaml; yaml.safe_load(open('.github/workflows/update-learn-page.yml'))" — valid.
  • Derived every number from the filesystem before writing anything: ls scanner/rules/az_*.py | wc -l → 65,
    ls playbooks/cli/*.sh | wc -l → 65, grep -l 'SEVERITY = "HIGH"' scanner/rules/az_*.py | wc -l → 38.
    Cross-checked every rule's declared PLAYBOOK field against the filename-derived path — 0 orphans
    either direction.
  • Idempotency, both files: reverted docs/learn/index.html and README.md to their pre-PR
    committed content, ran the script — output was byte-identical to the version already staged
    in this PR; a second run was a true no-op (git diff empty).
  • Fail-loud path, tested in isolation: reworded the hero-terminal HTML so the regex could not
    match — the script correctly named exactly that pattern and exited 1, and confirmed no file
    was written on that failure.
  • Empty-input guard, tested in isolation: pointed RULES_DIR/PLAYBOOKS_DIR at an empty temp
    directory — main() returned 1 and refused to write zeroes.
  • Missing-SEVERITY/CATEGORY warning path, tested in isolation with synthetic rule files —
    correctly named the offending file without failing the run.
  • Ran the actual DCO checker the repo uses in CI (python scripts/check_dco.py <base> <head>)
    against this branch — sign-off verified.

Related issue

Closes #228

Checklist

  • Every commit includes a DCO Signed-off-by trailer (git commit -s; see docs/dco.md)
  • My code follows the rule template in CONTRIBUTING.md — no new rule; Python follows the
    repo's Ruff/PEP 8 and type-hint standards
  • I added or updated the matching CLI playbook — not applicable, no new rule
  • I added or updated all four compliance framework mappings — not applicable, no new rule
  • I have not committed any real Azure credentials
  • My branch name follows the convention — docs/update-learn-page-and-add-cicd, matching
    the docs/description form in CONTRIBUTING.md

True numbers (derived from the filesystem, verified before any edit)

Metric Value
Rules (scanner/rules/az_*.py with RULE_ID) 65
Playbooks (playbooks/cli/*.sh) 65
Orphans (rule↔playbook) 0
HIGH / MEDIUM / LOW / CRITICAL severity 38 / 22 / 4 / 1
Categories Identity 15, Network 15, Supply Chain 8, Kubernetes 6, KeyVault 5, Storage 5, Compute 4, Database 4, PostQuantum 3

The 1 CRITICAL rule (AZ-SC-005) has no box in the Learn page's severity-distribution UI,
which is hardcoded to a 3-column HIGH/MEDIUM/LOW grid — documented as a known limitation, not
fixed here (see "Notes for reviewers").

Changes

File Change
docs/learn/index.html All previously-stale content fixed, not just the metric tiles: hero terminal 39 → 65 dynamic checks; severity boxes HIGH 22 → 38, MEDIUM 13 → 22 (LOW was already correct at 4); "Coverage by category" chart fully regenerated — previously omitted Supply Chain (8) and Kubernetes (6) entirely and undercounted Identity 4 → 15; removed a "known cleanup item" note about KeyVault vs Key Vault naming that the chart fix resolves (the chart now renders the category string the code actually declares); rewrote the "Known gaps" card's "counts are checked and updated with each release" claim to accurately describe what's CI-generated vs. hand-maintained.
README.md Fixed 4 stale counts: Misconfiguration Scanner feature-table row (51 → 65, and added the previously-unmentioned "supply chain" category), Remediation Playbooks row (51 → 65), and both Mermaid diagram nodes (Scanner Engine, Azure CLI Playbooks).
.github/scripts/update_learn_page.py Extended to cover the hero terminal line, all three severity boxes (previously only HIGH), and to fully regenerate the category chart's rows/counts/bar-widths from real per-category data (a new category now appears automatically instead of being silently dropped). Added render_readme() so the same script now also fixes README.md. Every substitution is tracked via re.subn; if any pattern matches zero times the script prints which one and exits non-zero instead of silently doing nothing and exiting 0. Rule files with no parseable SEVERITY/CATEGORY are now warned about by name. Still idempotent.
.github/workflows/update-learn-page.yml Extended to diff, git add, and commit README.md alongside docs/learn/index.html. Renamed to reflect the wider scope. SHA pins and permissions: contents: write unchanged from the first pass.

Decision: README.md is now automated, not left as a manual step

The task called for deciding — and stating clearly — whether to extend the workflow to also
keep README.md current, or leave that update as a one-time manual fix. I extended it: the
whole point of this issue is closing the exact class of drift where a doc's numbers silently
fall out of sync with the codebase, and README.md's 4 stale counts are the same failure mode
in a second file. The substitution surface is small and well-bounded (2 feature-table rows, 2
Mermaid nodes), reuses the same tested apply_replacements()/fail-loud machinery already built
for the Learn page, and is the only choice consistent with the "Known gaps" card now stating
that these stats are CI-generated. README.md's "30+ scan rules" roadmap checklist item and
other prose are unrelated to this PR's scope and were left untouched.

Notes for reviewers

  • Filed as a factual, no-marketing status comment on docs: update Learn page statistics and add CI/CD for auto-updates #228 before making any change, listing
    every stale location by file/line and the true numbers — see the issue thread.
  • Real discrepancy, not fixed in this PR (flagging for a follow-up issue):
    scanner/engine.py::load_rules() — the code that actually executes rules at scan time —
    discovers rule modules with RULES_DIR.glob("*.py"), excluding only filenames starting with
    _. It does not require the az_*.py prefix or a RULE_ID, unlike ci.yml's
    structure-validation job and this script, which both use the narrower convention. Today all
    three agree on 65 only because scanner/rules/ happens to contain no stray file outside
    those two patterns — nothing enforces that. A leftover or misnamed .py file with a scan()
    function would be loaded and executed in production without being validated by CI or counted
    in either doc.
  • Branch protection on dev, from the first review round: I don't have admin visibility
    into the repo's protection rules (only push access), so I can't fully confirm whether
    GITHUB_TOKEN can push directly to dev. GET /repos/.../rules/branches/dev (readable with
    plain read access) currently returns no effective rules, which suggests direct pushes are not
    blocked, but please verify in Settings → Branches before relying on that. If pushes are
    blocked, this workflow needs to open a PR instead of committing directly — I have not made
    that change silently.

Comment thread .github/workflows/update-learn-page.yml Fixed
Comment thread .github/workflows/update-learn-page.yml Fixed
@parthrohit22
parthrohit22 force-pushed the docs/update-learn-page-and-add-cicd branch from 528d756 to dcf7cd4 Compare August 5, 2026 12:11
@Vishnu2707

Copy link
Copy Markdown
Member

CI is failing @parthrohit22 - have a look at it!

@parthrohit22

Copy link
Copy Markdown
Member Author

CI is failing @parthrohit22 - have a look at it!

FIXED . THANK YOU

ritiksah141
ritiksah141 previously approved these changes Aug 5, 2026
@parthrohit22
parthrohit22 marked this pull request as draft August 5, 2026 18:11
Signed-off-by: Parth Rohit <parthrohit60@gmail.com>
@parthrohit22
parthrohit22 force-pushed the docs/update-learn-page-and-add-cicd branch from 22b3900 to 6ed2530 Compare August 6, 2026 08:50
@TFT444
TFT444 marked this pull request as ready for review August 6, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: update Learn page statistics and add CI/CD for auto-updates

4 participants