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

auto-updating config via websocket | setting: automatically include limit in query for tags/services #189

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

findus
Copy link

@findus findus commented Nov 12, 2024

Config option still missing

Websocket connection to update setting for all connected users on the fly
Introduces config endpoint that lets us configure settings on the fly and send it over instantly to all connected clients

@peace-maker not sure if https://www.youtube.com/watch?v=cDA3_5982h8 moment, but I tried.

#181

@findus findus marked this pull request as ready for review November 12, 2024 10:56
@peace-maker
Copy link
Collaborator

We try to make as much configurable during runtime without restarting pkappa2. So some config page and rest endpoints to change the config values would be good. You don't have to add the UI part yet to configure it.

The current way the ltime:-1h: expression is inserted into the search box when clicking on Help or All Streams confused me at first because the query isn't run yet. The All Streams page still shows all streams instead of only the ones from the last hour as shown in the search box. I'd expect the query to be applied. Can you try how it feels when actually including that constraint on the All Streams view?
The interaction when clearing the search box and submitting the empty query after having searched another query should be special. Right now the ltime expression is inserted right away again but the search is still the empty query. It should always be possible to send the empty query to get all streams (paginated of course).

I think it's useful to add it to the other tags too. When clicking on a tag like flag_in it should show the query like tag:flag_in ltime:-1h:.

We'll have to test if this is annoying or intuitive to use during a CTF.

@peace-maker peace-maker linked an issue Nov 17, 2024 that may be closed by this pull request
@findus
Copy link
Author

findus commented Nov 17, 2024

@peace-maker came up with a solution, now on result-view creation it gets checked if setting option is is enabled, if yes + query is empty the limit gets auto applied.

Also if any link is clicked in the sidebar the router sends an additional queryparam that indicates exactly that, then the limit also gets auto applied.

Opening links with already defined queries in url just are just getting placed as is.

Only remaining issue: searching with empty query not possible atm, limit always get applied every time now.

Copy link
Collaborator

@peace-maker peace-maker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you for working on this! The empty query could be allowed by not interacting with an manually entered empty query. So after clearing the searchbox and pressing enter, you wouldn't insert the time query part.

I think adding another websocket event to notify all clients of the changed config would be useful instead of polling, but that can be done later.

A note on the Settings page that changes are global and affect all users would hopefully avoid confusion on people trying to disable the autofill for themselves.

web/src/components/SearchBox.vue Show resolved Hide resolved
web/src/apiClient.ts Outdated Show resolved Hide resolved
cmd/pkappa2/main.go Outdated Show resolved Hide resolved
cmd/pkappa2/main.go Outdated Show resolved Hide resolved
cmd/pkappa2/main.go Outdated Show resolved Hide resolved
internal/index/manager/manager.go Outdated Show resolved Hide resolved
internal/index/manager/manager.go Outdated Show resolved Hide resolved
web/src/components/SearchBox.vue Outdated Show resolved Hide resolved
web/src/components/Settings.vue Outdated Show resolved Hide resolved
web/src/stores/index.ts Outdated Show resolved Hide resolved
@peace-maker peace-maker added enhancement New feature or request javascript Pull requests that update Javascript code go Pull requests that update Go code labels Nov 18, 2024
Copy link
Collaborator

@peace-maker peace-maker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tried running the code yet, so this is still just visual inspection. Looks good overall.

I had the idea of turning the config option into an arbitrary suffix to add to the query, so you can change the currently hardcoded "ltime:-1h:". I'm not sure it'd help usability though and this can be switched to that option when a different query was desired during a CTF. Just for future reference.

There are multiple linter warnings still yelling about.

cmd/pkappa2/main.go Outdated Show resolved Hide resolved
internal/index/manager/manager.go Outdated Show resolved Hide resolved
web/src/apiClient.ts Outdated Show resolved Hide resolved
web/src/components/Results.vue Outdated Show resolved Hide resolved
@findus findus force-pushed the limit-auto-fill branch 6 times, most recently from 2c17232 to 57a7529 Compare November 20, 2024 09:55
@findus findus changed the title auto include limit in query auto-updating config via websocket | setting: automatically include limit in query for tags/services Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request go Pull requests that update Go code javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Config option to search in last hour by default
2 participants