forked from projectdiscovery/alterx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
40 lines (32 loc) · 807 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package alterx
import (
"os"
_ "embed"
"github.com/projectdiscovery/gologger"
"gopkg.in/yaml.v3"
)
//go:embed permutations.yaml
var DefaultPermutationsBin []byte
// DefaultConfig contains default patterns and payloads
var DefaultConfig Config
type Config struct {
Patterns []string `yaml:"patterns"`
Payloads map[string][]string `yaml:"payloads"`
}
// NewConfig reads config from file
func NewConfig(filePath string) (*Config, error) {
bin, err := os.ReadFile(filePath)
if err != nil {
return nil, err
}
var cfg Config
if err = yaml.Unmarshal(bin, &cfg); err != nil {
return nil, err
}
return &cfg, nil
}
func init() {
if err := yaml.Unmarshal(DefaultPermutationsBin, &DefaultConfig); err != nil {
gologger.Error().Msgf("default wordlist not found: got %v", err)
}
}