-
Notifications
You must be signed in to change notification settings - Fork 0
/
plan.go
63 lines (52 loc) · 2.18 KB
/
plan.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
package plan
import (
"fmt"
"time"
"gopkg.in/mgo.v2/bson"
"github.com/bearded-web/bearded/models/target"
"github.com/bearded-web/bearded/pkg/pagination"
)
type File struct {
Path string `json:"path" description:"absolute path to file in container"`
Name string `json:"name" description:"rename file to name or use path if empty"`
}
type SharedFile struct {
Path string `json:"path" description:"path is relative to /share/"`
Text string `json:"text" description:"text is a content of text file"`
}
type Conf struct {
CommandArgs string `json:"commandArgs,omitempty" description:"passed to command line for plugins with type:util"`
Target string `json:"target,omitempty" description:"used in script, taken from scan conf directly"`
FormData string `json:"formData,omitempty" description:"data from form is saved as json string here"`
// this fields helps to communicate with container through files
TakeFiles []*File `json:"takeFiles,omitempty" description:"copy this files from container when it's done"`
SharedFiles []*SharedFile `json:"sharedFiles,omitempty" description:"share file to container"`
}
type WorkflowStep struct {
Plugin string `json:"plugin" description:"plugin name"`
Name string `json:"name" description:"step name"`
Desc string `json:"desc,omitempty" description:"step description"`
Conf *Conf `json:"conf,omitempty"`
}
type Plan struct {
Id bson.ObjectId `json:"id,omitempty" bson:"_id,omitempty"`
Name string `json:"name"`
Desc string `json:"desc"` // human readable description
Workflow []*WorkflowStep `json:"workflow"`
Created time.Time `json:"created,omitempty" description:"when plan is created"`
Updated time.Time `json:"updated,omitempty" description:"when plan is updated"`
TargetType target.TargetType `json:"targetType" bson:"targetType" description:"what target type is supported"`
}
type PlanList struct {
pagination.Meta `json:",inline"`
Results []*Plan `json:"results"`
}
func (p *Plan) String() string {
var str string
if p.Id != "" {
str = fmt.Sprintf("%x - %s", string(p.Id), p.Name)
} else {
str = fmt.Sprintf("%s", p.Name)
}
return str
}