Browse Source

fix some go problems

Andreas Peters 1 year ago
parent
commit
246b7ee018
4 changed files with 246 additions and 208 deletions
  1. 18
    0
      .vscode/launch.json
  2. 15
    15
      services/pentest/misc.go
  3. 43
    48
      services/pentest/pentest.go
  4. 170
    145
      services/pentest/pentest_struct.go

+ 18
- 0
.vscode/launch.json View File

@@ -0,0 +1,18 @@
1
+{
2
+    "version": "0.2.0",
3
+    "configurations": [
4
+        {
5
+            "name": "Launch",
6
+            "type": "go",
7
+            "request": "launch",
8
+            "mode": "debug",
9
+            "remotePath": "",
10
+            "port": 2345,
11
+            "host": "127.0.0.1",
12
+            "program": "${fileDirname}",
13
+            "env": {},
14
+            "args": [],
15
+            "showLog": true
16
+        }
17
+    ]
18
+}

+ 15
- 15
services/pentest/misc.go View File

@@ -1,4 +1,4 @@
1
-// Package invoice implements a Service which create invoices
1
+// Package pentest implements a Service to penetrate a server and crate reports of the result
2 2
 package pentest
3 3
 
4 4
 import (
@@ -12,10 +12,10 @@ import (
12 12
 )
13 13
 
14 14
 // start a task in OpenVAS
15
-func (s *Service) startTask(taskId string) (string, string, string) {
15
+func (s *Service) startTask(taskID string) (string, string, string) {
16 16
 	var xmlMsg string
17 17
 	xmlMsg = xmlMsg + fmt.Sprintf("<authenticate><credentials><username>%s</username><password>%s</password></credentials></authenticate>", s.OpenVASUsername, s.OpenVASPassword)
18
-	xmlMsg = xmlMsg + fmt.Sprintf("<start_task task_id=\"%s\"/>", taskId)
18
+	xmlMsg = xmlMsg + fmt.Sprintf("<start_task task_id=\"%s\"/>", taskID)
19 19
 	message := s.sendSocket(xmlMsg)
20 20
 
21 21
 	var res StartTaskResponse
@@ -25,14 +25,14 @@ func (s *Service) startTask(taskId string) (string, string, string) {
25 25
 		return "", "", "400"
26 26
 	}
27 27
 
28
-	return res.StartTask.ReportId, res.StartTask.Status, res.StartTask.StatusText
28
+	return res.StartTask.ReportID, res.StartTask.Status, res.StartTask.StatusText
29 29
 }
30 30
 
31 31
 // create a task in OpenVAS
32
-func (s *Service) createTask(name, scanConfigId, targetId string) (string, string) {
32
+func (s *Service) createTask(name, scanConfigID, targetID string) (string, string) {
33 33
 	var xmlMsg string
34 34
 	xmlMsg = xmlMsg + fmt.Sprintf("<authenticate><credentials><username>%s</username><password>%s</password></credentials></authenticate>", s.OpenVASUsername, s.OpenVASPassword)
35
-	xmlMsg = xmlMsg + fmt.Sprintf("<create_task><name>%s</name><config id=\"%s\"/><target id=\"%s\"/></create_task>", name, scanConfigId, targetId)
35
+	xmlMsg = xmlMsg + fmt.Sprintf("<create_task><name>%s</name><config id=\"%s\"/><target id=\"%s\"/></create_task>", name, scanConfigID, targetID)
36 36
 	message := s.sendSocket(xmlMsg)
37 37
 
38 38
 	var res CreateTaskResponse
@@ -42,14 +42,14 @@ func (s *Service) createTask(name, scanConfigId, targetId string) (string, strin
42 42
 		return "", "400"
43 43
 	}
44 44
 
45
-	return res.CreateTask.Id, res.CreateTask.Status
45
+	return res.CreateTask.ID, res.CreateTask.Status
46 46
 }
47 47
 
48 48
 // get out a report
49
-func (s *Service) getReportInFormat(reportId, formatId string) (string, string, string, string) {
49
+func (s *Service) getReportInFormat(reportID, formatID string) (string, string, string, string) {
50 50
 	var xmlMsg string
51 51
 	xmlMsg = xmlMsg + fmt.Sprintf("<authenticate><credentials><username>%s</username><password>%s</password></credentials></authenticate>", s.OpenVASUsername, s.OpenVASPassword)
52
-	xmlMsg = xmlMsg + fmt.Sprintf("<get_reports report_id=\"%s\" format_id=\"%s\"/>", reportId, formatId)
52
+	xmlMsg = xmlMsg + fmt.Sprintf("<get_reports report_id=\"%s\" format_id=\"%s\"/>", reportID, formatID)
53 53
 	message := s.sendSocket(xmlMsg)
54 54
 
55 55
 	var res GetReportsResponseInFormat
@@ -59,14 +59,14 @@ func (s *Service) getReportInFormat(reportId, formatId string) (string, string,
59 59
 		return "", "", "", "400"
60 60
 	}
61 61
 
62
-	return res.GetReportsResponse.Report.Data, res.GetReportsResponse.Report.Content_type, res.GetReportsResponse.Report.Extension, res.GetReportsResponse.Status
62
+	return res.GetReportsResponse.Report.Data, res.GetReportsResponse.Report.ContentType, res.GetReportsResponse.Report.Extension, res.GetReportsResponse.Status
63 63
 }
64 64
 
65 65
 // get out a report
66
-func (s *Service) getReport(reportId string) (string, string) {
66
+func (s *Service) getReport(reportID string) (string, string) {
67 67
 	var xmlMsg string
68 68
 	xmlMsg = xmlMsg + fmt.Sprintf("<authenticate><credentials><username>%s</username><password>%s</password></credentials></authenticate>", s.OpenVASUsername, s.OpenVASPassword)
69
-	xmlMsg = xmlMsg + fmt.Sprintf("<get_reports report_id=\"%s\"/>", reportId)
69
+	xmlMsg = xmlMsg + fmt.Sprintf("<get_reports report_id=\"%s\"/>", reportID)
70 70
 	message := s.sendSocket(xmlMsg)
71 71
 
72 72
 	var res GetReportsResponse
@@ -75,7 +75,7 @@ func (s *Service) getReport(reportId string) (string, string) {
75 75
 	if err != nil {
76 76
 		return "", "400"
77 77
 	}
78
-	return res.GetReportsResponse.Report.Report.Scan_run_status, res.GetReportsResponse.Status
78
+	return res.GetReportsResponse.Report.Report.ScanRunStatus, res.GetReportsResponse.Status
79 79
 }
80 80
 
81 81
 // get out all scan config id's
@@ -108,7 +108,7 @@ func (s *Service) getScanConfigIDs() (GetConfigsResponse, string) {
108 108
 		return res, "400"
109 109
 	}
110 110
 
111
-	return res, res.Get_configs_response.Status
111
+	return res, res.GetConfigsResponse.Status
112 112
 }
113 113
 
114 114
 // create a scan target in OpenVAS
@@ -124,7 +124,7 @@ func (s *Service) createTarget(name, target string) (string, string) {
124 124
 	if err != nil {
125 125
 		return "", "400"
126 126
 	}
127
-	return res.CreateTarget.Id, res.CreateTarget.Status
127
+	return res.CreateTarget.ID, res.CreateTarget.Status
128 128
 }
129 129
 
130 130
 // Authenticate against OpenVAS

+ 43
- 48
services/pentest/pentest.go View File

@@ -54,9 +54,8 @@ func (s *Service) Commands(cli *gomatrix.Client) []types.Command {
54 54
 			Command: func(roomID, userID string, args []string) (interface{}, error) {
55 55
 				if strings.Contains(s.AllowedUsers, userID) {
56 56
 					return s.cmdScanTarget(roomID, userID, args)
57
-				} else {
58
-					return &gomatrix.TextMessage{"m.notice", "U are not allowed to use this function"}, nil
59 57
 				}
58
+				return &gomatrix.TextMessage{"m.notice", "U are not allowed to use this function"}, nil
60 59
 			},
61 60
 		},
62 61
 		{
@@ -64,9 +63,8 @@ func (s *Service) Commands(cli *gomatrix.Client) []types.Command {
64 63
 			Command: func(roomID, userID string, args []string) (interface{}, error) {
65 64
 				if strings.Contains(s.AllowedUsers, userID) {
66 65
 					return s.cmdGetScanConfigIDs(roomID, userID, args)
67
-				} else {
68
-					return &gomatrix.TextMessage{"m.notice", "U are not allowed to use this function"}, nil
69 66
 				}
67
+				return &gomatrix.TextMessage{"m.notice", "U are not allowed to use this function"}, nil
70 68
 			},
71 69
 		},
72 70
 		{
@@ -74,9 +72,8 @@ func (s *Service) Commands(cli *gomatrix.Client) []types.Command {
74 72
 			Command: func(roomID, userID string, args []string) (interface{}, error) {
75 73
 				if strings.Contains(s.AllowedUsers, userID) {
76 74
 					return s.cmdGetReportFormatIDs(roomID, userID, args)
77
-				} else {
78
-					return &gomatrix.TextMessage{"m.notice", "U are not allowed to use this function"}, nil
79 75
 				}
76
+				return &gomatrix.TextMessage{"m.notice", "U are not allowed to use this function"}, nil
80 77
 			},
81 78
 		},
82 79
 		{
@@ -84,9 +81,8 @@ func (s *Service) Commands(cli *gomatrix.Client) []types.Command {
84 81
 			Command: func(roomID, userID string, args []string) (interface{}, error) {
85 82
 				if strings.Contains(s.AllowedUsers, userID) {
86 83
 					return s.cmdGetReport(roomID, userID, args)
87
-				} else {
88
-					return &gomatrix.TextMessage{"m.notice", "U are not allowed to use this function"}, nil
89 84
 				}
85
+				return &gomatrix.TextMessage{"m.notice", "U are not allowed to use this function"}, nil
90 86
 			},
91 87
 		},
92 88
 		{
@@ -94,9 +90,8 @@ func (s *Service) Commands(cli *gomatrix.Client) []types.Command {
94 90
 			Command: func(roomID, userID string, args []string) (interface{}, error) {
95 91
 				if strings.Contains(s.AllowedUsers, userID) {
96 92
 					return s.cmdDownloadReport(roomID, userID, cli, args)
97
-				} else {
98
-					return &gomatrix.TextMessage{"m.notice", "U are not allowed to use this function"}, nil
99 93
 				}
94
+				return &gomatrix.TextMessage{"m.notice", "U are not allowed to use this function"}, nil
100 95
 			},
101 96
 		},
102 97
 	}
@@ -113,7 +108,7 @@ func init() {
113 108
 // scan a server
114 109
 func (s *Service) cmdScanTarget(roomID, userID string, args []string) (interface{}, error) {
115 110
 	if len(args) < 3 {
116
-		return &gomatrix.TextMessage{"m.notice", fmt.Sprintf(`Missing parameters. Have a look with !pentest help`)}, nil
111
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: fmt.Sprintf(`Missing parameters. Have a look with !pentest help`)}, nil
117 112
 	}
118 113
 
119 114
 	var name = args[0]
@@ -122,46 +117,46 @@ func (s *Service) cmdScanTarget(roomID, userID string, args []string) (interface
122 117
 
123 118
 	// Authentication against openVAS
124 119
 	if s.omgAuthentication(userID) != "200" {
125
-		return &gomatrix.TextMessage{"m.notice", "OpenVAS think u are not trustfull enough :-)"}, nil
120
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: "OpenVAS think u are not trustfull enough :-)"}, nil
126 121
 	}
127 122
 
128 123
 	// let us create a target
129
-	targetId, status := s.createTarget(name, target)
124
+	targetID, status := s.createTarget(name, target)
130 125
 	if status == "400" {
131 126
 		// TODO: If its already exist, delete it
132
-		return &gomatrix.TextMessage{"m.notice", "Target already exist"}, nil
127
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: "Target already exist"}, nil
133 128
 	}
134 129
 	if status != "201" {
135
-		return &gomatrix.TextMessage{"m.notice", "Could not create target"}, nil
130
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: "Could not create target"}, nil
136 131
 	}
137 132
 
138
-	taskId, status := s.createTask(name, scanConfigID, targetId)
133
+	taskID, status := s.createTask(name, scanConfigID, targetID)
139 134
 	if status == "400" {
140 135
 		// TODO: If its already exist, delete it
141
-		return &gomatrix.TextMessage{"m.notice", "Task already exist"}, nil
136
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: "Task already exist"}, nil
142 137
 	}
143 138
 	if status != "201" {
144
-		return &gomatrix.TextMessage{"m.notice", "Could not create task"}, nil
139
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: "Could not create task"}, nil
145 140
 	}
146 141
 
147
-	reportId, status, statusText := s.startTask(taskId)
142
+	reportID, status, statusText := s.startTask(taskID)
148 143
 	if status != "202" {
149
-		return &gomatrix.TextMessage{"m.notice", fmt.Sprintf("Could not run the task with id: %s", taskId)}, nil
144
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: fmt.Sprintf("Could not run the task with id: %s", taskID)}, nil
150 145
 	}
151 146
 
152
-	res, status := s.getReport(reportId)
147
+	res, status := s.getReport(reportID)
153 148
 	if status != "200" {
154
-		return &gomatrix.TextMessage{"m.notice", "Could not find the report"}, nil
149
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: "Could not find the report"}, nil
155 150
 	}
156 151
 
157 152
 	var message string
158 153
 	message = message + fmt.Sprintf("```\n")
159 154
 	message = message + fmt.Sprintf("SCAN STATUS:   %s \n", printValueStr(statusText, 40))
160 155
 	message = message + fmt.Sprintf("REPORT STATUS: %s \n", printValueStr(res, 40))
161
-	message = message + fmt.Sprintf("REPORT ID:     %s \n", printValueStr(reportId, 50))
156
+	message = message + fmt.Sprintf("REPORT ID:     %s \n", printValueStr(reportID, 50))
162 157
 	message = message + fmt.Sprintf("```\n")
163 158
 
164
-	return &gomatrix.HTMLMessage{message, "m.text", "org.matrix.custom.html", markdownRender(message)}, nil
159
+	return &gomatrix.HTMLMessage{Body: message, MsgType: "m.text", Format: "org.matrix.custom.html", FormattedBody: markdownRender(message)}, nil
165 160
 
166 161
 }
167 162
 
@@ -169,12 +164,12 @@ func (s *Service) cmdScanTarget(roomID, userID string, args []string) (interface
169 164
 func (s *Service) cmdGetScanConfigIDs(roomID, userID string, args []string) (interface{}, error) {
170 165
 	// Authentication against openVAS
171 166
 	if s.omgAuthentication(userID) != "200" {
172
-		return &gomatrix.TextMessage{"m.notice", "OpenVAS think u are not trustfull enough :-)"}, nil
167
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: "OpenVAS think u are not trustfull enough :-)"}, nil
173 168
 	}
174 169
 
175 170
 	res, status := s.getScanConfigIDs()
176 171
 	if status != "200" {
177
-		return &gomatrix.TextMessage{"m.notice", "Could not find scan config id's"}, nil
172
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: "Could not find scan config id's"}, nil
178 173
 	}
179 174
 
180 175
 	var message string
@@ -184,25 +179,25 @@ func (s *Service) cmdGetScanConfigIDs(roomID, userID string, args []string) (int
184 179
 	message = message + fmt.Sprintf("| %s ", printValueStr("NAME", 20))
185 180
 	message = message + fmt.Sprintf("| %s\n", printValueStr("COMMENT", 50))
186 181
 
187
-	for i := 0; i < len(res.Get_configs_response.Config); i++ {
188
-		message = message + fmt.Sprintf("| %s ", printValueStr(res.Get_configs_response.Config[i].Id, 40))
189
-		message = message + fmt.Sprintf("| %s ", printValueStr(res.Get_configs_response.Config[i].Name[0], 20))
190
-		message = message + fmt.Sprintf("| %s\n", printValueStr(res.Get_configs_response.Config[i].Comment[0], 50))
182
+	for i := 0; i < len(res.GetConfigsResponse.Config); i++ {
183
+		message = message + fmt.Sprintf("| %s ", printValueStr(res.GetConfigsResponse.Config[i].ID, 40))
184
+		message = message + fmt.Sprintf("| %s ", printValueStr(res.GetConfigsResponse.Config[i].Name[0], 20))
185
+		message = message + fmt.Sprintf("| %s\n", printValueStr(res.GetConfigsResponse.Config[i].Comment[0], 50))
191 186
 	}
192 187
 	message = message + fmt.Sprintf("```\n")
193
-	return &gomatrix.HTMLMessage{message, "m.text", "org.matrix.custom.html", markdownRender(message)}, nil
188
+	return &gomatrix.HTMLMessage{Body: message, MsgType: "m.text", Format: "org.matrix.custom.html", FormattedBody: markdownRender(message)}, nil
194 189
 }
195 190
 
196 191
 // this function will give out a list of all in OpenVAS configured report formats
197 192
 func (s *Service) cmdGetReportFormatIDs(roomID, userID string, args []string) (interface{}, error) {
198 193
 	// Authentication against openVAS
199 194
 	if s.omgAuthentication(userID) != "200" {
200
-		return &gomatrix.TextMessage{"m.notice", "OpenVAS think u are not trustfull enough :-)"}, nil
195
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: "OpenVAS think u are not trustfull enough :-)"}, nil
201 196
 	}
202 197
 
203 198
 	res, status := s.getReportFormatIDs()
204 199
 	if status != "200" {
205
-		return &gomatrix.TextMessage{"m.notice", "Could not find scan config id's"}, nil
200
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: "Could not find scan config id's"}, nil
206 201
 	}
207 202
 
208 203
 	var message string
@@ -212,31 +207,31 @@ func (s *Service) cmdGetReportFormatIDs(roomID, userID string, args []string) (i
212 207
 	message = message + fmt.Sprintf("| %s ", printValueStr("NAME", 20))
213 208
 
214 209
 	for i := 0; i < len(res.GetReportFormatsResponse.ReportFormat); i++ {
215
-		message = message + fmt.Sprintf("| %s ", printValueStr(res.GetReportFormatsResponse.ReportFormat[i].Id, 40))
210
+		message = message + fmt.Sprintf("| %s ", printValueStr(res.GetReportFormatsResponse.ReportFormat[i].ID, 40))
216 211
 		message = message + fmt.Sprintf("| %s \n", printValueStr(res.GetReportFormatsResponse.ReportFormat[i].Name, 20))
217 212
 	}
218 213
 
219 214
 	message = message + fmt.Sprintf("```\n")
220 215
 
221
-	return &gomatrix.HTMLMessage{message, "m.text", "org.matrix.custom.html", markdownRender(message)}, nil
216
+	return &gomatrix.HTMLMessage{Body: message, MsgType: "m.text", Format: "org.matrix.custom.html", FormattedBody: markdownRender(message)}, nil
222 217
 }
223 218
 
224 219
 // get the current status of a report
225 220
 func (s *Service) cmdGetReport(roomID, userID string, args []string) (interface{}, error) {
226 221
 	if len(args) < 1 {
227
-		return &gomatrix.TextMessage{"m.notice", fmt.Sprintf(`Missing parameters. Have a look with !pentest help`)}, nil
222
+		return &gomatrix.TextMessage{MsgType: "MsgType: m.notice", Body: fmt.Sprintf(`Missing parameters. Have a look with !pentest help`)}, nil
228 223
 	}
229 224
 
230 225
 	var reportID = args[0]
231 226
 
232 227
 	// Authentication against openVAS
233 228
 	if s.omgAuthentication(userID) != "200" {
234
-		return &gomatrix.TextMessage{"m.notice", "OpenVAS think u are not trustfull enough :-)"}, nil
229
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: "OpenVAS think u are not trustfull enough :-)"}, nil
235 230
 	}
236 231
 
237 232
 	res, status := s.getReport(reportID)
238 233
 	if status != "200" {
239
-		return &gomatrix.TextMessage{"m.notice", "Could not find the report"}, nil
234
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: "Could not find the report"}, nil
240 235
 	}
241 236
 
242 237
 	var message string
@@ -244,40 +239,40 @@ func (s *Service) cmdGetReport(roomID, userID string, args []string) (interface{
244 239
 	message = message + fmt.Sprintf("REPORT STATUS: %s \n", printValueStr(res, 40))
245 240
 	message = message + fmt.Sprintf("```\n")
246 241
 
247
-	return &gomatrix.HTMLMessage{message, "m.text", "org.matrix.custom.html", markdownRender(message)}, nil
242
+	return &gomatrix.HTMLMessage{Body: message, MsgType: "m.text", Format: "org.matrix.custom.html", FormattedBody: markdownRender(message)}, nil
248 243
 }
249 244
 
250 245
 func (s *Service) cmdDownloadReport(roomID, userID string, cli *gomatrix.Client, args []string) (interface{}, error) {
251 246
 	if len(args) < 2 {
252
-		return &gomatrix.TextMessage{"m.notice", fmt.Sprintf(`Missing parameters. Have a look with !pentest help`)}, nil
247
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: fmt.Sprintf(`Missing parameters. Have a look with !pentest help`)}, nil
253 248
 	}
254 249
 
255
-	var reportId = args[0]
256
-	var formatId = args[1]
250
+	var reportID = args[0]
251
+	var formatID = args[1]
257 252
 
258 253
 	// Authentication against openVAS
259 254
 	if s.omgAuthentication(userID) != "200" {
260
-		return &gomatrix.TextMessage{"m.notice", "OpenVAS think u are not trustfull enough :-)"}, nil
255
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: "OpenVAS think u are not trustfull enough :-)"}, nil
261 256
 	}
262 257
 
263
-	data, contentType, extension, status := s.getReportInFormat(reportId, formatId)
258
+	data, contentType, extension, status := s.getReportInFormat(reportID, formatID)
264 259
 	if status != "200" {
265
-		return &gomatrix.TextMessage{"m.notice", "Could not find the report"}, nil
260
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: "Could not find the report"}, nil
266 261
 	}
