Skip to content

Commit

Permalink
Add Host timedout field
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Baert committed May 30, 2023
1 parent 89031ae commit 9ab5458
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/xml/scan_base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<taskend task="System CNAME DNS resolution of 8 hosts." time="1201481086" />
<taskbegin task="SCRIPT ENGINE" time="1201481086" />
<taskend task="SCRIPT ENGINE" time="1201481197" />
<host>
<host starttime="1684341000" endtime="1684342000" timedout="true">
<status state="up" reason="reset"/>
<address addr="66.35.250.168" addrtype="ipv4" />
<hostnames>
Expand Down
1 change: 1 addition & 0 deletions xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ type Host struct {
IPIDSequence IPIDSequence `xml:"ipidsequence" json:"ip_id_sequence"`
OS OS `xml:"os" json:"os"`
StartTime Timestamp `xml:"starttime,attr,omitempty" json:"start_time"`
TimedOut bool `xml:"timedout,attr,omitempty" json:"timed_out"`
Status Status `xml:"status" json:"status"`
TCPSequence TCPSequence `xml:"tcpsequence" json:"tcp_sequence"`
TCPTSSequence TCPTSSequence `xml:"tcptssequence" json:"tcp_ts_sequence"`
Expand Down
11 changes: 11 additions & 0 deletions xml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@ func TestParseRunXML(t *testing.T) {
},
Hosts: []Host{
{
StartTime: Timestamp(time.Unix(1684341000, 0)),
EndTime: Timestamp(time.Unix(1684342000, 0)),
TimedOut: true,
IPIDSequence: IPIDSequence{
Class: "All zeros",
Values: "0,0,0,0,0,0",
Expand Down Expand Up @@ -1179,6 +1182,10 @@ func compareResults(t *testing.T, expected, got *Run) {
t.Errorf("unexpected host distance, expected %+v got %+v", expected.Hosts[idx].Distance, got.Hosts[idx].Distance)
}

if !reflect.DeepEqual(expected.Hosts[idx].EndTime, got.Hosts[idx].EndTime) {
t.Errorf("unexpected host end time, expected %+v got %+v", expected.Hosts[idx].EndTime, got.Hosts[idx].EndTime)
}

if !reflect.DeepEqual(expected.Hosts[idx].ExtraPorts, got.Hosts[idx].ExtraPorts) {
t.Errorf("unexpected host extra ports, expected %+v got %+v", expected.Hosts[idx].ExtraPorts, got.Hosts[idx].ExtraPorts)
}
Expand Down Expand Up @@ -1233,6 +1240,10 @@ func compareResults(t *testing.T, expected, got *Run) {
t.Errorf("unexpected host start time, expected %+v got %+v", expected.Hosts[idx].StartTime, got.Hosts[idx].StartTime)
}

if !reflect.DeepEqual(expected.Hosts[idx].TimedOut, got.Hosts[idx].TimedOut) {
t.Errorf("unexpected host timedout, expected %+v got %+v", expected.Hosts[idx].TimedOut, got.Hosts[idx].TimedOut)
}

if !reflect.DeepEqual(expected.Hosts[idx].Status, got.Hosts[idx].Status) {
t.Errorf("unexpected host status, expected %+v got %+v", expected.Hosts[idx].Status, got.Hosts[idx].Status)
}
Expand Down

0 comments on commit 9ab5458

Please sign in to comment.