Skip to content

chore(deps): strip dependencies - #7457

Merged
dwisiswant0 merged 19 commits into
devfrom
dwisiswant0/chore/deps/strip-dependencies
Jun 20, 2026
Merged

chore(deps): strip dependencies#7457
dwisiswant0 merged 19 commits into
devfrom
dwisiswant0/chore/deps/strip-dependencies

Conversation

@dwisiswant0

@dwisiswant0 dwisiswant0 commented Jun 10, 2026

Copy link
Copy Markdown
Member

Proposed changes

Dependency strip:

  • Removed direct gopkg.in/yaml.v2 usage.
  • Removed local github.com/json-iterator/go imports; it is now indirect only (via github.com/projectdiscovery/interactsh/pkg/client).
  • Removed Echo/gommon & valyala's fasttemplate direct dependency paths.
  • Replaced old github.com/google/go-github import with github.com/google/go-github/v30.
  • Replaced bluele/gcache / Mzack9999/gcache usages with projectdiscovery/gcache.
  • Replaced weppos/publicsuffix-go with golang.org/x/net/publicsuffix.
  • Removed govalidator ASCII check with a local isASCII.

Follow ups:

  • Strip gopkg.in/yaml.v2 remains in go.sum via upstream github.com/Mzack9999/goja tests.

    $ go mod why -m gopkg.in/yaml.v2
    # gopkg.in/yaml.v2
    github.com/projectdiscovery/nuclei/v3/pkg/js/compiler
    github.com/Mzack9999/goja
    github.com/Mzack9999/goja.test
    gopkg.in/yaml.v2

    FYI, @Mzack9999. Also, I think we need to move that repo into the orgz.

  • Strip github.com/json-iterator/go usages upstream (github.com/projectdiscovery/interactsh/pkg/client).

  • Review whether dockertest replaceable with testcontainers.

Proof

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

  • New Features
    • Added stricter YAML parsing options (reject unknown/duplicate fields) and preserved ordered map decoding.
  • Improvements
    • Improved server-side auth validation with clearer 400/401 responses and proper CORS OPTIONS preflight behavior.
    • Migrated multiple HTTP endpoints from Echo to net/http for improved consistency.
    • Standardized YAML/JSON serialization across the project.
    • Safer shutdown to reduce potential panics; improved resilience in configuration handling.
  • Tests
    • Added unit tests for auth/CORS and YAML/JSON utilities, plus updates to integration expectations.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ec4e0d3d-fa81-499e-83a2-328fb057d340

📥 Commits

Reviewing files that changed from the base of the PR and between 1e2fe6d and 637ec6c.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod
🚧 Files skipped from review as they are similar to previous changes (1)
  • go.mod

Walkthrough

This pull request consolidates YAML and JSON serialization to internal utility packages backed by yaml.v3 and encoding/json, migrates multiple HTTP servers from Echo to net/http, realigns Go module dependencies with versioned imports, refactors behavioral utilities (DNS splitting, generic cache typing), and updates integration test harnesses including Docker/MongoDB container setup changes.

Changes

Dependency Migration and HTTP Server Refactoring

