Skip to content

feat: add -no-classify to skip ML page-type model download#2544

Open
jatinder14 wants to merge 2 commits into
projectdiscovery:devfrom
jatinder14:feat/no-classify-flag
Open

feat: add -no-classify to skip ML page-type model download#2544
jatinder14 wants to merge 2 commits into
projectdiscovery:devfrom
jatinder14:feat/no-classify-flag

Conversation

@jatinder14

@jatinder14 jatinder14 commented Jul 25, 2026

Copy link
Copy Markdown

Summary

  • Adds -nc / -no-classify so -json/-csv do not initialize the dit page-type classifier (and skip the ~92MB Hugging Face model download) when KnowledgeBase/PageType enrichment is not needed
  • Rejects combining -no-classify with -fpt / -fep (filtering requires the classifier)
  • Documents the flag in README and adds unit tests for classifier init + conflict validation

Fixes #2543

Test plan

  • go test ./runner/ -run 'TestShouldInitPageClassifier|TestNoClassifyConflictsWithPageTypeFilter|TestHasMatcherOrFilter'
  • Manual: rm -rf ~/.dit && echo https://example.com | ./httpx -json -no-classify — no model download / no classifier init warning about model
  • Manual: httpx -json -no-classify -fpt error — errors with conflict message

Made with Cursor

Summary by CodeRabbit

  • New Features
    • Added -nc / -no-classify to disable page-type classification and skip ML-based setup.
    • JSON/CSV exports can avoid downloading the classification model when classification isn’t required.
  • Bug Fixes
    • Prevented -no-classify from being used together with page-type or error-page filtering.
  • Documentation
    • Updated CLI help/README to document the new -nc / -no-classify flag and related behavior.
  • Tests
    • Added coverage for classifier initialization and the -no-classify validation conflict rules.

JSON/CSV output previously always initialized the dit classifier,
which downloads a ~92MB model even when PageType enrichment is unused.
Add -nc/-no-classify to opt out, reject combining it with -fpt/-fep,
and cover the behavior with unit tests.

Closes projectdiscovery#2543
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c3f5fdbc-9e71-4de5-929c-2f1b5d8f75f4

📥 Commits

Reviewing files that changed from the base of the PR and between d5e193e and 9f1a738.

📒 Files selected for processing (2)
  • README.md
  • runner/options.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • README.md
  • runner/options.go

Walkthrough

The CLI adds --no-classify, allowing JSON and CSV output without initializing the page classifier. Option validation rejects incompatible page-type filters, and runner construction uses the centralized initialization decision.

Changes

Page classification opt-out

Layer / File(s) Summary
No-classify option and validation
runner/options.go, runner/runner_test.go, README.md
Adds the NoClassify option and CLI flag, defines classifier initialization rules, validates incompatible filters, documents usage, and tests the behavior.
Classifier initialization wiring
runner/runner.go, runner/runner_test.go
Runner construction now initializes the page classifier through ShouldInitPageClassifier().

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant Options
  participant Runner
  participant Classifier
  CLI->>Options: Parse --no-classify
  Options->>Options: Evaluate ShouldInitPageClassifier()
  Runner->>Options: Request initialization decision
  Options-->>Runner: Return true or false
  Runner->>Classifier: Initialize when enabled
Loading

Poem

A rabbit hops past models bright,
“No classify” keeps downloads light.
Flags align and checks agree,
JSON blooms classifier-free.
Carrots cheer the tidy flow!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding a no-classify flag to skip page-type model loading.
Linked Issues check ✅ Passed The PR adds -no-classify, skips classifier initialization for json/csv output, and blocks incompatible filter combinations as required.
Out of Scope Changes check ✅ Passed All changes are directly tied to the new classification opt-out flag, its validation, documentation, and tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
runner/runner_test.go (1)

540-550: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the legacy -fep conflict path.

The implementation rejects both OutputFilterPageType and OutputFilterErrorPage, but this test only exercises the former. Add a case with OutputFilterErrorPage: true so the deprecated alias cannot regress silently.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@runner/runner_test.go` around lines 540 - 550, Add coverage to
TestNoClassifyConflictsWithPageTypeFilter for the legacy OutputFilterErrorPage
option by validating an Options case with NoClassify and OutputFilterErrorPage
set, and assert it returns an error mentioning "-no-classify"; retain the
existing OutputFilterPageType coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@runner/options.go`:
- Line 462: Resolve the duplicate nc shorthand between the no-classify option in
the options flag registration and the existing no-color registration. Keep a
single compatible alias or assign no-classify a unique shorthand, then update
the corresponding README/help text and add a parser-level test verifying the
finalized option mapping.

---

Nitpick comments:
In `@runner/runner_test.go`:
- Around line 540-550: Add coverage to TestNoClassifyConflictsWithPageTypeFilter
for the legacy OutputFilterErrorPage option by validating an Options case with
NoClassify and OutputFilterErrorPage set, and assert it returns an error
mentioning "-no-classify"; retain the existing OutputFilterPageType coverage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2297cd0f-e41f-4345-8f12-06eddfb21b4c

📥 Commits

Reviewing files that changed from the base of the PR and between d403a40 and d5e193e.

📒 Files selected for processing (4)
  • README.md
  • runner/options.go
  • runner/runner.go
  • runner/runner_test.go

Comment thread runner/options.go Outdated
CodeRabbit correctly flagged that -no-color already owns -nc.
Keep the long form -no-classify only and sync the README.
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.

Add a flag to disable page-type classification (dit model download) when using -json/-csv

1 participant