2023-04-19 21:58:48 +05:30
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
2025-07-09 14:47:26 -05:00
|
|
|
"runtime/debug"
|
2023-04-19 21:58:48 +05:30
|
|
|
|
|
|
|
|
"github.com/projectdiscovery/gologger"
|
|
|
|
|
"gopkg.in/yaml.v2"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// IgnoreFile is an internal nuclei template blocking configuration file
|
|
|
|
|
type IgnoreFile struct {
|
|
|
|
|
Tags []string `yaml:"tags"`
|
|
|
|
|
Files []string `yaml:"files"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ReadIgnoreFile reads the nuclei ignore file returning blocked tags and paths
|
|
|
|
|
func ReadIgnoreFile() IgnoreFile {
|
|
|
|
|
file, err := os.Open(DefaultConfig.GetIgnoreFilePath())
|
|
|
|
|
if err != nil {
|
2025-07-09 14:47:26 -05:00
|
|
|
gologger.Error().Msgf("Could not read nuclei-ignore file: %s\n%s\n", err, string(debug.Stack()))
|
2023-04-19 21:58:48 +05:30
|
|
|
return IgnoreFile{}
|
|
|
|
|
}
|
2025-07-01 00:40:44 +07:00
|
|
|
defer func() {
|
|
|
|
|
_ = file.Close()
|
|
|
|
|
}()
|
2023-04-19 21:58:48 +05:30
|
|
|
|
|
|
|
|
ignore := IgnoreFile{}
|
|
|
|
|
if err := yaml.NewDecoder(file).Decode(&ignore); err != nil {
|
|
|
|
|
gologger.Error().Msgf("Could not parse nuclei-ignore file: %s\n", err)
|
|
|
|
|
return IgnoreFile{}
|
|
|
|
|
}
|
|
|
|
|
return ignore
|
|
|
|
|
}
|