Skip to content

Commit 33cab3e

Browse files
committed
vdjagilev#60: Change certain fields to integers
1 parent e13792d commit 33cab3e

File tree

9 files changed

+118
-118
lines changed

9 files changed

+118
-118
lines changed

formatter/formatter_csv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (f *CSVFormatter) convert(td *TemplateData) (data [][]string) {
3232
data,
3333
[]string{
3434
"",
35-
port.PortID,
35+
fmt.Sprint(port.PortID),
3636
port.Protocol,
3737
port.State.State,
3838
port.Service.Name,

formatter/formatter_csv_test.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ func TestCSVFormatter_convert(t *testing.T) {
3838
NMAPRun: NMAPRun{
3939
Host: []Host{
4040
{
41-
StartTime: "",
42-
EndTime: "",
41+
StartTime: 0,
42+
EndTime: 0,
4343
Ports: Ports{},
4444
HostAddress: HostAddress{},
4545
HostNames: HostNames{},
@@ -101,8 +101,8 @@ func TestCSVFormatter_convert(t *testing.T) {
101101
NMAPRun: NMAPRun{
102102
Host: []Host{
103103
{
104-
StartTime: "",
105-
EndTime: "",
104+
StartTime: 0,
105+
EndTime: 0,
106106
Ports: Ports{},
107107
HostAddress: HostAddress{
108108
Address: "127.0.0.1",
@@ -139,13 +139,13 @@ func TestCSVFormatter_convert(t *testing.T) {
139139
NMAPRun: NMAPRun{
140140
Host: []Host{
141141
{
142-
StartTime: "",
143-
EndTime: "",
142+
StartTime: 0,
143+
EndTime: 0,
144144
Ports: Ports{
145145
Port: []Port{
146146
{
147147
Protocol: "tcp",
148-
PortID: "80",
148+
PortID: 80,
149149
State: PortState{
150150
State: "open",
151151
Reason: "syn-ack",
@@ -195,13 +195,13 @@ func TestCSVFormatter_convert(t *testing.T) {
195195
NMAPRun: NMAPRun{
196196
Host: []Host{
197197
{
198-
StartTime: "",
199-
EndTime: "",
198+
StartTime: 0,
199+
EndTime: 0,
200200
Ports: Ports{
201201
Port: []Port{
202202
{
203203
Protocol: "tcp",
204-
PortID: "80",
204+
PortID: 80,
205205
State: PortState{
206206
State: "open",
207207
Reason: "syn-ack",
@@ -215,7 +215,7 @@ func TestCSVFormatter_convert(t *testing.T) {
215215
},
216216
{
217217
Protocol: "tcp",
218-
PortID: "443",
218+
PortID: 443,
219219
State: PortState{
220220
State: "open",
221221
Reason: "syn-ack",
@@ -266,13 +266,13 @@ func TestCSVFormatter_convert(t *testing.T) {
266266
NMAPRun: NMAPRun{
267267
Host: []Host{
268268
{
269-
StartTime: "",
270-
EndTime: "",
269+
StartTime: 0,
270+
EndTime: 0,
271271
Ports: Ports{
272272
Port: []Port{
273273
{
274274
Protocol: "tcp",
275-
PortID: "80",
275+
PortID: 80,
276276
State: PortState{
277277
State: "open",
278278
Reason: "syn-ack",
@@ -286,7 +286,7 @@ func TestCSVFormatter_convert(t *testing.T) {
286286
},
287287
{
288288
Protocol: "tcp",
289-
PortID: "443",
289+
PortID: 443,
290290
State: PortState{
291291
State: "open",
292292
Reason: "syn-ack",
@@ -316,8 +316,8 @@ func TestCSVFormatter_convert(t *testing.T) {
316316
TCPTSSequence: TCPTSSequence{},
317317
},
318318
{
319-
StartTime: "",
320-
EndTime: "",
319+
StartTime: 0,
320+
EndTime: 0,
321321
Ports: Ports{},
322322
HostAddress: HostAddress{
323323
Address: "192.168.1.1",
@@ -356,13 +356,13 @@ func TestCSVFormatter_convert(t *testing.T) {
356356
NMAPRun: NMAPRun{
357357
Host: []Host{
358358
{
359-
StartTime: "",
360-
EndTime: "",
359+
StartTime: 0,
360+
EndTime: 0,
361361
Ports: Ports{
362362
Port: []Port{
363363
{
364364
Protocol: "tcp",
365-
PortID: "80",
365+
PortID: 80,
366366
State: PortState{
367367
State: "open",
368368
Reason: "syn-ack",
@@ -376,7 +376,7 @@ func TestCSVFormatter_convert(t *testing.T) {
376376
},
377377
{
378378
Protocol: "tcp",
379-
PortID: "443",
379+
PortID: 443,
380380
State: PortState{
381381
State: "open",
382382
Reason: "syn-ack",
@@ -406,8 +406,8 @@ func TestCSVFormatter_convert(t *testing.T) {
406406
TCPTSSequence: TCPTSSequence{},
407407
},
408408
{
409-
StartTime: "",
410-
EndTime: "",
409+
StartTime: 0,
410+
EndTime: 0,
411411
Ports: Ports{},
412412
HostAddress: HostAddress{
413413
Address: "192.168.1.1",
@@ -447,13 +447,13 @@ func TestCSVFormatter_convert(t *testing.T) {
447447
NMAPRun: NMAPRun{
448448
Host: []Host{
449449
{
450-
StartTime: "",
451-
EndTime: "",
450+
StartTime: 0,
451+
EndTime: 0,
452452
Ports: Ports{
453453
Port: []Port{
454454
{
455455
Protocol: "tcp",
456-
PortID: "80",
456+
PortID: 80,
457457
State: PortState{
458458
State: "open",
459459
Reason: "syn-ack",
@@ -467,7 +467,7 @@ func TestCSVFormatter_convert(t *testing.T) {
467467
},
468468
{
469469
Protocol: "tcp",
470-
PortID: "443",
470+
PortID: 443,
471471
State: PortState{
472472
State: "open",
473473
Reason: "syn-ack",
@@ -497,13 +497,13 @@ func TestCSVFormatter_convert(t *testing.T) {
497497
TCPTSSequence: TCPTSSequence{},
498498
},
499499
{
500-
StartTime: "",
501-
EndTime: "",
500+
StartTime: 0,
501+
EndTime: 0,
502502
Ports: Ports{
503503
Port: []Port{
504504
{
505505
Protocol: "tcp",
506-
PortID: "22",
506+
PortID: 22,
507507
State: PortState{
508508
State: "open",
509509
Reason: "syn-ack",

formatter/formatter_html_test.go

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ func TestHTMLFormatter_Format(t *testing.T) {
9090
NMAPRun: NMAPRun{
9191
Host: []Host{
9292
{
93-
StartTime: "",
94-
EndTime: "",
93+
StartTime: 0,
94+
EndTime: 0,
9595
Ports: Ports{},
9696
HostAddress: HostAddress{
9797
Address: "192.168.1.1",
@@ -109,8 +109,8 @@ func TestHTMLFormatter_Format(t *testing.T) {
109109
TCPTSSequence: TCPTSSequence{},
110110
},
111111
{
112-
StartTime: "",
113-
EndTime: "",
112+
StartTime: 0,
113+
EndTime: 0,
114114
Ports: Ports{},
115115
HostAddress: HostAddress{
116116
Address: "192.168.1.2",
@@ -152,8 +152,8 @@ func TestHTMLFormatter_Format(t *testing.T) {
152152
NMAPRun: NMAPRun{
153153
Host: []Host{
154154
{
155-
StartTime: "",
156-
EndTime: "",
155+
StartTime: 0,
156+
EndTime: 0,
157157
Ports: Ports{},
158158
HostAddress: HostAddress{
159159
Address: "192.168.1.1",
@@ -171,8 +171,8 @@ func TestHTMLFormatter_Format(t *testing.T) {
171171
TCPTSSequence: TCPTSSequence{},
172172
},
173173
{
174-
StartTime: "",
175-
EndTime: "",
174+
StartTime: 0,
175+
EndTime: 0,
176176
Ports: Ports{},
177177
HostAddress: HostAddress{
178178
Address: "192.168.1.2",
@@ -214,8 +214,8 @@ func TestHTMLFormatter_Format(t *testing.T) {
214214
NMAPRun: NMAPRun{
215215
Host: []Host{
216216
{
217-
StartTime: "",
218-
EndTime: "",
217+
StartTime: 0,
218+
EndTime: 0,
219219
Ports: Ports{},
220220
HostAddress: HostAddress{
221221
Address: "192.168.1.1",
@@ -233,8 +233,8 @@ func TestHTMLFormatter_Format(t *testing.T) {
233233
TCPTSSequence: TCPTSSequence{},
234234
},
235235
{
236-
StartTime: "",
237-
EndTime: "",
236+
StartTime: 0,
237+
EndTime: 0,
238238
Ports: Ports{},
239239
HostAddress: HostAddress{
240240
Address: "192.168.1.2",
@@ -276,13 +276,13 @@ func TestHTMLFormatter_Format(t *testing.T) {
276276
NMAPRun: NMAPRun{
277277
Host: []Host{
278278
{
279-
StartTime: "",
280-
EndTime: "",
279+
StartTime: 0,
280+
EndTime: 0,
281281
Ports: Ports{
282282
Port: []Port{
283283
{
284284
Protocol: "tcp",
285-
PortID: "80",
285+
PortID: 80,
286286
State: PortState{
287287
State: "open",
288288
},
@@ -291,7 +291,7 @@ func TestHTMLFormatter_Format(t *testing.T) {
291291
},
292292
{
293293
Protocol: "tcp",
294-
PortID: "443",
294+
PortID: 443,
295295
State: PortState{
296296
State: "up",
297297
},
@@ -316,13 +316,13 @@ func TestHTMLFormatter_Format(t *testing.T) {
316316
TCPTSSequence: TCPTSSequence{},
317317
},
318318
{
319-
StartTime: "",
320-
EndTime: "",
319+
StartTime: 0,
320+
EndTime: 0,
321321
Ports: Ports{
322322
Port: []Port{
323323
{
324324
Protocol: "tcp",
325-
PortID: "8080",
325+
PortID: 8080,
326326
State: PortState{
327327
State: "open",
328328
},
@@ -368,8 +368,8 @@ func TestHTMLFormatter_Format(t *testing.T) {
368368
NMAPRun: NMAPRun{
369369
Host: []Host{
370370
{
371-
StartTime: "",
372-
EndTime: "",
371+
StartTime: 0,
372+
EndTime: 0,
373373
Ports: Ports{},
374374
HostAddress: HostAddress{
375375
Address: "192.168.1.1",
@@ -387,8 +387,8 @@ func TestHTMLFormatter_Format(t *testing.T) {
387387
TCPTSSequence: TCPTSSequence{},
388388
},
389389
{
390-
StartTime: "",
391-
EndTime: "",
390+
StartTime: 0,
391+
EndTime: 0,
392392
Ports: Ports{},
393393
HostAddress: HostAddress{
394394
Address: "192.168.1.2",
@@ -406,8 +406,8 @@ func TestHTMLFormatter_Format(t *testing.T) {
406406
TCPTSSequence: TCPTSSequence{},
407407
},
408408
{
409-
StartTime: "",
410-
EndTime: "",
409+
StartTime: 0,
410+
EndTime: 0,
411411
Ports: Ports{},
412412
HostAddress: HostAddress{
413413
Address: "192.168.1.3",
@@ -449,8 +449,8 @@ func TestHTMLFormatter_Format(t *testing.T) {
449449
NMAPRun: NMAPRun{
450450
Host: []Host{
451451
{
452-
StartTime: "",
453-
EndTime: "",
452+
StartTime: 0,
453+
EndTime: 0,
454454
Ports: Ports{},
455455
HostAddress: HostAddress{
456456
Address: "192.168.1.1",
@@ -468,8 +468,8 @@ func TestHTMLFormatter_Format(t *testing.T) {
468468
TCPTSSequence: TCPTSSequence{},
469469
},
470470
{
471-
StartTime: "",
472-
EndTime: "",
471+
StartTime: 0,
472+
EndTime: 0,
473473
Ports: Ports{},
474474
HostAddress: HostAddress{
475475
Address: "192.168.1.2",
@@ -487,8 +487,8 @@ func TestHTMLFormatter_Format(t *testing.T) {
487487
TCPTSSequence: TCPTSSequence{},
488488
},
489489
{
490-
StartTime: "",
491-
EndTime: "",
490+
StartTime: 0,
491+
EndTime: 0,
492492
Ports: Ports{},
493493
HostAddress: HostAddress{
494494
Address: "192.168.1.3",

0 commit comments

Comments
 (0)