nuclei/v2/lib/helper.go
Tarun Koyalwar 2d317884b5
SDK: abstracted and minimal nuclei v3 sdk (#4104)
* new sdk progress

* nuclei v3 new sdk/library

* fix TestActionGetResource broken link

* fix clistats + clustering and more

* fix lint error

* fix missing ticker

* update advanced library usage example

* fix integration tests

* misc update

* add utm_source and fix lint error

---------

Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com>
2023-09-02 14:34:05 +05:30

34 lines
1.4 KiB
Go

package nuclei
import (
"context"
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/config"
uncoverNuclei "github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/uncover"
"github.com/projectdiscovery/nuclei/v2/pkg/templates"
"github.com/projectdiscovery/uncover"
)
// helper.go file proxy execution of all nuclei functions that are nested deep inside multiple packages
// but are helpful / useful while using nuclei as a library
// GetTargetsFromUncover returns targets from uncover in given format .
// supported formats are any string with [ip,host,port,url] placeholders
func GetTargetsFromUncover(ctx context.Context, outputFormat string, opts *uncover.Options) (chan string, error) {
return uncoverNuclei.GetTargetsFromUncover(ctx, outputFormat, opts)
}
// GetTargetsFromTemplateMetadata returns all targets by querying engine metadata (ex: fofo-query,shodan-query) etc from given templates .
// supported formats are any string with [ip,host,port,url] placeholders
func GetTargetsFromTemplateMetadata(ctx context.Context, templates []*templates.Template, outputFormat string, opts *uncover.Options) chan string {
return uncoverNuclei.GetUncoverTargetsFromMetadata(ctx, templates, outputFormat, opts)
}
// DefaultConfig is instance of default nuclei configs
// any mutations to this config will be reflected in all nuclei instances (saves some config to disk)
var DefaultConfig *config.Config
func init() {
DefaultConfig = config.DefaultConfig
}