Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/catalog/config/ignorefile.go
2070 views
1
package config
2
3
import (
4
"os"
5
"runtime/debug"
6
7
"github.com/projectdiscovery/gologger"
8
"gopkg.in/yaml.v2"
9
)
10
11
// IgnoreFile is an internal nuclei template blocking configuration file
12
type IgnoreFile struct {
13
Tags []string `yaml:"tags"`
14
Files []string `yaml:"files"`
15
}
16
17
// ReadIgnoreFile reads the nuclei ignore file returning blocked tags and paths
18
func ReadIgnoreFile() IgnoreFile {
19
file, err := os.Open(DefaultConfig.GetIgnoreFilePath())
20
if err != nil {
21
gologger.Error().Msgf("Could not read nuclei-ignore file: %s\n%s\n", err, string(debug.Stack()))
22
return IgnoreFile{}
23
}
24
defer func() {
25
_ = file.Close()
26
}()
27
28
ignore := IgnoreFile{}
29
if err := yaml.NewDecoder(file).Decode(&ignore); err != nil {
30
gologger.Error().Msgf("Could not parse nuclei-ignore file: %s\n", err)
31
return IgnoreFile{}
32
}
33
return ignore
34
}
35
36