Registry Mirror
Skip to content

Conversation

@TBX3D

@TBX3D TBX3D commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

stacked on #385, so only the commits above it are this pr's.

dns and tcp cover name resolution and raw sockets, but nothing in sif looks at the handshake itself, so an expired, self-signed or tls 1.0 endpoint reads as healthy.

ssl dials the port, handshakes with verification off since the module inspects the certificate rather than trusting it, and exposes tls_version, cipher, cn, san, not_after, self_signed and expired to the existing matcher, extractor and dsl machinery. self-signed detection uses CheckSignature and not CheckSignatureFrom, because the latter also enforces CA basic constraints, which a hand-rolled leaf usually omits and would then read as not self-signed. ships tls-certificate-health.yaml as a working example.

@TBX3D
TBX3D requested a review from vmfunc as a code owner July 31, 2026 02:30
@github-actions github-actions Bot added modules changes to scan modules docs documentation changes tests test changes deps dependency updates size/xl 500+ lines changed labels Jul 31, 2026
@github-actions

github-actions Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

pr summary

14 files changed (+1542 -25)

category files
go source 11
tests 5
deps 1

@codecov-commenter

codecov-commenter commented Jul 31, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 94.07407% with 16 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@e9d578a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
internal/modules/ssl.go 92.20% 6 Missing and 6 partials ⚠️
internal/modules/yaml.go 63.63% 4 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #388   +/-   ##
=======================================
  Coverage        ?   69.33%           
=======================================
  Files           ?       91           
  Lines           ?     9171           
  Branches        ?        0           
=======================================
  Hits            ?     6359           
  Misses          ?     2400           
  Partials        ?      412           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

vmfunc commented Aug 22, 2026

Copy link
Copy Markdown
Owner

good work - the self-signed rationale and the InsecureSkipVerify justification are exactly right, and ssl handshake inspection is a real gap. it's stacked on #385 → #384 though, so it waits on both. rebase after they land, and double-check the nil Resp path through dslVars/getPart stays clean for ssl.


Generated by Claude Code

TBX3D added 13 commits August 22, 2026 11:54
add the dsl matcher type with a curated helper allowlist and load-time
compile validation (bad syntax, non-allowlisted functions, empty or
over-length expressions all rejected before scan time). evaluation
lands in a follow-up; a loaded dsl matcher currently misses at match
time.
drives a live httptest server through ExecuteHTTPModule with a dsl
matcher bound to status_code and body, mirroring the existing favicon
integration test, and asserts exactly one finding.
parse the request url and expose host[:port] so a nuclei-style
host == "..." expression matches; dedupe the header serialization.
covers the bound variables, the helper allowlist and the load-time compile, so a
module author does not have to read dsl.go to know what an expression can touch.
expose the capitalized url-part variables (baseurl, rooturl, hostname,
host, port, path, query, file, scheme) and the dns vars (fqdn, rdn, dn,
tld, sd) to dsl matchers so a pasted nuclei expression referencing them
behaves as a nuclei user expects.

delegate to nuclei's own utils.GenerateVariables rather than
reimplementing: its semantics are deliberately counterintuitive (host is
the hostname without port while hostname carries it, path is the
directory, port defaults by scheme) and a hand copy would drift on every
nuclei bump. nuclei is already a direct dependency so go.mod and go.sum
are unchanged.
getPart read resp.Header unguarded, so evaluating a dsl matcher without a
response panicked instead of binding zero values.
dns and tcp cover name resolution and raw sockets; nothing in sif inspects
a tls handshake itself, so a self-signed, expired, or legacy-version cert
went undetected. ssl dials the target's port, completes a handshake with
verification off (the module inspects the cert, it doesn't trust it), and
exposes tls_version/cipher/cn/san/not_after/self_signed/expired to the
existing matcher, extractor, and dsl machinery.

self-signed detection uses CheckSignature rather than CheckSignatureFrom:
the latter also enforces CA basic-constraints, which a typical hand-rolled
self-signed leaf doesn't set and would then read as not self-signed.

MatchContext.Extra carries a non-http module's typed builtins (bools stay
bools, unlike Extracted) into dslVars. getPart's header/all branches guard
a nil Resp so evalDSL is safe to reuse when there is no http response.
exercises the expired/self-signed/weak-tls-version dsl vars against real
handshakes over net.Pipe (self-signed and ca-signed leaves), plus the
non-panic contract for a refused port, a plain-tcp handshake failure, and
an already-canceled context.
adds the ssl block, its dsl vars, and matcher/extractor support to the
module-writing guide, and ships tls-certificate-health.yaml as a working
example that flags an expired cert or a tls 1.0/1.1 negotiation.
ssl builds a MatchContext with no *http.Response, so the shared matcher
helpers are the ones that would panic. cover getPart and dslVars on that
shape directly instead of only through a live handshake.
validateSSL was only exercised directly; removing its call in ParseYAMLModule
left the suite green.
Copilot AI lite review requested due to automatic review settings August 22, 2026 20:05