Layer / File(s) Summary
Module manifest and import path realignment
go.mod, pkg/external/customtemplates/github.go, pkg/input/formats/openapi/generator.go, pkg/protocols/headless/engine/util.go, pkg/protocols/common/interactsh/interactsh.go, pkg/reporting/trackers/github/github.go, pkg/types/interfaces.go
Updates go.mod to reorganize direct/indirect dependencies, reclassify json-iterator and publicsuffix-go as indirect, upgrade go-github to v30, and switch fasttemplate/gcache imports to projectdiscovery versions; removes testcontainers and echo dependencies; adds local isASCII helper replacing govalidator; updates GitHub tracker with v30 client and nil-safe issue matching.
YAML v3 compatibility layer
pkg/utils/yaml/yaml_decode_wrapper.go, pkg/utils/yaml/yaml_decode_wrapper_test.go
Implements yaml.v3-backed decoder/encoder with strict/lax modes, duplicate-key normalization, yaml.v2-style interface-map restoration, MapSlice ordered decoding, and comprehensive tests for field strictness, duplicate handling, and order preservation.
YAML adoption in core and template parsing
cmd/nuclei/main.go, lib/config.go, pkg/catalog/config/ignorefile.go, pkg/templates/compile.go, pkg/templates/parser.go, pkg/templates/templates.go, pkg/templates/templates_test.go, pkg/templates/parser_test.go, pkg/model/model_test.go, pkg/model/types/severity/severity_test.go
Switches YAML imports to internal utilities across command, config, and template parsing; updates template marshaling output and adds parser strictness tests for unknown/duplicate fields and multi-protocol request-queue ordering.
YAML adoption in protocols and utilities
pkg/fuzz/type.go, pkg/fuzz/type_test.go, pkg/utils/insertion_ordered_map.go, pkg/utils/insertion_ordered_map_test.go, pkg/protocols/common/variables/variables_test.go, pkg/protocols/common/generators/generators_test.go, pkg/input/formats/yaml/ytt.go, pkg/reporting/reporting.go, pkg/protocols/utils/variables.go, pkg/protocols/utils/variables_test.go, pkg/protocols/common/automaticscan/automaticscan.go
Adopts internal YAML across fuzz types, insertion-ordered maps, and protocol utilities; refactors DNS variable splitting using golang.org/x/net/publicsuffix, adds fuzz type unmarshalling tests and table-driven DNS variable tests.
JSON utilities and adoption
pkg/utils/json/json_test.go, internal/runner/templates.go, pkg/output/format_json.go, pkg/output/output.go, pkg/fuzz/dataformat/json.go, pkg/protocols/common/contextargs/metainput.go, pkg/protocols/common/contextargs/metainput_test.go, pkg/protocols/http/http.go, pkg/protocols/ssl/ssl.go, pkg/protocols/whois/whois.go
Adds JSON utility tests for field output, encoder newlines, HTML escaping, and numeric round-tripping; replaces jsoniter usage with internal JSON helpers across runner, output, fuzz, and protocol paths.
DAST server net/http migration
internal/server/server.go, internal/server/server_test.go, internal/server/nuclei_sdk.go
Refactors DAST server from Echo to net/http with ServeMux routing, token-auth/CORS/logging/recovery middleware, structured JSON request/error handling, template-rendered stats endpoint, nil-safe executor and HTTP server Close; adds tests for auth rejection, CORS preflight bypass, and nil-safe Close.
Fuzz playground and scan charts net/http migration
internal/fuzzplayground/server.go, pkg/scan/charts/charts.go, pkg/scan/charts/echarts.go
Converts fuzz playground to PlaygroundServer wrapper over net/http with ServeMux routes and response helpers; migrates chart server and all endpoints to net/http with shared renderChart helper and updated query-string parsing.
Behavioral utility updates
pkg/fuzz/frequency/tracker.go, pkg/input/formats/swagger/swagger.go
Upgrades Tracker to typed generic gcache.Cache[string, *cacheItem] removing runtime casts; adds Swagger YAML normalization via yaml.v3 unmarshalling followed by JSON round-trip into OpenAPI v2 schema struct.
Integration test helpers and harness updates
internal/tests/integration/dns_test.go, internal/tests/integration/flow_test.go, internal/tests/integration/template-path_test.go, internal/tests/integration/http_test.go, internal/tests/integration/exporters_test.go, internal/tests/integration/javascript_test.go, internal/tests/integration/testdata/subdomains.txt
Introduces expectPublicDNSResultsCount helper and updates DNS/flow/template-path assertions; replaces testcontainers MongoDB with dockertest pool and URI construction; adds environment gating for Samba goexec tests, removes resource TTL expiration calls, and simplifies container cleanup.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

  • projectdiscovery/nuclei#7458: Dependency stripping and module consolidation initiative directly addressed by this PR through YAML/JSON utilities, HTTP server refactoring, GitHub client upgrade, and package manager updates.

Possibly related PRs

  • projectdiscovery/nuclei#7447: Both PRs adjust Docker and testcontainers dependencies; main PR prunes direct testcontainers-go and related moby modules, while the other modifies testcontainers ecosystem versions.

Suggested reviewers

  • Mzack9999
  • dogancanbakir

🐰 Whiskers twitch with delight,
YAML v3 wrapped so tight,
Echo fades to HTTP's embrace,
Dependencies find their place!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.28% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(deps): strip dependencies' clearly summarizes the main change—systematic removal and replacement of direct dependencies throughout the project.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dwisiswant0/chore/deps/strip-dependencies

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/fuzz/type.go (1)

105-107: ⚠️ Potential issue | 🟠 Major

Avoid panic on non-string YAML map entries in SliceOrMapSlice.UnmarshalYAML

pkg/fuzz/type.go lines 106–107 do unchecked v.Key.(string) / v.Value.(string) assertions after decoding into yaml.MapSlice (MapItem.Key/Value are interface{}). Non-string scalars (e.g., numbers/bools) will cause a panic instead of returning an error.

Proposed fix
 	for _, v := range node {
-		tmpx.Set(v.Key.(string), v.Value.(string))
+		key, ok := v.Key.(string)
+		if !ok {
+			return fmt.Errorf("invalid payload key type %T: expected string", v.Key)
+		}
+		val, ok := v.Value.(string)
+		if !ok {
+			return fmt.Errorf("invalid payload value type for key %q: %T (expected string)", key, v.Value)
+		}
+		tmpx.Set(key, val)
 	}
🤖 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 `@pkg/fuzz/type.go` around lines 105 - 107, In SliceOrMapSlice.UnmarshalYAML,
avoid panic from unchecked assertions by validating types before using
v.Key.(string) and v.Value.(string): when iterating the yaml.MapSlice (the loop
that calls tmpx.Set), perform safe type assertions or type switches on v.Key and
v.Value and if either is not a string return a descriptive error (e.g., using
fmt.Errorf) instead of panicking; ensure you reference the
SliceOrMapSlice.UnmarshalYAML method and the tmpx.Set call so the non-string
cases are handled gracefully and an error is propagated to the caller.
🧹 Nitpick comments (6)
internal/server/server.go (3)

