Skip to content

Commit

Permalink
fix loading dynamic auth templates on fuzzing (#5646)
Browse files Browse the repository at this point in the history
  • Loading branch information
RamanaReddy0M authored Sep 20, 2024
1 parent b69de15 commit 3eee967
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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"
)

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

0 comments on commit 3eee967

Please sign in to comment.