Skip to content

Commit 8c84654

Browse files
authored
Merge pull request #726 from jmpsec/query-overflow-table
Prevent query to overflow table
2 parents df46e0a + 50c02b3 commit 8c84654

File tree

5 files changed

+30
-18
lines changed

5 files changed

+30
-18
lines changed

cmd/admin/handlers/json-nodes.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ func (h *HandlersAdmin) JSONEnvironmentHandler(w http.ResponseWriter, r *http.Re
105105
Version: n.PlatformVersion,
106106
Osquery: n.OsqueryVersion,
107107
LastSeen: CreationTimes{
108-
Display: utils.PastFutureTimes(n.UpdatedAt),
109-
Timestamp: utils.TimeTimestamp(n.UpdatedAt),
108+
Display: utils.PastFutureTimes(n.LastSeen),
109+
Timestamp: utils.TimeTimestamp(n.LastSeen),
110110
},
111111
FirstSeen: CreationTimes{
112112
Display: utils.PastFutureTimes(n.CreatedAt),
@@ -207,8 +207,8 @@ func (h *HandlersAdmin) JSONEnvironmentPagingHandler(w http.ResponseWriter, r *h
207207
Version: n.PlatformVersion,
208208
Osquery: n.OsqueryVersion,
209209
LastSeen: CreationTimes{
210-
Display: utils.PastFutureTimes(n.UpdatedAt),
211-
Timestamp: utils.TimeTimestamp(n.UpdatedAt),
210+
Display: utils.PastFutureTimes(n.LastSeen),
211+
Timestamp: utils.TimeTimestamp(n.LastSeen),
212212
},
213213
FirstSeen: CreationTimes{
214214
Display: utils.PastFutureTimes(n.CreatedAt),

cmd/admin/static/css/custom.css

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ th {
4646
border-left: 1px solid #c8ced3;
4747
}
4848

49-
input[type=text]#query {
49+
input[type="text"]#query {
5050
font-family: monospace;
5151
}
5252

53-
input[type=text]#query-sql {
53+
input[type="text"]#query-sql {
5454
font-family: monospace;
5555
}
5656

57-
input[type=text]#carve {
57+
input[type="text"]#carve {
5858
font-family: monospace;
5959
}
6060

@@ -68,7 +68,7 @@ input[type=text]#carve {
6868
}
6969

7070
body {
71-
font-family: 'Bai Jamjuree', sans-serif;
71+
font-family: "Bai Jamjuree", sans-serif;
7272
background-image: url("/background-image");
7373
background-attachment: fixed;
7474
}
@@ -77,14 +77,14 @@ body {
7777
padding: 0.5rem;
7878
margin-top: 0.5rem;
7979
margin-bottom: 0.5rem;
80-
background-color: #F0F0F0;
80+
background-color: #f0f0f0;
8181
-ms-overflow-style: -ms-autohiding-scrollbar;
8282
}
8383

8484
.warning-back {
8585
padding: 0.5rem;
8686
margin-bottom: 0.5rem;
87-
background-color: #F0F0F0;
87+
background-color: #f0f0f0;
8888
-ms-overflow-style: -ms-autohiding-scrollbar;
8989
}
9090

@@ -102,11 +102,11 @@ body {
102102
right: 1rem;
103103
z-index: 10;
104104
display: block;
105-
padding: .25rem .5rem;
105+
padding: 0.25rem 0.5rem;
106106
cursor: pointer;
107107
background-color: transparent;
108108
border: 0;
109-
border-radius: .25rem;
109+
border-radius: 0.25rem;
110110
}
111111

112112
.btn-clipboard:hover {
@@ -162,6 +162,19 @@ button {
162162
.query-link {
163163
font-family: monospace;
164164
font-size: 1.3em;
165+
max-width: 400px;
166+
white-space: normal;
167+
word-break: break-word;
168+
}
169+
170+
.query-log {
171+
font-family: monospace;
172+
font-size: 1.3em;
173+
max-width: 400px;
174+
white-space: normal;
175+
word-break: break-word;
176+
text-align: center;
177+
vertical-align: middle;
165178
}
166179

167180
.badge-prefix {

cmd/admin/templates/queries-logs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</thead>
3838
<tbody>
3939
<tr>
40-
<td style="font-size: 1.5em; font-family: monospace; text-align: center; vertical-align: middle">
40+
<td class="query-log">
4141
<b>{{ .Query }}</b>
4242
</td>
4343
<td>

cmd/admin/templates/queries.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
{{ $metadata := .Metadata }}
4-
{{ $leftmeta := .LeftMetadata }}
5-
{{ template "page-head" . }}
3+
{{ $metadata := .Metadata }} {{ $leftmeta := .LeftMetadata }} {{ template "page-head" . }}
64

75
<body class="app header-fixed sidebar-fixed sidebar-lg-show">
86
{{ template "page-header" . }}
@@ -113,7 +111,9 @@
113111
data: 'query',
114112
render: function (data, type, row, meta) {
115113
if (type === 'display') {
116-
return queryResultLink(data.link, data.query, "/query/{{ $leftmeta.EnvUUID }}/logs/" + data.name);
114+
return '<div style="max-width:400px; white-space:normal; word-break:break-word;">' +
115+
queryResultLink(data.link, data.query, "/query/{{ $leftmeta.EnvUUID }}/logs/" + data.name) +
116+
'</div>';
117117
} else {
118118
return data;
119119
}

pkg/nodes/nodes.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ func (n *NodeManager) IncreaseBytes(node OsqueryNode, incBytes int) error {
432432
}
433433

434434
func (n *NodeManager) RefreshLastSeenBatch(nodeID []uint) error {
435-
436435
return n.DB.Model(&OsqueryNode{}).Where("id IN ?", nodeID).UpdateColumn("last_seen", time.Now()).Error
437436
}
438437

0 commit comments

Comments
 (0)