Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix loading dynamic auth templates on fuzzing #5646

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/runner/lazy.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func GetAuthTmplStore(opts types.Options, catalog catalog.Catalog, execOpts prot
opts.ExcludeProtocols = nil
opts.IncludeConditions = nil
cfg := loader.NewConfig(&opts, catalog, execOpts)
cfg.StoreId = loader.AuthStoreId
store, err := loader.New(cfg)
if err != nil {
return nil, errorutil.NewWithErr(err).Msgf("failed to initialize dynamic auth templates store")
Expand Down
11 changes: 10 additions & 1 deletion pkg/catalog/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
const (
httpPrefix = "http://"
httpsPrefix = "https://"
AuthStoreId = "auth_store"
RamanaReddy0M marked this conversation as resolved.
Show resolved Hide resolved
)

var (
Expand All @@ -41,6 +42,7 @@ var (

// Config contains the configuration options for the loader
type Config struct {
StoreId string // used to set store id (optional)
Templates []string
TemplateURLs []string
Workflows []string
Expand All @@ -67,6 +69,7 @@ type Config struct {

// Store is a storage for loaded nuclei templates
type Store struct {
id string // id of the store (optional)
tagFilter *templates.TagFilter
pathFilter *filter.PathFilter
config *Config
Expand Down Expand Up @@ -132,6 +135,7 @@ func New(cfg *Config) (*Store, error) {

// Create a tag filter based on provided configuration
store := &Store{
id: cfg.StoreId,
config: cfg,
tagFilter: tagFilter,
pathFilter: filter.NewPathFilter(&filter.PathFilterConfig{
Expand Down Expand Up @@ -230,6 +234,10 @@ func (store *Store) ReadTemplateFromURI(uri string, remote bool) ([]byte, error)
}
}

func (store *Store) ID() string {
return store.id
}

// Templates returns all the templates in the store
func (store *Store) Templates() []*templates.Template {
return store.templates
Expand Down Expand Up @@ -472,7 +480,8 @@ func (store *Store) LoadTemplatesWithTags(templatesList, tags []string) []*templ
return
}
// DAST only templates
if store.config.ExecutorOptions.Options.DAST {
// Skip DAST filter when loading auth templates
if store.ID() != AuthStoreId && store.config.ExecutorOptions.Options.DAST {
// check if the template is a DAST template
if parsed.IsFuzzing() {
loadTemplate(parsed)
Expand Down
Loading