-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd.go
90 lines (74 loc) · 1.58 KB
/
cmd.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package main
import (
"fmt"
"os"
)
type Tactic struct {
Id string
Name string
Techniques []Technique
}
type Technique struct {
Name string
Id string
Support string
}
type displayT struct {
Tactics []Tactic
}
func main() {
// parse the yaml
var t T
t = *t.parseFightYaml()
var a A
a = *a.parseAccuknoxYaml()
// copy the support from the accuknox support yaml
// populate the display var which is input to template renderer
var d displayT
for _, tactic := range t.Tactics {
var t_d Tactic
t_d.Id = tactic.Id
t_d.Name = tactic.Name
for _, technique := range t.Techniques {
for _, tqt := range technique.Tactics {
if t_d.Id == tqt {
t_d.Techniques = append(t_d.Techniques, Technique{technique.Name, technique.ID, a.Techniques[technique.Name]})
}
}
}
d.Tactics = append(d.Tactics, t_d)
}
// print the struct
for _, tactic := range d.Tactics {
for _, technique := range tactic.Techniques {
fmt.Printf("%s: %s: %s\n", tactic.Name, technique.Name, technique.Support)
}
}
// open output file
fo, err := os.Create("index.html")
if err != nil {
panic(err)
}
defer func() {
if err := fo.Close(); err != nil {
panic(err)
}
}()
// render the template
d.generateAllTacticsPage(fo)
for _, tactic := range d.Tactics {
// open output file
fname := fmt.Sprintf("tactic-%s.html", tactic.Id)
fo, err := os.Create(fname)
if err != nil {
panic(err)
}
defer func() {
if err := fo.Close(); err != nil {
panic(err)
}
}()
// render the template
tactic.generateTechniquesPerTacticPage(fo)
}
}