Skip to content

feat(modules): add ssl module type - #388

Open
TBX3D wants to merge 11 commits into
vmfunc:mainfrom
TBX3D:lane/ssl-module
Open

feat(modules): add ssl module type#388
TBX3D wants to merge 11 commits into
vmfunc:mainfrom
TBX3D:lane/ssl-module

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 added 11 commits July 30, 2026 19:12
checkMatchers/checkMatcher took (resp, body), so every matcher type that
needs anything else (the request url, how long the round trip took,
extractor output) forces another signature change through the whole engine
and all of its callers.

collect the per-response state into a MatchContext built once at each of the
two call sites (single request and chain step) and thread that instead. no
matcher behavior changes: the classic types read Resp and Body exactly as
before.

extraction moves above the matcher check in executeHTTPRequest. runExtractors
is side-effect-free and the finding is only built on a match, so the order is
behavior-preserving, and it lets a matcher read extractor values from the
context. in a chain step the context carries the running variable set, so a
matcher there also sees earlier steps' values.
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.
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.
@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

Copy link
Copy Markdown

pr summary

16 files changed (+1527 -52)

category files
go source 13
tests 7
deps 1

@codecov-commenter

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 93.33333% with 20 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@a38ba0a). 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 45.45% 5 Missing and 1 partial ⚠️
internal/modules/dsl.go 97.64% 1 Missing and 1 partial ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #388   +/-   ##
=======================================
  Coverage        ?   65.81%           
=======================================
  Files           ?       90           
  Lines           ?     8132           
  Branches        ?        0           
=======================================
  Hits            ?     5352           
  Misses          ?     2380           
  Partials        ?      400           

☔ 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.

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.

2 participants