-
Notifications
You must be signed in to change notification settings - Fork 132
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
Correlations #2455
Correlations #2455
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, nice work!! 🔥
src/js/state/Results/reducer.ts
Outdated
s.status = "ERROR" | ||
}, | ||
error: (s, a: Pay<{id: string; error: any; tabId: string}>) => { | ||
console.log(a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still want this?
id: `brimcap/try-conn-${queryId}`, | ||
}) | ||
const [conn] = await res.zed() | ||
console.log(conn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🪵
@@ -83,12 +84,15 @@ export default class BrimcapPlugin { | |||
this.updateSuricata() | |||
} | |||
|
|||
private async tryConn(detail: zed.Record, eventId: string) { | |||
// TODO: dispatch is only temporarily public to plugins, so this won't always be needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So happy this is now handled by this PR :)
public getState: () => State | ||
|
||
constructor() {} | ||
private dispatch: AppDispatch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
fixes #2443
This is exciting. We've heard from users who want to add custom correlation queries to brim. Before this PR, each correlation (zeek, suricata, md5) was implemented slightly differently and was hard-coded. This unifies the implementation and takes a huge step towards third-party correlations.
A significant change was extending the "Results" state slice. Now it can hold results for any number of queries, not just the main query. You provide an "id" whenever you set or select results.
I also created a simple
api.query
method on our BrimApi class. It cleans up after itself so that you don't have to think about it.Finally, I've made a
correlations/run()
thunk that uses the above two features. Each correlation is given an id, the query is issued, and the results are saved to the Results state slice under that id.Each correlation React component looks up the results by the relevant id.
The last piece of the puzzle is converting the brimcap-plugin to a new system. It currently relies on a thunk
fetchCorrelation
that needs to be deleted. We need to decide if we should issue a new query, or wait for the zeek query to find the conn record.UPDATE:
There is now a new api section called
correlations
.It works like this:
Whenever the current value (selected) changes, we call
dispatch(runCorrelations())
. It will grab all the correlation objects off the api, loop through them, check if they should run with thewhen
property, then run the query returned from thequery
property.The results get saved to the results slice under the
id
correlation property.Next Steps
To allow third-party javascript to add their own correlations, we only need to do two things: