Skip to content

Commit

Permalink
WIP: Event logging
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackDex committed Oct 26, 2022
1 parent b525f9a commit a0e4ef6
Show file tree
Hide file tree
Showing 27 changed files with 734 additions and 84 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
# This is done globally to prevent rebuilds when the RUSTFLAGS env variable changes.
env:
RUSTFLAGS: "-D warnings"
if: ${{ github.repository == 'BlackDex/vaultwarden' }} # HACK: Remove in final PR, leave for now to prevent rebuilds on push everytime
strategy:
fail-fast: false
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/hadolint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
hadolint:
name: Validate Dockerfile syntax
runs-on: ubuntu-20.04
if: ${{ github.repository == 'BlackDex/vaultwarden' }} # HACK: Remove in final PR, leave for now to prevent rebuilds on push everytime
steps:
# Checkout the repo
- name: Checkout
Expand Down
89 changes: 50 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ futures = "0.3.25"
tokio = { version = "1.21.2", features = ["rt-multi-thread", "fs", "io-util", "parking_lot", "time"] }

# A generic serialization/deserialization framework
serde = { version = "1.0.145", features = ["derive"] }
serde = { version = "1.0.147", features = ["derive"] }
serde_json = "1.0.87"

# A safe, extensible ORM and Query builder
Expand Down Expand Up @@ -122,11 +122,11 @@ html5gum = "0.5.2"
regex = { version = "1.6.0", features = ["std", "perf", "unicode-perl"], default-features = false }
data-url = "0.2.0"
bytes = "1.2.1"
cached = "0.39.0"
cached = "0.40.0"

# Used for custom short lived cookie jar during favicon extraction
cookie = "0.16.1"
cookie_store = "0.17.0"
cookie_store = { version = "0.18.0", features = ["log_secure_cookie_values"] }

# Used by U2F, JWT and Postgres
openssl = "0.10.42"
Expand Down
3 changes: 3 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

#![allow(clippy::uninlined_format_args)] // HACK: Temp allow so nightly builds work for me.

use std::env;
use std::process::Command;

Expand Down
1 change: 1 addition & 0 deletions migrations/mysql/2022-10-18-170602_add_events/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE event;
18 changes: 18 additions & 0 deletions migrations/mysql/2022-10-18-170602_add_events/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE event (
uuid CHAR(36) NOT NULL PRIMARY KEY,
event_type INTEGER NOT NULL,
user_uuid CHAR(36),
org_uuid CHAR(36),
cipher_uuid CHAR(36),
collection_uuid CHAR(36),
group_uuid CHAR(36),
org_user_uuid CHAR(36),
act_user_uuid CHAR(36),
device_type INTEGER,
ip_address TEXT,
event_date DATETIME NOT NULL,
provider_uuid CHAR(36),
provider_user_uuid CHAR(36),
provider_org_uuid CHAR(36),
UNIQUE (uuid)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE event;
18 changes: 18 additions & 0 deletions migrations/postgresql/2022-10-18-170602_add_events/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE event (
uuid CHAR(36) NOT NULL PRIMARY KEY,
event_type INTEGER NOT NULL,
user_uuid CHAR(36),
org_uuid CHAR(36),
cipher_uuid CHAR(36),
collection_uuid CHAR(36),
group_uuid CHAR(36),
org_user_uuid CHAR(36),
act_user_uuid CHAR(36),
device_type INTEGER,
ip_address TEXT,
event_date TIMESTAMP NOT NULL,
provider_uuid CHAR(36),
provider_user_uuid CHAR(36),
provider_org_uuid CHAR(36),
UNIQUE (uuid)
);
1 change: 1 addition & 0 deletions migrations/sqlite/2022-10-18-170602_add_events/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE event;
18 changes: 18 additions & 0 deletions migrations/sqlite/2022-10-18-170602_add_events/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE event (
uuid TEXT NOT NULL PRIMARY KEY,
event_type INTEGER NOT NULL,
user_uuid TEXT,
org_uuid TEXT,
cipher_uuid TEXT,
collection_uuid TEXT,
group_uuid TEXT,
org_user_uuid TEXT,
act_user_uuid TEXT,
device_type INTEGER,
ip_address TEXT,
event_date DATETIME NOT NULL,
provider_uuid TEXT,
provider_user_uuid TEXT,
provider_org_uuid TEXT,
UNIQUE (uuid)
);
4 changes: 2 additions & 2 deletions src/api/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,9 @@ async fn diagnostics(_token: AdminToken, ip_header: IpHeader, mut conn: DbConn)

// Get current running versions
let web_vault_version: WebVaultVersion =
match std::fs::read_to_string(&format!("{}/{}", CONFIG.web_vault_folder(), "vw-version.json")) {
match std::fs::read_to_string(format!("{}/{}", CONFIG.web_vault_folder(), "vw-version.json")) {
Ok(s) => serde_json::from_str(&s)?,
_ => match std::fs::read_to_string(&format!("{}/{}", CONFIG.web_vault_folder(), "version.json")) {
_ => match std::fs::read_to_string(format!("{}/{}", CONFIG.web_vault_folder(), "version.json")) {
Ok(s) => serde_json::from_str(&s)?,
_ => WebVaultVersion {
version: String::from("Version file missing"),
Expand Down
Loading

0 comments on commit a0e4ef6

Please sign in to comment.