Files
vulncheck/alembic/versions/024_add_priority_cpr_columns.py
T
vulncheck 0b71453c48 chore(release): drop personal attribution from comments and docstrings
Comments across the codebase credited one individual by role and, in places,
described that person's own machines: which SQL Server versions a host ran,
which devices were enrolled, what a particular dashboard showed, how many
findings sat open on which server. In a public repository that reads as a
profile of someone's unpatched estate.

The observations are why the code looks the way it does, so they stay. Every
CVE id, version, build number, count and date is preserved, as are the
verbatim quotes that motivated specific sort and filter rules — only the
attribution changes, to "field report", "observed", "a host". A local
variable in tests/test_autodesk_year.py was renamed for the same reason; its
value and every assertion around it are byte-identical.

PROJECT_OVERVIEW.md additionally loses a subtitle naming the kind of
organisation this was built for, and a support section pointing at an
internal team, both replaced with neutral wording.

Comments, docstrings and markdown prose only: 74 files, 200 lines, one-for-one
swaps. detect_changes reports 104 touched symbols and zero affected execution
flows, and all 55 test scripts pass. Nothing here needs re-testing.
2026-08-26 15:34:05 +02:00

57 lines
1.8 KiB
Python

"""Add materialised priority_score + cpr_score columns for SQL sort
Revision ID: 024
Revises: 023
Create Date: 2026-05-25 13:00:00.000000
Until now `priority_score` and `cpr_score` were computed in Python from
`calculate_priority_breakdown()` at response time. The list endpoint
paginated FIRST in SQL then re-sorted only the current page by the
computed score — so "PRIO desc" looked correct row-by-row but pages 2+
were not in global order.
Field report: "Spaltensortierung gilt nur teilweise für die
aktuell angezeigten CVES."
Add two indexed columns. Forward-write paths (sync / enrich / override
/ manual edits) call `vuln.refresh_scores()` to keep them current.
Existing rows backfill via a one-off `recompute_all_scores()` admin
endpoint (or the nightly Vulnrichment + URS jobs which already touch
every open vuln).
Idempotent — ADD COLUMN IF NOT EXISTS.
"""
from alembic import op
revision = "024"
down_revision = "023"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.execute("""
ALTER TABLE vulnerabilities
ADD COLUMN IF NOT EXISTS priority_score DOUBLE PRECISION,
ADD COLUMN IF NOT EXISTS cpr_score DOUBLE PRECISION;
""")
op.execute("""
CREATE INDEX IF NOT EXISTS ix_vulnerabilities_priority_score
ON vulnerabilities (priority_score);
""")
op.execute("""
CREATE INDEX IF NOT EXISTS ix_vulnerabilities_cpr_score
ON vulnerabilities (cpr_score);
""")
def downgrade() -> None:
op.execute("DROP INDEX IF EXISTS ix_vulnerabilities_priority_score;")
op.execute("DROP INDEX IF EXISTS ix_vulnerabilities_cpr_score;")
op.execute("""
ALTER TABLE vulnerabilities
DROP COLUMN IF EXISTS priority_score,
DROP COLUMN IF EXISTS cpr_score;
""")