Skip to content

fix: nuclei template freshness + debug-upload visibility#159

Merged
ShubhamRasal merged 3 commits into
mainfrom
shubh/fatal-template-update
Jun 8, 2026
Merged

fix: nuclei template freshness + debug-upload visibility#159
ShubhamRasal merged 3 commits into
mainfrom
shubh/fatal-template-update

Conversation

@ShubhamRasal

@ShubhamRasal ShubhamRasal commented Jun 2, 2026

Copy link
Copy Markdown
Member

Three related changes to the nuclei template lifecycle and debug-upload observability.

1. Make template install/update failure fatal at boot

ensureNucleiTemplates logged and returned on failure, so the agent kept running with a stale or incomplete nuclei-templates dir — surfacing later as per-template Failed to read template file ... no such file or directory mid-scan. Both failure paths (can't determine dir, update errors) now os.Exit(1), matching the prereq.EnsureAll() check right above the call site. A scanner with no usable templates should fail loud at startup, not silently degrade.

2. Refresh templates at the start of each vuln scan

Long-lived agents kept whatever templates they pulled at boot, so a template added upstream after startup never landed and the cloud's path for it failed mid-scan. processJetStreamScan now refreshes once per scan, before chunk processing. Serialized across concurrent scans (ScanParallelism > 1) and non-fatal — boot already guaranteed a usable set, so a transient refresh failure proceeds on the existing templates rather than dropping the scan. Enumeration doesn't touch templates, so it's untouched.

3. Log debug-upload URL availability

Whether the cloud issues a presigned debug-upload URL was invisible until upload time, and only at Debug level. Now surfaced as debug_upload_url_available=true|false on the NATS credentials line (startup + every refresh) and before the shutdown upload — so it's clear why a DB upload did or didn't happen.

Known gap (not addressed here)

A present-but-incomplete templates dir whose .templates-config.json version stamp is current still slips through — UpdateIfOutdated trusts the stamp and never reconciles files against the stored checksum. This is mostly a dev-box hygiene case (prod containers cold-start fresh). The correct fix is upstream in the nuclei SDK (reconcile the existing .checksum even when the version is current); tracking separately rather than adding brittle corruption heuristics here.

A failed install/update left the agent running with stale or missing
templates, surfacing as per-template "file not found" errors mid-scan
for every cloud-sent path absent locally. Exit on failure instead of
silently degrading.
@ShubhamRasal ShubhamRasal self-assigned this Jun 2, 2026
Long-lived agents kept whatever templates they pulled at boot, so a
template added after startup never landed and the cloud's path for it
failed mid-scan. Refresh once per scan in processJetStreamScan before
chunk processing. Serialized across concurrent scans and non-fatal:
boot already guaranteed a usable set, so a transient failure proceeds
on the existing templates.
Whether the cloud issues a presigned debug-upload URL was invisible
until upload time, and only at Debug level. Surface it on the NATS
credentials line at startup/refresh and before the shutdown upload so
it's clear why a DB upload did or didn't happen.
@ShubhamRasal ShubhamRasal changed the title fix: make nuclei template install/update failure fatal fix: nuclei template freshness + debug-upload visibility Jun 8, 2026
@ShubhamRasal ShubhamRasal merged commit 3a4ee7b into main Jun 8, 2026
5 checks passed
@ShubhamRasal ShubhamRasal deleted the shubh/fatal-template-update branch June 8, 2026 11:45
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.

1 participant