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.
45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
"""Add NESSUS to AssetSource + ASSET_DEACTIVATED/REACTIVATED audit types
|
|
|
|
Revision ID: 027
|
|
Revises: 026
|
|
Create Date: 2026-06-02 00:00:00.000000
|
|
|
|
Field feedback round 2026-06-01:
|
|
- Sync-driven reconciliation needs to distinguish Nessus-sourced
|
|
assets from Wazuh-sourced ones, so `AssetSource.NESSUS` is added.
|
|
- Audit log gains ASSET_DEACTIVATED + ASSET_REACTIVATED event types
|
|
so the lifecycle transitions are filterable in the audit UI.
|
|
|
|
Important: the existing PostgreSQL `assetsource` enum has UPPERCASE
|
|
labels ('WAZUH' / 'MANUAL'). The Python AssetSource enum has been
|
|
updated to use uppercase values to match. New PG enum value added
|
|
here is 'NESSUS' (uppercase) for consistency.
|
|
|
|
Important: PG requires a new enum value to be COMMITTED before it can
|
|
be used in the same session. A data UPDATE that references the new
|
|
value in the same transaction as the ALTER TYPE fails with
|
|
`unsafe use of new value ... of enum type`. Therefore this migration
|
|
ONLY extends the enums — the runtime backfill of MANUAL -> NESSUS for
|
|
assets that have a pinned nessus_host_uuid is performed lazily in
|
|
`app/services/asset_lifecycle.reconcile_missing_from_sync()` (called
|
|
on every Nessus sync), which runs in a later transaction.
|
|
"""
|
|
from alembic import op
|
|
|
|
|
|
revision = "027"
|
|
down_revision = "026"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.execute("ALTER TYPE assetsource ADD VALUE IF NOT EXISTS 'NESSUS'")
|
|
op.execute("ALTER TYPE auditeventtype ADD VALUE IF NOT EXISTS 'ASSET_DEACTIVATED'")
|
|
op.execute("ALTER TYPE auditeventtype ADD VALUE IF NOT EXISTS 'ASSET_REACTIVATED'")
|
|
|
|
|
|
def downgrade() -> None:
|
|
# PG cannot DROP VALUE on an enum. No-op.
|
|
pass
|