Documentation
¶
Index ¶
- Constants
- func FetchTemplateFromURL(ctx context.Context, templateURL string) ([]byte, error)
- func IPRange(startIP, endIP string) ([]string, error)
- func TargetsFromCIDR(cidr string) ([]string, error)
- func TargetsFromCIDRs(cidrs []string) ([]string, error)
- func TargetsFromFile(path string) ([]string, error)
- func TargetsFromReader(reader io.Reader) ([]string, error)
- func ValidateTemplate(data []byte) (string, error)
- type APISecurityScanner
- type AuthConfig
- func APIKeyHeader(headerName, apiKey string, domains ...string) AuthConfig
- func BasicAuth(username, password string, domains ...string) AuthConfig
- func BearerToken(token string, domains ...string) AuthConfig
- func CookieAuth(cookies map[string]string, domains ...string) AuthConfig
- func HeaderAuth(headers map[string]string, domains ...string) AuthConfig
- func QueryAuth(params map[string]string, domains ...string) AuthConfig
- type AuthType
- type ConcurrentScan
- type HeadlessConfig
- type LabeledResult
- type NetworkScanner
- type Option
- func WithAuth(auth AuthConfig) Option
- func WithAuthors(authors ...string) Option
- func WithBulkSize(count int) Option
- func WithCodeTemplates() Option
- func WithDASTMode() Option
- func WithDebug() Option
- func WithDisableMaxHostErr() Option
- func WithDisableTemplateCache() Option
- func WithExcludeSeverities(severities ...string) Option
- func WithExcludeTags(tags ...string) Option
- func WithExcludeTargets(hosts ...string) Option
- func WithExcludeTemplateIDs(ids ...string) Option
- func WithFileTemplates() Option
- func WithGlobalMatchersTemplates() Option
- func WithHTTPProbe() Option
- func WithHeader(key, value string) Option
- func WithHeaders(headers ...string) Option
- func WithHeadless(opts *HeadlessConfig) Option
- func WithHostConcurrency(count int) Option
- func WithIPVersion(versions ...string) Option
- func WithLeaveDefaultPorts() Option
- func WithMatcherStatus() Option
- func WithNetworkInterface(iface string) Option
- func WithNoInteractsh() Option
- func WithOpenAPISpec(path string) Option
- func WithPassiveMode() Option
- func WithPayloadConcurrency(count int) Option
- func WithProbeConcurrency(n int) Option
- func WithProtocolTypes(types string) Option
- func WithProxies(proxies ...string) Option
- func WithProxy(proxy string) Option
- func WithProxyInternal(enabled bool) Option
- func WithRateLimit(maxPerSecond int) Option
- func WithRateLimitCustom(count int, duration time.Duration) Option
- func WithResolvers(resolvers ...string) Option
- func WithResponseReadSize(size int) Option
- func WithResultSeverityFilter(severities ...string) Option
- func WithRetries(count int) Option
- func WithSandboxOptions(allowLocalFileAccess, restrictLocalNetworkAccess bool) Option
- func WithScanAllIPs() Option
- func WithScanStrategy(strategy string) Option
- func WithSecretsFile(path string) Option
- func WithSecretsFiles(paths ...string) Option
- func WithSelfContainedTemplates() Option
- func WithSeverityFilter(severities ...string) Option
- func WithSignedTemplatesOnly() Option
- func WithSilent() Option
- func WithSourceIP(ip string) Option
- func WithStopAtFirstMatch() Option
- func WithSwaggerSpec(path string) Option
- func WithSystemResolvers() Option
- func WithTags(tags ...string) Option
- func WithTargetFile(path string) Option
- func WithTargetReader(reader io.Reader) Option
- func WithTargets(targets ...string) Option
- func WithTemplateBytes(name string, data []byte) Option
- func WithTemplateDir(dir string) Option
- func WithTemplateDirs(dirs ...string) Option
- func WithTemplateFile(file string) Option
- func WithTemplateFiles(files ...string) Option
- func WithTemplateIDs(ids ...string) Option
- func WithTemplateURL(url string) Option
- func WithTemplateURLs(urls ...string) Option
- func WithThreads(count int) Option
- func WithTimeout(seconds int) Option
- func WithTrustedDomains(domains ...string) Option
- func WithUpdateCheck() Option
- func WithVar(key, value string) Option
- func WithVars(vars ...string) Option
- func WithVerbose() Option
- func WithWorkflows(paths ...string) Option
- type PoolStats
- type ScanConfig
- type ScanEngine
- func (se *ScanEngine) Close() error
- func (se *ScanEngine) GetLoadedTemplates() []*templates.Template
- func (se *ScanEngine) NewScanPool(ctx context.Context, workers int) *ScanPool
- func (se *ScanEngine) NucleiOptions() *types.Options
- func (se *ScanEngine) RunParallel(ctx context.Context, scans ...ConcurrentScan) (<-chan *LabeledResult, error)
- func (se *ScanEngine) RunScan(ctx context.Context, perScanOpts ...Option) (<-chan *ScanResult, error)
- func (se *ScanEngine) RunScanWithCallback(ctx context.Context, callback func(*ScanResult), perScanOpts ...Option) error
- func (se *ScanEngine) Scan(ctx context.Context, scanOpts *ScanOptions) (<-chan *ScanResult, error)
- func (se *ScanEngine) ScanWithCallback(ctx context.Context, scanOpts *ScanOptions, cb func(*ScanResult)) error
- func (se *ScanEngine) Setup() error
- type ScanOptions
- type ScanPool
- type ScanResult
- type Scanner
- type TemplateBytesEntry
- type TemplateInfo
- type WebScanner
- type WordPressScanner
Constants ¶
const ( StrategyTemplateSpray = "template-spray" StrategyHostSpray = "host-spray" )
Scan strategy constants.
Variables ¶
This section is empty.
Functions ¶
func FetchTemplateFromURL ¶
FetchTemplateFromURL downloads a template from a URL and returns the YAML bytes.
func TargetsFromCIDR ¶
TargetsFromCIDR expands a CIDR notation into individual IP targets.
func TargetsFromCIDRs ¶
TargetsFromCIDRs expands multiple CIDR notations into individual IP targets.
func TargetsFromFile ¶
TargetsFromFile reads targets from a file, one per line. Empty lines and lines starting with # are skipped.
func TargetsFromReader ¶
TargetsFromReader reads targets from an io.Reader, one per line. Empty lines and lines starting with # are skipped.
func ValidateTemplate ¶
ValidateTemplate parses raw YAML bytes and validates them as a valid nuclei template. Returns the template ID and any validation error.
Types ¶
type APISecurityScanner ¶
type APISecurityScanner struct {
// contains filtered or unexported fields
}
APISecurityScanner is a pre-configured scanner for API security testing. It focuses on REST API, GraphQL, and OpenAPI/Swagger-related vulnerabilities.
func NewAPISecurityScanner ¶
func NewAPISecurityScanner(opts ...Option) (*APISecurityScanner, error)
NewAPISecurityScanner creates a new API security scanner with sensible defaults. User-provided options override the defaults. Note: DAST mode is NOT enabled by default because it filters out detection templates (swagger, exposure, misconfig, etc.). Use WithDASTMode() explicitly if you want fuzzing-only scanning.
func (*APISecurityScanner) Close ¶
func (a *APISecurityScanner) Close() error
Close releases resources.
func (*APISecurityScanner) Run ¶
func (a *APISecurityScanner) Run(ctx context.Context) (<-chan *ScanResult, error)
Run executes the API security scan and returns results via a channel.
func (*APISecurityScanner) RunWithCallback ¶
func (a *APISecurityScanner) RunWithCallback(ctx context.Context, cb func(*ScanResult)) error
RunWithCallback executes the API security scan with a callback.
type AuthConfig ¶
type AuthConfig struct {
Type AuthType
Domains []string
Username string
Password string
Token string
Headers map[string]string
Cookies map[string]string
QueryParams map[string]string
}
AuthConfig represents an authentication configuration for scanning.
func APIKeyHeader ¶
func APIKeyHeader(headerName, apiKey string, domains ...string) AuthConfig
APIKeyHeader is a convenience function for single API key header auth.
func BasicAuth ¶
func BasicAuth(username, password string, domains ...string) AuthConfig
BasicAuth creates a basic auth configuration.
func BearerToken ¶
func BearerToken(token string, domains ...string) AuthConfig
BearerToken creates a bearer token auth configuration.
func CookieAuth ¶
func CookieAuth(cookies map[string]string, domains ...string) AuthConfig
CookieAuth creates a cookie-based auth configuration.
func HeaderAuth ¶
func HeaderAuth(headers map[string]string, domains ...string) AuthConfig
HeaderAuth creates a header-based auth configuration.
type ConcurrentScan ¶
type ConcurrentScan struct {
Label string // Identifier for routing results (e.g., "http", "dns", "wordpress")
Options []Option // Per-job options: targets, tags, protocol types, severity, etc.
}
ConcurrentScan defines a labeled scan job for RunParallel. Each job specifies its own targets, protocol types, tags, and severity filters.
type HeadlessConfig ¶
HeadlessConfig wraps headless browser options.
type LabeledResult ¶
type LabeledResult struct {
Label string `json:"label"`
*ScanResult
}
LabeledResult wraps a ScanResult with the scan job label it was matched to.
type NetworkScanner ¶
type NetworkScanner struct {
// contains filtered or unexported fields
}
NetworkScanner is a pre-configured scanner for network/infrastructure security testing. It focuses on DNS, SSL/TLS, and TCP-based vulnerability detection.
func NewNetworkScanner ¶
func NewNetworkScanner(opts ...Option) (*NetworkScanner, error)
NewNetworkScanner creates a new network/infra scanner with sensible defaults.
func (*NetworkScanner) Run ¶
func (n *NetworkScanner) Run(ctx context.Context) (<-chan *ScanResult, error)
Run executes the network scan and returns results via a channel.
func (*NetworkScanner) RunWithCallback ¶
func (n *NetworkScanner) RunWithCallback(ctx context.Context, cb func(*ScanResult)) error
RunWithCallback executes the network scan with a callback.
type Option ¶
type Option func(*ScanConfig) error
Option is a functional option for configuring the Scanner.
func WithAuth ¶
func WithAuth(auth AuthConfig) Option
WithAuth adds an authentication configuration.
func WithAuthors ¶
WithAuthors filters templates by author.
func WithBulkSize ¶
WithBulkSize is an alias for WithHostConcurrency.
func WithCodeTemplates ¶
func WithCodeTemplates() Option
WithCodeTemplates enables code protocol template execution.
func WithDisableMaxHostErr ¶
func WithDisableMaxHostErr() Option
WithDisableMaxHostErr disables skipping hosts that exceed max errors.
func WithDisableTemplateCache ¶
func WithDisableTemplateCache() Option
WithDisableTemplateCache disables caching of parsed templates.
func WithExcludeSeverities ¶
WithExcludeSeverities excludes templates with these severities.
func WithExcludeTags ¶
WithExcludeTags excludes templates with these tags.
func WithExcludeTargets ¶
WithExcludeTargets excludes specific hosts from scanning.
func WithExcludeTemplateIDs ¶
WithExcludeTemplateIDs excludes templates by ID.
func WithFileTemplates ¶
func WithFileTemplates() Option
WithFileTemplates enables execution of file protocol templates.
func WithGlobalMatchersTemplates ¶
func WithGlobalMatchersTemplates() Option
WithGlobalMatchersTemplates enables execution of global-matchers templates.
func WithHTTPProbe ¶
func WithHTTPProbe() Option
WithHTTPProbe enables HTTP probing for non-URL targets. When targets are raw hosts/IPs (without http:// or https://), nuclei will probe them via httpx to discover HTTP/HTTPS services.
func WithHeaders ¶
WithHeaders adds custom headers to all HTTP requests ("Key: Value" format).
func WithHeadless ¶
func WithHeadless(opts *HeadlessConfig) Option
WithHeadless enables headless browser for headless templates.
func WithHostConcurrency ¶
WithHostConcurrency sets the number of concurrent hosts per template.
func WithIPVersion ¶
WithIPVersion sets which IP versions to scan. Valid values: "4", "6". Default is IPv4 only. Pass both to scan dual-stack.
func WithLeaveDefaultPorts ¶
func WithLeaveDefaultPorts() Option
WithLeaveDefaultPorts preserves default ports in URLs (e.g., :80 for HTTP, :443 for HTTPS).
func WithMatcherStatus ¶
func WithMatcherStatus() Option
WithMatcherStatus enables reporting all matcher results (not just matches).
func WithNetworkInterface ¶
WithNetworkInterface sets the network interface to use for scanning.
func WithNoInteractsh ¶
func WithNoInteractsh() Option
WithNoInteractsh disables interactsh server for OOB testing. Use this when you don't need out-of-band interaction testing.
func WithOpenAPISpec ¶
WithOpenAPISpec sets an OpenAPI specification file for API security scanning. This is mutually exclusive with WithTargets/WithTargetFile/WithTargetReader.
func WithPassiveMode ¶
func WithPassiveMode() Option
WithPassiveMode enables passive HTTP response processing mode. In this mode, nuclei processes pre-recorded HTTP responses instead of sending requests.
func WithPayloadConcurrency ¶
WithPayloadConcurrency sets the maximum concurrent payloads per template.
func WithProbeConcurrency ¶
WithProbeConcurrency sets the number of concurrent HTTP probes. Default is 50. Only effective when HTTP probing is enabled.
func WithProtocolTypes ¶
WithProtocolTypes filters templates by protocol type (http, dns, network, ssl, etc.).
func WithProxyInternal ¶
WithProxyInternal enables proxy for internal nuclei requests.
func WithRateLimit ¶
WithRateLimit sets the maximum requests per second.
func WithRateLimitCustom ¶
WithRateLimitCustom sets a custom rate limit with duration.
func WithResolvers ¶
WithResolvers sets custom DNS resolvers.
func WithResponseReadSize ¶
WithResponseReadSize sets the maximum response read size in bytes.
func WithResultSeverityFilter ¶
WithResultSeverityFilter filters results by severity after scanning. This is a post-scan filter, separate from WithSeverityFilter which filters templates.
func WithRetries ¶
WithRetries sets the number of retries for failed requests.
func WithSandboxOptions ¶
WithSandboxOptions sets sandbox options for template execution. allowLocalFileAccess: allow templates to access local files. restrictLocalNetworkAccess: restrict templates from accessing local network.
func WithScanAllIPs ¶
func WithScanAllIPs() Option
WithScanAllIPs enables scanning all IPs associated with a DNS record. By default, only the first resolved IP is scanned.
func WithScanStrategy ¶
WithScanStrategy sets the scan strategy ("template-spray" or "host-spray").
func WithSecretsFile ¶
WithSecretsFile adds a nuclei secrets/credentials file.
func WithSecretsFiles ¶
WithSecretsFiles adds multiple nuclei secrets/credentials files.
func WithSelfContainedTemplates ¶
func WithSelfContainedTemplates() Option
WithSelfContainedTemplates enables execution of self-contained templates.
func WithSeverityFilter ¶
WithSeverityFilter filters templates by severity (info, low, medium, high, critical).
func WithSignedTemplatesOnly ¶
func WithSignedTemplatesOnly() Option
WithSignedTemplatesOnly restricts execution to signed templates only.
func WithSilent ¶
func WithSilent() Option
WithSilent enables silent mode (no output except results).
func WithSourceIP ¶
WithSourceIP sets the source IP address to use for scanning.
func WithStopAtFirstMatch ¶
func WithStopAtFirstMatch() Option
WithStopAtFirstMatch stops scanning a host after the first match is found.
func WithSwaggerSpec ¶
WithSwaggerSpec sets a Swagger specification file for API security scanning.
func WithSystemResolvers ¶
func WithSystemResolvers() Option
WithSystemResolvers uses system DNS resolvers instead of nuclei's default resolvers.
func WithTargetFile ¶
WithTargetFile sets a file path to read targets from (one per line).
func WithTargetReader ¶
WithTargetReader sets an io.Reader to read targets from (one per line).
func WithTargets ¶
WithTargets sets the target URLs/hosts to scan.
func WithTemplateBytes ¶
WithTemplateBytes adds a raw YAML template from bytes. The name is used as the filename (without .yaml extension).
func WithTemplateDir ¶
WithTemplateDir adds a directory of templates to scan with. If not called, nuclei uses the default templates directory (~/.local/nuclei-templates/).
func WithTemplateDirs ¶
WithTemplateDirs adds multiple template directories.
func WithTemplateFile ¶
WithTemplateFile adds a single template file path.
func WithTemplateFiles ¶
WithTemplateFiles adds multiple template file paths.
func WithTemplateIDs ¶
WithTemplateIDs filters templates by ID.
func WithTemplateURL ¶
WithTemplateURL adds a template to fetch from a URL.
func WithTemplateURLs ¶
WithTemplateURLs adds multiple templates to fetch from URLs.
func WithThreads ¶
WithThreads sets the number of concurrent templates to execute.
func WithTimeout ¶
WithTimeout sets the request timeout in seconds.
func WithTrustedDomains ¶
WithTrustedDomains adds trusted domains for remote template loading.
func WithUpdateCheck ¶
func WithUpdateCheck() Option
WithUpdateCheck enables nuclei update checks (disabled by default in SDK).
func WithWorkflows ¶
WithWorkflows adds workflow file/directory paths.
type PoolStats ¶
type PoolStats struct {
Submitted int64 `json:"submitted"`
Completed int64 `json:"completed"`
Failed int64 `json:"failed"`
Pending int64 `json:"pending"`
}
PoolStats holds scan pool statistics.
type ScanConfig ¶
type ScanConfig struct {
// contains filtered or unexported fields
}
ScanConfig holds all scanner configuration, populated by Option functions.
type ScanEngine ¶
type ScanEngine struct {
// contains filtered or unexported fields
}
ScanEngine provides a high-performance, concurrent scanning API.
Architecture: shared-global / ephemeral-per-scan
Global resources (initialized once in Setup, shared read-only across scans):
- Template catalog, parser, and loaded template store
- Output writer, progress tracker, interactsh client
- Rate limiter, browser instance, host error cache
Per-scan resources (created in each Scan call, lightweight):
- core.Engine (~5 fields), ExecutorOptions (shallow copy sharing global refs)
- SimpleInputProvider (just a []MetaInput slice)
- Filtered template list (runtime match from global store)
This design allows 1000+ concurrent Scan() calls with minimal per-scan overhead.
Usage:
engine, _ := nucleisdk.NewScanEngine(
nucleisdk.WithRateLimit(100),
nucleisdk.WithTimeout(10),
nucleisdk.WithNoInteractsh(),
)
if err := engine.Setup(); err != nil { log.Fatal(err) }
defer engine.Close()
// Lightweight concurrent scans
go func() {
results, _ := engine.Scan(ctx, &nucleisdk.ScanOptions{
Targets: []string{"https://example.com"},
Tags: []string{"cve", "exposure"},
Severities: []string{"high", "critical"},
ProtocolTypes: "http",
})
for r := range results { ... }
}()
func NewScanEngine ¶
func NewScanEngine(opts ...Option) (*ScanEngine, error)
NewScanEngine creates a new engine with the given configuration. This only stores config — call Setup() to initialize heavy resources.
func (*ScanEngine) Close ¶
func (se *ScanEngine) Close() error
Close releases all global resources held by the engine.
func (*ScanEngine) GetLoadedTemplates ¶
func (se *ScanEngine) GetLoadedTemplates() []*templates.Template
GetLoadedTemplates returns all templates loaded during Setup.
func (*ScanEngine) NewScanPool ¶
func (se *ScanEngine) NewScanPool(ctx context.Context, workers int) *ScanPool
NewScanPool creates a worker pool with the specified number of concurrent scan workers. Each worker calls engine.Scan() for each job it picks up, so the total concurrency is bounded by the worker count.
The pool starts immediately — workers begin consuming jobs as they are submitted. Call Close() when done to signal no more jobs and wait for completion.
The Results() channel MUST be consumed concurrently, otherwise workers will block.
func (*ScanEngine) NucleiOptions ¶
func (se *ScanEngine) NucleiOptions() *types.Options
NucleiOptions returns the underlying nuclei types.Options for advanced customization. Available only after Setup() has been called. Returns nil before Setup().
This gives Go users full access to every nuclei option beyond what the SDK's With* functions expose. Modify before calling Scan() — changes during a scan are not safe.
engine, _ := nucleisdk.NewScanEngine(nucleisdk.WithRateLimit(100)) engine.Setup() opts := engine.NucleiOptions() opts.FollowRedirects = true opts.MaxHostError = 5
func (*ScanEngine) RunParallel ¶
func (se *ScanEngine) RunParallel(ctx context.Context, scans ...ConcurrentScan) (<-chan *LabeledResult, error)
RunParallel launches multiple lightweight scans concurrently using the shared global resources. Each scan gets its own core.Engine and filtered templates. Results are tagged with the scan label.
This is the most efficient way to run multiple scan types concurrently. Unlike creating N separate engines, all scans share a single set of global resources (templates, interactsh, rate limiter, etc.).
func (*ScanEngine) RunScan ¶
func (se *ScanEngine) RunScan(ctx context.Context, perScanOpts ...Option) (<-chan *ScanResult, error)
RunScan provides backward compatibility with the old per-scan engine API. Internally, it creates a ScanOptions from the per-scan Option overrides and calls Scan(). Requires Setup() to have been called first.
func (*ScanEngine) RunScanWithCallback ¶
func (se *ScanEngine) RunScanWithCallback(ctx context.Context, callback func(*ScanResult), perScanOpts ...Option) error
RunScanWithCallback provides backward compatibility with the old callback API.
func (*ScanEngine) Scan ¶
func (se *ScanEngine) Scan(ctx context.Context, scanOpts *ScanOptions) (<-chan *ScanResult, error)
Scan executes a lightweight scan with the given per-scan options. Creates only a core.Engine, ExecutorOptions copy, and SimpleInputProvider per call. Safe to call concurrently from multiple goroutines.
Template selection has two modes:
Filter mode: If no direct templates are specified (TemplateFiles/TemplateDirs/TemplateBytes), templates are filtered from the global store using Tags/Severities/ProtocolTypes/TemplateIDs.
Direct mode: If TemplateFiles, TemplateDirs, or TemplateBytes are set, ONLY those templates are loaded and used. The global store filters are ignored. This is ideal for targeted scans (e.g., "scan target X with this specific CVE template").
func (*ScanEngine) ScanWithCallback ¶
func (se *ScanEngine) ScanWithCallback(ctx context.Context, scanOpts *ScanOptions, cb func(*ScanResult)) error
ScanWithCallback executes a scan and invokes the callback for each result. Blocks until scanning completes or the context is cancelled.
func (*ScanEngine) Setup ¶
func (se *ScanEngine) Setup() error
Setup performs the one-time heavy initialization of global resources: protocol state, catalog, parser, template loading, output writer, interactsh client, rate limiter, browser, etc.
This must be called before Scan(). It is safe to call only once.
type ScanOptions ¶
type ScanOptions struct {
// Targets to scan (URLs, domains, IPs, host:port)
Targets []string
TargetFile string
// Template filtering (applied at runtime against the pre-loaded template store)
// These are ignored when TemplateFiles/TemplateDirs/TemplateBytes are set.
Tags []string
ExcludeTags []string
Severities []string
ProtocolTypes string // "http", "dns", "ssl", "network" — comma-separated
TemplateIDs []string
ExcludeIDs []string
Authors []string
// Per-scan template sources (direct mode — bypasses global store)
TemplateFiles []string // Specific template file paths for this scan
TemplateDirs []string // Template directories for this scan
TemplateBytes []TemplateBytesEntry // Raw YAML templates (e.g., from API response)
// Result severity filter (post-scan filtering)
ResultSeverityFilter []string
}
ScanOptions defines per-scan parameters for ScanEngine.Scan(). These are lightweight, per-invocation settings — targets, template filters, etc. Global resources (interactsh, parser, catalog, browser) are shared from the engine.
Template selection works in two modes:
Filter mode (default): When only Tags/Severities/ProtocolTypes/TemplateIDs are set, templates are filtered at runtime from the engine's pre-loaded global template store.
Direct mode: When TemplateFiles, TemplateDirs, or TemplateBytes are set, ONLY those templates are loaded and used for this scan. The global store is not used. This is ideal for targeted scans where you know exactly which template to run.
type ScanPool ¶
type ScanPool struct {
// contains filtered or unexported fields
}
ScanPool manages a pool of concurrent scan workers backed by a shared ScanEngine. Jobs can be submitted dynamically at any time, and results stream through a unified channel. This is ideal for continuous scanning workflows where new targets/templates arrive over time (e.g., from an API, message queue, or webhook).
Usage:
pool := engine.NewScanPool(ctx, 10)
pool.Submit("CVE-2024-1234", &nucleisdk.ScanOptions{...})
pool.Submit("CVE-2024-5678", &nucleisdk.ScanOptions{...})
go func() {
for r := range pool.Results() {
fmt.Printf("[%s] %s\n", r.Label, r.TemplateID)
}
}()
pool.Submit("CVE-2024-9999", &nucleisdk.ScanOptions{...})
pool.Close()
fmt.Println(pool.Stats())
func (*ScanPool) Close ¶
func (p *ScanPool) Close()
Close signals that no more jobs will be submitted and waits for all active scans to complete. The Results() channel is closed after the last result is sent.
Safe to call multiple times.
func (*ScanPool) Results ¶
func (p *ScanPool) Results() <-chan *LabeledResult
Results returns the channel that streams all scan results from all jobs. Each result is tagged with the job label it belongs to.
The channel is closed after Close() is called and all pending jobs complete. This channel MUST be consumed — otherwise workers will block.
func (*ScanPool) Submit ¶
func (p *ScanPool) Submit(label string, opts *ScanOptions) error
Submit queues a labeled scan job for execution. Safe to call from multiple goroutines concurrently. Blocks if the internal job queue is full.
Returns an error if the pool has been closed or the context is cancelled.
type ScanResult ¶
type ScanResult struct {
// Core identification
TemplateID string `json:"template_id"`
TemplateName string `json:"template_name"`
TemplatePath string `json:"template_path,omitempty"`
Severity string `json:"severity"`
Type string `json:"type"`
// Match details
Host string `json:"host"`
MatchedURL string `json:"matched_url"`
MatcherName string `json:"matcher_name,omitempty"`
ExtractorName string `json:"extractor_name,omitempty"`
ExtractedResults []string `json:"extracted_results,omitempty"`
IP string `json:"ip,omitempty"`
Port string `json:"port,omitempty"`
Scheme string `json:"scheme,omitempty"`
URL string `json:"url,omitempty"`
Path string `json:"path,omitempty"`
// Request/Response
Request string `json:"request,omitempty"`
Response string `json:"response,omitempty"`
CURLCommand string `json:"curl_command,omitempty"`
// Metadata
Tags []string `json:"tags,omitempty"`
Authors []string `json:"authors,omitempty"`
Description string `json:"description,omitempty"`
Impact string `json:"impact,omitempty"`
Remediation string `json:"remediation,omitempty"`
Reference []string `json:"reference,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
// Classification
CVEID []string `json:"cve_id,omitempty"`
CWEID []string `json:"cwe_id,omitempty"`
CVSSMetrics string `json:"cvss_metrics,omitempty"`
CVSSScore float64 `json:"cvss_score,omitempty"`
EPSSScore float64 `json:"epss_score,omitempty"`
CPE string `json:"cpe,omitempty"`
// Fuzzing
IsFuzzingResult bool `json:"is_fuzzing_result,omitempty"`
FuzzingMethod string `json:"fuzzing_method,omitempty"`
FuzzingParameter string `json:"fuzzing_parameter,omitempty"`
FuzzingPosition string `json:"fuzzing_position,omitempty"`
// Status
MatcherStatus bool `json:"matcher_status"`
Timestamp time.Time `json:"timestamp"`
Error string `json:"error,omitempty"`
// contains filtered or unexported fields
}
ScanResult represents a single scan finding with a clean API.
func (*ScanResult) IsCritical ¶
func (r *ScanResult) IsCritical() bool
IsCritical returns true if the severity is critical.
func (*ScanResult) IsHighOrAbove ¶
func (r *ScanResult) IsHighOrAbove() bool
IsHighOrAbove returns true if the severity is high or critical.
func (*ScanResult) JSON ¶
func (r *ScanResult) JSON() string
JSON returns the result serialized as a JSON string.
func (*ScanResult) JSONBytes ¶
func (r *ScanResult) JSONBytes() ([]byte, error)
JSONBytes returns the result serialized as JSON bytes.
func (*ScanResult) JSONPretty ¶
func (r *ScanResult) JSONPretty() string
JSONPretty returns the result serialized as pretty-printed JSON.
func (*ScanResult) RawEvent ¶
func (r *ScanResult) RawEvent() *output.ResultEvent
RawEvent returns the underlying nuclei output.ResultEvent for advanced users.
func (*ScanResult) SeverityLevel ¶
func (r *ScanResult) SeverityLevel() int
SeverityLevel returns a numeric severity level. 0=unknown, 1=info, 2=low, 3=medium, 4=high, 5=critical
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner is the main entry point for running nuclei scans.
func NewScanner ¶
NewScanner creates a new Scanner with the given options.
func (*Scanner) Run ¶
func (s *Scanner) Run(ctx context.Context) (<-chan *ScanResult, error)
Run executes the scan and returns results via a channel. The channel is closed when scanning completes or the context is cancelled. Any scan execution errors are sent as a ScanResult with the Error field set.
func (*Scanner) RunWithCallback ¶
func (s *Scanner) RunWithCallback(ctx context.Context, callback func(*ScanResult)) error
RunWithCallback executes the scan and invokes the callback for each result. Blocks until scanning is complete or the context is cancelled.
type TemplateBytesEntry ¶
TemplateBytesEntry holds a named raw YAML template.
func TemplateBytes ¶
func TemplateBytes(name string, data []byte) TemplateBytesEntry
TemplateBytes creates a TemplateBytesEntry from a name and YAML data.
type TemplateInfo ¶
type TemplateInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Author string `json:"author"`
Severity string `json:"severity"`
Tags []string `json:"tags,omitempty"`
Description string `json:"description,omitempty"`
}
TemplateInfo contains parsed metadata from a nuclei template.
func ParseTemplateInfo ¶
func ParseTemplateInfo(data []byte) (*TemplateInfo, error)
ParseTemplateInfo extracts metadata from raw YAML template bytes without creating a full nuclei engine.
type WebScanner ¶
type WebScanner struct {
// contains filtered or unexported fields
}
WebScanner is a pre-configured scanner for general web security testing. It runs HTTP-based templates excluding destructive categories.
func NewWebScanner ¶
func NewWebScanner(opts ...Option) (*WebScanner, error)
NewWebScanner creates a new general web scanner with sensible defaults.
func (*WebScanner) Run ¶
func (w *WebScanner) Run(ctx context.Context) (<-chan *ScanResult, error)
Run executes the web scan and returns results via a channel.
func (*WebScanner) RunWithCallback ¶
func (w *WebScanner) RunWithCallback(ctx context.Context, cb func(*ScanResult)) error
RunWithCallback executes the web scan with a callback.
type WordPressScanner ¶
type WordPressScanner struct {
// contains filtered or unexported fields
}
WordPressScanner is a pre-configured scanner for WordPress security testing. It focuses on WordPress core, plugins, themes, and common misconfigurations.
func NewWordPressScanner ¶
func NewWordPressScanner(opts ...Option) (*WordPressScanner, error)
NewWordPressScanner creates a new WordPress scanner with sensible defaults.
func (*WordPressScanner) Run ¶
func (w *WordPressScanner) Run(ctx context.Context) (<-chan *ScanResult, error)
Run executes the WordPress scan and returns results via a channel.
func (*WordPressScanner) RunWithCallback ¶
func (w *WordPressScanner) RunWithCallback(ctx context.Context, cb func(*ScanResult)) error
RunWithCallback executes the WordPress scan with a callback.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
nuclei-sdk-bridge
command
|
|
|
examples
|
|
|
api_security
command
|
|
|
basic
command
|
|
|
concurrent
command
|
|
|
custom_config
command
|
|
|
raw_template
command
|
|
|
reusable_engine
command
|
|
|
scan_pool
command
|
|
|
targeted_scan
command
|
|
|
wordpress
command
|