Aircloak / aircloak

This repository contains the Aircloak Air frontend as well as the code for our Cloak query and anonymization platform
2 stars 0 forks source link

Add query history page #4940

Closed edongashi closed 3 years ago

edongashi commented 3 years ago

Closes #4889.

Some caveats:

aircloak-robot commented 3 years ago

air_test job errored 😒

You can see the full build log by running: ci/production.sh build_log pr 4940 air_test

You can restart the build by running: ci/production.sh force_build pr 4940 air_test

You can start the remote console by running: ci/production.sh remote_console pr 4940 air

Log tail:

    {Credo.Check.Warning.LazyLogging, false},

Please report incorrect results: https://github.com/rrrene/credo/issues

Analysis took 5.9 seconds (0.4s to load, 5.4s running 46 checks on 182 files)
1953 mods/funs, found no issues.

=> 9 sec

aircloak_ci: `/home/ci/.aircloak_ci/data/cache/builds/pr-4940/src/air/ci/container.sh run_in_container aircloak_ci_q3SH8cCi-BBN8XOXuuqimg make check-format`
mix format --check-formatted
=> 2 sec

aircloak_ci: `/home/ci/.aircloak_ci/data/cache/builds/pr-4940/src/air/ci/container.sh run_in_container aircloak_ci_q3SH8cCi-BBN8XOXuuqimg mix bom --elixir deps --node assets/node_modules /tmp`
Gathering package data...
Processing 911 packages...
Bill of Materials written to /tmp/bom.json
Packaging dependency sources...
Dependency sources written to /tmp/dependencies.zip
=> 46 sec

aircloak_ci: `/home/ci/.aircloak_ci/data/cache/builds/pr-4940/src/air/ci/container.sh run_in_container aircloak_ci_q3SH8cCi-BBN8XOXuuqimg MIX_HOME=_build make dialyze`
mix dialyze_retry
Finding applications for analysis

14:05:49.012 [info]  Compiling auto-completions
Finding suitable PLTs
Looking up modules in dialyze_erlang-23.1_elixir-1.11.1_deps-dev.plt
Finding applications for dialyze_erlang-23.1_elixir-1.11.1_deps-dev.plt
Finding modules for dialyze_erlang-23.1_elixir-1.11.1_deps-dev.plt
Checking 1334 modules in dialyze_erlang-23.1_elixir-1.11.1_deps-dev.plt
Finding applications for analysis
Looking up modules in dialyze_erlang-23.1_elixir-1.11.1_deps-dev.plt
Finding modules for analysis
Analysing 198 modules with dialyze_erlang-23.1_elixir-1.11.1_deps-dev.plt
lib/air_web/live/admin/audit_log_live/index.ex:155: The pattern 
          #{'__changed__' := _@33} can never match the type 
          #{'event' := _,
            'id' := _,
            'metadata' := _,
            'query_params' := _,
            'socket' := _,
            'timestamp' := _,
            'user_id' := _,
            'user_name' := _}

lib/air_web/live/admin/audit_log_live/index.ex:155: The pattern 
          #{'__changed__' := _@41} can never match the type 
          #{'event' := _,
            'id' := _,
            'metadata' := _,
            'query_params' := _,
            'socket' := _,
            'timestamp' := _,
            'user_id' := _,
            'user_name' := _}

lib/air_web/live/admin/audit_log_live/index.ex:155: The pattern 
          #{'__changed__' := _@52} can never match the type 
          #{'event' := _,
            'id' := _,
            'metadata' := _,
            'query_params' := _,
            'socket' := _,
            'timestamp' := _,
            'user_id' := _,
            'user_name' := _}

lib/air_web/live/admin/audit_log_live/index.ex:155: The pattern 
          #{'__changed__' := _@2} can never match the type 
          #{'event' := _,
            'id' := _,
            'metadata' := _,
            'query_params' := _,
            'socket' := _,
            'timestamp' := _,
            'user_id' := _,
            'user_name' := _}

