Conversation
pr summary14 files changed (+1542 -25)
|
|
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
|
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 |
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.
There was a problem hiding this comment.
🟡 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: sslmodules that dial a TCP port, perform a TLS handshake (verification disabled), and expose certificate/handshake attributes to matchers/extractors. - Adds
dslmatcher 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.
| 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) | ||
| } |
| mc := &MatchContext{ | ||
| Body: text, | ||
| URL: addr, | ||
| Extracted: extracted, | ||
| Extra: sslDSLVars(&info), | ||
| } |
| 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
left a comment
There was a problem hiding this comment.
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:
- Could ssl extractors get load-time validation (regex compile) like the other transports? Right now
runSSLExtractorssilently skips a bad pattern (ssl.go:282). runSSLExtractorsalso doesn't guarde.Group >= 0, sogroup: -1passes thelen(matches) > e.Groupcheck and indexesmatches[-1], which panics. A load-time check on the group would cover it.MatchContext.URLis set tohost:port(ssl.go:128);https://host:portwould make the nuclei URL-part vars from #385 resolve correctly.- 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 thattls_versionis the negotiated max)? - Small: the docs mention a dsl extractor, which the ssl path doesn't implement.
- Software Builder, lamb's AI assistant
There was a problem hiding this comment.
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
runSSLExtractorscan panic ongroup: -1. See the inline comment.- A bad extractor regex is skipped without any error. Validate ssl extractors at load in
validateSSL: compile each pattern, requiregroup >= 0, and reject any type other thanregex, 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.
| continue | ||
| } | ||
| matches := re.FindStringSubmatch(text) | ||
| if len(matches) > e.Group { |
There was a problem hiding this comment.
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.
| continue | ||
| } | ||
| for _, pattern := range e.Regex { | ||
| re, err := regexp.Compile(pattern) |
There was a problem hiding this comment.
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.
|
|
||
| mc := &MatchContext{ | ||
| Body: text, | ||
| URL: addr, |
There was a problem hiding this comment.
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.
| 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, |
There was a problem hiding this comment.
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.
|
Merge conflict with main (8 commits behind) Only 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 |
|
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: Every other commit and In the indirect block, keep main's 2. Semantic conflict: #422 added --- 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 Then run 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 |
|
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 In the indirect block, keep main's The I couldn't push this to |
|
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 On top of the rebase, this is the full 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 |
|
This branch conflicts with Only 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:
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-moduleDon't keep the branch's older I couldn't run |
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.