294-301: ⚖️ Poor tradeoff

Guard against writing headers twice after partial template execution.

If tmpl.Execute(w, stats) (line 299) writes partial output and then fails, the subsequent writeServerJSON call (line 300) will attempt to set headers again, potentially causing "http: superfluous response.WriteHeader" errors or malformed responses. Consider buffering the template output before writing to the response, or ensure template execution completes successfully before any writes.

♻️ Proposed fix using buffer
 func (s *DASTServer) handleStats(w http.ResponseWriter, _ *http.Request) {
 	stats, err := s.getStats()
 	if err != nil {
 		writeServerJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
 		return
 	}
 
 	tmpl, err := template.New("index").Parse(indexTemplate)
 	if err != nil {
 		writeServerJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
 		return
 	}
+	var buf bytes.Buffer
+	if err := tmpl.Execute(&buf, stats); err != nil {
-	if err := tmpl.Execute(w, stats); err != nil {
 		writeServerJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
+		return
 	}
+	w.Header().Set("Content-Type", "text/html; charset=UTF-8")
+	_, _ = w.Write(buf.Bytes())
 }
🤖 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 `@internal/server/server.go` around lines 294 - 301, The template execution
currently writes directly to the ResponseWriter (tmpl.Execute(w, stats)), so a
partial write followed by writeServerJSON can cause duplicate header writes; fix
by executing the parsed template into a buffer first (use the result of
template.New("index").Parse and call tmpl.Execute into a bytes.Buffer), check
for Execute error before writing any headers or body, and only copy the buffered
bytes to w on success—this ensures tmpl.Execute and writeServerJSON don't
compete for response headers and avoids "superfluous response.WriteHeader"
errors.

260-260: ⚡ Quick win

Use optionsOrDefault() for consistency.

Line 260 directly accesses s.options.Token, while the rest of the code uses the optionsOrDefault() helper (lines 140, 148, 172, 189). Although s.options is always initialized in constructors, using the helper maintains consistency and defensive programming style.

♻️ Suggested change
-		ServerAuthEnabled:     s.options.Token != "",
+		ServerAuthEnabled:     s.optionsOrDefault().Token != "",
🤖 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 `@internal/server/server.go` at line 260, The ServerAuthEnabled field is
reading s.options.Token directly; change it to use the helper optionsOrDefault()
for consistency and defensive behavior. Replace the direct access in the
ServerAuthEnabled assignment with optionsOrDefault(s.options).Token so the code
mirrors other uses (lines using optionsOrDefault()) and avoids direct s.options
dereference.

366-375: ⚡ Quick win

Log panics in recovery middleware for debuggability.

The recoverMiddleware swallows panics without logging them (line 369-370). This makes debugging production issues difficult since there's no record of what caused the panic. Consider logging the panic value and stack trace.

🔍 Proposed fix with logging
 func recoverMiddleware(next http.Handler) http.Handler {
 	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 		defer func() {
 			if recovered := recover(); recovered != nil {
+				gologger.Error().Msgf("Panic recovered in %s %s: %v", r.Method, r.URL.Path, recovered)
 				http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
 			}
 		}()
 		next.ServeHTTP(w, r)
 	})
 }
