feat(modules): add ssl module type - #388
Open
TBX3D wants to merge 11 commits into
Open
Conversation
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.
pr summary16 files changed (+1527 -52)
|
|
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.