lib/air_web/live/admin/audit_log_live/index.ex:155: The pattern 
          #{'__changed__' := _@21} can never match the type 
          #{'event' := _,
            'id' := _,
            'metadata' := _,
            'query_params' := _,
            'socket' := _,
            'timestamp' := _,
            'user_id' := _,
            'user_name' := _}

** (Mix) Dialyzer reported 5 warnings
make: *** [Makefile:41: dialyze] Error 1
=> 25 sec

aircloak_ci: error: 
error running `/home/ci/.aircloak_ci/data/cache/builds/pr-4940/src/air/ci/container.sh run_in_container aircloak_ci_q3SH8cCi-BBN8XOXuuqimg MIX_HOME=_build make dialyze`
aircloak_ci: result: `error`
aircloak_ci: finished in 5:29 min
aircloak-robot commented 3 years ago

Standard tests have passed πŸ’―

sebastian commented 3 years ago

Upon entering the queries page without having run any queries (with an empty database), I get the following JavaScript error:

TypeError: this.handleEvent is not a function. (In 'this.handleEvent("queries", function (data) { reactExports.setResults(data.queries); })', 'this.handleEvent' is undefined)

sebastian commented 3 years ago

And the page never seems to fully load. The loading bar continues to go forever. No errors in the elixir console though:

CleanShot 2021-07-07 at 17 41 37@2x

edongashi commented 3 years ago

TypeError: this.handleEvent is not a function. (In 'this.handleEvent("queries", function (data) { reactExports.setResults(data.queries); })', 'this.handleEvent' is undefined)

Our current liveview version does not support server-sent events. The updated version fixes this. You need to delete your deps and _build directory because webpack is stubborn and does not pick up the new file, probably because we're using a weird file dependency in package json:

https://github.com/Aircloak/aircloak/blob/376fa12bb9b90e96dfe61b052ecbba306573d2e7/air/assets/package.json#L21

sebastian commented 3 years ago

Our current liveview version does not support server-sent events. The updated version fixes this. You need to delete your deps and _build directory because webpack is stubborn and does not pick up the new file, probably because we're using a weird file dependency in package json:

Ah, I only deleted deps. Will try _build too.

sebastian commented 3 years ago

Looks good to me. One minor thing is that the padding is off:

CleanShot 2021-07-07 at 23 44 47@2x

vs

CleanShot 2021-07-07 at 23 44 42@2x

edongashi commented 3 years ago

Thanks for the feedback. All comments have been addressed.

What do you think about adding the data source next to the query date?

image

aircloak-robot commented 3 years ago

Standard tests have passed 😊

sebastian commented 3 years ago

What do you think about adding the data source next to the query date?

Yes please! I was going to suggest this! πŸ‘πŸ»

aircloak-robot commented 3 years ago

Pull request can be merged πŸ‘

edongashi commented 3 years ago

Added a clickable link for data sources next to the time.

Meanwhile I found a bug which we probably need to address: If you remove access to a data source for a user, they can no longer filter by it, even if they have queries on that DS. Should we instead show data sources where the user has queries?

aircloak-robot commented 3 years ago

Standard tests have passed πŸ‘

aircloak-robot commented 3 years ago

Standard tests have passed πŸ‘

aircloak-robot commented 3 years ago

Standard tests have passed πŸŽ‰

sebastian commented 3 years ago

Meanwhile I found a bug which we probably need to address: If you remove access to a data source for a user, they can no longer filter by it, even if they have queries on that DS. Should we instead show data sources where the user has queries?

Yes, that's a good point. Probably good to show all the data sources the user has queries for. Although isn't that potentially going to be a rather expensive query?

edongashi commented 3 years ago

Probably good to show all the data sources the user has queries for.

Done in 2f9a003 by reusing existing services.

Although isn't that potentially going to be a rather expensive query?

You first filter based on from/to, etc. From that result we gather the data sources in those queries. If it's a couple hundred records it's no big deal.

If you set a large window in say attack where a user has millions of queries, then we may get the same crash as audit log...

aircloak-robot commented 3 years ago

Pull request can be merged πŸ‘