🤖 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 `@internal/server/server.go` around lines 366 - 375, The recoverMiddleware
currently swallows panics and only returns a 500; update the deferred recovery
handler inside recoverMiddleware to log the recovered value and stack trace
before returning the 500. Specifically, in the anonymous defer function in
recoverMiddleware, capture the recovered value (recovered) and log it along with
runtime/debug.Stack() (or equivalent logger) so you record both the panic
message and stack; then call http.Error(w,
http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
as before. Ensure you reference the recoverMiddleware function and the existing
http.Error call when adding the logging so the panic is recorded for debugging.
pkg/scan/charts/charts.go (1)

82-82: 💤 Low value

log.Fatal will terminate the process on server error.

Line 82 uses log.Fatal which calls os.Exit(1) if ListenAndServe returns an error. This prevents graceful shutdown and cleanup. Consider returning the error to the caller or using a logger that doesn't exit the process.

♻️ Alternative approach
 func (sc *ScanEventsCharts) Start(addr string) {
-	log.Fatal(http.ListenAndServe(addr, sc.routes()))
+	if err := http.ListenAndServe(addr, sc.routes()); err != nil {
+		log.Printf("Charts server error: %v", err)
+	}
 }

Or better, return the error:

-func (sc *ScanEventsCharts) Start(addr string) {
-	log.Fatal(http.ListenAndServe(addr, sc.routes()))
+func (sc *ScanEventsCharts) Start(addr string) error {
+	return http.ListenAndServe(addr, sc.routes())
 }
🤖 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 `@pkg/scan/charts/charts.go` at line 82, Using log.Fatal with
http.ListenAndServe in charts.go will exit the process and prevent graceful
shutdown; replace the direct log.Fatal call so the server error is returned to
the caller (or logged without exiting) instead: call http.ListenAndServe(addr,
sc.routes()), capture its returned error, and if non-nil either return that
error from the enclosing function (propagating it up for cleanup) or log it with
a non-exiting logger; update the function containing the call to
accept/propagate an error return so callers can perform graceful shutdown rather
than relying on log.Fatal.
pkg/fuzz/type_test.go (1)

19-36: ⚡ Quick win

Add a regression test for non-string YAML map values.

Current tests only validate string key/value maps. Please add a case like count: 1 and assert the decoder returns an error (not panic) once the map-casting fix is applied.

🤖 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 `@pkg/fuzz/type_test.go` around lines 19 - 36, Update the
TestSliceOrMapSliceUnmarshalYAMLMapPreservesOrder test to also cover non-string
YAML map values: after the current successful string-map assertions, attempt
yaml.Unmarshal with input containing a non-string value (e.g. "count: 1") into a
new SliceOrMapSlice and assert that the Unmarshal returns a non-nil error (and
does not panic); reference the SliceOrMapSlice type and the existing
TestSliceOrMapSliceUnmarshalYAMLMapPreservesOrder test to add this new case,
using require.Error/require.NotNil on the returned err rather than expecting
success.
pkg/protocols/common/automaticscan/automaticscan.go (1)

16-17: Decouple automaticscan production code from internal/tests/testutils

pkg/protocols/common/automaticscan/automaticscan.go imports github.com/projectdiscovery/nuclei/v3/internal/tests/testutils (lines 16-17) and sets execOptions.Progress to &testutils.MockProgressClient{} during non-test execution (line 188). MockProgressClient is effectively a no-op implementation of pkg/progress.Progress, so it should live in a production package (e.g., pkg/progress as NoopProgress) to avoid coupling runtime to a tests namespace.

🤖 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 `@pkg/protocols/common/automaticscan/automaticscan.go` around lines 16 - 17,
The code currently imports internal/tests/testutils and sets
execOptions.Progress = &testutils.MockProgressClient{}, coupling production code
to test internals; replace that by creating or using a production no-op
implementation (e.g., pkg/progress.NoopProgress or NoopProgressClient
implementing pkg/progress.Progress) and set execOptions.Progress =
pkg/progress.NoopProgress{} (or &pkg/progress.NoopProgressClient{}) in
automaticscan.go; remove the testutils import from automaticscan.go and update
any tests to continue using testutils.MockProgressClient only within test
packages.
🤖 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 `@pkg/input/formats/yaml/ytt.go`:
- Around line 62-63: The function mapToKeyValueSlice currently ignores errors
from yamlutil.Marshal; change mapToKeyValueSlice to return ([]string, error),
check the error returned by yamlutil.Marshal(v) inside the loop, and on error
return a wrapped/contextual error (e.g., include the key name) instead of
continuing; on success continue to append fmt.Sprintf("%s=%s", k,
strings.TrimSpace(string(y))). Update any callers of mapToKeyValueSlice to
handle the returned error and propagate or handle it accordingly.

---

Outside diff comments:
In `@pkg/fuzz/type.go`:
- Around line 105-107: In SliceOrMapSlice.UnmarshalYAML, avoid panic from
unchecked assertions by validating types before using v.Key.(string) and
v.Value.(string): when iterating the yaml.MapSlice (the loop that calls
tmpx.Set), perform safe type assertions or type switches on v.Key and v.Value
and if either is not a string return a descriptive error (e.g., using
fmt.Errorf) instead of panicking; ensure you reference the
SliceOrMapSlice.UnmarshalYAML method and the tmpx.Set call so the non-string
cases are handled gracefully and an error is propagated to the caller.

---

Nitpick comments:
In `@internal/server/server.go`:
- Around line 294-301: The template execution currently writes directly to the
ResponseWriter (tmpl.Execute(w, stats)), so a partial write followed by
writeServerJSON can cause duplicate header writes; fix by executing the parsed
template into a buffer first (use the result of template.New("index").Parse and
call tmpl.Execute into a bytes.Buffer), check for Execute error before writing
any headers or body, and only copy the buffered bytes to w on success—this
ensures tmpl.Execute and writeServerJSON don't compete for response headers and
avoids "superfluous response.WriteHeader" errors.
- Line 260: The ServerAuthEnabled field is reading s.options.Token directly;
change it to use the helper optionsOrDefault() for consistency and defensive
behavior. Replace the direct access in the ServerAuthEnabled assignment with
optionsOrDefault(s.options).Token so the code mirrors other uses (lines using
optionsOrDefault()) and avoids direct s.options dereference.
- Around line 366-375: The recoverMiddleware currently swallows panics and only
returns a 500; update the deferred recovery handler inside recoverMiddleware to
log the recovered value and stack trace before returning the 500. Specifically,
in the anonymous defer function in recoverMiddleware, capture the recovered
value (recovered) and log it along with runtime/debug.Stack() (or equivalent
logger) so you record both the panic message and stack; then call http.Error(w,
http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
as before. Ensure you reference the recoverMiddleware function and the existing
http.Error call when adding the logging so the panic is recorded for debugging.

In `@pkg/fuzz/type_test.go`:
- Around line 19-36: Update the
TestSliceOrMapSliceUnmarshalYAMLMapPreservesOrder test to also cover non-string
YAML map values: after the current successful string-map assertions, attempt
yaml.Unmarshal with input containing a non-string value (e.g. "count: 1") into a
new SliceOrMapSlice and assert that the Unmarshal returns a non-nil error (and
does not panic); reference the SliceOrMapSlice type and the existing
TestSliceOrMapSliceUnmarshalYAMLMapPreservesOrder test to add this new case,
using require.Error/require.NotNil on the returned err rather than expecting
success.

In `@pkg/protocols/common/automaticscan/automaticscan.go`:
- Around line 16-17: The code currently imports internal/tests/testutils and
sets execOptions.Progress = &testutils.MockProgressClient{}, coupling production
code to test internals; replace that by creating or using a production no-op
implementation (e.g., pkg/progress.NoopProgress or NoopProgressClient
implementing pkg/progress.Progress) and set execOptions.Progress =
pkg/progress.NoopProgress{} (or &pkg/progress.NoopProgressClient{}) in
automaticscan.go; remove the testutils import from automaticscan.go and update
any tests to continue using testutils.MockProgressClient only within test
packages.

In `@pkg/scan/charts/charts.go`:
- Line 82: Using log.Fatal with http.ListenAndServe in charts.go will exit the
process and prevent graceful shutdown; replace the direct log.Fatal call so the
server error is returned to the caller (or logged without exiting) instead: call
http.ListenAndServe(addr, sc.routes()), capture its returned error, and if
non-nil either return that error from the enclosing function (propagating it up
for cleanup) or log it with a non-exiting logger; update the function containing
the call to accept/propagate an error return so callers can perform graceful
shutdown rather than relying on log.Fatal.
🪄 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

Run ID: 25cf300f-0769-4fcc-b976-5bde38d0856f

📥 Commits

Reviewing files that changed from the base of the PR and between 85e218a and f7cc001.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (54)
  • cmd/nuclei/main.go
  • go.mod
  • internal/fuzzplayground/server.go
  • internal/runner/templates.go
  • internal/server/nuclei_sdk.go
  • internal/server/server.go
  • internal/server/server_test.go
  • internal/tests/integration/dns_test.go
  • internal/tests/integration/exporters_test.go
  • internal/tests/integration/flow_test.go
  • internal/tests/integration/http_test.go
  • internal/tests/integration/javascript_test.go
  • internal/tests/integration/template-path_test.go
  • lib/config.go
  • pkg/catalog/config/ignorefile.go
  • pkg/external/customtemplates/github.go
  • pkg/fuzz/dataformat/json.go
  • pkg/fuzz/frequency/tracker.go
  • pkg/fuzz/type.go
  • pkg/fuzz/type_test.go
  • pkg/input/formats/openapi/generator.go
  • pkg/input/formats/swagger/swagger.go
  • pkg/input/formats/yaml/ytt.go
  • pkg/model/model_test.go
  • pkg/model/types/severity/severity_test.go
  • pkg/output/format_json.go
  • pkg/output/output.go
  • pkg/protocols/common/automaticscan/automaticscan.go
  • pkg/protocols/common/contextargs/metainput.go
  • pkg/protocols/common/contextargs/metainput_test.go
  • pkg/protocols/common/generators/generators_test.go
  • pkg/protocols/common/interactsh/interactsh.go
  • pkg/protocols/common/variables/variables_test.go
  • pkg/protocols/headless/engine/util.go
  • pkg/protocols/http/http.go
  • pkg/protocols/ssl/ssl.go
  • pkg/protocols/utils/variables.go
  • pkg/protocols/utils/variables_test.go
  • pkg/protocols/whois/whois.go
  • pkg/reporting/reporting.go
  • pkg/reporting/trackers/github/github.go
  • pkg/scan/charts/charts.go
  • pkg/scan/charts/echarts.go
  • pkg/templates/compile.go
  • pkg/templates/parser.go
  • pkg/templates/parser_test.go
  • pkg/templates/templates.go
  • pkg/templates/templates_test.go
  • pkg/types/interfaces.go
  • pkg/utils/insertion_ordered_map.go
  • pkg/utils/insertion_ordered_map_test.go
  • pkg/utils/json/json_test.go
  • pkg/utils/yaml/yaml_decode_wrapper.go
  • pkg/utils/yaml/yaml_decode_wrapper_test.go

Comment on lines +62 to 63
y, _ := yamlutil.Marshal(v)
result = append(result, fmt.Sprintf("%s=%s", k, strings.TrimSpace(string(y))))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate and print the relevant portion of the file around the referenced lines
FILE="pkg/input/formats/yaml/ytt.go"
if [ -f "$FILE" ]; then
  echo "=== $FILE (lines 40-90) ==="
  nl -ba "$FILE" | sed -n '40,90p'
else
  echo "File not found: $FILE" >&2
  exit 1
fi

# Check whether yamlutil.Marshal errors are handled elsewhere in the file/repo
echo "=== yamlutil.Marshal call sites (repo) ==="
rg -n "yamlutil\.Marshal\(" -S . || true

# Identify the surrounding function (likely mapToKeyValueSlice)
echo "=== mapToKeyValueSlice definition/context ==="
rg -n "mapToKeyValueSlice" "$FILE" || true

# Run gofmt + go vet per guidelines
echo "=== go fmt ./... ==="
go fmt ./...

echo "=== go vet ./... ==="
go vet ./...

Repository: projectdiscovery/nuclei

Length of output: 180


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="pkg/input/formats/yaml/ytt.go"

echo "=== Checking file exists ==="
ls -la "$FILE" || exit 1

echo "=== $FILE (lines 40-90) ==="
cat -n "$FILE" | sed -n '40,90p'

echo "=== yamlutil.Marshal call sites (repo) ==="
rg -n "yamlutil\.Marshal\(" -S . || true

echo "=== mapToKeyValueSlice definition/context ==="
rg -n "mapToKeyValueSlice" "$FILE" || true

echo "=== toolchain check ==="
if command -v go >/dev/null 2>&1; then
  echo "go found at: $(command -v go)"
  echo "=== go fmt ./... ==="
  go fmt ./...
  echo "=== go vet ./... ==="
  go vet ./...
else
  echo "go not found; skipping go fmt/vet."
fi

Repository: projectdiscovery/nuclei

Length of output: 3166


Handle yamlutil.Marshal errors in mapToKeyValueSlice
mapToKeyValueSlice discards the error from yamlutil.Marshal (y, _ := yamlutil.Marshal(v)), so failures can generate incorrect key=value payloads for ytt. Propagate or return an error when marshalling fails instead of dropping it.

🤖 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 `@pkg/input/formats/yaml/ytt.go` around lines 62 - 63, The function
mapToKeyValueSlice currently ignores errors from yamlutil.Marshal; change
mapToKeyValueSlice to return ([]string, error), check the error returned by
yamlutil.Marshal(v) inside the loop, and on error return a wrapped/contextual
error (e.g., include the key name) instead of continuing; on success continue to
append fmt.Sprintf("%s=%s", k, strings.TrimSpace(string(y))). Update any callers
of mapToKeyValueSlice to handle the returned error and propagate or handle it
accordingly.

Comment thread internal/fuzzplayground/server.go Dismissed
Comment thread internal/fuzzplayground/server.go Dismissed
Comment thread internal/fuzzplayground/server.go Dismissed
Comment thread internal/fuzzplayground/server.go Dismissed
Comment thread internal/fuzzplayground/server.go Dismissed
@dwisiswant0

Copy link
Copy Markdown
Member Author

@coderabbitai Create an issue for this, prefxied with "[MAINTENANCE]".

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
gh issue create \
  --repo projectdiscovery/nuclei \
  --title "[MAINTENANCE] Strip and reduce direct dependencies" \
  --assignee dwisiswant0 \
  --body "## Overview

This issue tracks the ongoing effort to reduce the dependency surface of nuclei by removing or replacing direct dependencies with lighter alternatives or internal implementations.

Related PR: projectdiscovery/nuclei#7457

## Completed (in `#7457`)

- Removed direct \`gopkg.in/yaml.v2\` usage; routed callers through \`pkg/utils/yaml\` wrappers.
- Removed direct \`github.com/json-iterator/go\` imports; routed callers through \`pkg/utils/json\` wrapper (now indirect only via \`github.com/projectdiscovery/interactsh/pkg/client\`).
- Removed direct Echo (\`github.com/labstack/echo/v4\`) and \`gommon\`/\`valyala/fasttemplate\` dependencies; replaced HTTP servers with \`net/http\`.
- Replaced \`github.com/google/go-github\` with \`github.com/google/go-github/v30\`.
- Replaced \`bluele/gcache\` / \`Mzack9999/gcache\` with \`projectdiscovery/gcache\`.
- Replaced \`weppos/publicsuffix-go\` with \`golang.org/x/net/publicsuffix\`.
- Replaced \`govalidator\` ASCII check with a local \`isASCII\` implementation.

## Remaining Follow-ups

- [ ] \`gopkg.in/yaml.v2\` remains in \`go.sum\` via upstream \`github.com/Mzack9999/goja\` tests (\`go mod why\` chain: \`github.com/Mzack9999/goja.test\`). Investigate removing or replacing \`github.com/Mzack9999/goja\`.
- [ ] Remove \`json-iterator\` usages upstream in \`github.com/projectdiscovery/interactsh/pkg/client\` so the dependency becomes fully removable.
- [ ] Consider replacing \`dockertest\` with \`testcontainers-go\` for integration tests (see \`internal/tests/integration/exporters_test.go\`).

## References

- PR `#7457`: https://github.com/projectdiscovery/nuclei/pull/7457
- Requested by `@dwisiswant0`
"

Length of output: 1943



@dwisiswant0: Done! The issue has been created and assigned to you:

[MAINTENANCE] Strip and reduce direct dependencies#7458

It summarises what was completed in this PR and tracks the three remaining follow-ups (yaml.v2 via Mzack9999/goja, json-iterator upstream in interactsh, and dockertest → testcontainers migration).

@Mzack9999
Mzack9999 self-requested a review June 16, 2026 20:41

@Mzack9999 Mzack9999 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

merge conflicts

Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
@dwisiswant0
dwisiswant0 force-pushed the dwisiswant0/chore/deps/strip-dependencies branch from e60bf64 to d217213 Compare June 19, 2026 09:14
@dwisiswant0
dwisiswant0 requested a review from Mzack9999 June 19, 2026 09:14

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@pkg/protocols/ssl/ssl.go`:
- Around line 269-270: The json.Marshal call on the line assigning to jsonData
is ignoring the returned error by using a blank identifier, which can cause
silent data corruption when marshaling fails. Modify the json.Marshal statement
to capture the error, then check if the error is not nil and handle it
appropriately before proceeding with the string conversion. This ensures that if
json.Marshal fails, the error is caught and addressed rather than allowing empty
or corrupted data to be stored in data["response"].
🪄 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

Run ID: 0b75f23a-a817-496b-ba1c-aef4cd66aa9e

📥 Commits

Reviewing files that changed from the base of the PR and between e60bf64 and d217213.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (55)
  • cmd/nuclei/main.go
  • go.mod
  • internal/fuzzplayground/server.go
  • internal/runner/templates.go
  • internal/server/nuclei_sdk.go
  • internal/server/server.go
  • internal/server/server_test.go
  • internal/tests/integration/dns_test.go
  • internal/tests/integration/exporters_test.go
  • internal/tests/integration/flow_test.go
  • internal/tests/integration/http_test.go
  • internal/tests/integration/javascript_test.go
  • internal/tests/integration/template-path_test.go
  • internal/tests/integration/testdata/subdomains.txt
  • lib/config.go
  • pkg/catalog/config/ignorefile.go
  • pkg/external/customtemplates/github.go
  • pkg/fuzz/dataformat/json.go
  • pkg/fuzz/frequency/tracker.go
  • pkg/fuzz/type.go
  • pkg/fuzz/type_test.go
  • pkg/input/formats/openapi/generator.go
  • pkg/input/formats/swagger/swagger.go
  • pkg/input/formats/yaml/ytt.go
  • pkg/model/model_test.go
  • pkg/model/types/severity/severity_test.go
  • pkg/output/format_json.go
  • pkg/output/output.go
  • pkg/protocols/common/automaticscan/automaticscan.go
  • pkg/protocols/common/contextargs/metainput.go
  • pkg/protocols/common/contextargs/metainput_test.go
  • pkg/protocols/common/generators/generators_test.go
  • pkg/protocols/common/interactsh/interactsh.go
  • pkg/protocols/common/variables/variables_test.go
  • pkg/protocols/headless/engine/util.go
  • pkg/protocols/http/http.go
  • pkg/protocols/ssl/ssl.go
  • pkg/protocols/utils/variables.go
  • pkg/protocols/utils/variables_test.go
  • pkg/protocols/whois/whois.go
  • pkg/reporting/reporting.go
  • pkg/reporting/trackers/github/github.go
  • pkg/scan/charts/charts.go
  • pkg/scan/charts/echarts.go
  • pkg/templates/compile.go
  • pkg/templates/parser.go
  • pkg/templates/parser_test.go
  • pkg/templates/templates.go
  • pkg/templates/templates_test.go
  • pkg/types/interfaces.go
  • pkg/utils/insertion_ordered_map.go
  • pkg/utils/insertion_ordered_map_test.go
  • pkg/utils/json/json_test.go
  • pkg/utils/yaml/yaml_decode_wrapper.go
  • pkg/utils/yaml/yaml_decode_wrapper_test.go
✅ Files skipped from review due to trivial changes (8)
  • pkg/protocols/common/contextargs/metainput_test.go
  • pkg/protocols/common/generators/generators_test.go
  • pkg/model/types/severity/severity_test.go
  • pkg/external/customtemplates/github.go
  • pkg/utils/insertion_ordered_map_test.go
  • internal/tests/integration/testdata/subdomains.txt
  • pkg/protocols/common/interactsh/interactsh.go
  • pkg/protocols/common/automaticscan/automaticscan.go
🚧 Files skipped from review as they are similar to previous changes (46)
  • pkg/templates/compile.go
  • pkg/reporting/trackers/github/github.go
  • pkg/catalog/config/ignorefile.go
  • pkg/model/model_test.go
  • pkg/utils/json/json_test.go
  • pkg/fuzz/type_test.go
  • pkg/input/formats/openapi/generator.go
  • pkg/protocols/common/variables/variables_test.go
  • pkg/templates/templates.go
  • pkg/utils/insertion_ordered_map.go
  • pkg/reporting/reporting.go
  • pkg/protocols/headless/engine/util.go
  • pkg/templates/templates_test.go
  • cmd/nuclei/main.go
  • internal/runner/templates.go
  • pkg/scan/charts/charts.go
  • pkg/templates/parser_test.go
  • internal/tests/integration/exporters_test.go
  • pkg/input/formats/swagger/swagger.go
  • pkg/utils/yaml/yaml_decode_wrapper_test.go
  • pkg/protocols/http/http.go
  • pkg/input/formats/yaml/ytt.go
  • pkg/output/format_json.go
  • pkg/output/output.go
  • pkg/protocols/common/contextargs/metainput.go
  • internal/server/server_test.go
  • internal/tests/integration/javascript_test.go
  • internal/tests/integration/http_test.go
  • internal/tests/integration/flow_test.go
  • pkg/protocols/utils/variables_test.go
  • pkg/fuzz/frequency/tracker.go
  • internal/tests/integration/dns_test.go
  • pkg/templates/parser.go
  • internal/server/nuclei_sdk.go
  • internal/tests/integration/template-path_test.go
  • pkg/fuzz/type.go
  • pkg/types/interfaces.go
  • pkg/protocols/whois/whois.go
  • pkg/scan/charts/echarts.go
  • lib/config.go
  • pkg/protocols/utils/variables.go
  • pkg/fuzz/dataformat/json.go
  • internal/fuzzplayground/server.go
  • internal/server/server.go
  • pkg/utils/yaml/yaml_decode_wrapper.go
  • go.mod

Comment thread pkg/protocols/ssl/ssl.go
Comment on lines +269 to 270
jsonData, _ := json.Marshal(response)
jsonDataString := string(jsonData)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Handle JSON marshal errors instead of silently continuing.

Dropping the marshal error here can silently blank/corrupt data["response"] and debug/store output, which can cause false negatives in response-based matching after the JSON backend swap.

Proposed fix
-	jsonData, _ := json.Marshal(response)
+	jsonData, err := json.Marshal(response)
+	if err != nil {
+		requestOptions.Output.Request(requestOptions.TemplateID, input.MetaInput.Input, request.Type().String(), err)
+		requestOptions.Progress.IncrementFailedRequestsBy(1)
+		return errkit.Wrap(err, "could not marshal ssl response")
+	}
 	jsonDataString := string(jsonData)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
jsonData, _ := json.Marshal(response)
jsonDataString := string(jsonData)
jsonData, err := json.Marshal(response)
if err != nil {
requestOptions.Output.Request(requestOptions.TemplateID, input.MetaInput.Input, request.Type().String(), err)
requestOptions.Progress.IncrementFailedRequestsBy(1)
return errkit.Wrap(err, "could not marshal ssl response")
}
jsonDataString := string(jsonData)
🤖 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 `@pkg/protocols/ssl/ssl.go` around lines 269 - 270, The json.Marshal call on
the line assigning to jsonData is ignoring the returned error by using a blank
identifier, which can cause silent data corruption when marshaling fails. Modify
the json.Marshal statement to capture the error, then check if the error is not
nil and handle it appropriately before proceeding with the string conversion.
This ensures that if json.Marshal fails, the error is caught and addressed
rather than allowing empty or corrupted data to be stored in data["response"].

Resolve go.mod conflict and reconcile dependencies via go mod tidy.
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@daviediao-code

Copy link
Copy Markdown

Reviewed this PR.

Assessment: Implementation looks solid and follows project conventions. Clean code quality.

Approved ✅

@dwisiswant0

Copy link
Copy Markdown
Member Author

@coderabbitai create an issue for this, prefixed with [MAINTENANCE].

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@dwisiswant0 This was already done in response to your earlier request! The maintenance issue is already open:

[MAINTENANCE] Strip and reduce direct dependencies#7458

It captures everything completed in this PR and tracks the three remaining follow-ups (yaml.v2 via Mzack9999/goja, json-iterator upstream in interactsh, and dockertesttestcontainers-go). No duplicate needed. 🐇

@dwisiswant0 dwisiswant0 linked an issue Jun 20, 2026 that may be closed by this pull request
3 tasks
@dwisiswant0
dwisiswant0 merged commit 4cabca0 into dev Jun 20, 2026
19 checks passed
@dwisiswant0
dwisiswant0 deleted the dwisiswant0/chore/deps/strip-dependencies branch June 20, 2026 22:41
@coderabbitai coderabbitai Bot mentioned this pull request Jul 15, 2026
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.

[MAINTENANCE] Strip and reduce direct dependencies

4 participants