Copilot AI 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.

🟡 Changes recommended

SSL range matcher source handling and SSL MatchContext URL binding need tightening to avoid silent misconfiguration and incorrect/missing DSL URL-part variables.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a new ssl module transport and a DSL matcher capability so Sif can evaluate TLS handshake/certificate health (e.g., expiry, self-signed, legacy TLS versions) using the existing matcher/extractor machinery.

Changes:

  • Introduces type: ssl modules that dial a TCP port, perform a TLS handshake (verification disabled), and expose certificate/handshake attributes to matchers/extractors.
  • Adds dsl matcher support with load-time compilation, helper allowlisting, and variable binding (including nuclei URL-part variables).
  • Updates documentation and ships a working example module (tls-certificate-health.yaml).
File summaries
File Description
modules/recon/tls-certificate-health.yaml Adds an example SSL module to flag expired certs / TLS 1.0–1.1 and extract key fields.
internal/modules/yaml.go Extends YAML module schema/validation and dispatch to include ssl.
internal/modules/ssl.go Implements SSL transport execution, TLS handshake, evidence rendering, and SSL-specific matcher/extractor plumbing.
internal/modules/ssl_test.go Adds unit tests for SSL validation, handshake behavior, extraction, and DSL variables.
internal/modules/module.go Adds TypeSSL, adds Matcher.DSL, and extends MatchContext to carry typed non-HTTP vars.
internal/modules/matchers_test.go Adds parser test to ensure invalid DSL expressions fail at module load.
internal/modules/favicon.go Extends matcher validation to compile/validate DSL expressions at load time.
internal/modules/favicon_test.go Adds test cases covering DSL validation behavior.
internal/modules/executor.go Adds DSL matcher evaluation and makes header extraction nil-safe for non-HTTP contexts.
internal/modules/executor_test.go Adds end-to-end executor tests for DSL matching and URL-part variable binding.
internal/modules/dsl.go Introduces DSL compilation, caching, helper allowlisting, and variable binding.
internal/modules/dsl_test.go Adds comprehensive tests for DSL compilation, evaluation semantics, and variable binding.
go.mod Promotes projectdiscovery/dsl and projectdiscovery/govaluate to direct dependencies.
docs/modules.md Documents the new ssl module type and the new dsl matcher behavior/variables.
Review details
  • Files reviewed: 14/14 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/modules/ssl.go
Comment on lines +51 to +54
case "range":
if strings.EqualFold(cfg.Matchers[i].Source, "status") {
return fmt.Errorf("ssl range matcher source %q is not supported (status is http only; use size)", cfg.Matchers[i].Source)
}
Comment thread internal/modules/ssl.go
Comment on lines +126 to +131
mc := &MatchContext{
Body: text,
URL: addr,
Extracted: extracted,
Extra: sslDSLVars(&info),
}
Comment thread docs/modules.md
Comment on lines +248 to +252
ssl runs `word`, `regex`, `size`, `range` and `dsl` matchers (no
`status`/`favicon`, those are http only) against a summary line of the
negotiated connection, and `regex` extractors pull values out of it. there is
no `part` selector. a `dsl` matcher or extractor additionally sees these vars,
typed (`expired` and `self_signed` are real booleans, not strings):

@vmfunc vmfunc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Nice work, SSL inspection is a real gap and the InsecureSkipVerify / CheckSignature reasoning is spot on. A few things for when you rebase after #384/#385:

  1. Could ssl extractors get load-time validation (regex compile) like the other transports? Right now runSSLExtractors silently skips a bad pattern (ssl.go:282).
  2. runSSLExtractors also doesn't guard e.Group >= 0, so group: -1 passes the len(matches) > e.Group check and indexes matches[-1], which panics. A load-time check on the group would cover it.
  3. MatchContext.URL is set to host:port (ssl.go:128); https://host:port would make the nuclei URL-part vars from #385 resolve correctly.
  4. Go's default client cipher suites no longer include RSA key exchange or 3DES, so servers limited to those will fail the handshake and the health module will error instead of flagging them. Would you consider adding tls.InsecureCipherSuites() to the inspection config (and noting that tls_version is the negotiated max)?
  5. Small: the docs mention a dsl extractor, which the ssl path doesn't implement.
  • Software Builder, lamb's AI assistant

@devin-ai-integration devin-ai-integration 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.

Nice feature; the InsecureSkipVerify reasoning and the CheckSignature vs CheckSignatureFrom choice are both right. Head 97e021b still has the points from the 2026-10-08 review, and one of them can panic, so I'm requesting changes.

Blocking

  1. runSSLExtractors can panic on group: -1. See the inline comment.
  2. A bad extractor regex is skipped without any error. Validate ssl extractors at load in validateSSL: compile each pattern, require group >= 0, and reject any type other than regex, since the others are dropped without notice.

Should fix
3. MatchContext.URL is set to the bare host:port, so the nuclei URL-part DSL vars from #385 do not resolve correctly. Use "https://" + addr.
4. Go's default client cipher list leaves out RSA-kex and 3DES suites. A server that only offers those fails the handshake, so the health module returns an error instead of flagging the server. Consider CipherSuites built from tls.CipherSuites() plus tls.InsecureCipherSuites(). Also document that tls_version is the negotiated version, not the highest one the server supports.
5. range matchers accept any source other than status, then use the text length anyway. Reject any non-empty source other than size.
6. The docs say "dsl matcher or extractor", but there is no dsl extractor.

Tests: please add a validation test for a bad extractor regex and a negative group, plus a test that mc.URL gives the expected host/port DSL vars.

Process: this PR is stacked on #384 and #385, which are still unmerged, so it includes their commits. It also conflicts with main in go.mod. Details are in a separate comment.

Written by Devin

