Skip to content

fix(runner): use Print instead to listAvailableStoreTags#7145

Merged
Mzack9999 merged 2 commits into
devfrom
dwisiswant0/fix/runner/use-Print-instead-to-listAvailableStoreTags
Mar 7, 2026
Merged

fix(runner): use Print instead to listAvailableStoreTags#7145
Mzack9999 merged 2 commits into
devfrom
dwisiswant0/fix/runner/use-Print-instead-to-listAvailableStoreTags

Conversation

@dwisiswant0
Copy link
Copy Markdown
Member

@dwisiswant0 dwisiswant0 commented Mar 7, 2026

Proposed changes

Tag listing (`-tgl`) output was moved to debug log
level, making it invisible during normal runs.
Restore tag output to default log level (Print)
for better usability.

Fixes #7142

Proof

before:

Image

Must use -debug flag.

after:

image

And it's 2x++ faster (#7143).

Checklist

  • Pull request is created against the dev branch
  • All checks passed (lint, unit/integration/regression tests etc.) with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Summary by CodeRabbit

  • Chores
    • Refactored internal template and tag listing operations to improve code organization and efficiency.

Tag listing (`-tgl`) output was moved to debug log
level, making it invisible during normal runs.
Restore tag output to default log level (Print)
for better usability.

Fixes #7142

Signed-off-by: Dwi Siswanto <git@dw1.io>
@auto-assign auto-assign Bot requested a review from Mzack9999 March 7, 2026 06:13
@neo-by-projectdiscovery-dev
Copy link
Copy Markdown

neo-by-projectdiscovery-dev Bot commented Mar 7, 2026

Neo - PR Security Review

No security issues found

Highlights

  • Restores -tgl flag output visibility by changing from debug log level to Print
  • Fixes issue [BUG] -tgl not working #7142 where tag listing was invisible during normal runs
  • Improves performance (2x++ faster according to PR description)
Hardening Notes
  • The change from debug logging to Print level for listAvailableStoreTags is purely a usability improvement
  • Tag listing output does not contain sensitive information that would pose a security risk when displayed at default log level
  • No user-controlled input is being processed differently, no new attack surface introduced

Comment @neo help for available commands. · Open in Neo

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 7, 2026

Walkthrough

The changes fix the tag listing functionality by separating tag and template listing logic paths. A new LoadTemplateTags method is added to compute tag occurrence counts, and the tag listing function is refactored to accept a pre-built tags map instead of deriving it from store data.

Changes

Cohort / File(s) Summary
Tag and template listing separation
internal/runner/runner.go, internal/runner/templates.go
Separates conditional branches for TagList versus TemplateList/TemplateDisplay. Renames listAvailableStoreTags to listAvailableTags, changes its signature to accept a pre-built tags map, and switches logging from Debug to Print level.
Template tag extraction
pkg/catalog/loader/loader.go
Adds new public method LoadTemplateTags() to Store that computes tag occurrence counts using metadata index when available, falls back to parser-based extraction, handles excluded templates, and caches results.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A tag list was lost in the shuffle, you see,
So we split the paths and set them all free,
New LoadTemplateTags reads the tags with care,
Now -tgl works again, everywhere! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title references 'listAvailableStoreTags' but the actual change renames this function to 'listAvailableTags' and also involves separating template/tag loading logic, making the title partially accurate but not fully representative of the main changes. Consider using a more comprehensive title like 'refactor(runner): separate tag and template listing with improved logging' to better reflect all the changes.
Out of Scope Changes check ❓ Inconclusive The PR includes a new LoadTemplateTags method and refactors tag/template separation, extending beyond the minimal fix for issue #7142 but appearing related to performance improvements referenced in #7143. Clarify whether LoadTemplateTags and the tag/template separation are necessary for fixing #7142 or if they represent optimization work that should be separated.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR successfully addresses issue #7142 by switching logging from Debug to Print level, restoring tag list visibility in normal runs without the debug flag.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dwisiswant0/fix/runner/use-Print-instead-to-listAvailableStoreTags

Comment @coderabbitai help to get the list of available commands and usage tips.

Uses metadata caching via catalog index to reduce
runtime overhead.

Add `(*Store).LoadTemplateTags` for efficient tag
aggregation.

Signed-off-by: Dwi Siswanto <git@dw1.io>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/runner/templates.go (1)

100-108: Consider using Silent() for JSONL output to enable clean piping.

Based on learnings, Print() writes to stderr while Silent() writes to stdout. For the JSONL output path (Line 103), using Silent() would allow users to pipe the machine-readable output cleanly:

nuclei -tgl --jsonl | jq '.tag'

Currently, both JSONL and regular output go to stderr, which may complicate scripting use cases.

♻️ Suggested change for JSONL output
 	for _, tag := range tagsList {
 		if r.options.JSONL {
 			marshalled, _ := jsoniter.Marshal(tag)
-			r.Logger.Print().Msgf("%s", string(marshalled))
+			r.Logger.Silent().Msgf("%s", string(marshalled))
 		} else {
 			r.Logger.Print().Msgf("%s (%d)", tag.Key, tag.Value)
 		}
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/runner/templates.go` around lines 100 - 108, The loop that emits
tags uses r.Logger.Print() for both output modes so JSONL output is written to
stderr; when r.options.JSONL is true, switch the logger call to
r.Logger.Silent() so the marshalled JSON (marshalled variable in the JSONL
branch) is written to stdout for clean piping, while leaving the non-JSONL
branch using r.Logger.Print() to keep human-readable output on stderr.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/runner/templates.go`:
- Around line 100-108: The loop that emits tags uses r.Logger.Print() for both
output modes so JSONL output is written to stderr; when r.options.JSONL is true,
switch the logger call to r.Logger.Silent() so the marshalled JSON (marshalled
variable in the JSONL branch) is written to stdout for clean piping, while
leaving the non-JSONL branch using r.Logger.Print() to keep human-readable
output on stderr.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e21aeed1-d157-49f4-9fa3-b02c0ccb1d38

📥 Commits

Reviewing files that changed from the base of the PR and between 884d0b5 and 18b4981.

📒 Files selected for processing (3)
  • internal/runner/runner.go
  • internal/runner/templates.go
  • pkg/catalog/loader/loader.go

@Mzack9999 Mzack9999 merged commit f9b21a7 into dev Mar 7, 2026
20 checks passed
@Mzack9999 Mzack9999 deleted the dwisiswant0/fix/runner/use-Print-instead-to-listAvailableStoreTags branch March 7, 2026 21:51
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.

[BUG] -tgl not working

2 participants