267 262
 
268 263
 	dataDecode, err := base64.StdEncoding.DecodeString(data)
269 264
 	if err != nil {
270
-		return &gomatrix.TextMessage{"m.notice", fmt.Sprintf("Could not decode data: %s", err)}, nil
265
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: fmt.Sprintf("Could not decode data: %s", err)}, nil
271 266
 	}
272 267
 
273 268
 	rmu, err := cli.UploadToContentRepo(bytes.NewReader(dataDecode), contentType, int64(len(dataDecode)))
274 269
 	if err != nil {
275
-		return &gomatrix.TextMessage{"m.notice", fmt.Sprintf("Could not upload the report: %s", err)}, nil
270
+		return &gomatrix.TextMessage{MsgType: "m.notice", Body: fmt.Sprintf("Could not upload the report: %s", err)}, nil
276 271
 	}
277 272
 	log.Info(rmu.ContentURI)
278 273
 
279 274
 	return &gomatrix.FileMessage{
280
-		Body:    fmt.Sprintf("%s.%s", reportId, extension),
275
+		Body:    fmt.Sprintf("%s.%s", reportID, extension),
281 276
 		MsgType: "m.file",
282 277
 		URL:     rmu.ContentURI,
283 278
 		Info: gomatrix.FileInfo{

+ 170
- 145
services/pentest/pentest_struct.go View File

@@ -2,121 +2,132 @@ package pentest
2 2
 
3 3
 import "encoding/xml"
4 4
 
5
+// AuthenticateResponse is a structure of the response
5 6
 type AuthenticateResponse struct {
6 7
 	XMLName    xml.Name `xml:"authenticate_response"`
7 8
 	Status     string   `xml:"status,attr"`
8 9
 	StatusText string   `xml:"status_text,attr"`
9 10
 	Role       string   `xml:"role"`
10
-	Timezone   string   `xml:"timezone`
11
-	Severity   string   `xml:"severity`
11
+	Timezone   string   `xml:"timezone"`
12
+	Severity   string   `xml:"severity"`
12 13
 }
13 14
 
14 15
 // ###################################################
15 16
 
17
+// CreateTargetResponse is a structure of the response
16 18
 type CreateTargetResponse struct {
17 19
 	Authenticate AuthenticateResponse `xml:"authenticate_response"`
18 20
 	CreateTarget struct {
19 21
 		XMLName    xml.Name `xml:"create_target_response"`
20 22
 		Status     string   `xml:"status,attr"`
21 23
 		StatusText string   `xml:"status_text,attr"`
22
-		Id         string   `xml:"id,attr"`
24
+		ID         string   `xml:"id,attr"`
23 25
 	}
24 26
 }
25 27
 
26 28
 // ###################################################
27 29
 
30
+// GetConfigsResponse is a structure of the response
28 31
 type GetConfigsResponse struct {
29
-	Authenticate         AuthenticateResponse `xml:"authenticate_response"`
30
-	Get_configs_response struct {
31
-		XMLName     xml.Name `xml:"get_configs_response"`
32
-		Status      string   `xml:"status,attr"`
33
-		Status_text string   `xml:"status_text,attr"`
34
-		Config      []Config `xml:"config"`
35
-		Filters     Filters  `xml:"filters"`
36
-		Configs     Configs  `xml:"configs"`
37
-		Field       string   `xml:"sort>field"`
32
+	Authenticate       AuthenticateResponse `xml:"authenticate_response"`
33
+	GetConfigsResponse struct {
34
+		XMLName    xml.Name `xml:"get_configs_response"`
35
+		Status     string   `xml:"status,attr"`
36
+		StatusText string   `xml:"status_text,attr"`
37
+		Config     []Config `xml:"config"`
38
+		Filters    Filters  `xml:"filters"`
39
+		Configs    Configs  `xml:"configs"`
40
+		Field      string   `xml:"sort>field"`
38 41
 	}
39 42
 }
40 43
 
44
+// Filters is a structure
41 45
 type Filters struct {
42 46
 	XMLName  xml.Name `xml:"filters"`
43
-	Id       string   `xml:"id,attr"`
47
+	ID       string   `xml:"id,attr"`
44 48
 	Term     string   `xml:"term"`
45 49
 	Value    []string `xml:"keywords>keyword>value"`
46 50
 	Column   []string `xml:"keywords>keyword>column"`
47 51
 	Relation []string `xml:"keywords>keyword>relation"`
48 52
 }
53
+
54
+// Configs is a structure
49 55
 type Configs struct {
50 56
 	Max   string `xml:"max,attr"`
51 57
 	Start string `xml:"start,attr"`
52 58
 }
53 59
 
60
+// Config is a structure
54 61
 type Config struct {
55
-	XMLName                        xml.Name `xml:"config"`
56
-	Id                             string   `xml:"id,attr"`
57
-	Config_count                   string   `xml:"config_count"`
58
-	Family_count                   []string `xml:"family_count"`
59
-	Type                           []string `xml:"type"`
60
-	Nvt_count                      []string `xml:"nvt_count"`
61
-	Count                          []string `xml:"user_tags>count"`
62
-	Permissions                    []string `xml:"permissions"`
63
-	Comment                        []string `xml:"comment"`
64
-	Writable                       []string `xml:"writable"`
65
-	In_use                         []string `xml:"in_use"`
66
-	Creation_time                  []string `xml:"creation_time"`
67
-	Modification_time              []string `xml:"modification_time"`
68
-	Name                           []string `xml:"owner>name"`
69
-	NameConfigGet_configs_response []string `xml:"name"`
62
+	XMLName                      xml.Name `xml:"config"`
63
+	ID                           string   `xml:"id,attr"`
64
+	ConfigCount                  string   `xml:"config_count"`
65
+	FamilyCount                  []string `xml:"family_count"`
66
+	Type                         []string `xml:"type"`
67
+	NvtCount                     []string `xml:"nvt_count"`
68
+	Count                        []string `xml:"user_tags>count"`
69
+	Permissions                  []string `xml:"permissions"`
70
+	Comment                      []string `xml:"comment"`
71
+	Writable                     []string `xml:"writable"`
72
+	InUse                        []string `xml:"in_use"`
73
+	CreationTime                 []string `xml:"creation_time"`
74
+	ModificationTime             []string `xml:"modification_time"`
75
+	Name                         []string `xml:"owner>name"`
76
+	NameConfigGetConfigsResponse []string `xml:"name"`
70 77
 }
71 78
 
72 79
 // ###################################################
73 80
 
81
+// CreateTaskResponse is a structure of the response
74 82
 type CreateTaskResponse struct {
75 83
 	Authenticate AuthenticateResponse `xml:"authenticate_response"`
76 84
 	CreateTask   struct {
77 85
 		XMLName    xml.Name `xml:"create_task_response"`
78 86
 		Status     string   `xml:"status,attr"`
79 87
 		StatusText string   `xml:"status_text,attr"`
80
-		Id         string   `xml:"id,attr"`
88
+		ID         string   `xml:"id,attr"`
81 89
 	}
82 90
 }
83 91
 
84 92
 // ###################################################
85 93
 
94
+// StartTaskResponse is a structure of the response
86 95
 type StartTaskResponse struct {
87 96
 	Authenticate AuthenticateResponse `xml:"authenticate_response"`
88 97
 	StartTask    struct {
89 98
 		XMLName    xml.Name `xml:"start_task_response"`
90 99
 		Status     string   `xml:"status,attr"`
91 100
 		StatusText string   `xml:"status_text,attr"`
92
-		ReportId   string   `xml:"report_id"`
101
+		ReportID   string   `xml:"report_id"`
93 102
 	}
94 103
 }
95 104
 
96 105
 // ###################################################
97 106
 
107
+// GetReportsResponse is a structure of the response
98 108
 type GetReportsResponse struct {
99 109
 	Authenticate       AuthenticateResponse `xml:"authenticate_response"`
100 110
 	GetReportsResponse struct {
101
-		XMLName      xml.Name `xml:"get_reports_response"`
102
-		Status       string   `xml:"status,attr"`
103
-		Status_text  string   `xml:"status_text,attr"`
104
-		Report_count string   `xml:"report_count"`
105
-		Filters      Filters  `xml:"filters"`
106
-		Reports      Reports  `xml:"reports"`
107
-		Report       Report   `xml:"report"`
111
+		XMLName     xml.Name `xml:"get_reports_response"`
112
+		Status      string   `xml:"status,attr"`
113
+		StatusText  string   `xml:"status_text,attr"`
114
+		ReportCount string   `xml:"report_count"`
115
+		Filters     Filters  `xml:"filters"`
116
+		Reports     Reports  `xml:"reports"`
117
+		Report      Report   `xml:"report"`
108 118
 	}
109 119
 	FieldSort string `xml:"sort>field"`
110 120
 }
111 121
 
122
+// Report is a structure
112 123
 type Report struct {
113 124
 	XMLName          xml.Name     `xml:"report"`
114
-	Format_id        string       `xml:"format_id,attr"`
115
-	Content_type     string       `xml:"content_type,attr"`
125
+	FormatID         string       `xml:"format_id,attr"`
126
+	ContentType      string       `xml:"content_type,attr"`
116 127
 	Type             string       `xml:"type,attr"`
117 128
 	Extension        string       `xml:"extension,attr"`
118
-	Id               string       `xml:"id,attr"`
119
-	In_use           string       `xml:"in_use"`
129
+	ID               string       `xml:"id,attr"`
130
+	InUse            string       `xml:"in_use"`
120 131
 	Writable         string       `xml:"writable"`
121 132
 	Comment          string       `xml:"comment"`
122 133
 	Name             string       `xml:"name"`
@@ -126,56 +137,57 @@ type Report struct {
126 137
 	Report           ReportReport `xml:"report"`
127 138
 	Task             struct {
128 139
 		XMLName xml.Name `xml:"task"`
129
-		Id      string   `xml:"id,attr"`
140
+		ID      string   `xml:"id,attr"`
130 141
 		Name    string   `xml:"name"`
131 142
 	}
132 143
 }
133 144
 
145
+// ReportReport is a structure
134 146
 type ReportReport struct {
135
-	XMLName                                        xml.Name `xml:"report"`
136
-	Id                                             string   `xml:"id,attr"`
137
-	PageInfoResult_countHostReportReport           string   `xml:"host>result_count>info>page"`
138
-	Scan_start                                     string   `xml:"scan_start"`
139
-	Filtered                                       string   `xml:"severity>filtered"`
140
-	PageHoleResult_countHostReportReport           string   `xml:"host>result_count>hole>page"`
141
-	NameDetailHostReportReport                     []string `xml:"host>detail>name"`
142
-	CountVulnsReportReport                         string   `xml:"vulns>count"`
143
-	HostHost_endReportReport                       string   `xml:"host_end>host"`
144
-	Field                                          string   `xml:"sort>field"`
145
-	Timezone                                       string   `xml:"timezone"`
146
-	PageFalse_positiveResult_countHostReportReport string   `xml:"host>result_count>false_positive>page"`
147
-	Timezone_abbrev                                string   `xml:"timezone_abbrev"`
148
-	Value                                          []string `xml:"host>detail>value"`
149
-	End                                            string   `xml:"host>end"`
150
-	CountSsl_certsReportReport                     string   `xml:"ssl_certs>count"`
151
-	Full                                           string   `xml:"severity>full"`
152
-	CountErrorsReportReport                        string   `xml:"errors>count"`
153
-	PageWarningResult_countHostReportReport        string   `xml:"host>result_count>warning>page"`
154
-	Type                                           []string `xml:"host>detail>source>type"`
155
-	Ip                                             string   `xml:"host>ip"`
156
-	Scan_run_status                                string   `xml:"scan_run_status"`
157
-	Result_count                                   string   `xml:"result_count"`
158
-	NameSourceDetailHostReportReport               []string `xml:"host>detail>source>name"`
159
-	CountAppsReportReport                          string   `xml:"apps>count"`
160
-	Report_format                                  string   `xml:"report_format"`
161
-	Version                                        string   `xml:"omp>version"`
162
-	CountClosed_cvesReportReport                   string   `xml:"closed_cves>count"`
163
-	Extra                                          []string `xml:"host>detail>extra"`
164
-	Scan_end                                       string   `xml:"scan_end"`
165
-	CountHostsReportReport                         string   `xml:"hosts>count"`
166
-	Start                                          string   `xml:"host>start"`
167
-	PageLogResult_countHostReportReport            string   `xml:"host>result_count>log>page"`
168
-	Timestamp                                      string   `xml:"timestamp"`
169
-	Page                                           string   `xml:"host>port_count>page"`
170
-	Description                                    []string `xml:"host>detail>source>description"`
171
-	Asset                                          Asset    `xml:"host>asset"`
172
-	Count                                          string   `xml:"user_tags>count"`
173
-	PageResult_countHostReportReport               string   `xml:"host>result_count>page"`
174
-	CountOsReportReport                            string   `xml:"os>count"`
175
-	Results                                        Results  `xml:"results"`
176
-	SeverityClass                                  struct {
147
+	XMLName                                      xml.Name `xml:"report"`
148
+	ID                                           string   `xml:"id,attr"`
149
+	PageInfoResultCountHostReportReport          string   `xml:"host>result_count>info>page"`
150
+	ScanStart                                    string   `xml:"scan_start"`
151
+	Filtered                                     string   `xml:"severity>filtered"`
152
+	PageHoleResultCountHostReportReport          string   `xml:"host>result_count>hole>page"`
153
+	NameDetailHostReportReport                   []string `xml:"host>detail>name"`
154
+	CountVulnsReportReport                       string   `xml:"vulns>count"`
155
+	HostHostEndReportReport                      string   `xml:"host_end>host"`
156
+	Field                                        string   `xml:"sort>field"`
157
+	Timezone                                     string   `xml:"timezone"`
158
+	PageFalsePositiveResultCountHostReportReport string   `xml:"host>result_count>false_positive>page"`
159
+	TimezoneAbbrev                               string   `xml:"timezone_abbrev"`
160
+	Value                                        []string `xml:"host>detail>value"`
161
+	End                                          string   `xml:"host>end"`
162
+	CountSslCertsReportReport                    string   `xml:"ssl_certs>count"`
163
+	Full                                         string   `xml:"severity>full"`
164
+	CountErrorsReportReport                      string   `xml:"errors>count"`
165
+	PageWarningResultCountHostReportReport       string   `xml:"host>result_count>warning>page"`
166
+	Type                                         []string `xml:"host>detail>source>type"`
167
+	IP                                           string   `xml:"host>ip"`
168
+	ScanRunStatus                                string   `xml:"scan_run_status"`
169
+	ResultCount                                  string   `xml:"result_count"`
170
+	NameSourceDetailHostReportReport             []string `xml:"host>detail>source>name"`
171
+	CountAppsReportReport                        string   `xml:"apps>count"`
172
+	ReportFormat                                 string   `xml:"report_format"`
173
+	Version                                      string   `xml:"omp>version"`
174
+	CountClosedCvesReportReport                  string   `xml:"closed_cves>count"`
175
+	Extra                                        []string `xml:"host>detail>extra"`
176
+	ScanEnd                                      string   `xml:"scan_end"`
177
+	CountHostsReportReport                       string   `xml:"hosts>count"`
178
+	Start                                        string   `xml:"host>start"`
179
+	PageLogResultCountHostReportReport           string   `xml:"host>result_count>log>page"`
180
+	Timestamp                                    string   `xml:"timestamp"`
181
+	Page                                         string   `xml:"host>port_count>page"`
182
+	Description                                  []string `xml:"host>detail>source>description"`
183
+	Asset                                        Asset    `xml:"host>asset"`
184
+	Count                                        string   `xml:"user_tags>count"`
185
+	PageResultCountHostReportReport              string   `xml:"host>result_count>page"`
186
+	CountOsReportReport                          string   `xml:"os>count"`
187
+	Results                                      Results  `xml:"results"`
188
+	SeverityClass                                struct {
177 189
 		XMLName  xml.Name `xml:"severity_class"`
178
-		Id       string   `xml:"id,attr"`
190
+		ID       string   `xml:"id,attr"`
179 191
 		FullName string   `xml:"full_name"`
180 192
 		Name     string   `xml:"name"`
181 193
 		Range    []struct {
@@ -222,7 +234,7 @@ type ReportReport struct {
222 234
 			}
223 235
 			Slave struct {
224 236
 				XMLName xml.Name `xml:"slave"`
225
-				Id      string   `xml:"id,attr"`
237
+				ID      string   `xml:"id,attr"`
226 238
 				Name    string   `xml:"name"`
227 239
 				Port    string   `xml:"port"`
228 240
 				Host    string   `xml:"host"`
@@ -231,41 +243,42 @@ type ReportReport struct {
231 243
 	}
232 244
 }
233 245
 
246
+// Results is a structure
234 247
 type Results struct {
235 248
 	XMLName xml.Name `xml:"results"`
236 249
 	Start   string   `xml:"start,attr"`
237 250
 	Max     string   `xml:"max,attr"`
238 251
 	Result  struct {
239
-		XMLName                                 xml.Name `xml:"result"`
240
-		Comment                                 string   `xml:"comment"`
241
-		CreationTime                            string   `xml:"creation_time"`
242
-		Name                                    string   `xml:"name"`
243
-		Port                                    string   `xml:"port"`
244
-		Description                             string   `xml:"description"`
245
-		ModificationTime                        string   `xml:"modification_time"`
246
-		Secerity                                string   `xml:"severity"`
247
-		CountUser_tagsResultResultsReportReport string   `xml:"user_tags>count"`
248
-		NameOwnerResultResultsReportReport      string   `xml:"owner>name"`
249
-		Scan_nvt_version                        string   `xml:"scan_nvt_version"`
250
-		ThreatResultResultsReportReport         string   `xml:"threat"`
251
-		HostResultResultsReportReport           string   `xml:"host"`
252
-		Qod                                     []struct {
252
+		XMLName                                xml.Name `xml:"result"`
253
+		Comment                                string   `xml:"comment"`
254
+		CreationTime                           string   `xml:"creation_time"`
255
+		Name                                   string   `xml:"name"`
256
+		Port                                   string   `xml:"port"`
257
+		Description                            string   `xml:"description"`
258
+		ModificationTime                       string   `xml:"modification_time"`
259
+		Secerity                               string   `xml:"severity"`
260
+		CountUserTagsResultResultsReportReport string   `xml:"user_tags>count"`
261
+		NameOwnerResultResultsReportReport     string   `xml:"owner>name"`
262
+		ScanNvtVersion                         string   `xml:"scan_nvt_version"`
263
+		ThreatResultResultsReportReport        string   `xml:"threat"`
264
+		HostResultResultsReportReport          string   `xml:"host"`
265
+		Qod                                    []struct {
253 266
 			XMLName xml.Name `xml:"qod"`
254 267
 			Value   string   `xml:"value"`
255 268
 			Type    string   `xml:"type"`
256 269
 		}
257 270
 		Nvt []struct {
258
-			XMLName   xml.Name `xml:"nvt"`
259
-			Oid       string   `xml:"oid,attr"`
260
-			Cve       string   `xml:"cve"`
261
-			Tags      string   `xml:"tags"`
262
-			Name      string   `xml:"name"`
263
-			Cvss_base string   `xml:"cvss_base"`
264
-			Family    string   `xml:"family"`
265
-			Bid       string   `xml:"bid"`
266
-			Type      string   `xml:"type"`
267
-			Cert      string   `xml:"cert"`
268
-			Xref      string   `xml:"xref"`
271
+			XMLName  xml.Name `xml:"nvt"`
272
+			Oid      string   `xml:"oid,attr"`
273
+			Cve      string   `xml:"cve"`
274
+			Tags     string   `xml:"tags"`
275
+			Name     string   `xml:"name"`
276
+			CvssBase string   `xml:"cvss_base"`
277
+			Family   string   `xml:"family"`
278
+			Bid      string   `xml:"bid"`
279
+			Type     string   `xml:"type"`
280
+			Cert     string   `xml:"cert"`
281
+			Xref     string   `xml:"xref"`
269 282
 		}
270 283
 	}
271 284
 	Task struct {
@@ -281,55 +294,66 @@ type Results struct {
281 294
 	}
282 295
 }
283 296
 
297
+// Result is a structure
284 298
 type Result struct {
285
-	Id string `xml:"id,attr"`
299
+	ID string `xml:"id,attr"`
286 300
 }
287
-type Report_formatReport struct {
288
-	Id string `xml:"id,attr"`
301
+
302
+// ReportFormatReport is a structure
303
+type ReportFormatReport struct {
304
+	ID string `xml:"id,attr"`
289 305
 }
306
+
307
+// Reports is a structure
290 308
 type Reports struct {
291 309
 	Start string `xml:"start,attr"`
292 310
 	Max   string `xml:"max,attr"`
293 311
 }
312
+
313
+// Asset is a structure
294 314
 type Asset struct {
295
-	Asset_id string `xml:"asset_id,attr"`
315
+	AssetID string `xml:"asset_id,attr"`
296 316
 }
297 317
 
318
+// TaskReport is a structure
298 319
 type TaskReport struct {
299
-	Id string `xml:"id,attr"`
320
+	ID string `xml:"id,attr"`
300 321
 }
301 322
 
323
+// Target is a structure
302 324
 type Target struct {
303
-	Id string `xml:"id,attr"`
325
+	ID string `xml:"id,attr"`
304 326
 }
305 327
 
306 328
 // ######################################
307 329
 
330
+// GetReportsResponseInFormat is a structure
308 331
 type GetReportsResponseInFormat struct {
309 332
 	Authenticate       AuthenticateResponse `xml:"authenticate_response"`
310 333
 	GetReportsResponse struct {
311
-		XMLName     xml.Name `xml:"get_reports_response"`
312
-		Status      string   `xml:"status,attr"`
313
-		Status_text string   `xml:"status_text,attr"`
314
-		Report      struct {
315
-			XMLName      xml.Name `xml:"report"`
316
-			Id           string   `xml:"id,attr"`
317
-			Format_id    string   `xml:"format_id,attr"`
318
-			Content_type string   `xml:"content_type,attr"`
319
-			Extension    string   `xml:"extension,attr"`
320
-			Data         string   `xml:",chardata"`
334
+		XMLName    xml.Name `xml:"get_reports_response"`
335
+		Status     string   `xml:"status,attr"`
336
+		StatusText string   `xml:"status_text,attr"`
337
+		Report     struct {
338
+			XMLName     xml.Name `xml:"report"`
339
+			ID          string   `xml:"id,attr"`
340
+			FormatID    string   `xml:"format_id,attr"`
341
+			ContentType string   `xml:"content_type,attr"`
342
+			Extension   string   `xml:"extension,attr"`
343
+			Data        string   `xml:",chardata"`
321 344
 		}
322 345
 	}
323 346
 }
324 347
 
325 348
 // ######################################
326 349
 
350
+// GetReportFormatsResponse is a structure
327 351
 type GetReportFormatsResponse struct {
328 352
 	Authenticate             AuthenticateResponse `xml:"authenticate_response"`
329 353
 	GetReportFormatsResponse struct {
330 354
 		XMLName       xml.Name `xml:"get_report_formats_response"`
331 355
 		Status        string   `xml:"status,attr"`
332
-		Status_text   string   `xml:"status_text,attr"`
356
+		StatusText    string   `xml:"status_text,attr"`
333 357
 		SortField     string   `xml:"sort>field"`
334 358
 		SortOrder     string   `xml:"sort>order"`
335 359
 		ReportFormats struct {
@@ -348,24 +372,25 @@ type GetReportFormatsResponse struct {
348 372
 	}
349 373
 }
350 374
 
375
+// ReportFormat is a structure
351 376
 type ReportFormat struct {
352
-	XMLName           xml.Name `xml:"report_format"`
353
-	Id                string   `xml:"id,attr"`
354
-	OnwerName         string   `xml:"owner>name"`
355
-	Name              string   `xml:"name"`
356
-	Comment           string   `xml:"comment"`
357
-	Creation_time     string   `xml:"creation_time"`
358
-	Modification_time string   `xml:"modification_time"`
359
-	Writable          string   `xml:"writable"`
360
-	In_use            string   `xml:"in_use"`
361
-	NamePermission    string   `xml:"permissions>permission>name"`
362
-	UserTagsCount     string   `xml:"user_tags>count"`
363
-	Extension         string   `xml:"extension"`
364
-	Content_type      string   `xml:"content_type"`
365
-	Summary           string   `xml:"summary"`
366
-	Description       string   `xml:"description"`
367
-	Predefined        string   `xml:"predefined"`
368
-	Trust             struct {
377
+	XMLName          xml.Name `xml:"report_format"`
378
+	ID               string   `xml:"id,attr"`
379
+	OnwerName        string   `xml:"owner>name"`
380
+	Name             string   `xml:"name"`
381
+	Comment          string   `xml:"comment"`
382
+	CreationTime     string   `xml:"creation_time"`
383
+	ModificationTime string   `xml:"modification_time"`
384
+	Writable         string   `xml:"writable"`
385
+	InUse            string   `xml:"in_use"`
386
+	NamePermission   string   `xml:"permissions>permission>name"`
387
+	UserTagsCount    string   `xml:"user_tags>count"`
388
+	Extension        string   `xml:"extension"`
389
+	ContentType      string   `xml:"content_type"`
390
+	Summary          string   `xml:"summary"`
391
+	Description      string   `xml:"description"`
392
+	Predefined       string   `xml:"predefined"`
393
+	Trust            struct {
369 394
 		XMLName xml.Name `xml:"trust"`
370 395
 		Text    string   `xml:",chardata"`
371 396
 		Time    string   `xml:"time"`

Loading…
Cancel
Save