Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Histogram is Back in Zui #2472

Merged
merged 30 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2afb54a
App can render
jameskerr Aug 2, 2022
f5c1807
Remove old console.log
jameskerr Aug 3, 2022
dc95f89
Run the correct histogram query
jameskerr Aug 3, 2022
2bdd361
Create Entity Slice
jameskerr Aug 10, 2022
6597340
Merge remote-tracking branch 'origin/main' into histogram-is-back
jameskerr Aug 24, 2022
f4f614e
Add a Histogram state slice
jameskerr Aug 24, 2022
46150aa
Merge remote-tracking branch 'origin/main' into histogram-is-back
jameskerr Aug 24, 2022
363d9a1
Histogram working well
jameskerr Aug 24, 2022
099a87d
Use Current, not Editor
jameskerr Aug 25, 2022
de6befa
A system to update the app menu
jameskerr Aug 25, 2022
010a30b
Save the showHistogram state
jameskerr Aug 25, 2022
a0b9b58
Entity Slice is Ready
jameskerr Aug 29, 2022
797da8a
Rework active query concept
jameskerr Aug 30, 2022
c1db8d5
Fix Typescript
jameskerr Aug 30, 2022
040026c
Look up the remote queries as well
jameskerr Aug 31, 2022
f9f4c4d
Update to tests
jameskerr Aug 31, 2022
7ad52bd
Fix import queries and added a test
jameskerr Aug 31, 2022
c11c333
Fix span bug
jameskerr Aug 31, 2022
10ae884
Lock in the histogram with a playwright test
jameskerr Aug 31, 2022
12377ac
Add negative test for non-zeek data
jameskerr Aug 31, 2022
5789961
Style fix
jameskerr Aug 31, 2022
cb34090
Fix time range pins
jameskerr Aug 31, 2022
09c987d
Remove a stray console.log
jameskerr Aug 31, 2022
f5211a6
Account for null range
jameskerr Aug 31, 2022
ca1b1b9
Add utc default range
jameskerr Aug 31, 2022
a394b37
Make PRSs test data one line
jameskerr Sep 1, 2022
33e6c3b
Make PRSs test data one line
jameskerr Sep 1, 2022
f136f88
Make test data oneline
jameskerr Sep 1, 2022
03bd5af
Remove unused file
jameskerr Sep 1, 2022
0f7de63
Remove snapshot
jameskerr Sep 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@
"typescript": "^4.6.2",
"web-streams-polyfill": "^3.2.0",
"whatwg-fetch": "^3.2.0",
"win-7zip": "^0.1.0"
"win-7zip": "^0.1.0",
"zui-test-data": "workspace:*"
},
"dependencies": {
"@babel/core": "^7.17.9",
Expand Down
4 changes: 4 additions & 0 deletions packages/e2e-tests/helpers/test-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export default class TestApp {
this.zealot = new Client("http://localhost:9867")
}

find(text: string) {
return this.mainWin.locator(text)
}

async init() {
const userDataDir = path.resolve(
path.join(itestDir(), this.name, (this.testNdx++).toString())
Expand Down
37 changes: 37 additions & 0 deletions packages/e2e-tests/tests/histogram.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {test, expect} from "@playwright/test"
import TestApp from "../helpers/test-app"
import {getPath} from "zui-test-data"

test.describe("Histogram Spec", () => {
const app = new TestApp("Histogram Spec")

test.beforeAll(async () => {
await app.init()
})

test.afterAll(async () => {
await app.shutdown()
})

test("Histogram appears for zeek data", async () => {
await app.createPool([getPath("small-zeek.zng")])
await app.find(`role=button[name="Query Pool"]`).click()

const results = app.find(`role=status[name="results"]`)
await expect(results).toHaveText(/Results:/)

const chart = app.find(`[aria-label="histogram"]`)
await expect(chart).toBeVisible()
})

test("Histogram does not appears for non-zeek data", async () => {
await app.createPool([getPath("prs.json")])
await app.find(`role=button[name="Query Pool"]`).click()

const results = app.find(`role=status[name="results"]`)
await expect(results).toHaveText(/Results:/)

const chart = app.find(`[aria-label="histogram"]`)
await expect(chart).toBeHidden()
})
})
4 changes: 1 addition & 3 deletions packages/zealot/src/client/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ test("#query collector", async () => {

const fn = jest.fn()
await resp.collect(fn)
// It calls when the first 30 are returned, then when they
// are all returned
expect(fn).toHaveBeenCalledTimes(2)
expect(fn).toHaveBeenCalledTimes(1)
})

test("curl", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/zealot/src/query/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export class Channel extends EventEmitter {
*/
let first = true
let count = 0
let countThresh = 30
let timeThresh = 500
let countThresh = 2000
let timeThresh = 2000
let timeId = 0

const flush = () => {
Expand Down
65 changes: 65 additions & 0 deletions packages/zui-test-data/data/brimcap-queries.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"name": "Brimcap",
"items": [
{
"name": "Activity Overview",
"value": "count() by _path | sort -r",
"description": "Shows a list of all Zeek streams in the data set, with a count of associated records"
},
{
"name": "Unique DNS Queries",
"value": "_path==\"dns\" | count() by query | sort -r",
"description": "Shows all unique DNS queries in the data set with count"
},
{
"name": "Windows Networking Activity",
"value": "grep(smb*,_path) OR _path==\"dce_rpc\"",
"description": "Filters and displays smb_files, smb_mapping and DCE_RPC activity"
},
{
"name": "HTTP Requests",
"value": "_path==\"http\" | cut id.orig_h, id.resp_h, id.resp_p, method, host, uri | uniq -c",
"description": "Displays a list of the count of unique HTTP requests including source and destination"
},
{
"name": "Unique Network Connections",
"value": "_path==\"conn\" | cut id.orig_h, id.resp_p, id.resp_h | sort | uniq",
"description": "Displays a table showing all unique source:port:destination connections pairings"
},
{
"name": "Connection Received Data",
"value": "_path==\"conn\" | put total_bytes := orig_bytes + resp_bytes | sort -r total_bytes | cut uid, id, orig_bytes, resp_bytes, total_bytes",
"description": "Shows the connections between hosts, sorted by data received"
},
{
"name": "File Activity",
"value": "filename!=null | cut _path, tx_hosts, rx_hosts, conn_uids, mime_type, filename, md5, sha1",
"description": "Displays a curated view of file data including md5 and sha1 for complete file transfers"
},
{
"name": "HTTP Post Requests",
"value": "method==\"POST\" | cut ts, uid, id, method, uri, status_code",
"description": "Displays all HTTP Post requests including the URI and HTTP status code"
},
{
"name": "Show IP Subnets",
"value": "_path==\"conn\" | put classnet := network_of(id.resp_h) | cut classnet | count() by classnet | sort -r",
"description": "Enumerates the classful networks for all destination IP addresses including count of connections"
},
{
"name": "Suricata Alerts by Category",
"value": "event_type==\"alert\" | count() by alert.severity,alert.category | sort count",
"description": "Shows all Suricata alert counts by category and severity"
},
{
"name": "Suricata Alerts by Source and Destination",
"value": "event_type==\"alert\" | alerts := union(alert.category) by src_ip, dest_ip",
"description": "Shows all Suricata alerts in a list by unique source and destination IP addresses"
},
{
"name": "Suricata Alerts by Subnet",
"value": "event_type==\"alert\" | alerts := union(alert.category) by network_of(dest_ip)",
"description": "Displays a list of Suricata alerts by CIDR network"
}
]
}
Loading