-
Notifications
You must be signed in to change notification settings - Fork 0
/
discovery.go
128 lines (114 loc) · 5.06 KB
/
discovery.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package horizon
type EventStatus string
const (
Success EventStatus = "success"
Warning EventStatus = "warning"
Failure EventStatus = "failure"
)
type DiscoveryEventCode string
const (
DiscoveryLocalScan DiscoveryEventCode = "LOCALSCAN"
DiscoveryNetscan DiscoveryEventCode = "NETSCAN"
DiscoveryImportscan DiscoveryEventCode = "IMPORTSCAN"
DiscoveryLocalImport DiscoveryEventCode = "LOCALIMPORT"
DiscoveryNetImport DiscoveryEventCode = "NETIMPORT"
DiscoveryEst DiscoveryEventCode = "EST"
DiscoveryAcme DiscoveryEventCode = "ACME"
DiscoveryWebRA DiscoveryEventCode = "WEBRA"
)
// Certificate is the struct of the locally discovered certs
type DiscoveredCertificate struct {
DiscoveryCampaign string `json:"campaign,omitempty"`
SessionId string `json:"sessionId,omitempty"`
Certificate string `json:"certificate,omitempty"`
ContactEmail string `json:"contactEmail,omitempty"`
Code DiscoveryEventCode `json:"code,omitempty"`
DiscoveryData *DiscoveryData `json:"hostDiscoveryData,omitempty"`
Metadata []Metadata `json:"metadata,omitempty"`
ThirdPartyData []ThirdPartyItem `json:"thirdPartyData,omitempty"`
PrivateKey string `json:"privateKey,omitempty"`
}
type DiscoveredCertificateParams struct {
Certificate string
Code DiscoveryEventCode
DiscoveryData *DiscoveryData
Metadata []Metadata
PrivateKey string
ContactEmail string
ThirdPartyData []ThirdPartyItem
}
type EnforcedIdentityProviders struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
}
type AuthorizationLevel struct {
AccessLevel string `json:"accessLevel,omitempty"`
EnforcedIdentityProviders []EnforcedIdentityProviders
}
type AuthorizationLevels struct {
Search AuthorizationLevel `json:"search,omitempty"`
Feed AuthorizationLevel `json:"feed,omitempty"`
}
// DiscoveryCampaign is the struct of the discovery campaign as defined in Horizon
type DiscoveryCampaign struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Enabled bool `json:"enabled,omitempty"`
GradingPolicies []string `json:"gradingPolicies,omitempty"`
AuthorizationLevels AuthorizationLevels `json:"authorizationLevels,omitempty"`
Id string `json:"id,omitempty"`
EventOnSuccess bool `json:"eventOnSuccess,omitempty"`
EventOnFailure bool `json:"eventOnFailure,omitempty"`
EventOnWarning bool `json:"eventOnWarning,omitempty"`
Hosts []string `json:"hosts,omitempty"`
Ports []string `json:"ports,omitempty"`
}
// DiscoverySession is the struct that holds info about a sessions
type DiscoverySession struct {
Campaign string `json:"campaign,omitempty"`
Id string `json:"id,omitempty"`
EventOnSuccess bool `json:"eventOnSuccess,omitempty"`
EventOnFailure bool `json:"eventOnFailure,omitempty"`
EventOnWarning bool `json:"eventOnWarning,omitempty"`
Hosts []string `json:"hosts,omitempty"`
Ports []string `json:"ports,omitempty"`
}
// DiscoveryEvent is the struct for the discovery event as defined in Horizon
type DiscoveryEvent struct {
Id string `json:"_id,omitempty"`
Code DiscoveryEventCode `json:"code,omitempty"`
Campaign string `json:"campaign,omitempty"`
SessionId string `json:"sessionId,omitempty"`
Status EventStatus `json:"status,omitempty"`
ErrorCode string `json:"errorCode,omitempty"`
ErrorMessage string `json:"errorMessage,omitempty"`
Timestamp int `json:"timestamp,omitempty"`
ClientVersion string `json:"clientVersion,omitempty"`
ClientIp string `json:"clientIp,omitempty"`
ClientId string `json:"clientId,omitempty"`
ActorId string `json:"actorId,omitempty"`
CertificateId string `json:"certificateId,omitempty"`
Hostname string `json:"hostname,omitempty"`
Ip string `json:"ip,omitempty"`
Port int `json:"port,omitempty"`
Source string `json:"source,omitempty"`
}
// DiscoveryEventParams is the struct to build a discoveryEvent
type DiscoveryEventParams struct {
Code DiscoveryEventCode
Status EventStatus
ErrorCode string
ErrorMessage string
Hostname string
Ip string
Port int
Source string
}
// DiscoveryEventSearchQuery is the struct to query discovery events
type DiscoveryEventSearchQuery struct {
Query string `json:"query,omitempty"`
SortedBy []SortFields `json:"sortedBy,omitempty"`
PageIndex int `json:"pageIndex,omitempty"`
PageSize int `json:"pageSize,omitempty"`
WithCount bool `json:"withCount,omitempty"`
}