-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathyaml_demo.go
More file actions
51 lines (44 loc) · 1.15 KB
/
Copy pathyaml_demo.go
File metadata and controls
51 lines (44 loc) · 1.15 KB
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
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"gopkg.in/yaml.v2"
"io/ioutil"
"log"
)
type Poc struct {
Name string `yaml:"name"`
Set Set `yaml:"set"`
Rules []Rules `yaml:"rules"`
Detail Detail `yaml:"detail"`
}
type Set struct {
Filename string `yaml:"filename"`
FileContent string `yaml:"fileContent"`
}
type Headers struct {
Cookie string `yaml:"Cookie"`
ContentType string `yaml:"Content-Type"`
}
type Rules struct {
Method string `yaml:"method"`
Path string `yaml:"path"`
Headers Headers `yaml:"headers"`
Body string `yaml:"body"`
Search string `yaml:"search"`
FollowRedirects bool `yaml:"follow_redirects"`
Expression string `yaml:"expression"`
}
type Detail struct {
Author string `yaml:"author"`
Links []string `yaml:"links"`
}
func (p *Poc) PocGetter(path string) *Poc {
yamlFile, err := ioutil.ReadFile(path)
if err != nil {
log.Fatalf("yaml_file Get err: %#v\n", err)
}
err = yaml.Unmarshal(yamlFile, p)
if err != nil {
log.Fatalf("yaml.Unmarshal err: %#v\n", err)
}
return p
}