Comment thread internal/modules/ssl.go
continue
}
matches := re.FindStringSubmatch(text)
if len(matches) > e.Group {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There is no e.Group >= 0 guard here. With group: -1, len(matches) > -1 is always true, and matches[-1] then panics and takes down the scan worker. The HTTP extractor guards this (executor.go: if e.Group >= 0 && len(matches) > e.Group). Add the same guard, and ideally also reject a negative group at load time.

Comment thread internal/modules/ssl.go
continue
}
for _, pattern := range e.Regex {
re, err := regexp.Compile(pattern)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A bad pattern is skipped here without any error, so a broken module never reports anything. Compile the extractor regexes in validateSSL so the error shows up when the module loads.

Comment thread internal/modules/ssl.go

mc := &MatchContext{
Body: text,
URL: addr,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

addr is a bare host:port. GenerateVariables expects a URL with a scheme, so the host/port/scheme DSL vars come out wrong. Use URL: "https://" + addr.

Comment thread internal/modules/ssl.go
conn := tls.Client(raw, &tls.Config{
InsecureSkipVerify: true, //nolint:gosec // scanner inspects the cert itself; it does not trust the connection
ServerName: serverName,
MinVersion: tls.VersionTLS10,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Also consider setting CipherSuites to include tls.InsecureCipherSuites(). Then a server that only offers RSA-kex or 3DES suites completes the handshake and gets flagged, instead of causing a handshake error.

@devin-ai-integration

Copy link
Copy Markdown

Merge conflict with main (8 commits behind)

Only go.mod conflicts. go.sum and the workflow files merge cleanly. The cause: main bumped goflags to v0.2.0, utils to v0.11.8, retryabledns to v1.0.116, fastdialer to v0.5.20 and others, while this branch moved projectdiscovery/dsl and projectdiscovery/govaluate from indirect to direct dependencies.

To resolve:

git fetch upstream && git merge upstream/main   # or rebase
git checkout --theirs go.mod                     # take main's versions
# then, in go.mod:
#  - delete the `// indirect` lines for github.com/projectdiscovery/dsl and github.com/projectdiscovery/govaluate
#  - add `github.com/projectdiscovery/dsl v0.8.20` and
#    `github.com/projectdiscovery/govaluate v0.0.0-20260615100919-5ee2581bbf7e` to the direct require block
go mod tidy && go build ./... && go test ./...

Since this PR is stacked on #384 and #385, the simplest path is to wait until those land and then rebase onto main. After that, the diff only contains the ssl commits.

I did not push a resolution because I couldn't run go build or go test in my environment, and I didn't want to push an untested go.mod to your branch.

Written by Devin

@devin-ai-integration

Copy link
Copy Markdown

Updated conflict-resolution notes (main is now at 6cb9451, 26 commits ahead)

I rebased this branch onto current main locally. Two things need fixing.

1. Textual conflict: go.mod only, in the first commit (610d371, dsl matchers)

Every other commit and go.sum replay cleanly. Since my 2026-11-04 comment, main has also bumped goflags to v0.2.0 and added mattn/go-isatty v0.0.22 as a direct dependency. The resolved direct block should read:

	github.com/mattn/go-isatty v0.0.22
	github.com/projectdiscovery/dsl v0.8.20
	github.com/projectdiscovery/goflags v0.2.0
	github.com/projectdiscovery/govaluate v0.0.0-20260615100919-5ee2581bbf7e
	github.com/projectdiscovery/nuclei/v3 v3.11.0

In the indirect block, keep main's github.com/projectdiscovery/fastdialer v0.5.20 // indirect and remove the // indirect lines for dsl and govaluate. After that, git diff origin/main -- go.mod is just those two deps moving from indirect to direct, and go.sum needs no changes.

2. Semantic conflict: sif modules lint will reject the new ssl type

#422 added internal/modules/lint.go, which has a knownModuleTypes allowlist without TypeSSL. #423 added the modules workflow, which runs ./sif modules lint on any PR that touches modules/** or internal/modules/**. That makes modules/recon/tls-certificate-health.yaml (type: ssl) fail the gate with unknown type "ssl". lintRegexes also skips ssl matchers and extractors. Suggested extra commit on top of the rebase:

--- a/internal/modules/lint.go
+++ b/internal/modules/lint.go
@@ var knownModuleTypes = map[ModuleType]bool{
 	TypeHTTP:        true,
 	TypeDNS:         true,
 	TypeTCP:         true,
+	TypeSSL:         true,
 	TypeFingerprint: true,
 	TypeScript:      true,
 }
@@ func lintFile(path string, report *LintReport) string {
 	if !knownModuleTypes[def.Type] {
-		add(LintError, id, "unknown type %q (want http, dns, tcp, fingerprint or script)", def.Type)
+		add(LintError, id, "unknown type %q (want http, dns, tcp, ssl, fingerprint or script)", def.Type)
 	}
@@ func lintRegexes(def *YAMLModule, id string, add func(LintLevel, string, string, ...any)) {
 	case def.TCP != nil:
 		matchers, extractors = def.TCP.Matchers, def.TCP.Extractors
+	case def.SSL != nil:
+		matchers, extractors = def.SSL.Matchers, def.SSL.Extractors
 	}

A lint_test.go case for an ssl module with a bad regex would be a good addition. sif modules test is fine as-is: the tls module has no tests: block, so a directory run skips it.

Then run make && ./sif modules lint && ./sif modules test && go test ./....

I couldn't push this myself because the branch lives on the TBX3D fork, which isn't writable from my environment. I also couldn't run go build or go test here because the Go toolchain download is blocked, so the resolution above hasn't been compiled. The only remaining dependency on #384 and #385 is their own commits. Once they land, a rebase drops them from this PR.

Written by Devin

@devin-ai-integration

Copy link
Copy Markdown

Updated conflict notes (main is now at 5ed3a4c)

I rebased onto current main locally again. My 2026-11-05 notes still apply, with one change: #433 bumped goflags to v0.2.1. The go.mod conflict in 610d371 should now resolve to:

	github.com/mattn/go-isatty v0.0.22
	github.com/projectdiscovery/dsl v0.8.20
	github.com/projectdiscovery/goflags v0.2.1
	github.com/projectdiscovery/govaluate v0.0.0-20260615100919-5ee2581bbf7e
	github.com/projectdiscovery/nuclei/v3 v3.11.0

In the indirect block, keep main's fastdialer v0.5.20 // indirect and remove the // indirect lines for dsl and govaluate. The other 12 commits and go.sum replay cleanly. After the rebase, git diff origin/main -- go.mod shows only dsl and govaluate moving from indirect to direct, and go.sum is identical to main.

The internal/modules/lint.go change from my earlier notes is also still needed: add TypeSSL to knownModuleTypes, update the error message, and lint ssl matchers/extractors. lint.go has not changed on main since then.

I couldn't push this to TBX3D:lane/ssl-module (403). I also couldn't run go build/go test this time because my environment had no Go toolchain, so CI will be the check once you push.

Written by Devin

@devin-ai-integration

Copy link
Copy Markdown

Conflict status re-checked (main still at 5ed3a4c, PR head still 97e021b)

My 2026-11-09 notes still apply as written. I redid the rebase locally: the only textual conflict is go.mod in 610d371 (resolve as described there), the other 12 commits replay cleanly, and go.sum ends up identical to main.

On top of the rebase, this is the full internal/modules/lint.go change needed so sif modules lint (the gate from #423) accepts modules/recon/tls-certificate-health.yaml:

diff --git a/internal/modules/lint.go b/internal/modules/lint.go
index b09bb82..2df30f4 100644
--- a/internal/modules/lint.go
+++ b/internal/modules/lint.go
@@ -54,6 +54,7 @@ var knownModuleTypes = map[ModuleType]bool{
 	TypeHTTP:        true,
 	TypeDNS:         true,
 	TypeTCP:         true,
+	TypeSSL:         true,
 	TypeFingerprint: true,
 	TypeScript:      true,
 }
@@ -154,7 +155,7 @@ func lintFile(path string, report *LintReport) string {
 
 	id := def.ID
 	if !knownModuleTypes[def.Type] {
-		add(LintError, id, "unknown type %q (want http, dns, tcp, fingerprint or script)", def.Type)
+		add(LintError, id, "unknown type %q (want http, dns, tcp, ssl, fingerprint or script)", def.Type)
 	}
 	lintInfo(def, id, add)
 	lintHTTPPaths(def, id, add)
@@ -251,6 +252,8 @@ func lintRegexes(def *YAMLModule, id string, add func(LintLevel, string, string,
 		matchers, extractors = def.DNS.Matchers, def.DNS.Extractors
 	case def.TCP != nil:
 		matchers, extractors = def.TCP.Matchers, def.TCP.Extractors
+	case def.SSL != nil:
+		matchers, extractors = def.SSL.Matchers, def.SSL.Extractors
 	}
 
 	for i := range matchers {

I couldn't push to TBX3D:lane/ssl-module (403), and I couldn't run go build/go test because my sandbox can't download the Go toolchain. CI will be the check after you push.

Written by Devin

@devin-ai-integration

Copy link
Copy Markdown

This branch conflicts with main (5ed3a4c), and I can't push to the fork, so here are rebase steps.

Only go.mod conflicts, and only in the first commit (610d371, "validate and compile dsl matchers at load"). The other 12 commits (including #385's) rebase cleanly. go.sum needs no change, because main already pins the same dsl/govaluate versions as indirect deps.

git fetch upstream            # upstream = github.com/vmfunc/sif
git checkout lane/ssl-module
git rebase upstream/main
# conflict in go.mod on 610d371:
git checkout --ours go.mod    # take main's go.mod (newer goflags v0.2.1, fastdialer v0.5.20, etc.)

Then make the commit's actual change on top of main's versions:

  • in the direct require block, add github.com/projectdiscovery/dsl v0.8.20 (before goflags) and github.com/projectdiscovery/govaluate v0.0.0-20260615100919-5ee2581bbf7e (after goflags)
  • in the indirect block, delete the // indirect lines for those two modules
go mod tidy                   # should be a no-op
git add go.mod && git rebase --continue
go build ./... && go test ./...
git push --force-with-lease origin lane/ssl-module

Don't keep the branch's older goflags v0.1.76 / fastdialer v0.5.11; main has moved past them. The rebased diff against main is the same as now: 14 files, +1542/-25.

I couldn't run go build/go test on the rebased tree myself because my environment has no Go toolchain, so please run them before pushing. #385 has the same go.mod conflict.

Written by Devin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deps dependency updates docs documentation changes modules changes to scan modules size/xl 500+ lines changed tests test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants