Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60761284b4 |
@@ -1,149 +0,0 @@
|
|||||||
name: Dependency hygiene
|
|
||||||
|
|
||||||
# GitHub Actions is public mirror validation only.
|
|
||||||
# Primary registry release evidence must be produced on Russian build-runner.
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
pull_request:
|
|
||||||
workflow_dispatch:
|
|
||||||
schedule:
|
|
||||||
- cron: "17 2 * * 1"
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pull-requests: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
unused-dependencies:
|
|
||||||
name: Unused dependency check
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: bash
|
|
||||||
working-directory: adk-rust
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
lfs: false
|
|
||||||
|
|
||||||
- name: Install stable Rust
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
|
|
||||||
- name: Install cargo-machete
|
|
||||||
run: cargo install cargo-machete --locked
|
|
||||||
|
|
||||||
- name: cargo metadata
|
|
||||||
run: cargo metadata --locked --format-version 1 > /tmp/aw-rus-cargo-metadata.json
|
|
||||||
|
|
||||||
- name: cargo machete
|
|
||||||
run: cargo machete --with-metadata
|
|
||||||
|
|
||||||
- name: Ensure cargo-machete metadata did not rewrite manifests
|
|
||||||
working-directory: .
|
|
||||||
run: git diff --exit-code -- adk-rust/Cargo.lock adk-rust/Cargo.toml adk-rust/crates
|
|
||||||
|
|
||||||
- name: Require explicit justification for cargo-machete ignores
|
|
||||||
working-directory: .
|
|
||||||
run: |
|
|
||||||
python3 - <<'PY'
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
failures = []
|
|
||||||
for path in Path("adk-rust").rglob("Cargo.toml"):
|
|
||||||
lines = path.read_text(encoding="utf-8").splitlines()
|
|
||||||
in_machete = False
|
|
||||||
for idx, line in enumerate(lines):
|
|
||||||
stripped = line.strip()
|
|
||||||
if stripped.startswith("[") and stripped.endswith("]"):
|
|
||||||
in_machete = stripped == "[package.metadata.cargo-machete]"
|
|
||||||
continue
|
|
||||||
if not in_machete or not stripped.startswith("ignored"):
|
|
||||||
continue
|
|
||||||
same_line_comment = "#" in line and line.split("#", 1)[1].strip()
|
|
||||||
prev_comment = idx > 0 and lines[idx - 1].strip().startswith("#")
|
|
||||||
if not same_line_comment and not prev_comment:
|
|
||||||
failures.append(f"{path}:{idx + 1}")
|
|
||||||
|
|
||||||
if failures:
|
|
||||||
print("cargo-machete ignored entries require an adjacent TOML comment explaining why the dependency is intentionally kept:")
|
|
||||||
for item in failures:
|
|
||||||
print(f" {item}")
|
|
||||||
raise SystemExit(1)
|
|
||||||
PY
|
|
||||||
|
|
||||||
dependency-tree:
|
|
||||||
name: Dependency duplicate report
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: bash
|
|
||||||
working-directory: adk-rust
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
lfs: false
|
|
||||||
|
|
||||||
- name: Install stable Rust
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
|
|
||||||
- name: cargo tree duplicates
|
|
||||||
run: cargo tree --duplicates --locked
|
|
||||||
|
|
||||||
dependency-security:
|
|
||||||
name: Dependency security policy
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: bash
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
lfs: false
|
|
||||||
|
|
||||||
- name: Install stable Rust
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
|
|
||||||
- name: Install cargo-audit
|
|
||||||
uses: taiki-e/install-action@cargo-audit
|
|
||||||
|
|
||||||
- name: Install cargo-deny
|
|
||||||
uses: taiki-e/install-action@cargo-deny
|
|
||||||
|
|
||||||
- name: cargo audit
|
|
||||||
working-directory: adk-rust
|
|
||||||
run: cargo audit --deny warnings
|
|
||||||
|
|
||||||
- name: cargo deny
|
|
||||||
run: |
|
|
||||||
cargo deny --manifest-path adk-rust/Cargo.toml check \
|
|
||||||
--config deny.toml \
|
|
||||||
--hide-inclusion-graph \
|
|
||||||
--show-stats
|
|
||||||
|
|
||||||
cargo-udeps-nightly:
|
|
||||||
name: Cargo udeps nightly advisory
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
continue-on-error: true
|
|
||||||
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: bash
|
|
||||||
working-directory: adk-rust
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
lfs: false
|
|
||||||
|
|
||||||
- name: Install nightly Rust
|
|
||||||
uses: dtolnay/rust-toolchain@nightly
|
|
||||||
|
|
||||||
- name: Install cargo-udeps
|
|
||||||
run: cargo install cargo-udeps --locked
|
|
||||||
|
|
||||||
- name: cargo udeps
|
|
||||||
run: cargo +nightly udeps --workspace --all-targets
|
|
||||||
Generated
+13
-3
@@ -122,9 +122,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.103"
|
version = "1.0.102"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3"
|
checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arbitrary"
|
name = "arbitrary"
|
||||||
@@ -198,9 +198,12 @@ name = "aw-contour-smoke"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"tempfile",
|
||||||
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -247,6 +250,7 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -455,6 +459,7 @@ dependencies = [
|
|||||||
"clap",
|
"clap",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -466,6 +471,7 @@ dependencies = [
|
|||||||
"clap",
|
"clap",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -733,7 +739,6 @@ dependencies = [
|
|||||||
"sha2",
|
"sha2",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"tiny_http",
|
"tiny_http",
|
||||||
"url",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -771,6 +776,7 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
"detmir-state",
|
"detmir-state",
|
||||||
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -781,6 +787,7 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1249,6 +1256,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
"urlencoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1924,6 +1932,7 @@ dependencies = [
|
|||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3283,6 +3292,7 @@ dependencies = [
|
|||||||
"tempfile",
|
"tempfile",
|
||||||
"tiny_http",
|
"tiny_http",
|
||||||
"url",
|
"url",
|
||||||
|
"urlencoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ publish.workspace = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
chrono.workspace = true
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
reqwest.workspace = true
|
reqwest.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
url.workspace = true
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tempfile.workspace = true
|
||||||
|
|||||||
@@ -10,3 +10,6 @@ publish.workspace = true
|
|||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
reqwest.workspace = true
|
reqwest.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tempfile.workspace = true
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use std::path::{Path, PathBuf};
|
|||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use anyhow::{Context, Result, anyhow};
|
use anyhow::{Context, Result};
|
||||||
use chrono::{DateTime, Duration as ChronoDuration, SecondsFormat, Utc};
|
use chrono::{DateTime, Duration as ChronoDuration, SecondsFormat, Utc};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use detmir_core::{exit_codes, parse_utc_rfc3339};
|
use detmir_core::{exit_codes, parse_utc_rfc3339};
|
||||||
@@ -25,10 +25,10 @@ struct Cli {
|
|||||||
#[arg(long, default_value = "http://127.0.0.1:5610")]
|
#[arg(long, default_value = "http://127.0.0.1:5610")]
|
||||||
worktime_api: String,
|
worktime_api: String,
|
||||||
|
|
||||||
#[arg(long, default_value = "")]
|
#[arg(long, default_value = "198.51.100.18")]
|
||||||
rdp_host: String,
|
rdp_host: String,
|
||||||
|
|
||||||
#[arg(long, default_value = "")]
|
#[arg(long, default_value = "HOST-EXAMPLE")]
|
||||||
rdp_hostname: String,
|
rdp_hostname: String,
|
||||||
|
|
||||||
#[arg(long, default_value = "/var/lib/activitywatch/health")]
|
#[arg(long, default_value = "/var/lib/activitywatch/health")]
|
||||||
@@ -61,9 +61,6 @@ struct Cli {
|
|||||||
#[arg(long, default_value_t = 3.0)]
|
#[arg(long, default_value_t = 3.0)]
|
||||||
tcp_timeout_seconds: f64,
|
tcp_timeout_seconds: f64,
|
||||||
|
|
||||||
#[arg(long, default_value_t = true)]
|
|
||||||
rdp_tcp_required: bool,
|
|
||||||
|
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
json: bool,
|
json: bool,
|
||||||
}
|
}
|
||||||
@@ -132,10 +129,6 @@ impl Cli {
|
|||||||
self.tcp_timeout_seconds,
|
self.tcp_timeout_seconds,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if !cli_arg_present("--rdp-tcp-required") {
|
|
||||||
self.rdp_tcp_required =
|
|
||||||
env_bool_default("AW_RUS_HEALTH_RDP_TCP_REQUIRED", self.rdp_tcp_required);
|
|
||||||
}
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,42 +221,9 @@ fn env_f64(name: &str, fallback: f64) -> f64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn env_bool(name: &str) -> bool {
|
fn env_bool(name: &str) -> bool {
|
||||||
env_bool_default(name, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn env_bool_default(name: &str, fallback: bool) -> bool {
|
|
||||||
env_string(name)
|
env_string(name)
|
||||||
.map(|value| match value.to_ascii_lowercase().as_str() {
|
.map(|value| matches!(value.to_ascii_lowercase().as_str(), "1" | "true" | "yes"))
|
||||||
"1" | "true" | "yes" | "on" => true,
|
.unwrap_or(false)
|
||||||
"0" | "false" | "no" | "off" => false,
|
|
||||||
_ => fallback,
|
|
||||||
})
|
|
||||||
.unwrap_or(fallback)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn validate_cli_config(cli: &Cli) -> Result<()> {
|
|
||||||
validate_prod_host("rdp_host", &cli.rdp_host)?;
|
|
||||||
validate_prod_host("rdp_hostname", &cli.rdp_hostname)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn validate_prod_host(name: &str, value: &str) -> Result<()> {
|
|
||||||
let value = value.trim();
|
|
||||||
if value.is_empty() {
|
|
||||||
return Err(anyhow!("invalid config {name}: value is empty"));
|
|
||||||
}
|
|
||||||
let lowered = value.to_ascii_lowercase();
|
|
||||||
if lowered == "host-example"
|
|
||||||
|| lowered.ends_with(".example")
|
|
||||||
|| lowered.starts_with("192.0.2.")
|
|
||||||
|| lowered.starts_with("198.51.100.")
|
|
||||||
|| lowered.starts_with("203.0.113.")
|
|
||||||
{
|
|
||||||
return Err(anyhow!(
|
|
||||||
"invalid config {name}: placeholder/documentation host is not allowed"
|
|
||||||
));
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_env_file(path: &Path) {
|
fn load_env_file(path: &Path) {
|
||||||
@@ -721,16 +681,6 @@ fn normalize_aw_api_base(aw_server: &str) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tcp_check_status(ok: bool, required: bool) -> &'static str {
|
|
||||||
if ok {
|
|
||||||
"ok"
|
|
||||||
} else if required {
|
|
||||||
"fail"
|
|
||||||
} else {
|
|
||||||
"warn"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn validation_check(report: &mut ReportBuilder, validation_dir: &Path, max_age_seconds: i64) {
|
fn validation_check(report: &mut ReportBuilder, validation_dir: &Path, max_age_seconds: i64) {
|
||||||
let Some(path) = latest_validation_report(validation_dir) else {
|
let Some(path) = latest_validation_report(validation_dir) else {
|
||||||
report.add(
|
report.add(
|
||||||
@@ -862,18 +812,15 @@ fn run(cli: &Cli) -> Result<HealthReport> {
|
|||||||
|
|
||||||
for (port, label) in [(5985_u16, "winrm"), (3389_u16, "rdp")] {
|
for (port, label) in [(5985_u16, "winrm"), (3389_u16, "rdp")] {
|
||||||
let (ok, message) = tcp_connect(&cli.rdp_host, port, cli.tcp_timeout_seconds);
|
let (ok, message) = tcp_connect(&cli.rdp_host, port, cli.tcp_timeout_seconds);
|
||||||
let status = tcp_check_status(ok, cli.rdp_tcp_required);
|
|
||||||
report.add(
|
report.add(
|
||||||
format!("tcp:{label}"),
|
format!("tcp:{label}"),
|
||||||
status,
|
if ok { "ok" } else { "fail" },
|
||||||
if ok {
|
if ok {
|
||||||
message
|
message
|
||||||
} else if cli.rdp_tcp_required {
|
|
||||||
format!("unreachable: {message}")
|
|
||||||
} else {
|
} else {
|
||||||
format!("optional unreachable: {message}")
|
format!("unreachable: {message}")
|
||||||
},
|
},
|
||||||
json!({"host": cli.rdp_host, "port": port, "required": cli.rdp_tcp_required}),
|
json!({"host": cli.rdp_host, "port": port}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1002,7 +949,6 @@ fn run(cli: &Cli) -> Result<HealthReport> {
|
|||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let cli = Cli::parse().apply_env();
|
let cli = Cli::parse().apply_env();
|
||||||
validate_cli_config(&cli)?;
|
|
||||||
let report = run(&cli)?;
|
let report = run(&cli)?;
|
||||||
let json_text = serde_json::to_string_pretty(&report)? + "\n";
|
let json_text = serde_json::to_string_pretty(&report)? + "\n";
|
||||||
let text = render_text(&report) + "\n";
|
let text = render_text(&report) + "\n";
|
||||||
@@ -1083,20 +1029,4 @@ mod tests {
|
|||||||
"http://127.0.0.1:5600/api/0"
|
"http://127.0.0.1:5600/api/0"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn optional_rdp_tcp_downgrades_unreachable_to_warn() {
|
|
||||||
assert_eq!(tcp_check_status(false, true), "fail");
|
|
||||||
assert_eq!(tcp_check_status(false, false), "warn");
|
|
||||||
assert_eq!(tcp_check_status(true, false), "ok");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn healthd_rejects_placeholder_hosts() {
|
|
||||||
assert!(validate_prod_host("rdp_host", "192.168.100.19").is_ok());
|
|
||||||
assert!(validate_prod_host("rdp_hostname", "SHARKON2025").is_ok());
|
|
||||||
assert!(validate_prod_host("rdp_host", "198.51.100.18").is_err());
|
|
||||||
assert!(validate_prod_host("rdp_hostname", "HOST-EXAMPLE").is_err());
|
|
||||||
assert!(validate_prod_host("rdp_host", "").is_err());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,3 +12,6 @@ chrono.workspace = true
|
|||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
reqwest.workspace = true
|
reqwest.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tempfile.workspace = true
|
||||||
|
|||||||
@@ -12,3 +12,6 @@ chrono.workspace = true
|
|||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
reqwest.workspace = true
|
reqwest.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tempfile.workspace = true
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ serde_json.workspace = true
|
|||||||
serde_yaml.workspace = true
|
serde_yaml.workspace = true
|
||||||
sha2.workspace = true
|
sha2.workspace = true
|
||||||
tiny_http.workspace = true
|
tiny_http.workspace = true
|
||||||
url.workspace = true
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile.workspace = true
|
tempfile.workspace = true
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,6 @@ use anyhow::{Result, anyhow};
|
|||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
use serde_json::{Value, json};
|
use serde_json::{Value, json};
|
||||||
use tiny_http::StatusCode;
|
use tiny_http::StatusCode;
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Cli, MAX_ALLOWED_PAGE_SIZE, MAX_ALLOWED_REPORT_DATE_RANGE_DAYS, MAX_ALLOWED_REQUEST_BODY_BYTES,
|
Cli, MAX_ALLOWED_PAGE_SIZE, MAX_ALLOWED_REPORT_DATE_RANGE_DAYS, MAX_ALLOWED_REQUEST_BODY_BYTES,
|
||||||
@@ -78,11 +77,6 @@ pub(crate) fn validate_portal_config(args: &Cli) -> Result<()> {
|
|||||||
"invalid config max_request_body_bytes: expected 1024..={MAX_ALLOWED_REQUEST_BODY_BYTES}"
|
"invalid config max_request_body_bytes: expected 1024..={MAX_ALLOWED_REQUEST_BODY_BYTES}"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
validate_runtime_url("worktime_url", &args.worktime_url)?;
|
|
||||||
validate_runtime_url("one_c_url", &args.one_c_url)?;
|
|
||||||
validate_probe_command("status_cmd", &args.status_cmd)?;
|
|
||||||
validate_probe_command("check_cmd", &args.check_cmd)?;
|
|
||||||
validate_probe_command("failed_units_cmd", &args.failed_units_cmd)?;
|
|
||||||
|
|
||||||
// SECURITY: environment and module names can reach metrics/log labels.
|
// SECURITY: environment and module names can reach metrics/log labels.
|
||||||
// Restrict them to short ASCII tokens to avoid label injection and runaway
|
// Restrict them to short ASCII tokens to avoid label injection and runaway
|
||||||
@@ -118,46 +112,6 @@ pub(crate) fn validate_portal_config(args: &Cli) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate_runtime_url(name: &str, value: &str) -> Result<()> {
|
|
||||||
let url = Url::parse(value).map_err(|err| anyhow!("invalid config {name}: {err}"))?;
|
|
||||||
if !matches!(url.scheme(), "http" | "https") {
|
|
||||||
return Err(anyhow!("invalid config {name}: expected http or https URL"));
|
|
||||||
}
|
|
||||||
let Some(host) = url.host_str() else {
|
|
||||||
return Err(anyhow!("invalid config {name}: missing host"));
|
|
||||||
};
|
|
||||||
if is_placeholder_host(host) {
|
|
||||||
return Err(anyhow!(
|
|
||||||
"invalid config {name}: placeholder/documentation host is not allowed in production"
|
|
||||||
));
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_placeholder_host(host: &str) -> bool {
|
|
||||||
let host = host.trim().to_ascii_lowercase();
|
|
||||||
host.is_empty()
|
|
||||||
|| host == "host-example"
|
|
||||||
|| host.ends_with(".example")
|
|
||||||
|| host.starts_with("192.0.2.")
|
|
||||||
|| host.starts_with("198.51.100.")
|
|
||||||
|| host.starts_with("203.0.113.")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn validate_probe_command(name: &str, command: &str) -> Result<()> {
|
|
||||||
let command = command.trim();
|
|
||||||
if command.is_empty() {
|
|
||||||
return Err(anyhow!("invalid config {name}: command is empty"));
|
|
||||||
}
|
|
||||||
let forbidden = ['\n', '\r', '\0', ';', '|', '&', '<', '>', '`'];
|
|
||||||
if command.contains("$(") || command.chars().any(|ch| forbidden.contains(&ch)) {
|
|
||||||
return Err(anyhow!(
|
|
||||||
"invalid config {name}: shell control operators are not allowed"
|
|
||||||
));
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_safe_environment_name(value: &str) -> bool {
|
fn is_safe_environment_name(value: &str) -> bool {
|
||||||
let value = value.trim();
|
let value = value.trim();
|
||||||
!value.is_empty()
|
!value.is_empty()
|
||||||
@@ -276,7 +230,6 @@ mod tests {
|
|||||||
slow_request_log_ms: DEFAULT_SLOW_REQUEST_LOG_MS,
|
slow_request_log_ms: DEFAULT_SLOW_REQUEST_LOG_MS,
|
||||||
environment: "test".to_string(),
|
environment: "test".to_string(),
|
||||||
enabled_modules: "executive,workforce,security,forensics,admin".to_string(),
|
enabled_modules: "executive,workforce,security,forensics,admin".to_string(),
|
||||||
dlp_module_enabled: true,
|
|
||||||
state_dir: dir.join("state"),
|
state_dir: dir.join("state"),
|
||||||
dlp_db_path: dir.join("dlp.sqlite"),
|
dlp_db_path: dir.join("dlp.sqlite"),
|
||||||
evidence_root: dir.to_path_buf(),
|
evidence_root: dir.to_path_buf(),
|
||||||
@@ -340,39 +293,6 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn config_validation_rejects_placeholder_endpoints_and_shell_operators() {
|
|
||||||
let dir = tempfile::tempdir().unwrap();
|
|
||||||
let args = test_cli(dir.path());
|
|
||||||
|
|
||||||
let mut invalid = args.clone();
|
|
||||||
invalid.worktime_url = "http://192.0.2.13:5610".to_string();
|
|
||||||
assert!(
|
|
||||||
validate_portal_config(&invalid)
|
|
||||||
.unwrap_err()
|
|
||||||
.to_string()
|
|
||||||
.contains("placeholder")
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut invalid = args.clone();
|
|
||||||
invalid.one_c_url = "http://198.51.100.2:8710".to_string();
|
|
||||||
assert!(
|
|
||||||
validate_portal_config(&invalid)
|
|
||||||
.unwrap_err()
|
|
||||||
.to_string()
|
|
||||||
.contains("placeholder")
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut invalid = args.clone();
|
|
||||||
invalid.check_cmd = "detmir-check --json; curl http://127.0.0.1".to_string();
|
|
||||||
assert!(
|
|
||||||
validate_portal_config(&invalid)
|
|
||||||
.unwrap_err()
|
|
||||||
.to_string()
|
|
||||||
.contains("shell control")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn query_limits_reject_page_size_and_report_range() {
|
fn query_limits_reject_page_size_and_report_range() {
|
||||||
let dir = tempfile::tempdir().unwrap();
|
let dir = tempfile::tempdir().unwrap();
|
||||||
|
|||||||
@@ -34,10 +34,6 @@ struct HttpMetricValue {
|
|||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
struct PortalMetrics {
|
struct PortalMetrics {
|
||||||
http: BTreeMap<HttpMetricKey, HttpMetricValue>,
|
http: BTreeMap<HttpMetricKey, HttpMetricValue>,
|
||||||
report_requests_total: u64,
|
|
||||||
report_cache_hits_total: u64,
|
|
||||||
report_cache_misses_total: u64,
|
|
||||||
report_cache_stale_hits_total: u64,
|
|
||||||
reports_generated_total: u64,
|
reports_generated_total: u64,
|
||||||
ingestion_records_total: u64,
|
ingestion_records_total: u64,
|
||||||
ingestion_rejected_total: u64,
|
ingestion_rejected_total: u64,
|
||||||
@@ -74,32 +70,6 @@ pub(crate) fn record_report_generated() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn record_report_request() {
|
|
||||||
if let Ok(mut metrics) = portal_metrics().lock() {
|
|
||||||
metrics.report_requests_total = metrics.report_requests_total.saturating_add(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn record_report_cache_hit() {
|
|
||||||
if let Ok(mut metrics) = portal_metrics().lock() {
|
|
||||||
metrics.report_cache_hits_total = metrics.report_cache_hits_total.saturating_add(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn record_report_cache_stale_hit() {
|
|
||||||
if let Ok(mut metrics) = portal_metrics().lock() {
|
|
||||||
metrics.report_cache_hits_total = metrics.report_cache_hits_total.saturating_add(1);
|
|
||||||
metrics.report_cache_stale_hits_total =
|
|
||||||
metrics.report_cache_stale_hits_total.saturating_add(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn record_report_cache_miss() {
|
|
||||||
if let Ok(mut metrics) = portal_metrics().lock() {
|
|
||||||
metrics.report_cache_misses_total = metrics.report_cache_misses_total.saturating_add(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn record_ingestion_accepted() {
|
pub(crate) fn record_ingestion_accepted() {
|
||||||
if let Ok(mut metrics) = portal_metrics().lock() {
|
if let Ok(mut metrics) = portal_metrics().lock() {
|
||||||
metrics.ingestion_records_total = metrics.ingestion_records_total.saturating_add(1);
|
metrics.ingestion_records_total = metrics.ingestion_records_total.saturating_add(1);
|
||||||
@@ -179,26 +149,6 @@ pub(crate) fn render_prometheus_metrics(args: &Cli) -> String {
|
|||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
for (name, help, value) in [
|
for (name, help, value) in [
|
||||||
(
|
|
||||||
"awatch_report_requests_total",
|
|
||||||
"Report payload requests handled by the portal cache layer",
|
|
||||||
metrics.report_requests_total,
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"awatch_report_cache_hits_total",
|
|
||||||
"Report payload requests served from the in-process cache",
|
|
||||||
metrics.report_cache_hits_total,
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"awatch_report_cache_misses_total",
|
|
||||||
"Report payload requests that triggered report regeneration",
|
|
||||||
metrics.report_cache_misses_total,
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"awatch_report_cache_stale_hits_total",
|
|
||||||
"Report payload requests served from stale cache while refresh runs",
|
|
||||||
metrics.report_cache_stale_hits_total,
|
|
||||||
),
|
|
||||||
(
|
(
|
||||||
"awatch_reports_generated_total",
|
"awatch_reports_generated_total",
|
||||||
"Reports generated by the portal",
|
"Reports generated by the portal",
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ pub(crate) use limits::{is_limited_api_route, validate_api_query_limits, validat
|
|||||||
pub(crate) use logging::log_http_request;
|
pub(crate) use logging::log_http_request;
|
||||||
pub(crate) use metrics::{
|
pub(crate) use metrics::{
|
||||||
record_http_metric, record_ingestion_accepted, record_ingestion_rejected,
|
record_http_metric, record_ingestion_accepted, record_ingestion_rejected,
|
||||||
record_report_cache_hit, record_report_cache_miss, record_report_cache_stale_hit,
|
record_report_generated, render_prometheus_metrics,
|
||||||
record_report_generated, record_report_request, render_prometheus_metrics,
|
|
||||||
};
|
};
|
||||||
pub(crate) use readiness::build_readyz;
|
pub(crate) use readiness::build_readyz;
|
||||||
pub(crate) use request_context::{http_request_metadata, mark_request_started};
|
pub(crate) use request_context::{http_request_metadata, mark_request_started};
|
||||||
|
|||||||
@@ -6,20 +6,13 @@
|
|||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::thread;
|
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use crate::{Cli, HealthResponse, Snapshot, build_health, build_snapshot, now};
|
use crate::{Cli, HealthResponse, Snapshot, build_health, build_snapshot, now};
|
||||||
|
|
||||||
const SNAPSHOT_CACHE_TTL: Duration = Duration::from_secs(120);
|
const SNAPSHOT_CACHE_TTL: Duration = Duration::from_secs(120);
|
||||||
|
|
||||||
pub(crate) type SnapshotCache = Arc<Mutex<SnapshotCacheState>>;
|
pub(crate) type SnapshotCache = Arc<Mutex<Option<CachedSnapshot>>>;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
|
||||||
pub(crate) struct SnapshotCacheState {
|
|
||||||
pub(crate) entry: Option<CachedSnapshot>,
|
|
||||||
pub(crate) refresh_in_progress: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) struct CachedSnapshot {
|
pub(crate) struct CachedSnapshot {
|
||||||
@@ -28,7 +21,7 @@ pub(crate) struct CachedSnapshot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn new_snapshot_cache() -> SnapshotCache {
|
pub(crate) fn new_snapshot_cache() -> SnapshotCache {
|
||||||
Arc::new(Mutex::new(SnapshotCacheState::default()))
|
Arc::new(Mutex::new(None))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn clone_snapshot_cache(cache: &SnapshotCache) -> SnapshotCache {
|
pub(crate) fn clone_snapshot_cache(cache: &SnapshotCache) -> SnapshotCache {
|
||||||
@@ -36,76 +29,23 @@ pub(crate) fn clone_snapshot_cache(cache: &SnapshotCache) -> SnapshotCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cached_snapshot(args: &Cli, cache: &SnapshotCache) -> Snapshot {
|
pub(crate) fn cached_snapshot(args: &Cli, cache: &SnapshotCache) -> Snapshot {
|
||||||
{
|
let mut guard = cache.lock().expect("snapshot cache mutex poisoned");
|
||||||
let guard = cache.lock().expect("snapshot cache mutex poisoned");
|
if let Some(cached) = guard.as_ref() {
|
||||||
if let Some(cached) = guard.entry.as_ref() {
|
if cached.created.elapsed() <= SNAPSHOT_CACHE_TTL {
|
||||||
if cached.created.elapsed() <= SNAPSHOT_CACHE_TTL {
|
return cached.snapshot.clone();
|
||||||
return cached.snapshot.clone();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let snapshot = build_snapshot(args);
|
let snapshot = build_snapshot(args);
|
||||||
let mut guard = cache.lock().expect("snapshot cache mutex poisoned");
|
*guard = Some(CachedSnapshot {
|
||||||
guard.entry = Some(CachedSnapshot {
|
|
||||||
created: Instant::now(),
|
created: Instant::now(),
|
||||||
snapshot: snapshot.clone(),
|
snapshot: snapshot.clone(),
|
||||||
});
|
});
|
||||||
guard.refresh_in_progress = false;
|
|
||||||
snapshot
|
snapshot
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn cached_snapshot_or_refresh(args: &Cli, cache: &SnapshotCache) -> Option<Snapshot> {
|
|
||||||
let mut should_spawn = false;
|
|
||||||
let mut snapshot_to_return = None;
|
|
||||||
{
|
|
||||||
let mut guard = cache.lock().expect("snapshot cache mutex poisoned");
|
|
||||||
if let Some(cached) = guard.entry.as_ref() {
|
|
||||||
let snapshot = cached.snapshot.clone();
|
|
||||||
if cached.created.elapsed() <= SNAPSHOT_CACHE_TTL {
|
|
||||||
return Some(snapshot);
|
|
||||||
}
|
|
||||||
if !guard.refresh_in_progress {
|
|
||||||
guard.refresh_in_progress = true;
|
|
||||||
should_spawn = true;
|
|
||||||
}
|
|
||||||
snapshot_to_return = Some(snapshot);
|
|
||||||
} else if !guard.refresh_in_progress {
|
|
||||||
guard.refresh_in_progress = true;
|
|
||||||
should_spawn = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if should_spawn {
|
|
||||||
spawn_snapshot_refresh(args.clone(), clone_snapshot_cache(cache));
|
|
||||||
}
|
|
||||||
snapshot_to_return
|
|
||||||
}
|
|
||||||
|
|
||||||
fn spawn_snapshot_refresh(args: Cli, cache: SnapshotCache) {
|
|
||||||
thread::spawn(move || {
|
|
||||||
let result =
|
|
||||||
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| build_snapshot(&args)));
|
|
||||||
let mut guard = cache.lock().expect("snapshot cache mutex poisoned");
|
|
||||||
match result {
|
|
||||||
Ok(snapshot) => {
|
|
||||||
guard.entry = Some(CachedSnapshot {
|
|
||||||
created: Instant::now(),
|
|
||||||
snapshot,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Err(_) => {
|
|
||||||
eprintln!("detmir-portal snapshot cache refresh panicked");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
guard.refresh_in_progress = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn build_fast_health(cache: &SnapshotCache) -> HealthResponse {
|
pub(crate) fn build_fast_health(cache: &SnapshotCache) -> HealthResponse {
|
||||||
match cache.try_lock() {
|
match cache.try_lock() {
|
||||||
Ok(guard) => guard
|
Ok(guard) => guard
|
||||||
.entry
|
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|cached| build_health(&cached.snapshot))
|
.map(|cached| build_health(&cached.snapshot))
|
||||||
.unwrap_or_else(lightweight_health),
|
.unwrap_or_else(lightweight_health),
|
||||||
|
|||||||
@@ -549,7 +549,6 @@ mod tests {
|
|||||||
};
|
};
|
||||||
Snapshot {
|
Snapshot {
|
||||||
generated_at_utc: "2026-06-07T10:00:00Z".to_string(),
|
generated_at_utc: "2026-06-07T10:00:00Z".to_string(),
|
||||||
dlp_module_enabled: true,
|
|
||||||
detmir_status: SourceStatus {
|
detmir_status: SourceStatus {
|
||||||
ok: true,
|
ok: true,
|
||||||
status: "OK".to_string(),
|
status: "OK".to_string(),
|
||||||
|
|||||||
@@ -18,9 +18,7 @@ const DEFAULT_AW_ENV_FILE: &str = "/etc/activitywatch/aw-server.env";
|
|||||||
const DEFAULT_GRAFANA_ENV_FILE: &str = "/etc/detmir-grafana-check.env";
|
const DEFAULT_GRAFANA_ENV_FILE: &str = "/etc/detmir-grafana-check.env";
|
||||||
const DEFAULT_GRAFANA_URL: &str = "http://127.0.0.1:3000";
|
const DEFAULT_GRAFANA_URL: &str = "http://127.0.0.1:3000";
|
||||||
const DEFAULT_GRAFANA_DATASOURCE_UID: &str = "influxdb_aw";
|
const DEFAULT_GRAFANA_DATASOURCE_UID: &str = "influxdb_aw";
|
||||||
const DEFAULT_SYSTEMD_SERVICES: &str =
|
const DEFAULT_SYSTEMD_SERVICES: &str = "activitywatch-server,aw-worktime-api,aw-worktime-influx-exporter.timer,aw-dlp-influx-exporter.timer";
|
||||||
"activitywatch-server,aw-worktime-api,aw-worktime-influx-exporter.timer";
|
|
||||||
const DEFAULT_DLP_SYSTEMD_SERVICES: &str = "aw-dlp-influx-exporter.timer";
|
|
||||||
const DEFAULT_RETENTION_DAYS: i64 = 30;
|
const DEFAULT_RETENTION_DAYS: i64 = 30;
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
@@ -220,26 +218,14 @@ fn run(cli: &Cli) -> Result<Report> {
|
|||||||
let mut checks = Vec::new();
|
let mut checks = Vec::new();
|
||||||
let worktime = influx_config(&aw_env, "AW_WORKTIME_INFLUX");
|
let worktime = influx_config(&aw_env, "AW_WORKTIME_INFLUX");
|
||||||
let dlp = influx_config(&aw_env, "AW_DLP_INFLUX");
|
let dlp = influx_config(&aw_env, "AW_DLP_INFLUX");
|
||||||
let dlp_enabled = env_bool(&aw_env, "AW_DLP_ENABLED", true);
|
|
||||||
|
|
||||||
checks.push(check_influx_env(&worktime, cli.allow_disabled_influx));
|
checks.push(check_influx_env(&worktime, cli.allow_disabled_influx));
|
||||||
if dlp_enabled {
|
checks.push(check_influx_env(&dlp, cli.allow_disabled_influx));
|
||||||
checks.push(check_influx_env(&dlp, cli.allow_disabled_influx));
|
|
||||||
} else {
|
|
||||||
checks.push(warn(
|
|
||||||
"env:AW_DLP_INFLUX",
|
|
||||||
"DLP Influx runtime disabled by AW_DLP_ENABLED=false",
|
|
||||||
json!({"enabled": false, "mode": "disabled"}),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
if cli.skip_systemd {
|
if cli.skip_systemd {
|
||||||
checks.push(warn("systemd", "systemd checks skipped", json!({})));
|
checks.push(warn("systemd", "systemd checks skipped", json!({})));
|
||||||
} else {
|
} else {
|
||||||
checks.extend(check_systemd_services(&systemd_services_for_mode(
|
checks.extend(check_systemd_services(&cli.systemd_services));
|
||||||
&cli.systemd_services,
|
|
||||||
dlp_enabled,
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if cli.skip_influx_write {
|
if cli.skip_influx_write {
|
||||||
@@ -250,15 +236,7 @@ fn run(cli: &Cli) -> Result<Report> {
|
|||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
checks.push(check_influx_write(&client, "worktime", &worktime));
|
checks.push(check_influx_write(&client, "worktime", &worktime));
|
||||||
if dlp_enabled {
|
checks.push(check_influx_write(&client, "dlp", &dlp));
|
||||||
checks.push(check_influx_write(&client, "dlp", &dlp));
|
|
||||||
} else {
|
|
||||||
checks.push(warn(
|
|
||||||
"influx:write:dlp",
|
|
||||||
"DLP write probe skipped because DLP is disabled",
|
|
||||||
json!({"enabled": false, "mode": "disabled"}),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if cli.skip_grafana {
|
if cli.skip_grafana {
|
||||||
@@ -292,7 +270,7 @@ fn run(cli: &Cli) -> Result<Report> {
|
|||||||
git_commit: cli.git_commit.clone(),
|
git_commit: cli.git_commit.clone(),
|
||||||
counts,
|
counts,
|
||||||
checks,
|
checks,
|
||||||
limitations: build_limitations(cli, dlp_enabled),
|
limitations: build_limitations(cli),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,20 +338,6 @@ fn split_csv(value: &str) -> Vec<String> {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn systemd_services_for_mode(csv: &str, dlp_enabled: bool) -> String {
|
|
||||||
let mut services = split_csv(csv);
|
|
||||||
if dlp_enabled {
|
|
||||||
for service in split_csv(DEFAULT_DLP_SYSTEMD_SERVICES) {
|
|
||||||
if !services.iter().any(|item| item == &service) {
|
|
||||||
services.push(service);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
services.retain(|service| !service.contains("dlp"));
|
|
||||||
}
|
|
||||||
services.into_iter().collect::<Vec<_>>().join(",")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn hostname() -> String {
|
fn hostname() -> String {
|
||||||
Command::new("hostname")
|
Command::new("hostname")
|
||||||
.output()
|
.output()
|
||||||
@@ -384,7 +348,7 @@ fn hostname() -> String {
|
|||||||
.unwrap_or_else(|| "unknown".to_string())
|
.unwrap_or_else(|| "unknown".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_limitations(cli: &Cli, dlp_enabled: bool) -> Vec<String> {
|
fn build_limitations(cli: &Cli) -> Vec<String> {
|
||||||
let mut limitations = Vec::new();
|
let mut limitations = Vec::new();
|
||||||
limitations.push(
|
limitations.push(
|
||||||
"Проверка подтверждает состояние runtime на момент формирования акта и не заменяет аудит конфигурации, нагрузочное тестирование или приемочные испытания заказчика.".to_string(),
|
"Проверка подтверждает состояние runtime на момент формирования акта и не заменяет аудит конфигурации, нагрузочное тестирование или приемочные испытания заказчика.".to_string(),
|
||||||
@@ -413,11 +377,6 @@ fn build_limitations(cli: &Cli, dlp_enabled: bool) -> Vec<String> {
|
|||||||
.to_string(),
|
.to_string(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if !dlp_enabled {
|
|
||||||
limitations.push(
|
|
||||||
"DLP runtime отключен штатно через AW_DLP_ENABLED=false; readiness не считает DLP services/timers и DLP Influx write обязательными.".to_string(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
limitations
|
limitations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,4 +19,5 @@ adk-rust.workspace = true
|
|||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
detmir-state.workspace = true
|
detmir-state.workspace = true
|
||||||
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
|||||||
@@ -10,3 +10,6 @@ publish.workspace = true
|
|||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
chrono.workspace = true
|
chrono.workspace = true
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tempfile.workspace = true
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ regex.workspace = true
|
|||||||
reqwest.workspace = true
|
reqwest.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
urlencoding.workspace = true
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile.workspace = true
|
tempfile.workspace = true
|
||||||
|
|||||||
@@ -13,3 +13,6 @@ clap.workspace = true
|
|||||||
reqwest.workspace = true
|
reqwest.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tempfile.workspace = true
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ serde.workspace = true
|
|||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
tiny_http.workspace = true
|
tiny_http.workspace = true
|
||||||
url.workspace = true
|
url.workspace = true
|
||||||
|
urlencoding.workspace = true
|
||||||
regex.workspace = true
|
regex.workspace = true
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|||||||
+58
-294
@@ -19,22 +19,6 @@
|
|||||||
aw_db_vacuum_timer_enabled: false
|
aw_db_vacuum_timer_enabled: false
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Refuse inconsistent DLP resource profile
|
|
||||||
ansible.builtin.assert:
|
|
||||||
that:
|
|
||||||
- aw_dlp_profile | default('core_only') in ['core_only', 'light', 'on_demand', 'full']
|
|
||||||
- (aw_dlp_profile | default('core_only') == 'core_only') or (aw_dlp_enabled | default(false) | bool)
|
|
||||||
- (aw_dlp_enabled | default(false) | bool) or not (
|
|
||||||
aw_dlp_influx_enabled | default(false) | bool
|
|
||||||
or aw_dlp_ioc_enabled | default(false) | bool
|
|
||||||
or aw_dlp_policy_engine_enabled | default(false) | bool
|
|
||||||
or aw_dlp_content_analysis_enabled | default(false) | bool
|
|
||||||
or aw_dlp_integrations_enabled | default(false) | bool
|
|
||||||
or aw_dlp_case_management_enabled | default(false) | bool
|
|
||||||
or aw_dlp_compliance_enabled | default(false) | bool
|
|
||||||
)
|
|
||||||
fail_msg: "Inconsistent DLP profile: keep aw_dlp_enabled=false with all DLP component flags false, or explicitly choose aw_dlp_enabled=true and aw_dlp_profile=light|on_demand|full."
|
|
||||||
|
|
||||||
- name: Установить базовые пакеты
|
- name: Установить базовые пакеты
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name:
|
name:
|
||||||
@@ -94,7 +78,6 @@
|
|||||||
- "{{ aw_server_data_dir }}/backups"
|
- "{{ aw_server_data_dir }}/backups"
|
||||||
- "{{ aw_server_data_dir }}/slo"
|
- "{{ aw_server_data_dir }}/slo"
|
||||||
- "{{ aw_server_data_dir }}/browser-smoke"
|
- "{{ aw_server_data_dir }}/browser-smoke"
|
||||||
- "{{ aw_security_finding_executor_work_dir | default(aw_server_data_dir ~ '/security-finding-executor') }}"
|
|
||||||
- "{{ aw_rus_health_state_dir }}"
|
- "{{ aw_rus_health_state_dir }}"
|
||||||
- "{{ aw_rus_health_validation_dir }}"
|
- "{{ aw_rus_health_validation_dir }}"
|
||||||
- "{{ aw_server_log_dir }}"
|
- "{{ aw_server_log_dir }}"
|
||||||
@@ -125,7 +108,6 @@
|
|||||||
- "{{ aw_server_data_dir }}/backups"
|
- "{{ aw_server_data_dir }}/backups"
|
||||||
- "{{ aw_server_data_dir }}/slo"
|
- "{{ aw_server_data_dir }}/slo"
|
||||||
- "{{ aw_server_data_dir }}/browser-smoke"
|
- "{{ aw_server_data_dir }}/browser-smoke"
|
||||||
- "{{ aw_security_finding_executor_work_dir | default(aw_server_data_dir ~ '/security-finding-executor') }}"
|
|
||||||
- "{{ aw_rus_health_state_dir }}"
|
- "{{ aw_rus_health_state_dir }}"
|
||||||
- "{{ aw_rus_health_validation_dir }}"
|
- "{{ aw_rus_health_validation_dir }}"
|
||||||
- "{{ aw_server_log_dir }}"
|
- "{{ aw_server_log_dir }}"
|
||||||
@@ -731,9 +713,7 @@
|
|||||||
- aw_effective_dlp_influx_token | length > 0
|
- aw_effective_dlp_influx_token | length > 0
|
||||||
- (aw_effective_dlp_influx_token | string | lower | regex_search('^(change_me|changeme|replace-me|replace_me|token|secret|password|api_key|influx_token|write_token|your_.*|<.*>)$')) is none
|
- (aw_effective_dlp_influx_token | string | lower | regex_search('^(change_me|changeme|replace-me|replace_me|token|secret|password|api_key|influx_token|write_token|your_.*|<.*>)$')) is none
|
||||||
fail_msg: "aw_dlp_influx_enabled=true, но token пуст и в локальном env, и в текущем /etc/activitywatch/aw-server.env. Exporter будет падать и Grafana не получит DLP-ряды."
|
fail_msg: "aw_dlp_influx_enabled=true, но token пуст и в локальном env, и в текущем /etc/activitywatch/aw-server.env. Exporter будет падать и Grafana не получит DLP-ряды."
|
||||||
when:
|
when: aw_dlp_influx_enabled | default(false) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_influx_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Проверить destination для AW worktime Influx exporter
|
- name: Проверить destination для AW worktime Influx exporter
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
@@ -765,9 +745,7 @@
|
|||||||
- (aw_dlp_influx_hosts | default('') | string | length) > 0
|
- (aw_dlp_influx_hosts | default('') | string | length) > 0
|
||||||
- "'WINDOWS_USER_EXAMPLE' not in (aw_dlp_influx_hosts | default('') | string)"
|
- "'WINDOWS_USER_EXAMPLE' not in (aw_dlp_influx_hosts | default('') | string)"
|
||||||
fail_msg: "aw_dlp_influx_enabled=true, но URL/org/bucket/hosts похожи на public example/TEST-NET значения. Задайте live значения в private inventory/env, не в public repo."
|
fail_msg: "aw_dlp_influx_enabled=true, но URL/org/bucket/hosts похожи на public example/TEST-NET значения. Задайте live значения в private inventory/env, не в public repo."
|
||||||
when:
|
when: aw_dlp_influx_enabled | default(false) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_influx_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Записать /etc/activitywatch/aw-server.env перед хотфиксами
|
- name: Записать /etc/activitywatch/aw-server.env перед хотфиксами
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -786,7 +764,7 @@
|
|||||||
AW_SERVER_GROUP={{ aw_server_group }}
|
AW_SERVER_GROUP={{ aw_server_group }}
|
||||||
AW_WORKTIME_REPORT_BASE={{ aw_worktime_report_base }}
|
AW_WORKTIME_REPORT_BASE={{ aw_worktime_report_base }}
|
||||||
AW_WORKTIME_TZ={{ aw_worktime_timezone }}
|
AW_WORKTIME_TZ={{ aw_worktime_timezone }}
|
||||||
AW_WORKTIME_HOST={{ aw_effective_worktime_host | default(aw_effective_monitored_windows_hostname | default('HOST-EXAMPLE')) }}
|
AW_WORKTIME_HOST={{ aw_effective_worktime_host | default(aw_effective_monitored_windows_hostname | default('SHARKON2025')) }}
|
||||||
AW_WORKTIME_EVENTS_LIMIT={{ aw_worktime_events_limit | default(5000) }}
|
AW_WORKTIME_EVENTS_LIMIT={{ aw_worktime_events_limit | default(5000) }}
|
||||||
AW_WORKTIME_AW_HTTP_TIMEOUT_SECONDS={{ aw_worktime_aw_http_timeout_seconds | default(6) }}
|
AW_WORKTIME_AW_HTTP_TIMEOUT_SECONDS={{ aw_worktime_aw_http_timeout_seconds | default(6) }}
|
||||||
AW_WORKTIME_EVENTS_CACHE_TTL_SECONDS={{ aw_worktime_events_cache_ttl_seconds | default(300) }}
|
AW_WORKTIME_EVENTS_CACHE_TTL_SECONDS={{ aw_worktime_events_cache_ttl_seconds | default(300) }}
|
||||||
@@ -809,7 +787,7 @@
|
|||||||
AW_WORKTIME_INFLUX_URL={{ aw_worktime_influx_url | default('') }}
|
AW_WORKTIME_INFLUX_URL={{ aw_worktime_influx_url | default('') }}
|
||||||
AW_WORKTIME_INFLUX_ORG={{ aw_worktime_influx_org | default('proxmox') }}
|
AW_WORKTIME_INFLUX_ORG={{ aw_worktime_influx_org | default('proxmox') }}
|
||||||
AW_WORKTIME_INFLUX_BUCKET={{ aw_worktime_influx_bucket | default('aw_metrics') }}
|
AW_WORKTIME_INFLUX_BUCKET={{ aw_worktime_influx_bucket | default('aw_metrics') }}
|
||||||
AW_WORKTIME_INFLUX_HOSTS={{ aw_worktime_influx_hosts | default(aw_effective_monitored_windows_hostname | default('HOST-EXAMPLE')) }}
|
AW_WORKTIME_INFLUX_HOSTS={{ aw_worktime_influx_hosts | default('SHARKON2025') }}
|
||||||
AW_WORKTIME_INFLUX_DAYS={{ aw_worktime_influx_days | default('today,yesterday') }}
|
AW_WORKTIME_INFLUX_DAYS={{ aw_worktime_influx_days | default('today,yesterday') }}
|
||||||
AW_WORKTIME_INFLUX_TOKEN={{ aw_effective_worktime_influx_token | default('') }}
|
AW_WORKTIME_INFLUX_TOKEN={{ aw_effective_worktime_influx_token | default('') }}
|
||||||
AW_WORKTIME_MANAGEMENT_HISTORY_DIR={{ aw_worktime_management_history_dir | default(aw_server_data_dir ~ '/worktime-management-history') }}
|
AW_WORKTIME_MANAGEMENT_HISTORY_DIR={{ aw_worktime_management_history_dir | default(aw_server_data_dir ~ '/worktime-management-history') }}
|
||||||
@@ -820,28 +798,11 @@
|
|||||||
AW_WORKTIME_MANAGER_TREND_DELTA_PCT={{ aw_worktime_manager_trend_delta_pct | default(10) }}
|
AW_WORKTIME_MANAGER_TREND_DELTA_PCT={{ aw_worktime_manager_trend_delta_pct | default(10) }}
|
||||||
AW_WORKTIME_MANAGER_OFF_HOURS_THRESHOLD_SECONDS={{ aw_worktime_manager_off_hours_threshold_seconds | default(1800) }}
|
AW_WORKTIME_MANAGER_OFF_HOURS_THRESHOLD_SECONDS={{ aw_worktime_manager_off_hours_threshold_seconds | default(1800) }}
|
||||||
AW_WORKTIME_MANAGER_INTERPRETATION_POLICY={{ aw_worktime_interpretation_policy_path | default('/etc/activitywatch/worktime-interpretation-policy.json') }}
|
AW_WORKTIME_MANAGER_INTERPRETATION_POLICY={{ aw_worktime_interpretation_policy_path | default('/etc/activitywatch/worktime-interpretation-policy.json') }}
|
||||||
AW_DLP_ENABLED={{ 'true' if (aw_dlp_enabled | default(false) | bool) else 'false' }}
|
AW_DLP_INFLUX_ENABLED={{ 'true' if (aw_dlp_influx_enabled | default(false) | bool) else 'false' }}
|
||||||
AW_DLP_PROFILE={{ aw_dlp_profile | default('core_only') }}
|
|
||||||
AW_DLP_DISABLED_REASON={{ aw_dlp_disabled_reason | default('') }}
|
|
||||||
AW_DLP_DISABLED_SINCE={{ aw_dlp_disabled_since | default('') }}
|
|
||||||
AW_DLP_GUARD_ENABLED={{ 'true' if (aw_dlp_light_guard_enabled | default(true) | bool) else 'false' }}
|
|
||||||
AW_DLP_GUARD_STATE_DIR={{ aw_dlp_light_guard_state_dir | default(aw_server_data_dir ~ '/health') }}
|
|
||||||
AW_DLP_GUARD_LOAD_RATIO={{ aw_dlp_light_guard_load_ratio | default('1.50') }}
|
|
||||||
AW_DLP_GUARD_MEM_AVAILABLE_PCT_MIN={{ aw_dlp_light_guard_mem_available_pct_min | default('15') }}
|
|
||||||
AW_DLP_GUARD_IOWAIT_PCT_MAX={{ aw_dlp_light_guard_iowait_pct_max | default('20') }}
|
|
||||||
AW_DLP_GUARD_STRIKES_REQUIRED={{ aw_dlp_light_guard_strikes_required | default(3) }}
|
|
||||||
AW_DLP_CONTROL_BIN=/usr/local/bin/detmir-dlp-runtime-control
|
|
||||||
AW_CONTAINMENT_ENABLED={{ 'true' if (aw_containment_enabled | default(false) | bool) else 'false' }}
|
|
||||||
AW_CONTAINMENT_MODE={{ aw_containment_mode | default('shadow') }}
|
|
||||||
AW_CONTAINMENT_POLICY={{ aw_containment_policy_path | default('/etc/activitywatch/containment-policy.json') }}
|
|
||||||
AW_CONTAINMENT_DEFAULT_TTL_MINUTES={{ aw_containment_default_ttl_minutes | default(60) }}
|
|
||||||
AW_CONTAINMENT_REQUIRE_ADMIN_CHANNEL_CHECK={{ 'true' if (aw_containment_require_admin_channel_check | default(true) | bool) else 'false' }}
|
|
||||||
AW_CONTAINMENT_ALLOW_AUTO_FOR_SERVERS={{ 'true' if (aw_containment_allow_auto_for_servers | default(false) | bool) else 'false' }}
|
|
||||||
AW_DLP_INFLUX_ENABLED={{ 'true' if ((aw_dlp_enabled | default(false) | bool) and (aw_dlp_influx_enabled | default(false) | bool)) else 'false' }}
|
|
||||||
AW_DLP_INFLUX_URL={{ aw_dlp_influx_url | default('') }}
|
AW_DLP_INFLUX_URL={{ aw_dlp_influx_url | default('') }}
|
||||||
AW_DLP_INFLUX_ORG={{ aw_dlp_influx_org | default('proxmox') }}
|
AW_DLP_INFLUX_ORG={{ aw_dlp_influx_org | default('proxmox') }}
|
||||||
AW_DLP_INFLUX_BUCKET={{ aw_dlp_influx_bucket | default('aw_metrics') }}
|
AW_DLP_INFLUX_BUCKET={{ aw_dlp_influx_bucket | default('aw_metrics') }}
|
||||||
AW_DLP_INFLUX_HOSTS={{ aw_dlp_influx_hosts | default(aw_effective_monitored_windows_hostname | default('HOST-EXAMPLE')) }}
|
AW_DLP_INFLUX_HOSTS={{ aw_dlp_influx_hosts | default('SHARKON2025') }}
|
||||||
AW_DLP_INFLUX_LOOKBACK_DAYS={{ aw_dlp_influx_lookback_days | default(30) }}
|
AW_DLP_INFLUX_LOOKBACK_DAYS={{ aw_dlp_influx_lookback_days | default(30) }}
|
||||||
AW_DLP_INFLUX_EVENT_LIMIT={{ aw_dlp_influx_event_limit | default(2000) }}
|
AW_DLP_INFLUX_EVENT_LIMIT={{ aw_dlp_influx_event_limit | default(2000) }}
|
||||||
AW_DLP_INFLUX_TOKEN={{ aw_effective_dlp_influx_token | default('') }}
|
AW_DLP_INFLUX_TOKEN={{ aw_effective_dlp_influx_token | default('') }}
|
||||||
@@ -859,7 +820,6 @@
|
|||||||
AW_RUS_HEALTH_SESSION_EVENTS_MAX_AGE_SECONDS={{ aw_rus_health_session_events_max_age_seconds | default(86400) }}
|
AW_RUS_HEALTH_SESSION_EVENTS_MAX_AGE_SECONDS={{ aw_rus_health_session_events_max_age_seconds | default(86400) }}
|
||||||
AW_RUS_HEALTH_GUARD_MAX_AGE_SECONDS={{ aw_rus_health_guard_max_age_seconds | default(300) }}
|
AW_RUS_HEALTH_GUARD_MAX_AGE_SECONDS={{ aw_rus_health_guard_max_age_seconds | default(300) }}
|
||||||
AW_RUS_HEALTH_GUARD_REQUIRED={{ 1 if (aw_rus_health_guard_required | default(true) | bool) else 0 }}
|
AW_RUS_HEALTH_GUARD_REQUIRED={{ 1 if (aw_rus_health_guard_required | default(true) | bool) else 0 }}
|
||||||
AW_RUS_HEALTH_RDP_TCP_REQUIRED={{ 'true' if (aw_rus_health_rdp_tcp_required | default(true) | bool) else 'false' }}
|
|
||||||
AW_RUS_SLO_STATE_DIR={{ aw_server_data_dir }}/slo
|
AW_RUS_SLO_STATE_DIR={{ aw_server_data_dir }}/slo
|
||||||
AW_RUS_SLO_AW_BASE=http://127.0.0.1:5600
|
AW_RUS_SLO_AW_BASE=http://127.0.0.1:5600
|
||||||
AW_RUS_SLO_WORKTIME_BASE={{ aw_rus_health_worktime_api_base | default('http://127.0.0.1:5610') }}
|
AW_RUS_SLO_WORKTIME_BASE={{ aw_rus_health_worktime_api_base | default('http://127.0.0.1:5610') }}
|
||||||
@@ -877,104 +837,6 @@
|
|||||||
AW_HAYABUSA_TELEGRAM_MIN_SEVERITY={{ aw_hayabusa_telegram_min_severity | default('high') }}
|
AW_HAYABUSA_TELEGRAM_MIN_SEVERITY={{ aw_hayabusa_telegram_min_severity | default('high') }}
|
||||||
AW_HAYABUSA_TELEGRAM_BOT_TOKEN={{ aw_hayabusa_telegram_bot_token | default('') }}
|
AW_HAYABUSA_TELEGRAM_BOT_TOKEN={{ aw_hayabusa_telegram_bot_token | default('') }}
|
||||||
AW_HAYABUSA_TELEGRAM_CHAT_IDS={{ aw_hayabusa_telegram_chat_ids | default('') }}
|
AW_HAYABUSA_TELEGRAM_CHAT_IDS={{ aw_hayabusa_telegram_chat_ids | default('') }}
|
||||||
AW_SECURITY_FINDING_INBOX_ENABLED={{ 'true' if (aw_security_finding_inbox_enabled | default(false) | bool) else 'false' }}
|
|
||||||
AW_SECURITY_FINDING_INBOX_REQUIRED={{ 'true' if (aw_security_finding_inbox_required | default(false) | bool) else 'false' }}
|
|
||||||
AW_SECURITY_FINDING_INBOX_BIN={{ aw_security_finding_inbox_bin | default('/usr/local/bin/security-finding-inbox') }}
|
|
||||||
AW_SECURITY_FINDING_INBOX_MIN_SEVERITY={{ aw_security_finding_inbox_min_severity | default('medium') }}
|
|
||||||
AW_SECURITY_FINDING_EXECUTOR_WORK_DIR={{ aw_security_finding_executor_work_dir | default(aw_server_data_dir ~ '/security-finding-executor') }}
|
|
||||||
AW_SECURITY_FINDING_EXECUTOR_LOCK={{ aw_security_finding_executor_lock | default('/var/lock/aw-security-finding-executor.lock') }}
|
|
||||||
AW_CONTAINMENT_ENGINE_BIN={{ aw_containment_engine_bin | default('/usr/local/bin/containment-engine') }}
|
|
||||||
AW_CONTAINMENT_MANAGEMENT_ALLOWLIST={{ aw_containment_management_allowlist | default('') }}
|
|
||||||
AW_CONTAINMENT_BLOCKED_REMOTE_ADDRESSES={{ aw_containment_blocked_remote_addresses | default('') }}
|
|
||||||
|
|
||||||
- name: Установить runtime control для optional DLP контура
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "{{ aw_repo_root }}/scripts/detmir_dlp_runtime_control.sh"
|
|
||||||
dest: /usr/local/bin/detmir-dlp-runtime-control
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
- name: Установить load guard для lightweight DLP контура
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "{{ aw_repo_root }}/scripts/detmir_dlp_load_guard.sh"
|
|
||||||
dest: /usr/local/bin/detmir-dlp-load-guard
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
- name: Установить systemd unit DLP load guard
|
|
||||||
ansible.builtin.copy:
|
|
||||||
dest: /etc/systemd/system/detmir-dlp-load-guard.service
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0644"
|
|
||||||
content: |
|
|
||||||
[Unit]
|
|
||||||
Description=DetMir lightweight DLP load guard
|
|
||||||
After=activitywatch-server.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
EnvironmentFile=-/etc/activitywatch/aw-server.env
|
|
||||||
ExecStart=/usr/local/bin/detmir-dlp-load-guard
|
|
||||||
Nice=10
|
|
||||||
IOSchedulingClass=best-effort
|
|
||||||
IOSchedulingPriority=7
|
|
||||||
TimeoutStartSec=45
|
|
||||||
|
|
||||||
- name: Установить systemd timer DLP load guard
|
|
||||||
ansible.builtin.copy:
|
|
||||||
dest: /etc/systemd/system/detmir-dlp-load-guard.timer
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0644"
|
|
||||||
content: |
|
|
||||||
[Unit]
|
|
||||||
Description=Run DetMir lightweight DLP load guard
|
|
||||||
|
|
||||||
[Timer]
|
|
||||||
OnBootSec=3min
|
|
||||||
OnUnitActiveSec=1min
|
|
||||||
AccuracySec=30s
|
|
||||||
Persistent=false
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=timers.target
|
|
||||||
|
|
||||||
- name: Включить DLP load guard timer
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
name: detmir-dlp-load-guard.timer
|
|
||||||
enabled: true
|
|
||||||
state: started
|
|
||||||
daemon_reload: true
|
|
||||||
when: aw_dlp_light_guard_enabled | default(true) | bool
|
|
||||||
|
|
||||||
- name: Отключить DLP load guard timer, если guard явно выключен
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
name: detmir-dlp-load-guard.timer
|
|
||||||
enabled: false
|
|
||||||
state: stopped
|
|
||||||
daemon_reload: true
|
|
||||||
failed_when: false
|
|
||||||
when: not (aw_dlp_light_guard_enabled | default(true) | bool)
|
|
||||||
|
|
||||||
- name: Создать каталог containment policy
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: "{{ (aw_containment_policy_path | default('/etc/activitywatch/containment-policy.json')) | dirname }}"
|
|
||||||
state: directory
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
- name: Установить default containment policy, если live policy отсутствует
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "{{ aw_repo_root }}/configs/containment-policy.example.json"
|
|
||||||
dest: "{{ aw_containment_policy_path | default('/etc/activitywatch/containment-policy.json') }}"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0644"
|
|
||||||
force: false
|
|
||||||
|
|
||||||
- name: Создать каталог DLP policy engine
|
- name: Создать каталог DLP policy engine
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
@@ -983,9 +845,7 @@
|
|||||||
owner: "{{ aw_server_user }}"
|
owner: "{{ aw_server_user }}"
|
||||||
group: "{{ aw_server_group }}"
|
group: "{{ aw_server_group }}"
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
when:
|
when: aw_dlp_policy_engine_enabled | default(false) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_policy_engine_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Установить systemd unit DLP policy engine
|
- name: Установить systemd unit DLP policy engine
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -994,9 +854,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
when:
|
when: aw_dlp_policy_engine_enabled | default(false) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_policy_engine_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Проверить локальный Rust DLP policy engine
|
- name: Проверить локальный Rust DLP policy engine
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
@@ -1031,7 +889,7 @@
|
|||||||
owner: "{{ aw_server_user }}"
|
owner: "{{ aw_server_user }}"
|
||||||
group: "{{ aw_server_group }}"
|
group: "{{ aw_server_group }}"
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
when: aw_dlp_content_analysis_enabled | default(false) | bool
|
when: aw_dlp_content_analysis_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Скопировать файлы DLP content analysis
|
- name: Скопировать файлы DLP content analysis
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1040,7 +898,7 @@
|
|||||||
owner: "{{ aw_server_user }}"
|
owner: "{{ aw_server_user }}"
|
||||||
group: "{{ aw_server_group }}"
|
group: "{{ aw_server_group }}"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
when: aw_dlp_content_analysis_enabled | default(false) | bool
|
when: aw_dlp_content_analysis_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Установить wrapper запуска DLP content analysis через virtualenv
|
- name: Установить wrapper запуска DLP content analysis через virtualenv
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1049,7 +907,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
when: aw_dlp_content_analysis_enabled | default(false) | bool
|
when: aw_dlp_content_analysis_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Проверить локальный Rust DLP content analyzer
|
- name: Проверить локальный Rust DLP content analyzer
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
@@ -1057,7 +915,7 @@
|
|||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: dlp_content_analyzer_rust_binary
|
register: dlp_content_analyzer_rust_binary
|
||||||
become: false
|
become: false
|
||||||
when: aw_dlp_content_analysis_enabled | default(false) | bool
|
when: aw_dlp_content_analysis_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Установить Rust DLP content analyzer
|
- name: Установить Rust DLP content analyzer
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1067,7 +925,7 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
when:
|
when:
|
||||||
- aw_dlp_content_analysis_enabled | default(false) | bool
|
- aw_dlp_content_analysis_enabled | default(true) | bool
|
||||||
- dlp_content_analyzer_rust_binary.stat.exists | default(false)
|
- dlp_content_analyzer_rust_binary.stat.exists | default(false)
|
||||||
|
|
||||||
- name: Создать virtualenv DLP content analysis
|
- name: Создать virtualenv DLP content analysis
|
||||||
@@ -1075,13 +933,13 @@
|
|||||||
cmd: python3 -m venv /opt/activitywatch/dlp-content-analysis/.venv
|
cmd: python3 -m venv /opt/activitywatch/dlp-content-analysis/.venv
|
||||||
args:
|
args:
|
||||||
creates: /opt/activitywatch/dlp-content-analysis/.venv/bin/python
|
creates: /opt/activitywatch/dlp-content-analysis/.venv/bin/python
|
||||||
when: aw_dlp_content_analysis_enabled | default(false) | bool
|
when: aw_dlp_content_analysis_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Установить зависимости DLP content analysis
|
- name: Установить зависимости DLP content analysis
|
||||||
ansible.builtin.pip:
|
ansible.builtin.pip:
|
||||||
requirements: /opt/activitywatch/dlp-content-analysis/requirements.txt
|
requirements: /opt/activitywatch/dlp-content-analysis/requirements.txt
|
||||||
virtualenv: /opt/activitywatch/dlp-content-analysis/.venv
|
virtualenv: /opt/activitywatch/dlp-content-analysis/.venv
|
||||||
when: aw_dlp_content_analysis_enabled | default(false) | bool
|
when: aw_dlp_content_analysis_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Создать каталог DLP integrations
|
- name: Создать каталог DLP integrations
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
@@ -1090,9 +948,7 @@
|
|||||||
owner: "{{ aw_server_user }}"
|
owner: "{{ aw_server_user }}"
|
||||||
group: "{{ aw_server_group }}"
|
group: "{{ aw_server_group }}"
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
when:
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_integrations_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Скопировать файлы DLP integrations
|
- name: Скопировать файлы DLP integrations
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1105,9 +961,7 @@
|
|||||||
- cef-config.yaml
|
- cef-config.yaml
|
||||||
- syslog-forwarder-config.yaml
|
- syslog-forwarder-config.yaml
|
||||||
- webhook-config.yaml
|
- webhook-config.yaml
|
||||||
when:
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_integrations_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Создать state каталог DLP integrations
|
- name: Создать state каталог DLP integrations
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
@@ -1116,9 +970,7 @@
|
|||||||
owner: "{{ aw_server_user }}"
|
owner: "{{ aw_server_user }}"
|
||||||
group: "{{ aw_server_group }}"
|
group: "{{ aw_server_group }}"
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
when:
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_integrations_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Установить systemd unit CEF exporter
|
- name: Установить systemd unit CEF exporter
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1127,9 +979,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
when:
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_integrations_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Установить systemd timer CEF exporter
|
- name: Установить systemd timer CEF exporter
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1138,9 +988,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
when:
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_integrations_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Проверить локальный Rust CEF exporter
|
- name: Проверить локальный Rust CEF exporter
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
@@ -1148,16 +996,14 @@
|
|||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: dlp_cef_exporter_rust_binary
|
register: dlp_cef_exporter_rust_binary
|
||||||
become: false
|
become: false
|
||||||
when:
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_integrations_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Требовать Rust CEF exporter artifact
|
- name: Требовать Rust CEF exporter artifact
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- dlp_cef_exporter_rust_binary.stat.exists | default(false)
|
- dlp_cef_exporter_rust_binary.stat.exists | default(false)
|
||||||
fail_msg: "Missing Rust artifact: {{ aw_rust_release_dir }}/dlp-cef-exporter"
|
fail_msg: "Missing Rust artifact: {{ aw_rust_release_dir }}/dlp-cef-exporter"
|
||||||
when: aw_dlp_integrations_enabled | default(false) | bool
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Установить Rust CEF exporter
|
- name: Установить Rust CEF exporter
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1167,7 +1013,7 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
when:
|
when:
|
||||||
- aw_dlp_integrations_enabled | default(false) | bool
|
- aw_dlp_integrations_enabled | default(true) | bool
|
||||||
- dlp_cef_exporter_rust_binary.stat.exists | default(false)
|
- dlp_cef_exporter_rust_binary.stat.exists | default(false)
|
||||||
|
|
||||||
- name: Установить systemd unit syslog forwarder
|
- name: Установить systemd unit syslog forwarder
|
||||||
@@ -1177,7 +1023,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
when: aw_dlp_integrations_enabled | default(false) | bool
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Установить systemd timer syslog forwarder
|
- name: Установить systemd timer syslog forwarder
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1186,7 +1032,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
when: aw_dlp_integrations_enabled | default(false) | bool
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Проверить локальный Rust syslog forwarder
|
- name: Проверить локальный Rust syslog forwarder
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
@@ -1194,14 +1040,14 @@
|
|||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: dlp_syslog_forwarder_rust_binary
|
register: dlp_syslog_forwarder_rust_binary
|
||||||
become: false
|
become: false
|
||||||
when: aw_dlp_integrations_enabled | default(false) | bool
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Требовать Rust syslog forwarder artifact
|
- name: Требовать Rust syslog forwarder artifact
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- dlp_syslog_forwarder_rust_binary.stat.exists | default(false)
|
- dlp_syslog_forwarder_rust_binary.stat.exists | default(false)
|
||||||
fail_msg: "Missing Rust artifact: {{ aw_rust_release_dir }}/dlp-syslog-forwarder"
|
fail_msg: "Missing Rust artifact: {{ aw_rust_release_dir }}/dlp-syslog-forwarder"
|
||||||
when: aw_dlp_integrations_enabled | default(false) | bool
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Установить Rust syslog forwarder
|
- name: Установить Rust syslog forwarder
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1211,7 +1057,7 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
when:
|
when:
|
||||||
- aw_dlp_integrations_enabled | default(false) | bool
|
- aw_dlp_integrations_enabled | default(true) | bool
|
||||||
- dlp_syslog_forwarder_rust_binary.stat.exists | default(false)
|
- dlp_syslog_forwarder_rust_binary.stat.exists | default(false)
|
||||||
|
|
||||||
- name: Установить systemd unit webhook sender
|
- name: Установить systemd unit webhook sender
|
||||||
@@ -1221,7 +1067,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
when: aw_dlp_integrations_enabled | default(false) | bool
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Установить systemd timer webhook sender
|
- name: Установить systemd timer webhook sender
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1230,7 +1076,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
when: aw_dlp_integrations_enabled | default(false) | bool
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Проверить локальный Rust webhook sender
|
- name: Проверить локальный Rust webhook sender
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
@@ -1238,14 +1084,14 @@
|
|||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: dlp_webhook_sender_rust_binary
|
register: dlp_webhook_sender_rust_binary
|
||||||
become: false
|
become: false
|
||||||
when: aw_dlp_integrations_enabled | default(false) | bool
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Требовать Rust webhook sender artifact
|
- name: Требовать Rust webhook sender artifact
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- dlp_webhook_sender_rust_binary.stat.exists | default(false)
|
- dlp_webhook_sender_rust_binary.stat.exists | default(false)
|
||||||
fail_msg: "Missing Rust artifact: {{ aw_rust_release_dir }}/dlp-webhook-sender"
|
fail_msg: "Missing Rust artifact: {{ aw_rust_release_dir }}/dlp-webhook-sender"
|
||||||
when: aw_dlp_integrations_enabled | default(false) | bool
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Установить Rust webhook sender
|
- name: Установить Rust webhook sender
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1255,7 +1101,7 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
when:
|
when:
|
||||||
- aw_dlp_integrations_enabled | default(false) | bool
|
- aw_dlp_integrations_enabled | default(true) | bool
|
||||||
- dlp_webhook_sender_rust_binary.stat.exists | default(false)
|
- dlp_webhook_sender_rust_binary.stat.exists | default(false)
|
||||||
|
|
||||||
- name: Создать каталог DLP case management
|
- name: Создать каталог DLP case management
|
||||||
@@ -1265,9 +1111,7 @@
|
|||||||
owner: "{{ aw_server_user }}"
|
owner: "{{ aw_server_user }}"
|
||||||
group: "{{ aw_server_group }}"
|
group: "{{ aw_server_group }}"
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
when:
|
when: aw_dlp_case_management_enabled | default(true) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_case_management_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Установить systemd unit DLP case management
|
- name: Установить systemd unit DLP case management
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1276,9 +1120,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
when:
|
when: aw_dlp_case_management_enabled | default(true) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_case_management_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Проверить локальный Rust DLP case management
|
- name: Проверить локальный Rust DLP case management
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
@@ -1286,14 +1128,14 @@
|
|||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: aw_dlp_case_management_rust_binary
|
register: aw_dlp_case_management_rust_binary
|
||||||
become: false
|
become: false
|
||||||
when: aw_dlp_case_management_enabled | default(false) | bool
|
when: aw_dlp_case_management_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Требовать Rust DLP case management artifact
|
- name: Требовать Rust DLP case management artifact
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- aw_dlp_case_management_rust_binary.stat.exists | default(false)
|
- aw_dlp_case_management_rust_binary.stat.exists | default(false)
|
||||||
fail_msg: "Missing Rust artifact: {{ aw_rust_release_dir }}/dlp-case-management"
|
fail_msg: "Missing Rust artifact: {{ aw_rust_release_dir }}/dlp-case-management"
|
||||||
when: aw_dlp_case_management_enabled | default(false) | bool
|
when: aw_dlp_case_management_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Установить Rust DLP case management
|
- name: Установить Rust DLP case management
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1303,7 +1145,7 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
when:
|
when:
|
||||||
- aw_dlp_case_management_enabled | default(false) | bool
|
- aw_dlp_case_management_enabled | default(true) | bool
|
||||||
- aw_dlp_case_management_rust_binary.stat.exists | default(false)
|
- aw_dlp_case_management_rust_binary.stat.exists | default(false)
|
||||||
|
|
||||||
- name: Создать каталоги DLP compliance
|
- name: Создать каталоги DLP compliance
|
||||||
@@ -1317,9 +1159,7 @@
|
|||||||
- /opt/activitywatch/dlp-compliance
|
- /opt/activitywatch/dlp-compliance
|
||||||
- /opt/activitywatch/dlp-compliance/templates
|
- /opt/activitywatch/dlp-compliance/templates
|
||||||
- "{{ aw_dlp_compliance_report_dir }}"
|
- "{{ aw_dlp_compliance_report_dir }}"
|
||||||
when:
|
when: aw_dlp_compliance_enabled | default(true) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_compliance_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Скопировать файлы DLP compliance
|
- name: Скопировать файлы DLP compliance
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1333,9 +1173,7 @@
|
|||||||
- { src: "templates/pci-dss-report.html", dest: "/opt/activitywatch/dlp-compliance/templates/pci-dss-report.html", mode: "0644" }
|
- { src: "templates/pci-dss-report.html", dest: "/opt/activitywatch/dlp-compliance/templates/pci-dss-report.html", mode: "0644" }
|
||||||
- { src: "report-scheduler.service", dest: "/etc/systemd/system/aw-dlp-report-scheduler.service", mode: "0644" }
|
- { src: "report-scheduler.service", dest: "/etc/systemd/system/aw-dlp-report-scheduler.service", mode: "0644" }
|
||||||
- { src: "report-scheduler.timer", dest: "/etc/systemd/system/aw-dlp-report-scheduler.timer", mode: "0644" }
|
- { src: "report-scheduler.timer", dest: "/etc/systemd/system/aw-dlp-report-scheduler.timer", mode: "0644" }
|
||||||
when:
|
when: aw_dlp_compliance_enabled | default(true) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_compliance_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Проверить локальный Rust DLP compliance
|
- name: Проверить локальный Rust DLP compliance
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
@@ -1343,18 +1181,14 @@
|
|||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: aw_dlp_compliance_rust_binary
|
register: aw_dlp_compliance_rust_binary
|
||||||
become: false
|
become: false
|
||||||
when:
|
when: aw_dlp_compliance_enabled | default(true) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_compliance_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Требовать Rust DLP compliance artifact
|
- name: Требовать Rust DLP compliance artifact
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- aw_dlp_compliance_rust_binary.stat.exists | default(false)
|
- aw_dlp_compliance_rust_binary.stat.exists | default(false)
|
||||||
fail_msg: "Missing Rust artifact: {{ aw_rust_release_dir }}/dlp-compliance"
|
fail_msg: "Missing Rust artifact: {{ aw_rust_release_dir }}/dlp-compliance"
|
||||||
when:
|
when: aw_dlp_compliance_enabled | default(true) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_compliance_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Установить Rust DLP compliance
|
- name: Установить Rust DLP compliance
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1364,7 +1198,7 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
when:
|
when:
|
||||||
- aw_dlp_compliance_enabled | default(false) | bool
|
- aw_dlp_compliance_enabled | default(true) | bool
|
||||||
- aw_dlp_compliance_rust_binary.stat.exists | default(false)
|
- aw_dlp_compliance_rust_binary.stat.exists | default(false)
|
||||||
|
|
||||||
- name: Проверить локальный Rust dlp-admin-cli
|
- name: Проверить локальный Rust dlp-admin-cli
|
||||||
@@ -1603,47 +1437,6 @@
|
|||||||
mode: "0755"
|
mode: "0755"
|
||||||
when: dlp_health_check_rust_binary.stat.exists | default(false)
|
when: dlp_health_check_rust_binary.stat.exists | default(false)
|
||||||
|
|
||||||
- name: Проверить локальный Rust containment-engine
|
|
||||||
ansible.builtin.stat:
|
|
||||||
path: "{{ aw_rust_release_dir }}/containment-engine"
|
|
||||||
delegate_to: localhost
|
|
||||||
register: containment_engine_rust_binary
|
|
||||||
become: false
|
|
||||||
|
|
||||||
- name: Установить Rust containment-engine
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "{{ aw_rust_release_dir }}/containment-engine"
|
|
||||||
dest: /usr/local/bin/containment-engine
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0755"
|
|
||||||
when: containment_engine_rust_binary.stat.exists | default(false)
|
|
||||||
|
|
||||||
- name: Проверить локальный Rust security-finding-inbox
|
|
||||||
ansible.builtin.stat:
|
|
||||||
path: "{{ aw_rust_release_dir }}/security-finding-inbox"
|
|
||||||
delegate_to: localhost
|
|
||||||
register: security_finding_inbox_rust_binary
|
|
||||||
become: false
|
|
||||||
|
|
||||||
- name: Установить Rust security-finding-inbox
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "{{ aw_rust_release_dir }}/security-finding-inbox"
|
|
||||||
dest: /usr/local/bin/security-finding-inbox
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0755"
|
|
||||||
when: security_finding_inbox_rust_binary.stat.exists | default(false)
|
|
||||||
|
|
||||||
- name: Установить systemd unit Security Finding Inbox executor
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "{{ aw_repo_root }}/ops/systemd/aw-security-finding-executor.service"
|
|
||||||
dest: /etc/systemd/system/aw-security-finding-executor.service
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0644"
|
|
||||||
notify: Перезагрузить systemd
|
|
||||||
|
|
||||||
- name: Проверить локальный Rust AW-RUS healthd
|
- name: Проверить локальный Rust AW-RUS healthd
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ aw_rust_release_dir }}/aw-rus-healthd"
|
path: "{{ aw_rust_release_dir }}/aw-rus-healthd"
|
||||||
@@ -1851,9 +1644,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
when:
|
when: aw_dlp_influx_enabled | default(false) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_influx_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Проверить локальный Rust AW DLP Influx exporter
|
- name: Проверить локальный Rust AW DLP Influx exporter
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
@@ -1861,18 +1652,14 @@
|
|||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: aw_dlp_influx_exporter_rust_binary
|
register: aw_dlp_influx_exporter_rust_binary
|
||||||
become: false
|
become: false
|
||||||
when:
|
when: aw_dlp_influx_enabled | default(false) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_influx_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Требовать Rust AW DLP Influx exporter artifact
|
- name: Требовать Rust AW DLP Influx exporter artifact
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- aw_dlp_influx_exporter_rust_binary.stat.exists | default(false)
|
- aw_dlp_influx_exporter_rust_binary.stat.exists | default(false)
|
||||||
fail_msg: "Missing Rust artifact: {{ aw_rust_release_dir }}/dlp-influx-exporter"
|
fail_msg: "Missing Rust artifact: {{ aw_rust_release_dir }}/dlp-influx-exporter"
|
||||||
when:
|
when: aw_dlp_influx_enabled | default(false) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_influx_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Установить Rust AW DLP Influx exporter
|
- name: Установить Rust AW DLP Influx exporter
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -1892,9 +1679,7 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
when:
|
when: aw_dlp_influx_enabled | default(false) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_influx_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Проверить локальный Rust DetMir readiness checker
|
- name: Проверить локальный Rust DetMir readiness checker
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
@@ -2046,42 +1831,42 @@
|
|||||||
name: aw-dlp-cef-exporter.timer
|
name: aw-dlp-cef-exporter.timer
|
||||||
enabled: true
|
enabled: true
|
||||||
state: restarted
|
state: restarted
|
||||||
when: aw_dlp_integrations_enabled | default(false) | bool
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Включить и перезапустить timer syslog forwarder
|
- name: Включить и перезапустить timer syslog forwarder
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: aw-dlp-syslog-forwarder.timer
|
name: aw-dlp-syslog-forwarder.timer
|
||||||
enabled: true
|
enabled: true
|
||||||
state: restarted
|
state: restarted
|
||||||
when: aw_dlp_integrations_enabled | default(false) | bool
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Включить и перезапустить timer webhook sender
|
- name: Включить и перезапустить timer webhook sender
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: aw-dlp-webhook-sender.timer
|
name: aw-dlp-webhook-sender.timer
|
||||||
enabled: true
|
enabled: true
|
||||||
state: restarted
|
state: restarted
|
||||||
when: aw_dlp_integrations_enabled | default(false) | bool
|
when: aw_dlp_integrations_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Включить и перезапустить DLP case management
|
- name: Включить и перезапустить DLP case management
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: aw-dlp-case-management.service
|
name: aw-dlp-case-management.service
|
||||||
enabled: true
|
enabled: true
|
||||||
state: restarted
|
state: restarted
|
||||||
when: aw_dlp_case_management_enabled | default(false) | bool
|
when: aw_dlp_case_management_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Включить и перезапустить timer DLP compliance report
|
- name: Включить и перезапустить timer DLP compliance report
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: aw-dlp-report-scheduler.timer
|
name: aw-dlp-report-scheduler.timer
|
||||||
enabled: true
|
enabled: true
|
||||||
state: restarted
|
state: restarted
|
||||||
when: aw_dlp_compliance_enabled | default(false) | bool
|
when: aw_dlp_compliance_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Выполнить разовый прогон DLP compliance report
|
- name: Выполнить разовый прогон DLP compliance report
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: aw-dlp-report-scheduler.service
|
name: aw-dlp-report-scheduler.service
|
||||||
state: started
|
state: started
|
||||||
failed_when: false
|
failed_when: false
|
||||||
when: aw_dlp_compliance_enabled | default(false) | bool
|
when: aw_dlp_compliance_enabled | default(true) | bool
|
||||||
|
|
||||||
- name: Включить и перезапустить AW worktime API
|
- name: Включить и перезапустить AW worktime API
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
@@ -2448,11 +2233,6 @@
|
|||||||
mode: "0755"
|
mode: "0755"
|
||||||
when: dlp_aggregator_rust_binary.stat.exists | default(false)
|
when: dlp_aggregator_rust_binary.stat.exists | default(false)
|
||||||
|
|
||||||
- name: Удалить stale drop-in, переопределяющий lightweight DLP aggregator
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: /etc/systemd/system/activitywatch-dlp-aggregator.service.d/20-rust-switch.conf
|
|
||||||
state: absent
|
|
||||||
|
|
||||||
- name: Установить systemd unit для агрегатора
|
- name: Установить systemd unit для агрегатора
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
dest: /etc/systemd/system/activitywatch-dlp-aggregator.service
|
dest: /etc/systemd/system/activitywatch-dlp-aggregator.service
|
||||||
@@ -2461,7 +2241,7 @@
|
|||||||
mode: "0644"
|
mode: "0644"
|
||||||
content: |
|
content: |
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=ActivityWatch Lightweight DLP Event Aggregator
|
Description=ActivityWatch DLP Event Aggregator
|
||||||
After=activitywatch-server.service
|
After=activitywatch-server.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
@@ -2471,18 +2251,7 @@
|
|||||||
ExecStart=/usr/local/bin/dlp-aggregator-rust \
|
ExecStart=/usr/local/bin/dlp-aggregator-rust \
|
||||||
--aw-url http://127.0.0.1:{{ aw_server_port }}/api/0 \
|
--aw-url http://127.0.0.1:{{ aw_server_port }}/api/0 \
|
||||||
--sqlite-path {{ aw_server_data_dir }}/dlp_warehouse.sqlite \
|
--sqlite-path {{ aw_server_data_dir }}/dlp_warehouse.sqlite \
|
||||||
--state-path {{ aw_server_data_dir }}/dlp-aggregator-state.json \
|
--state-path {{ aw_server_data_dir }}/dlp-aggregator-state.json
|
||||||
--bucket-prefixes {{ aw_dlp_aggregator_bucket_prefixes | default('aw-file-operations_,aw-dlp-incidents_') }} \
|
|
||||||
--lookback-hours {{ aw_dlp_aggregator_lookback_hours | default(2) }} \
|
|
||||||
--overlap-seconds {{ aw_dlp_aggregator_overlap_seconds | default(60) }} \
|
|
||||||
--limit {{ aw_dlp_aggregator_limit | default(500) }} \
|
|
||||||
--timeout {{ aw_dlp_aggregator_timeout_seconds | default(8) }}
|
|
||||||
Nice=10
|
|
||||||
IOSchedulingClass=best-effort
|
|
||||||
IOSchedulingPriority=7
|
|
||||||
CPUQuota={{ aw_dlp_aggregator_cpu_quota | default('10%') }}
|
|
||||||
MemoryMax={{ aw_dlp_aggregator_memory_max | default('256M') }}
|
|
||||||
TimeoutStartSec={{ (aw_dlp_aggregator_timeout_seconds | default(8) | int) + 15 }}
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
@@ -2492,10 +2261,10 @@
|
|||||||
dest: /etc/systemd/system/activitywatch-dlp-aggregator.timer
|
dest: /etc/systemd/system/activitywatch-dlp-aggregator.timer
|
||||||
content: |
|
content: |
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Run ActivityWatch Lightweight DLP Aggregator
|
Description=Run ActivityWatch DLP Aggregator every 5 minutes
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar={{ aw_dlp_aggregator_on_calendar | default('*:3/15:10') }}
|
OnCalendar=*:3/10:10
|
||||||
AccuracySec=30s
|
AccuracySec=30s
|
||||||
RandomizedDelaySec=30s
|
RandomizedDelaySec=30s
|
||||||
Persistent=false
|
Persistent=false
|
||||||
@@ -2509,14 +2278,9 @@
|
|||||||
enabled: true
|
enabled: true
|
||||||
state: started
|
state: started
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
when:
|
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_light_collector_enabled | default(false) | bool
|
|
||||||
|
|
||||||
- name: Настроить IOC enrichment из Hayabusa Sigma
|
- name: Настроить IOC enrichment из Hayabusa Sigma
|
||||||
when:
|
when: aw_dlp_ioc_enabled | default(false) | bool
|
||||||
- aw_dlp_enabled | default(false) | bool
|
|
||||||
- aw_dlp_ioc_enabled | default(false) | bool
|
|
||||||
block:
|
block:
|
||||||
- name: Создать каталог IOC enrichment
|
- name: Создать каталог IOC enrichment
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
|
|||||||
@@ -15,16 +15,8 @@
|
|||||||
detmir_portal_workforce_policy_path: "/etc/detmir-portal-workforce-policy.json"
|
detmir_portal_workforce_policy_path: "/etc/detmir-portal-workforce-policy.json"
|
||||||
detmir_portal_ueba_policy_path: "/etc/detmir-portal-ueba-policy.yaml"
|
detmir_portal_ueba_policy_path: "/etc/detmir-portal-ueba-policy.yaml"
|
||||||
detmir_portal_readiness_bundle_dir: "{{ detmir_portal_readiness_bundle_dir_override | default('/var/lib/activitywatch/health/readiness-bundle', true) }}"
|
detmir_portal_readiness_bundle_dir: "{{ detmir_portal_readiness_bundle_dir_override | default('/var/lib/activitywatch/health/readiness-bundle', true) }}"
|
||||||
detmir_portal_dlp_module_enabled: "{{ detmir_portal_dlp_module_enabled_override | default(false) }}"
|
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Refuse inconsistent DetMir portal DLP profile
|
|
||||||
ansible.builtin.assert:
|
|
||||||
that:
|
|
||||||
- detmir_portal_dlp_profile | default('core_only') in ['core_only', 'light', 'on_demand', 'full']
|
|
||||||
- (detmir_portal_dlp_profile | default('core_only') != 'core_only') or not (detmir_portal_dlp_module_enabled | bool)
|
|
||||||
fail_msg: "Inconsistent DetMir portal DLP profile: core_only must keep DETMIR_PORTAL_DLP_MODULE_ENABLED=false."
|
|
||||||
|
|
||||||
- name: Check local detmir-portal binary
|
- name: Check local detmir-portal binary
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ aw_rust_release_dir }}/detmir-portal"
|
path: "{{ aw_rust_release_dir }}/detmir-portal"
|
||||||
@@ -62,8 +54,6 @@
|
|||||||
DETMIR_PORTAL_UEBA_POLICY_PATH={{ detmir_portal_ueba_policy_path }}
|
DETMIR_PORTAL_UEBA_POLICY_PATH={{ detmir_portal_ueba_policy_path }}
|
||||||
DETMIR_PORTAL_TIMEOUT_SECONDS=25
|
DETMIR_PORTAL_TIMEOUT_SECONDS=25
|
||||||
DETMIR_PORTAL_STATE_DIR=/var/lib/detmir-portal
|
DETMIR_PORTAL_STATE_DIR=/var/lib/detmir-portal
|
||||||
DETMIR_PORTAL_DLP_MODULE_ENABLED={{ detmir_portal_dlp_module_enabled | bool | ternary('true', 'false') }}
|
|
||||||
DETMIR_PORTAL_DLP_PROFILE={{ detmir_portal_dlp_profile | default('core_only') }}
|
|
||||||
DETMIR_PORTAL_DLP_DB_PATH=/var/lib/activitywatch/dlp_warehouse.sqlite
|
DETMIR_PORTAL_DLP_DB_PATH=/var/lib/activitywatch/dlp_warehouse.sqlite
|
||||||
DETMIR_PORTAL_EVIDENCE_ROOT=/var/lib/detmir-portal/evidence
|
DETMIR_PORTAL_EVIDENCE_ROOT=/var/lib/detmir-portal/evidence
|
||||||
DETMIR_PORTAL_READINESS_BUNDLE_DIR={{ detmir_portal_readiness_bundle_dir }}
|
DETMIR_PORTAL_READINESS_BUNDLE_DIR={{ detmir_portal_readiness_bundle_dir }}
|
||||||
@@ -75,65 +65,6 @@
|
|||||||
CLICKHOUSE_USER={{ detmir_clickhouse_user | default('default') }}
|
CLICKHOUSE_USER={{ detmir_clickhouse_user | default('default') }}
|
||||||
CLICKHOUSE_PASSWORD={{ detmir_clickhouse_password | default('') }}
|
CLICKHOUSE_PASSWORD={{ detmir_clickhouse_password | default('') }}
|
||||||
|
|
||||||
- name: Install lightweight DLP warehouse sync helper
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "{{ aw_repo_root }}/scripts/detmir_dlp_warehouse_sync.sh"
|
|
||||||
dest: /usr/local/bin/detmir-dlp-warehouse-sync
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
- name: Install lightweight DLP warehouse sync service
|
|
||||||
ansible.builtin.copy:
|
|
||||||
dest: /etc/systemd/system/detmir-dlp-warehouse-sync.service
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0644"
|
|
||||||
content: |
|
|
||||||
[Unit]
|
|
||||||
Description=Sync lightweight DetMir DLP SQLite warehouse for portal
|
|
||||||
After=network-online.target
|
|
||||||
Wants=network-online.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
Environment=AW_DLP_WAREHOUSE_SOURCE_HOST={{ detmir_portal_dlp_warehouse_source_host | default('igor@10.10.10.13') }}
|
|
||||||
Environment=AW_DLP_WAREHOUSE_SOURCE_PATH={{ detmir_portal_dlp_warehouse_source_path | default('/var/lib/activitywatch/dlp_warehouse.sqlite') }}
|
|
||||||
Environment=AW_DLP_WAREHOUSE_DEST_PATH={{ detmir_portal_dlp_warehouse_dest_path | default('/var/lib/activitywatch/dlp_warehouse.sqlite') }}
|
|
||||||
Environment=AW_DLP_WAREHOUSE_SYNC_STATE_DIR={{ detmir_portal_dlp_warehouse_sync_state_dir | default('/var/lib/activitywatch/health') }}
|
|
||||||
ExecStart=/usr/local/bin/detmir-dlp-warehouse-sync
|
|
||||||
Nice=10
|
|
||||||
IOSchedulingClass=best-effort
|
|
||||||
IOSchedulingPriority=7
|
|
||||||
TimeoutStartSec=60
|
|
||||||
|
|
||||||
- name: Install lightweight DLP warehouse sync timer
|
|
||||||
ansible.builtin.copy:
|
|
||||||
dest: /etc/systemd/system/detmir-dlp-warehouse-sync.timer
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0644"
|
|
||||||
content: |
|
|
||||||
[Unit]
|
|
||||||
Description=Run lightweight DetMir DLP SQLite warehouse sync
|
|
||||||
|
|
||||||
[Timer]
|
|
||||||
OnBootSec=4min
|
|
||||||
OnUnitActiveSec={{ detmir_portal_dlp_warehouse_sync_interval | default('2min') }}
|
|
||||||
AccuracySec=30s
|
|
||||||
Persistent=false
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=timers.target
|
|
||||||
|
|
||||||
- name: Enable lightweight DLP warehouse sync timer
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
name: detmir-dlp-warehouse-sync.timer
|
|
||||||
enabled: true
|
|
||||||
state: started
|
|
||||||
daemon_reload: true
|
|
||||||
when: detmir_portal_dlp_module_enabled | bool
|
|
||||||
|
|
||||||
- name: Preserve local ClickHouse security-events settings when available
|
- name: Preserve local ClickHouse security-events settings when available
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@@ -186,9 +117,7 @@
|
|||||||
state: absent
|
state: absent
|
||||||
loop:
|
loop:
|
||||||
- /etc/systemd/system/detmir-portal.service.d/20-timeouts.conf
|
- /etc/systemd/system/detmir-portal.service.d/20-timeouts.conf
|
||||||
- /etc/systemd/system/detmir-portal.service.d/20-prod-timeout.conf
|
|
||||||
- /etc/systemd/system/detmir-portal.service.d/30-warm-cache.conf
|
- /etc/systemd/system/detmir-portal.service.d/30-warm-cache.conf
|
||||||
- /etc/systemd/system/detmir-portal.service.d/30-prewarm-after-start.conf
|
|
||||||
register: detmir_portal_stale_overrides
|
register: detmir_portal_stale_overrides
|
||||||
|
|
||||||
- name: Install initial workforce policy when absent
|
- name: Install initial workforce policy when absent
|
||||||
@@ -245,11 +174,6 @@
|
|||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
register: detmir_portal_service_unit
|
register: detmir_portal_service_unit
|
||||||
|
|
||||||
- name: Remove stale detmir-portal timeout override
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: /etc/systemd/system/detmir-portal.service.d/10-detmir-check-env.conf
|
|
||||||
state: absent
|
|
||||||
|
|
||||||
- name: Reload systemd
|
- name: Reload systemd
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|||||||
@@ -33,10 +33,7 @@ aw_worktime_manager_trend_min_points: 3
|
|||||||
aw_worktime_manager_trend_delta_pct: 10
|
aw_worktime_manager_trend_delta_pct: 10
|
||||||
aw_worktime_manager_off_hours_threshold_seconds: 1800
|
aw_worktime_manager_off_hours_threshold_seconds: 1800
|
||||||
aw_worktime_interpretation_policy_path: "/etc/activitywatch/worktime-interpretation-policy.json"
|
aw_worktime_interpretation_policy_path: "/etc/activitywatch/worktime-interpretation-policy.json"
|
||||||
aw_dlp_profile: "core_only"
|
aw_dlp_influx_enabled: true
|
||||||
detmir_portal_dlp_profile: "light"
|
|
||||||
detmir_portal_dlp_module_enabled_override: true
|
|
||||||
aw_dlp_influx_enabled: false
|
|
||||||
aw_dlp_influx_url: "http://192.0.2.10:8086"
|
aw_dlp_influx_url: "http://192.0.2.10:8086"
|
||||||
aw_dlp_influx_org: "proxmox"
|
aw_dlp_influx_org: "proxmox"
|
||||||
aw_dlp_influx_bucket: "aw_metrics"
|
aw_dlp_influx_bucket: "aw_metrics"
|
||||||
@@ -50,7 +47,6 @@ aw_worktime_host: "{{ aw_monitored_windows_hostname }}"
|
|||||||
aw_rus_health_worktime_api_base: "http://127.0.0.1:5610"
|
aw_rus_health_worktime_api_base: "http://127.0.0.1:5610"
|
||||||
aw_rus_health_state_dir: "{{ aw_server_data_dir }}/health"
|
aw_rus_health_state_dir: "{{ aw_server_data_dir }}/health"
|
||||||
aw_rus_health_validation_dir: "{{ aw_rus_health_state_dir }}/windows-validation"
|
aw_rus_health_validation_dir: "{{ aw_rus_health_state_dir }}/windows-validation"
|
||||||
aw_rus_health_rdp_tcp_required: false
|
|
||||||
aw_hayabusa_auto_case_enabled: true
|
aw_hayabusa_auto_case_enabled: true
|
||||||
aw_hayabusa_auto_case_min_severity: "medium"
|
aw_hayabusa_auto_case_min_severity: "medium"
|
||||||
aw_hayabusa_telegram_enabled: true
|
aw_hayabusa_telegram_enabled: true
|
||||||
@@ -69,46 +65,22 @@ aw_server_cors_origins:
|
|||||||
|
|
||||||
aw_apply_worktime_settings: true
|
aw_apply_worktime_settings: true
|
||||||
|
|
||||||
aw_dlp_ioc_enabled: false
|
aw_dlp_ioc_enabled: true
|
||||||
aw_dlp_enabled: false
|
|
||||||
aw_dlp_disabled_reason: ""
|
|
||||||
aw_dlp_disabled_since: ""
|
|
||||||
aw_dlp_light_collector_enabled: false
|
|
||||||
aw_dlp_light_guard_enabled: true
|
|
||||||
aw_dlp_light_guard_load_ratio: "1.50"
|
|
||||||
aw_dlp_light_guard_mem_available_pct_min: "15"
|
|
||||||
aw_dlp_light_guard_iowait_pct_max: "20"
|
|
||||||
aw_dlp_light_guard_strikes_required: 3
|
|
||||||
aw_dlp_light_guard_state_dir: "{{ aw_server_data_dir }}/health"
|
|
||||||
aw_dlp_aggregator_bucket_prefixes: "aw-file-operations_,aw-dlp-incidents_"
|
|
||||||
aw_dlp_aggregator_limit: 500
|
|
||||||
aw_dlp_aggregator_lookback_hours: 2
|
|
||||||
aw_dlp_aggregator_overlap_seconds: 60
|
|
||||||
aw_dlp_aggregator_timeout_seconds: 8
|
|
||||||
aw_dlp_aggregator_on_calendar: "*:3/15:10"
|
|
||||||
aw_dlp_aggregator_cpu_quota: "10%"
|
|
||||||
aw_dlp_aggregator_memory_max: "256M"
|
|
||||||
aw_containment_enabled: false
|
|
||||||
aw_containment_mode: "shadow"
|
|
||||||
aw_containment_policy_path: "/etc/activitywatch/containment-policy.json"
|
|
||||||
aw_containment_default_ttl_minutes: 60
|
|
||||||
aw_containment_require_admin_channel_check: true
|
|
||||||
aw_containment_allow_auto_for_servers: false
|
|
||||||
aw_dlp_ioc_workdir: "/opt/activitywatch/dlp-ioc"
|
aw_dlp_ioc_workdir: "/opt/activitywatch/dlp-ioc"
|
||||||
aw_dlp_ioc_rules_zip_url: "https://github.com/Yamato-Security/hayabusa-rules/archive/refs/heads/main.zip"
|
aw_dlp_ioc_rules_zip_url: "https://github.com/Yamato-Security/hayabusa-rules/archive/refs/heads/main.zip"
|
||||||
aw_dlp_ioc_refresh_on_boot_sec: "5min"
|
aw_dlp_ioc_refresh_on_boot_sec: "5min"
|
||||||
aw_dlp_ioc_refresh_interval: "6h"
|
aw_dlp_ioc_refresh_interval: "6h"
|
||||||
aw_dlp_policy_engine_enabled: false
|
aw_dlp_policy_engine_enabled: true
|
||||||
aw_dlp_policy_engine_bind_host: "0.0.0.0"
|
aw_dlp_policy_engine_bind_host: "0.0.0.0"
|
||||||
aw_dlp_policy_engine_port: 5601
|
aw_dlp_policy_engine_port: 5601
|
||||||
aw_dlp_policy_engine_db_path: "{{ aw_server_data_dir }}/dlp-policy-engine.sqlite"
|
aw_dlp_policy_engine_db_path: "{{ aw_server_data_dir }}/dlp-policy-engine.sqlite"
|
||||||
aw_dlp_content_analysis_enabled: false
|
aw_dlp_content_analysis_enabled: true
|
||||||
aw_dlp_integrations_enabled: false
|
aw_dlp_integrations_enabled: true
|
||||||
aw_dlp_case_management_enabled: false
|
aw_dlp_case_management_enabled: true
|
||||||
aw_dlp_case_bind_host: "0.0.0.0"
|
aw_dlp_case_bind_host: "0.0.0.0"
|
||||||
aw_dlp_case_port: 5602
|
aw_dlp_case_port: 5602
|
||||||
aw_dlp_case_db_path: "/opt/activitywatch/dlp-case-management/cases.db"
|
aw_dlp_case_db_path: "/opt/activitywatch/dlp-case-management/cases.db"
|
||||||
aw_dlp_compliance_enabled: false
|
aw_dlp_compliance_enabled: true
|
||||||
aw_dlp_compliance_report_dir: "/opt/activitywatch/dlp-compliance/reports"
|
aw_dlp_compliance_report_dir: "/opt/activitywatch/dlp-compliance/reports"
|
||||||
aw_dlp_compliance_template_path: "/opt/activitywatch/dlp-compliance/templates/152-fz-report.html"
|
aw_dlp_compliance_template_path: "/opt/activitywatch/dlp-compliance/templates/152-fz-report.html"
|
||||||
aw_server_post_deploy_health_check_enabled: true
|
aw_server_post_deploy_health_check_enabled: true
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ AW_SERVER_GROUP=activitywatch
|
|||||||
AW_SERVER_PUBLIC_HOST=aw-server
|
AW_SERVER_PUBLIC_HOST=aw-server
|
||||||
AW_WORKTIME_REPORT_BASE=http://aw-server:5610
|
AW_WORKTIME_REPORT_BASE=http://aw-server:5610
|
||||||
AW_WORKTIME_TZ=Europe/Moscow
|
AW_WORKTIME_TZ=Europe/Moscow
|
||||||
AW_WORKTIME_HOST=HOST-EXAMPLE
|
AW_WORKTIME_HOST=SHARKON2025
|
||||||
AW_WORKTIME_EVENTS_LIMIT=5000
|
AW_WORKTIME_EVENTS_LIMIT=5000
|
||||||
AW_WORKTIME_AW_HTTP_TIMEOUT_SECONDS=6
|
AW_WORKTIME_AW_HTTP_TIMEOUT_SECONDS=6
|
||||||
AW_WORKTIME_EVENTS_CACHE_TTL_SECONDS=300
|
AW_WORKTIME_EVENTS_CACHE_TTL_SECONDS=300
|
||||||
@@ -33,16 +33,6 @@ AW_WORKTIME_MANAGEMENT_WARM_URL=http://127.0.0.1:5610/reports/worktime/managemen
|
|||||||
AW_WORKTIME_MANAGEMENT_WARM_TIMEOUT_SECONDS=70
|
AW_WORKTIME_MANAGEMENT_WARM_TIMEOUT_SECONDS=70
|
||||||
|
|
||||||
# DLP IOC Configuration
|
# DLP IOC Configuration
|
||||||
AW_DLP_ENABLED=false
|
|
||||||
AW_DLP_PROFILE=core_only
|
|
||||||
AW_DLP_DISABLED_REASON=detmir_prod_resource_guardrail
|
|
||||||
AW_DLP_DISABLED_SINCE=
|
|
||||||
AW_CONTAINMENT_ENABLED=false
|
|
||||||
AW_CONTAINMENT_MODE=shadow
|
|
||||||
AW_CONTAINMENT_POLICY=/etc/activitywatch/containment-policy.json
|
|
||||||
AW_CONTAINMENT_DEFAULT_TTL_MINUTES=60
|
|
||||||
AW_CONTAINMENT_REQUIRE_ADMIN_CHANNEL_CHECK=true
|
|
||||||
AW_CONTAINMENT_ALLOW_AUTO_FOR_SERVERS=false
|
|
||||||
AW_DLP_IOC_DIR=/opt/activitywatch/dlp-ioc/output
|
AW_DLP_IOC_DIR=/opt/activitywatch/dlp-ioc/output
|
||||||
|
|
||||||
# DLP Policy Engine Configuration
|
# DLP Policy Engine Configuration
|
||||||
@@ -60,24 +50,22 @@ AW_HEALTH_CHECK_ENABLED=true
|
|||||||
AW_HEALTH_CHECK_INTERVAL=60
|
AW_HEALTH_CHECK_INTERVAL=60
|
||||||
AW_EXPECT_START_OF_DAY=00:00
|
AW_EXPECT_START_OF_DAY=00:00
|
||||||
AW_EXPECT_ALWAYS_ACTIVE_PATTERN=aw-watcher-window
|
AW_EXPECT_ALWAYS_ACTIVE_PATTERN=aw-watcher-window
|
||||||
AW_EXPECT_LANDINGPAGE=/#/activity/HOST-EXAMPLE/view/
|
AW_EXPECT_LANDINGPAGE=/#/activity/SHARKON2025/view/
|
||||||
AW_HEALTH_STRICT_FILEOPS=0
|
AW_HEALTH_STRICT_FILEOPS=0
|
||||||
AW_MONITORED_WINDOWS_HOST=<WINDOWS_HOST>
|
AW_MONITORED_WINDOWS_HOST=<WINDOWS_HOST>
|
||||||
AW_MONITORED_WINDOWS_HOSTNAME=HOST-EXAMPLE
|
AW_MONITORED_WINDOWS_HOSTNAME=SHARKON2025
|
||||||
AW_RUS_HEALTH_WORKTIME_API=http://127.0.0.1:5610
|
AW_RUS_HEALTH_WORKTIME_API=http://127.0.0.1:5610
|
||||||
AW_RUS_HEALTH_STATE_DIR=/var/lib/activitywatch/health
|
AW_RUS_HEALTH_STATE_DIR=/var/lib/activitywatch/health
|
||||||
AW_RUS_HEALTH_VALIDATION_DIR=/var/lib/activitywatch/health/windows-validation
|
AW_RUS_HEALTH_VALIDATION_DIR=/var/lib/activitywatch/health/windows-validation
|
||||||
AW_RUS_HEALTH_SESSION_EVENTS_MAX_AGE_SECONDS=86400
|
AW_RUS_HEALTH_SESSION_EVENTS_MAX_AGE_SECONDS=86400
|
||||||
AW_RUS_HEALTH_GUARD_MAX_AGE_SECONDS=300
|
AW_RUS_HEALTH_GUARD_MAX_AGE_SECONDS=300
|
||||||
AW_RUS_HEALTH_GUARD_REQUIRED=1
|
AW_RUS_HEALTH_GUARD_REQUIRED=1
|
||||||
AW_RUS_HEALTH_RDP_TCP_REQUIRED=true
|
|
||||||
AW_RUS_HEALTH_WRAPPER_TIMEOUT_SECONDS=90
|
|
||||||
AW_RUS_SLO_AW_BASE=http://127.0.0.1:5600
|
AW_RUS_SLO_AW_BASE=http://127.0.0.1:5600
|
||||||
AW_RUS_SLO_WORKTIME_BASE=http://127.0.0.1:5610
|
AW_RUS_SLO_WORKTIME_BASE=http://127.0.0.1:5610
|
||||||
AW_RUS_SLO_TARGET_PERCENT=99.97
|
AW_RUS_SLO_TARGET_PERCENT=99.97
|
||||||
AW_BROWSER_SMOKE_AW_BASE=http://127.0.0.1:5600
|
AW_BROWSER_SMOKE_AW_BASE=http://127.0.0.1:5600
|
||||||
AW_BROWSER_SMOKE_WORKTIME_BASE=http://127.0.0.1:5610
|
AW_BROWSER_SMOKE_WORKTIME_BASE=http://127.0.0.1:5610
|
||||||
AW_BROWSER_SMOKE_HOST=HOST-EXAMPLE
|
AW_BROWSER_SMOKE_HOST=SHARKON2025
|
||||||
AW_BROWSER_SMOKE_OUTPUT_DIR=/var/lib/activitywatch/browser-smoke
|
AW_BROWSER_SMOKE_OUTPUT_DIR=/var/lib/activitywatch/browser-smoke
|
||||||
AW_BROWSER_SMOKE_KEEP_RUNS=24
|
AW_BROWSER_SMOKE_KEEP_RUNS=24
|
||||||
AW_BROWSER_SMOKE_ENGINE=chromium-cli
|
AW_BROWSER_SMOKE_ENGINE=chromium-cli
|
||||||
@@ -91,15 +79,6 @@ AW_HAYABUSA_TELEGRAM_ENABLED=true
|
|||||||
AW_HAYABUSA_TELEGRAM_MIN_SEVERITY=high
|
AW_HAYABUSA_TELEGRAM_MIN_SEVERITY=high
|
||||||
AW_HAYABUSA_TELEGRAM_BOT_TOKEN=
|
AW_HAYABUSA_TELEGRAM_BOT_TOKEN=
|
||||||
AW_HAYABUSA_TELEGRAM_CHAT_IDS=
|
AW_HAYABUSA_TELEGRAM_CHAT_IDS=
|
||||||
AW_SECURITY_FINDING_INBOX_ENABLED=false
|
|
||||||
AW_SECURITY_FINDING_INBOX_REQUIRED=false
|
|
||||||
AW_SECURITY_FINDING_INBOX_BIN=/usr/local/bin/security-finding-inbox
|
|
||||||
AW_SECURITY_FINDING_INBOX_MIN_SEVERITY=medium
|
|
||||||
AW_SECURITY_FINDING_EXECUTOR_WORK_DIR=/var/lib/activitywatch/security-finding-executor
|
|
||||||
AW_SECURITY_FINDING_EXECUTOR_LOCK=/var/lock/aw-security-finding-executor.lock
|
|
||||||
AW_CONTAINMENT_ENGINE_BIN=/usr/local/bin/containment-engine
|
|
||||||
AW_CONTAINMENT_MANAGEMENT_ALLOWLIST=
|
|
||||||
AW_CONTAINMENT_BLOCKED_REMOTE_ADDRESSES=
|
|
||||||
|
|
||||||
# Integration Test Configuration
|
# Integration Test Configuration
|
||||||
AW_INTEGRATION_TEST_ENABLED=false
|
AW_INTEGRATION_TEST_ENABLED=false
|
||||||
|
|||||||
Generated
+3
-3
@@ -638,15 +638,15 @@ wheels = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "starlette"
|
name = "starlette"
|
||||||
version = "1.1.0"
|
version = "1.3.1"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "anyio" },
|
{ name = "anyio" },
|
||||||
{ name = "typing-extensions", marker = "python_full_version < '3.13'" },
|
{ name = "typing-extensions", marker = "python_full_version < '3.13'" },
|
||||||
]
|
]
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/95/66/4d20cdf39a8d6a51e663b7038e3b828ff211d3891a43a713fe7e4643f3a8/starlette-1.1.0.tar.gz", hash = "sha256:e83c7fe0ddecd8719c5b840080325aec0260acec86e9832899e377b91d65e90f", size = 2660060, upload-time = "2026-05-23T16:55:41.376Z" }
|
sdist = { url = "https://files.pythonhosted.org/packages/eb/e3/7c1dc7381d9f8ab7d854328ebfa884e62cb3f3d8549ddfd37c7814f42afa/starlette-1.3.1.tar.gz", hash = "sha256:05d0213193f2fbaae60e2ecb593b4add4262ad4e46536b54abe36f11a71724e0", size = 2703240, upload-time = "2026-06-12T09:23:11.602Z" }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/93/79/920b8e0a8b20f793e8d64855095cb8febabf6175b8550b6f7a547d813891/starlette-1.1.0-py3-none-any.whl", hash = "sha256:7f0dfd38e428aad5cb6f9f667f0ca1d2d8ca3f3385dccac8305f79ec98458382", size = 72899, upload-time = "2026-05-23T16:55:39.201Z" },
|
{ url = "https://files.pythonhosted.org/packages/ec/bb/2799cc2ede3ed41131f8975621e7213dfc7ef4acbbaadfa440f32500c370/starlette-1.3.1-py3-none-any.whl", hash = "sha256:c7372aae11c3c3f26a42df7bd626cec2f47d03483d261d369516a615a53714c6", size = 73632, upload-time = "2026-06-12T09:23:10.017Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -26,38 +26,19 @@ logical host id остаётся `SHARKON2025`. Подробный post-restore
|
|||||||
`653b22b0fbf29a22f7de42ade7b689490b1de16fa07e785e4e0efd3078e7a3bc`.
|
`653b22b0fbf29a22f7de42ade7b689490b1de16fa07e785e4e0efd3078e7a3bc`.
|
||||||
- Бэкап предыдущего binary на сервере:
|
- Бэкап предыдущего binary на сервере:
|
||||||
`/usr/local/bin/detmir-portal.bak.20260625T045640Z`.
|
`/usr/local/bin/detmir-portal.bak.20260625T045640Z`.
|
||||||
- Runtime mode после 2026-06-30 prod hardening:
|
- Runtime mode после phase 1 deploy:
|
||||||
server-side DLP runtime зафиксирован в `core_only/disabled`.
|
`DETMIR_PORTAL_DLP_MODULE_ENABLED=false`.
|
||||||
Portal DLP UI/API module может оставаться включённым для чтения исторического
|
|
||||||
SQLite/evidence-среза, но это не означает запуск DLP collectors/exporters.
|
|
||||||
- Server-side optional DLP runtime control:
|
- Server-side optional DLP runtime control:
|
||||||
`AW_DLP_ENABLED=false|true` и `DETMIR_DLP_ENABLED=false|true`.
|
`AW_DLP_ENABLED=false|true` и `DETMIR_DLP_ENABLED=false|true`.
|
||||||
- Current resource profile: `AW_DLP_ENABLED=false`,
|
|
||||||
`AW_DLP_PROFILE=core_only`; возврат в `light` выполняется только вручную
|
|
||||||
после проверки нагрузки.
|
|
||||||
- Runtime control/statistics script:
|
- Runtime control/statistics script:
|
||||||
`scripts/detmir_dlp_runtime_control.sh` / live
|
`scripts/detmir_dlp_runtime_control.sh` / live
|
||||||
`/usr/local/bin/detmir-dlp-runtime-control`.
|
`/usr/local/bin/detmir-dlp-runtime-control`.
|
||||||
- DLP runtime state after 2026-06-30 prod hardening:
|
- Live DLP runtime state after 2026-06-25 controlled disable:
|
||||||
`AW_DLP_ENABLED=false`, `AW_DLP_PROFILE=core_only`,
|
`AW_DLP_ENABLED=false`, `AW_DLP_INFLUX_ENABLED=false`;
|
||||||
`AW_DLP_INFLUX_ENABLED=false`; optional DLP units should be
|
active/enabled DLP units: `0/0`.
|
||||||
`inactive/disabled`. `detmir-dlp-load-guard.timer` remains enabled and active
|
|
||||||
as protection for any later operator re-enable.
|
|
||||||
- Reason: DLP runtime materially increases Proxmox VM/LXC, InfluxDB, Grafana,
|
- Reason: DLP runtime materially increases Proxmox VM/LXC, InfluxDB, Grafana,
|
||||||
ClickHouse and AW server load. In production DetMir the safe default is
|
ClickHouse and AW server load. In production DetMir it is currently kept
|
||||||
`core_only`; `light` is a reconnectable profile, not the automatic default.
|
disabled, but remains a documented optional module that can be enabled later.
|
||||||
- Auto-disable guard:
|
|
||||||
`scripts/detmir_dlp_load_guard.sh` / live
|
|
||||||
`/usr/local/bin/detmir-dlp-load-guard`. При перегрузе переводит DLP в
|
|
||||||
`core_only` через runtime-control и пишет evidence в
|
|
||||||
`/var/lib/activitywatch/health/dlp-light-guard-state.json`.
|
|
||||||
- DLP warehouse sync для портала:
|
|
||||||
`scripts/detmir_dlp_warehouse_sync.sh` / live
|
|
||||||
`/usr/local/bin/detmir-dlp-warehouse-sync`. Доставляет локальный SQLite
|
|
||||||
snapshot на portal host для UEBA/DLP views без heavy DLP hot path.
|
|
||||||
- Loki CT is intentionally excluded from the current DetMir production resource
|
|
||||||
profile. It must not be returned by routine deploy/recovery while the goal is
|
|
||||||
to keep Proxmox VM/LXC load low.
|
|
||||||
- Health после деплоя: `/healthz` возвращал `status=ok`.
|
- Health после деплоя: `/healthz` возвращал `status=ok`.
|
||||||
- Readiness после деплоя: `/readyz` возвращал `status=ready`.
|
- Readiness после деплоя: `/readyz` возвращал `status=ready`.
|
||||||
|
|
||||||
@@ -103,11 +84,9 @@ logical host id остаётся `SHARKON2025`. Подробный post-restore
|
|||||||
- DLP evidence, screenshots, endpoint signals, case review и forensics
|
- DLP evidence, screenshots, endpoint signals, case review и forensics
|
||||||
enrichment требуют больше CPU/IO/сетевых операций, чем Workforce core.
|
enrichment требуют больше CPU/IO/сетевых операций, чем Workforce core.
|
||||||
|
|
||||||
Вывод: DLP/evidence/forensics enrichment вынесен из обязательного hot path.
|
Вывод: DLP/evidence/forensics enrichment уже вынесен из обязательного hot path
|
||||||
Phase 1 делал это через `DETMIR_PORTAL_DLP_MODULE_ENABLED=false`; текущий
|
phase 1 через `DETMIR_PORTAL_DLP_MODULE_ENABLED=false`, но полная оптимизация
|
||||||
lightweight-профиль оставляет DLP-status/UEBA-сигналы включенными без тяжелого
|
тяжелого snapshot/prewarm остается отдельной инженерной задачей.
|
||||||
evidence/case/exporter path. Полная оптимизация тяжелого snapshot/prewarm
|
|
||||||
остается отдельной инженерной задачей.
|
|
||||||
|
|
||||||
## Целевая граница после переработки
|
## Целевая граница после переработки
|
||||||
|
|
||||||
@@ -175,45 +154,23 @@ AW_DLP_ENABLED=true|false
|
|||||||
DETMIR_DLP_ENABLED=true|false
|
DETMIR_DLP_ENABLED=true|false
|
||||||
```
|
```
|
||||||
|
|
||||||
DetMir production default после 2026-06-30 hardening:
|
Default остается `true`, чтобы существующее поведение не менялось без явного
|
||||||
`AW_DLP_ENABLED=false` / `AW_DLP_PROFILE=core_only`. Portal DLP module may stay
|
решения администратора. Для ускоренного Workforce/operator режима допускается
|
||||||
enabled for historical/security views, but server-side DLP collectors/exporters
|
`DETMIR_PORTAL_DLP_MODULE_ENABLED=false`; в этом режиме портал:
|
||||||
remain off. В этом режиме портал:
|
|
||||||
|
|
||||||
- не читает DLP incident/case/review/audit файлы в основном report/operator
|
- не читает DLP incident/case/review/audit файлы в основном report/operator
|
||||||
path;
|
path;
|
||||||
- использует только уже имеющийся лёгкий DLP-срез для UEBA и статуса;
|
- отключает security-events backend внутри snapshot, не меняя сохраненные
|
||||||
- не включает evidence/case/exporters/Loki/Influx-heavy path;
|
ClickHouse credentials;
|
||||||
- не считает отсутствие heavy DLP ошибкой Workforce core.
|
- возвращает disabled-state для DLP evidence API;
|
||||||
|
- не считает отсутствие DLP ошибкой Workforce core.
|
||||||
|
|
||||||
Ansible-параметр поставки для старого disabled-профиля:
|
Ansible-параметр поставки:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
detmir_portal_dlp_module_enabled_override: false
|
detmir_portal_dlp_module_enabled_override: false
|
||||||
```
|
```
|
||||||
|
|
||||||
Для текущего safe production профиля:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
detmir_portal_dlp_module_enabled_override: true
|
|
||||||
aw_dlp_profile: "core_only"
|
|
||||||
aw_dlp_enabled: false
|
|
||||||
aw_dlp_influx_enabled: false
|
|
||||||
aw_dlp_light_collector_enabled: false
|
|
||||||
aw_dlp_light_guard_enabled: true
|
|
||||||
```
|
|
||||||
|
|
||||||
Возврат в `light` выполняется только после resource check:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo AW_DLP_DISABLED_REASON=operator_reenable_after_resource_check \
|
|
||||||
/usr/local/bin/detmir-dlp-runtime-control set-profile light
|
|
||||||
sudo sed -i \
|
|
||||||
-e 's/^AW_DLP_ENABLED=.*/AW_DLP_ENABLED=true/' \
|
|
||||||
-e 's/^AW_DLP_PROFILE=.*/AW_DLP_PROFILE=light/' \
|
|
||||||
/etc/activitywatch/aw-server.env
|
|
||||||
```
|
|
||||||
|
|
||||||
Отдельный `detmir-portal-evidence` сервис не отключается этим флагом и остается
|
Отдельный `detmir-portal-evidence` сервис не отключается этим флагом и остается
|
||||||
самостоятельным контуром evidence/API при наличии отдельной конфигурации.
|
самостоятельным контуром evidence/API при наличии отдельной конфигурации.
|
||||||
|
|
||||||
@@ -232,7 +189,6 @@ Hayabusa/Velociraptor boundary:
|
|||||||
Server-side optional DLP runtime описан отдельно:
|
Server-side optional DLP runtime описан отдельно:
|
||||||
|
|
||||||
- [DLP_OPTIONAL_RUNTIME_RU.md](DLP_OPTIONAL_RUNTIME_RU.md).
|
- [DLP_OPTIONAL_RUNTIME_RU.md](DLP_OPTIONAL_RUNTIME_RU.md).
|
||||||
- [DLP_RESOURCE_PROFILES_RU.md](DLP_RESOURCE_PROFILES_RU.md).
|
|
||||||
|
|
||||||
При `AW_DLP_ENABLED=false`:
|
При `AW_DLP_ENABLED=false`:
|
||||||
|
|
||||||
@@ -241,27 +197,10 @@ Server-side optional DLP runtime описан отдельно:
|
|||||||
- `detmir-check`, `check-aw-full` и `check-aw-data` не считают DLP buckets
|
- `detmir-check`, `check-aw-full` и `check-aw-data` не считают DLP buckets
|
||||||
обязательными;
|
обязательными;
|
||||||
- `detmir-readiness` не требует DLP Influx write и DLP systemd units;
|
- `detmir-readiness` не требует DLP Influx write и DLP systemd units;
|
||||||
- DLP profile changes use
|
|
||||||
`/usr/local/bin/detmir-dlp-runtime-control set-profile <profile>` and keep a
|
|
||||||
rollback snapshot for `/usr/local/bin/detmir-dlp-runtime-control rollback`;
|
|
||||||
- перед отключением и после отключения собираются JSON-срезы в
|
- перед отключением и после отключения собираются JSON-срезы в
|
||||||
`/var/lib/activitywatch/health/dlp-runtime-history/`, latest-срез остается в
|
`/var/lib/activitywatch/health/dlp-runtime-history/`, latest-срез остается в
|
||||||
`/var/lib/activitywatch/health/dlp-runtime-state.json`.
|
`/var/lib/activitywatch/health/dlp-runtime-state.json`.
|
||||||
|
|
||||||
При `AW_DLP_PROFILE=light`:
|
|
||||||
|
|
||||||
- `activitywatch-dlp-aggregator.timer` собирает только ограниченный набор DLP
|
|
||||||
events в локальный SQLite warehouse;
|
|
||||||
- `detmir-dlp-warehouse-sync.timer` доставляет этот warehouse на portal host
|
|
||||||
атомарным snapshot;
|
|
||||||
- UEBA может учитывать `dlp_warn`/`dlp_fail` без запуска Loki/Influx-heavy path;
|
|
||||||
- `detmir-dlp-load-guard.timer` автоматически переводит профиль в `core_only`
|
|
||||||
при превышении порогов load/RAM/iowait;
|
|
||||||
- тяжёлые DLP units (`aw-dlp-influx-exporter`, report/syslog/webhook/CEF,
|
|
||||||
policy engine, case management, evidence API) должны оставаться выключенными.
|
|
||||||
- если `detmir-dlp-load-guard.timer` видит повторный перегруз, он автоматически
|
|
||||||
возвращает DLP runtime в `core_only`.
|
|
||||||
|
|
||||||
Live disable evidence 2026-06-25:
|
Live disable evidence 2026-06-25:
|
||||||
|
|
||||||
- `dlp-health-check` returned `ok=true`, `dlp:mode=disabled`;
|
- `dlp-health-check` returned `ok=true`, `dlp:mode=disabled`;
|
||||||
@@ -368,7 +307,6 @@ curl -sS --max-time 5 http://10.10.10.2:8720/healthz
|
|||||||
- Не удалять DLP collectors и warehouse ради ускорения портала.
|
- Не удалять DLP collectors и warehouse ради ускорения портала.
|
||||||
- Не включать heavy DLP или Velociraptor server runtime автоматически при
|
- Не включать heavy DLP или Velociraptor server runtime автоматически при
|
||||||
обычном deploy без ресурсного решения.
|
обычном deploy без ресурсного решения.
|
||||||
- Не включать Loki CT автоматически при обычном deploy/recovery DetMir.
|
|
||||||
- Не менять UI/API несовместимо: новые поля должны быть additive.
|
- Не менять UI/API несовместимо: новые поля должны быть additive.
|
||||||
- Не заявлять completed DLP decoupling до live deploy и browser/API smoke.
|
- Не заявлять completed DLP decoupling до live deploy и browser/API smoke.
|
||||||
- Не позиционировать AWatch-rus как сертифицированную DLP/SIEM/EDR/СЗИ.
|
- Не позиционировать AWatch-rus как сертифицированную DLP/SIEM/EDR/СЗИ.
|
||||||
|
|||||||
@@ -1,37 +1,14 @@
|
|||||||
# Optional DLP runtime for DetMir
|
# Optional DLP runtime for DetMir
|
||||||
|
|
||||||
Цель: DLP-контур должен оставаться подключаемым, но production default для
|
Цель: DLP-контур должен отключаться управляемо, без ложных аварий в health/readiness и без автоматического подъема heavy-пайплайна, когда задача контура - снизить нагрузку на InfluxDB, Grafana и ClickHouse.
|
||||||
DetMir сейчас `core_only/disabled`. Возврат в лёгкий режим выполняется вручную
|
|
||||||
после resource check; при перегрузе guard снова переводит DLP в `core_only`.
|
|
||||||
|
|
||||||
Ресурсные профили и rollback-процедура описаны отдельно:
|
|
||||||
[DLP_RESOURCE_PROFILES_RU.md](DLP_RESOURCE_PROFILES_RU.md).
|
|
||||||
|
|
||||||
## Что отключается
|
## Что отключается
|
||||||
|
|
||||||
Текущий production-профиль DetMir после 2026-06-30 prod hardening -
|
|
||||||
`core_only/disabled`:
|
|
||||||
|
|
||||||
- `AW_DLP_ENABLED=false`;
|
|
||||||
- `AW_DLP_PROFILE=core_only`;
|
|
||||||
- `AW_DLP_INFLUX_ENABLED=false`;
|
|
||||||
- optional DLP timers/services inactive/disabled;
|
|
||||||
- `detmir-dlp-load-guard.timer` остаётся enabled/active как защита на случай
|
|
||||||
последующего operator re-enable;
|
|
||||||
- heavy DLP units, Influx exporter, evidence/case/report/integration units и
|
|
||||||
Loki остаются выключенными.
|
|
||||||
|
|
||||||
Автоотключение выполняет `detmir-dlp-load-guard`: при превышении порогов
|
|
||||||
load/RAM/iowait он переводит DLP в `core_only` через
|
|
||||||
`detmir-dlp-runtime-control set-profile core_only`. После стабилизации контур
|
|
||||||
возвращается вручную командой `set-profile light`.
|
|
||||||
|
|
||||||
Штатный runtime off включает:
|
Штатный runtime off включает:
|
||||||
|
|
||||||
- `AW_DLP_ENABLED=false` на AW server;
|
- `AW_DLP_ENABLED=false` на AW server;
|
||||||
- `DETMIR_DLP_ENABLED=false` в управляющем DetMir contour check;
|
- `DETMIR_DLP_ENABLED=false` в управляющем DetMir contour check;
|
||||||
- portal UI/API DLP-модуль может оставаться включённым для исторического
|
- `DETMIR_PORTAL_DLP_MODULE_ENABLED=false` для portal UI/API DLP-модуля;
|
||||||
SQLite/evidence-среза; это не запускает server-side DLP runtime;
|
|
||||||
- остановку DLP timers/services:
|
- остановку DLP timers/services:
|
||||||
- `aw-dlp-influx-exporter.timer`;
|
- `aw-dlp-influx-exporter.timer`;
|
||||||
- `activitywatch-dlp-aggregator.timer`;
|
- `activitywatch-dlp-aggregator.timer`;
|
||||||
@@ -160,31 +137,10 @@ AW_DLP_ENABLED=false check-aw-full
|
|||||||
|
|
||||||
## Возврат DLP
|
## Возврат DLP
|
||||||
|
|
||||||
Для DetMir предпочтительно возвращать не весь DLP сразу, а лёгкий профиль.
|
|
||||||
Перед этим проверить load/RAM/iowait на Proxmox/AW/Influx/Grafana/ClickHouse.
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo AW_DLP_DISABLED_REASON=operator_reenable_after_resource_check \
|
sudo sed -i 's/^AW_DLP_ENABLED=.*/AW_DLP_ENABLED=true/' /etc/activitywatch/aw-server.env
|
||||||
/usr/local/bin/detmir-dlp-runtime-control set-profile light
|
sudo /usr/local/bin/detmir-dlp-runtime-control enable
|
||||||
sudo sed -i \
|
sudo systemctl restart aw-worktime-api.service || true
|
||||||
-e 's/^AW_DLP_ENABLED=.*/AW_DLP_ENABLED=true/' \
|
|
||||||
-e 's/^AW_DLP_PROFILE=.*/AW_DLP_PROFILE=light/' \
|
|
||||||
-e 's/^AW_DLP_INFLUX_ENABLED=.*/AW_DLP_INFLUX_ENABLED=false/' \
|
|
||||||
/etc/activitywatch/aw-server.env
|
|
||||||
```
|
|
||||||
|
|
||||||
Если профиль ухудшил состояние контура:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo /usr/local/bin/detmir-dlp-runtime-control rollback
|
|
||||||
```
|
|
||||||
|
|
||||||
`on_demand` и `full` включаются только вручную после отдельного resource
|
|
||||||
preflight:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo /usr/local/bin/detmir-dlp-runtime-control set-profile on_demand
|
|
||||||
sudo /usr/local/bin/detmir-dlp-runtime-control set-profile full
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Для portal:
|
Для portal:
|
||||||
@@ -231,27 +187,13 @@ production DetMir без отдельного ресурсного решени
|
|||||||
В inventory/group vars:
|
В inventory/group vars:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
aw_dlp_profile: "core_only"
|
|
||||||
aw_dlp_enabled: false
|
aw_dlp_enabled: false
|
||||||
aw_dlp_influx_enabled: false
|
aw_dlp_disabled_reason: "operator_disabled_to_reduce_influx_grafana_clickhouse_load"
|
||||||
aw_dlp_light_collector_enabled: false
|
aw_dlp_disabled_since: "2026-06-25"
|
||||||
aw_dlp_light_guard_enabled: true
|
detmir_portal_dlp_module_enabled_override: false
|
||||||
detmir_portal_dlp_module_enabled_override: true
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Для временного operator re-enable в `light`:
|
При `aw_dlp_enabled: false` playbook пишет `AW_DLP_ENABLED=false`, не включает DLP service/timer runtime и не должен возвращать DLP Influx exporter/aggregator в active state.
|
||||||
|
|
||||||
```yaml
|
|
||||||
aw_dlp_profile: "light"
|
|
||||||
aw_dlp_enabled: true
|
|
||||||
aw_dlp_influx_enabled: false
|
|
||||||
aw_dlp_light_collector_enabled: true
|
|
||||||
aw_dlp_light_guard_enabled: true
|
|
||||||
```
|
|
||||||
|
|
||||||
При `aw_dlp_profile: light` playbook включает только лёгкий агрегатор, IOC
|
|
||||||
refresh и load guard. DLP Influx exporter, report/syslog/webhook/CEF,
|
|
||||||
policy/case/evidence и Loki не должны возвращаться в active state.
|
|
||||||
|
|
||||||
## Ограничения
|
## Ограничения
|
||||||
|
|
||||||
|
|||||||
@@ -1,196 +0,0 @@
|
|||||||
# DLP resource profiles for DetMir
|
|
||||||
|
|
||||||
Дата фиксации: 2026-06-30.
|
|
||||||
|
|
||||||
Цель: сохранить стабильный Workforce/AW hot path на малом DetMir Proxmox
|
|
||||||
контуре и оставить DLP подключаемым модулем. Loki CT в текущем production
|
|
||||||
resource profile отключен намеренно и не является обязательной зависимостью
|
|
||||||
AWatch-rus.
|
|
||||||
|
|
||||||
## Профили
|
|
||||||
|
|
||||||
### `core_only`
|
|
||||||
|
|
||||||
Production default и аварийный/экономный профиль для DetMir.
|
|
||||||
|
|
||||||
- DLP runtime: выключен.
|
|
||||||
- DLP Influx exporter: выключен.
|
|
||||||
- DLP aggregators/report/syslog/webhook/CEF/case/evidence units: выключены.
|
|
||||||
- Loki/Promtail: выключены.
|
|
||||||
- Workforce, Worktime, ActivityWatch, ClickHouse 1C, Grafana core,
|
|
||||||
Hayabusa/Security Finding Inbox: работают независимо от DLP.
|
|
||||||
|
|
||||||
Назначение: безопасное состояние при перегрузе CPU/RAM/IOPS или при ручном
|
|
||||||
отключении DLP.
|
|
||||||
|
|
||||||
### `light`
|
|
||||||
|
|
||||||
Операторский re-enable профиль для DetMir после проверки ресурсов: лёгкий DLP
|
|
||||||
режим без Loki и без Influx-heavy path.
|
|
||||||
|
|
||||||
- Разрешены `activitywatch-dlp-aggregator.timer` и
|
|
||||||
`aw-dlp-ioc-refresh.timer`.
|
|
||||||
- `dlp-aggregator-rust` собирает ограниченный срез из bucket-ов
|
|
||||||
`aw-file-operations_` и `aw-dlp-incidents_` в локальный
|
|
||||||
`dlp_warehouse.sqlite` для последующей UEBA-корреляции.
|
|
||||||
- `detmir-dlp-warehouse-sync.timer` доставляет SQLite warehouse на portal host
|
|
||||||
через атомарный snapshot, чтобы DetMir Portal/UEBA читали локальный файл, а
|
|
||||||
не блокировали AW server hot path.
|
|
||||||
- Для агрегатора заданы короткий lookback, малый event limit, timeout,
|
|
||||||
`CPUQuota` и `MemoryMax`.
|
|
||||||
- Evidence, screenshots, case management и exporters остаются выключенными.
|
|
||||||
- InfluxDB/Grafana/Loki не участвуют в hot path лёгкого DLP.
|
|
||||||
- Используется для ежедневной эксплуатации, когда нужны DLP-сигналы для UEBA,
|
|
||||||
но нельзя нагружать Proxmox/Influx/Grafana/ClickHouse.
|
|
||||||
|
|
||||||
### `on_demand`
|
|
||||||
|
|
||||||
Временный режим для конкретного инцидента или окна проверки.
|
|
||||||
|
|
||||||
- Разрешены IOC refresh, policy engine, case management и evidence API.
|
|
||||||
- Influx exporter, CEF/syslog/webhook/report scheduler и aggregator остаются
|
|
||||||
выключенными, если администратор отдельно не выбрал `full`.
|
|
||||||
- После окна проверки профиль должен быть возвращён в `core_only`.
|
|
||||||
|
|
||||||
### `full`
|
|
||||||
|
|
||||||
Только вручную, только после resource preflight.
|
|
||||||
|
|
||||||
- Может включать DLP Influx exporter, aggregator, reports, integrations,
|
|
||||||
policy/case и evidence.
|
|
||||||
- На DetMir не является штатным production режимом.
|
|
||||||
- Запрещено включать автоматически при обычном deploy/recovery.
|
|
||||||
|
|
||||||
## Управление
|
|
||||||
|
|
||||||
На AW server:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo /usr/local/bin/detmir-dlp-runtime-control status
|
|
||||||
sudo /usr/local/bin/detmir-dlp-runtime-control set-profile core_only
|
|
||||||
sudo /usr/local/bin/detmir-dlp-runtime-control set-profile light
|
|
||||||
sudo /usr/local/bin/detmir-dlp-runtime-control set-profile on_demand
|
|
||||||
sudo /usr/local/bin/detmir-dlp-runtime-control set-profile full
|
|
||||||
sudo /usr/local/bin/detmir-dlp-load-guard
|
|
||||||
```
|
|
||||||
|
|
||||||
Перед каждым `set-profile` скрипт сохраняет rollback-снимок active/enabled
|
|
||||||
состояния DLP units:
|
|
||||||
|
|
||||||
```text
|
|
||||||
/var/lib/activitywatch/health/dlp-runtime-rollback.state
|
|
||||||
```
|
|
||||||
|
|
||||||
Откат к предыдущему состоянию:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo /usr/local/bin/detmir-dlp-runtime-control rollback
|
|
||||||
```
|
|
||||||
|
|
||||||
Важно: rollback восстанавливает только systemd active/enabled состояния DLP
|
|
||||||
units. Он не меняет retention, не удаляет данные и не включает Loki CT.
|
|
||||||
|
|
||||||
## Автоотключение при перегрузе
|
|
||||||
|
|
||||||
`detmir-dlp-load-guard.timer` запускает
|
|
||||||
`/usr/local/bin/detmir-dlp-load-guard`. Guard читает `/proc/loadavg`,
|
|
||||||
`/proc/meminfo` и `/proc/stat`; если load, свободная память или iowait выходят
|
|
||||||
за пороги несколько запусков подряд (`AW_DLP_GUARD_STRIKES_REQUIRED`, default
|
|
||||||
`3`), а DLP units активны, он переводит DLP в `core_only` через:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
AW_DLP_DISABLED_REASON=auto_disabled_by_dlp_load_guard:<reason> \
|
|
||||||
/usr/local/bin/detmir-dlp-runtime-control set-profile core_only
|
|
||||||
```
|
|
||||||
|
|
||||||
State и история пишутся в:
|
|
||||||
|
|
||||||
```text
|
|
||||||
/var/lib/activitywatch/health/dlp-light-guard-state.json
|
|
||||||
/var/lib/activitywatch/health/dlp-light-guard-history/
|
|
||||||
```
|
|
||||||
|
|
||||||
Единичный IO/load spike фиксируется как `observe_overload`, но DLP не
|
|
||||||
отключается до достижения порога подряд. Guard не перезапускает
|
|
||||||
ActivityWatch/портал, не меняет маршруты, не трогает ClickHouse/Grafana и не
|
|
||||||
включает Loki. Возврат из `core_only` в `light` делает администратор после
|
|
||||||
стабилизации контура и проверки Proxmox/AW/Influx/Grafana/ClickHouse load. Если
|
|
||||||
перегруз повторится, guard снова переведёт профиль в `core_only`.
|
|
||||||
|
|
||||||
## Доставка DLP warehouse на портал
|
|
||||||
|
|
||||||
Portal читает DLP-срез из локального
|
|
||||||
`/var/lib/activitywatch/dlp_warehouse.sqlite`. На разнесённом контуре DetMir
|
|
||||||
этот файл создаётся на AW server, поэтому используется лёгкий sync:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo systemctl start detmir-dlp-warehouse-sync.service
|
|
||||||
sudo systemctl status detmir-dlp-warehouse-sync.timer
|
|
||||||
sudo jq . /var/lib/activitywatch/health/dlp-warehouse-sync-state.json
|
|
||||||
```
|
|
||||||
|
|
||||||
Sync делает SQLite backup на AW server и атомарно заменяет локальный файл на
|
|
||||||
portal host. Он не запускает DLP evidence/case/exporters и не включает Loki.
|
|
||||||
|
|
||||||
## Ansible defaults
|
|
||||||
|
|
||||||
Для DetMir production defaults должны оставаться экономными и
|
|
||||||
самозащищающимися:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
aw_dlp_profile: "core_only"
|
|
||||||
aw_dlp_enabled: false
|
|
||||||
aw_dlp_influx_enabled: false
|
|
||||||
aw_dlp_light_collector_enabled: false
|
|
||||||
aw_dlp_light_guard_enabled: true
|
|
||||||
detmir_portal_dlp_profile: "core_only"
|
|
||||||
detmir_portal_dlp_module_enabled_override: true
|
|
||||||
```
|
|
||||||
|
|
||||||
Для временного возврата в лёгкий профиль:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
aw_dlp_profile: "light"
|
|
||||||
aw_dlp_enabled: true
|
|
||||||
aw_dlp_influx_enabled: false
|
|
||||||
aw_dlp_light_collector_enabled: true
|
|
||||||
aw_dlp_light_guard_enabled: true
|
|
||||||
detmir_portal_dlp_profile: "light"
|
|
||||||
detmir_portal_dlp_module_enabled_override: true
|
|
||||||
```
|
|
||||||
|
|
||||||
Все тяжёлые DLP component flags должны быть `false`, пока администратор явно не
|
|
||||||
выбрал `on_demand` или `full`.
|
|
||||||
|
|
||||||
## Resource preflight перед `full`
|
|
||||||
|
|
||||||
Перед временным включением `full` проверить:
|
|
||||||
|
|
||||||
- Proxmox host load и steal/wait;
|
|
||||||
- свободную RAM и swap pressure;
|
|
||||||
- IOPS/latency storage;
|
|
||||||
- ClickHouse health и backlog ingest;
|
|
||||||
- InfluxDB/Grafana health, если они участвуют в выбранном профиле;
|
|
||||||
- ActivityWatch `/healthz`, Worktime API и portal latency;
|
|
||||||
- отсутствие старого Loki CT в autostart.
|
|
||||||
|
|
||||||
Если любой core-сервис деградирует, DLP возвращается в `core_only`.
|
|
||||||
|
|
||||||
## Проверка
|
|
||||||
|
|
||||||
```bash
|
|
||||||
DETMIR_RESILIENCE_EXPECT_DLP_PROFILE=light \
|
|
||||||
DETMIR_RESILIENCE_EXPECT_LOKI_OFF=1 \
|
|
||||||
scripts/detmir_resilience_check.sh --repo
|
|
||||||
```
|
|
||||||
|
|
||||||
Live check на сервере в `light` должен показывать inactive для heavy DLP units
|
|
||||||
и Loki units. В `core_only` inactive должны быть все optional DLP units.
|
|
||||||
|
|
||||||
## Запрещённые утверждения
|
|
||||||
|
|
||||||
- Не заявлять, что AWatch-rus заменяет DLP/SIEM/EDR.
|
|
||||||
- Не заявлять, что Loki обязателен для DetMir production.
|
|
||||||
- Не заявлять DLP health OK, если DLP выключен.
|
|
||||||
- Не запускать автоматическое блокирование рабочих станций без approve/apply
|
|
||||||
workflow.
|
|
||||||
@@ -47,8 +47,6 @@ bounded payload/query limits и role-gate smoke.
|
|||||||
| `--slow-request-log-ms` | `AWATCH_PORTAL_SLOW_REQUEST_LOG_MS` | Порог медленного запроса для логов |
|
| `--slow-request-log-ms` | `AWATCH_PORTAL_SLOW_REQUEST_LOG_MS` | Порог медленного запроса для логов |
|
||||||
| `--environment` | `AWATCH_PORTAL_ENVIRONMENT` | Безопасное имя окружения |
|
| `--environment` | `AWATCH_PORTAL_ENVIRONMENT` | Безопасное имя окружения |
|
||||||
| `--enabled-modules` | `AWATCH_PORTAL_ENABLED_MODULES` | Разрешенные модули портала |
|
| `--enabled-modules` | `AWATCH_PORTAL_ENABLED_MODULES` | Разрешенные модули портала |
|
||||||
| `--dlp-module-enabled` | `DETMIR_PORTAL_DLP_MODULE_ENABLED` | Включает DLP/security status для портала; может оставаться `true` для исторического SQLite/evidence-среза без запуска server-side DLP runtime |
|
|
||||||
| DLP resource profile | `AW_DLP_PROFILE`, `DETMIR_PORTAL_DLP_PROFILE` | Для DetMir production default `core_only`; `light` включается оператором после resource check |
|
|
||||||
|
|
||||||
Ограничения применяются к тяжелым API:
|
Ограничения применяются к тяжелым API:
|
||||||
|
|
||||||
@@ -68,21 +66,6 @@ bounded payload/query limits и role-gate smoke.
|
|||||||
возвращает `400`;
|
возвращает `400`;
|
||||||
- слишком большое тело запроса возвращает `413`;
|
- слишком большое тело запроса возвращает `413`;
|
||||||
- role gate возвращает `403`.
|
- role gate возвращает `403`.
|
||||||
- при `DETMIR_PORTAL_DLP_MODULE_ENABLED=true` и `AW_DLP_PROFILE=core_only`
|
|
||||||
портал может показывать исторический DLP/security status без запуска
|
|
||||||
collectors/exporters.
|
|
||||||
- при `DETMIR_PORTAL_DLP_MODULE_ENABLED=true` и `AW_DLP_PROFILE=light`
|
|
||||||
Workforce core, `/healthz`, `/readyz`, `/api/reports` и `/api/operator`
|
|
||||||
должны оставаться доступными без тяжелого DLP/case/evidence чтения.
|
|
||||||
- при `AW_DLP_ENABLED=false` и `DETMIR_DLP_ENABLED=false` server-side
|
|
||||||
DLP health/readiness/checks должны возвращать контролируемый disabled-state,
|
|
||||||
а не пытаться поднять DLP Influx/exporter/aggregator/case runtime.
|
|
||||||
Runbook: [DLP_OPTIONAL_RUNTIME_RU.md](DLP_OPTIONAL_RUNTIME_RU.md).
|
|
||||||
- при `AW_DLP_PROFILE=light` активны только lightweight collector/IOC/guard;
|
|
||||||
Loki/DLP heavy runtime должен оставаться inactive. При перегрузе
|
|
||||||
`detmir-dlp-load-guard` переводит DLP в `core_only`; возврат выполняется
|
|
||||||
только через profile switch и rollback, см.
|
|
||||||
[DLP_RESOURCE_PROFILES_RU.md](DLP_RESOURCE_PROFILES_RU.md).
|
|
||||||
|
|
||||||
### Request ID, logs и metrics
|
### Request ID, logs и metrics
|
||||||
|
|
||||||
|
|||||||
+17
-22
@@ -66,25 +66,23 @@ backup, registry-readiness документации, плана российск
|
|||||||
`653b22b0fbf29a22f7de42ade7b689490b1de16fa07e785e4e0efd3078e7a3bc`.
|
`653b22b0fbf29a22f7de42ade7b689490b1de16fa07e785e4e0efd3078e7a3bc`.
|
||||||
- DetMir portal cold-start UI hang: mitigated. During cold/prewarm state the UI
|
- DetMir portal cold-start UI hang: mitigated. During cold/prewarm state the UI
|
||||||
now shows `STALE / Первичный срез прогревается`, not endless loading.
|
now shows `STALE / Первичный срез прогревается`, not endless loading.
|
||||||
- DetMir DLP hot-path boundary: phase 1 deployed; current production runtime
|
- DetMir DLP hot-path boundary: phase 1 deployed on the portal service with
|
||||||
uses `AW_DLP_ENABLED=false`, `AW_DLP_PROFILE=core_only`. The portal DLP module
|
`DETMIR_PORTAL_DLP_MODULE_ENABLED=false`.
|
||||||
may stay enabled for historical/security views, but server-side DLP
|
|
||||||
collectors/exporters are off.
|
|
||||||
- DetMir optional DLP runtime controls: implemented in code/docs through
|
- DetMir optional DLP runtime controls: implemented in code/docs through
|
||||||
`AW_DLP_ENABLED`, `DETMIR_DLP_ENABLED`,
|
`AW_DLP_ENABLED`, `DETMIR_DLP_ENABLED`,
|
||||||
`scripts/detmir_dlp_runtime_control.sh` and
|
`scripts/detmir_dlp_runtime_control.sh` and
|
||||||
`docs/DLP_OPTIONAL_RUNTIME_RU.md`. Resource profiles
|
`docs/DLP_OPTIONAL_RUNTIME_RU.md`.
|
||||||
`core_only|light|on_demand|full` and rollback are documented in
|
- DetMir optional DLP runtime live state: disabled on 2026-06-25 to reduce
|
||||||
`docs/DLP_RESOURCE_PROFILES_RU.md`.
|
InfluxDB/Grafana/ClickHouse/AW server load. Evidence:
|
||||||
- DetMir optional DLP runtime state: 2026-06-25 controlled disable evidence is
|
`dlp-health-check=dlp:mode disabled`, `detmir-dlp=dlp:mode disabled`,
|
||||||
retained; 2026-06-30 prod hardening keeps production in `core_only` by
|
active/enabled DLP units `0/0`, history snapshots under
|
||||||
default. `light` can be re-enabled by operator command after
|
`/var/lib/activitywatch/health/dlp-runtime-history/`.
|
||||||
Proxmox/InfluxDB/Grafana/ClickHouse capacity check.
|
- DetMir DLP contour status: disabled for the current production resource
|
||||||
- DetMir DLP contour status: server-side DLP collection is currently disabled;
|
profile, not removed. It remains a documented optional module and must only be
|
||||||
heavy DLP remains optional and must only be enabled after explicit operator
|
re-enabled after explicit operator decision and Proxmox/InfluxDB/Grafana/
|
||||||
decision and resource check.
|
ClickHouse capacity check.
|
||||||
- DetMir DLP auto-disable guard: `detmir-dlp-load-guard` records load/RAM/iowait
|
- DetMir DLP buckets in manual full check: `SKIPPED` under
|
||||||
state and switches DLP to `core_only` if thresholds are exceeded.
|
`AW_DLP_ENABLED=false`, not reported as dead.
|
||||||
- DetMir RDP collector freshness after 2026-06-29 restore: physical RDP target
|
- DetMir RDP collector freshness after 2026-06-29 restore: physical RDP target
|
||||||
is `192.168.100.19`, stable AW logical host id remains `SHARKON2025`.
|
is `192.168.100.19`, stable AW logical host id remains `SHARKON2025`.
|
||||||
Buckets are fresh/inactive as expected, collector guard quarantine was reset,
|
Buckets are fresh/inactive as expected, collector guard quarantine was reset,
|
||||||
@@ -114,9 +112,6 @@ backup, registry-readiness документации, плана российск
|
|||||||
resource usage. Proxmox LXC `202 loki-logs` is stopped, active config has
|
resource usage. Proxmox LXC `202 loki-logs` is stopped, active config has
|
||||||
`onboot: 0`, and smoke checks skip Loki by default unless
|
`onboot: 0`, and smoke checks skip Loki by default unless
|
||||||
`AW_SMOKE_LOKI_ENABLED=1` is set.
|
`AW_SMOKE_LOKI_ENABLED=1` is set.
|
||||||
- DetMir DLP rollback guard: `detmir-dlp-runtime-control set-profile` stores
|
|
||||||
the previous DLP systemd active/enabled state and `rollback` restores it.
|
|
||||||
Rollback does not start Loki CT.
|
|
||||||
- DetMir restore baseline 2026-06-29:
|
- DetMir restore baseline 2026-06-29:
|
||||||
`docs/DETMIR_RESTORE_BASELINE_2026-06-29_RU.md`.
|
`docs/DETMIR_RESTORE_BASELINE_2026-06-29_RU.md`.
|
||||||
- DetMir API smoke after phase 1: `/healthz` and `/readyz` OK;
|
- DetMir API smoke after phase 1: `/healthz` and `/readyz` OK;
|
||||||
@@ -202,9 +197,9 @@ backup, registry-readiness документации, плана российск
|
|||||||
- External peer review remains pending.
|
- External peer review remains pending.
|
||||||
- Community adoption remains low until external contributors, public reviews
|
- Community adoption remains low until external contributors, public reviews
|
||||||
and sustained third-party activity appear.
|
and sustained third-party activity appear.
|
||||||
- DetMir lightweight DLP profile is implemented in repo defaults/scripts/docs;
|
- DetMir DLP runtime disable is complete for the current live contour; deeper
|
||||||
heavy DLP modularization and retention/cleanup policy remain separate future
|
long-term DLP product modularization and retention/cleanup policy remain
|
||||||
work.
|
separate future work.
|
||||||
- DetMir RDP collector/session recovery after 2026-06-29 restore is verified by
|
- DetMir RDP collector/session recovery after 2026-06-29 restore is verified by
|
||||||
live smoke: `check-aw-full` reports `FRESH=8 STALE=0 DEAD=0`.
|
live smoke: `check-aw-full` reports `FRESH=8 STALE=0 DEAD=0`.
|
||||||
|
|
||||||
|
|||||||
@@ -342,7 +342,7 @@
|
|||||||
"id": 7,
|
"id": 7,
|
||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
"query": "import \"date\"\nimport \"strings\"\nimport \"timezone\"\noption location = timezone.location(name: \"Europe/Moscow\")\ntoday = strings.substring(v: string(v: date.add(d: 3h, to: date.truncate(t: now(), unit: 1d))), start: 0, end: 10)\nfrom(bucket: \"aw_metrics\")\n |> range(start: -3d)\n |> filter(fn: (r) => r._measurement == \"aw_true_active_app_daily\" and r.host == \"${host}\" and r.report_date == today)\n |> filter(fn: (r) => r._field == \"proved_work_seconds\" or r._field == \"evidence_events\" or r._field == \"last_action\" or r._field == \"last_action_local\")\n |> group(columns:[\"application\",\"report_date\",\"_field\"])\n |> last()\n |> keep(columns:[\"application\",\"report_date\",\"_field\",\"_value\"])\n |> map(fn:(r)=>({ r with _value: string(v:r._value) }))\n |> group()\n |> pivot(rowKey:[\"application\",\"report_date\"], columnKey:[\"_field\"], valueColumn:\"_value\")\n |> map(fn:(r)=>({ r with hours: float(v:r.proved_work_seconds) / 3600.0 }))\n |> sort(columns:[\"hours\"], desc:true)\n |> group()\n |> keep(columns:[\"report_date\",\"application\",\"hours\",\"last_action_local\",\"last_action\",\"evidence_events\"])\n |> rename(columns:{report_date:\"Дата\", application:\"Приложение\", hours:\"Доказано, ч\", last_action_local:\"Последнее действие\", last_action:\"Окно / действие\", evidence_events:\"Подтверждений\"})\n",
|
"query": "import \"date\"\nimport \"strings\"\nimport \"timezone\"\noption location = timezone.location(name: \"Europe/Moscow\")\ntoday = strings.substring(v: string(v: date.add(d: 3h, to: date.truncate(t: now(), unit: 1d))), start: 0, end: 10)\nbase = from(bucket: \"aw_metrics\")\n |> range(start: -3d)\n |> filter(fn: (r) => r._measurement == \"aw_true_active_app_daily\" and r.host == \"${host}\" and r.report_date == today)\n\nnums = base\n |> filter(fn: (r) => r._field == \"proved_work_seconds\" or r._field == \"evidence_events\")\n |> group(columns:[\"application\",\"_field\"])\n |> last()\n |> group()\n |> pivot(rowKey:[\"application\",\"report_date\"], columnKey:[\"_field\"], valueColumn:\"_value\")\n\ntexts = base\n |> filter(fn: (r) => r._field == \"last_action\" or r._field == \"last_action_local\")\n |> group(columns:[\"application\",\"_field\"])\n |> last()\n |> group()\n |> pivot(rowKey:[\"application\",\"report_date\"], columnKey:[\"_field\"], valueColumn:\"_value\")\n\njoin(tables: {n: nums, t: texts}, on: [\"application\", \"report_date\"])\n |> map(fn:(r)=>({ r with hours: float(v:r.proved_work_seconds) / 3600.0 }))\n |> sort(columns:[\"proved_work_seconds\"], desc:true)\n |> group()\n |> keep(columns:[\"report_date\",\"application\",\"hours\",\"last_action_local\",\"last_action\",\"evidence_events\"])\n |> rename(columns:{report_date:\"Дата\", application:\"Приложение\", hours:\"Доказано, ч\", last_action_local:\"Последнее действие\", last_action:\"Окно / действие\", evidence_events:\"Подтверждений\"})\n",
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -630,7 +630,7 @@
|
|||||||
},
|
},
|
||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
"query": "import \"date\"\nimport \"strings\"\nimport \"timezone\"\noption location = timezone.location(name: \"Europe/Moscow\")\ntoday = strings.substring(v: string(v: date.add(d: 3h, to: date.truncate(t: now(), unit: 1d))), start: 0, end: 10)\nfrom(bucket: \"aw_metrics\")\n |> range(start: -3d)\n |> filter(fn: (r) => r._measurement == \"aw_true_active_app_daily\" and r.host == \"${host}\" and r.report_date == today)\n |> filter(fn: (r) => r._field == \"proved_work_seconds\" or r._field == \"evidence_events\" or r._field == \"last_action\" or r._field == \"last_action_local\")\n |> group(columns:[\"application\",\"report_date\",\"_field\"])\n |> last()\n |> keep(columns:[\"application\",\"report_date\",\"_field\",\"_value\"])\n |> map(fn:(r)=>({ r with _value: string(v:r._value) }))\n |> group()\n |> pivot(rowKey:[\"application\",\"report_date\"], columnKey:[\"_field\"], valueColumn:\"_value\")\n |> map(fn:(r)=>({ r with hours: float(v:r.proved_work_seconds) / 3600.0 }))\n |> sort(columns:[\"hours\"], desc:true)\n |> group()\n |> keep(columns:[\"report_date\",\"application\",\"hours\",\"last_action_local\",\"last_action\",\"evidence_events\"])\n |> rename(columns:{report_date:\"Дата\", application:\"Приложение\", hours:\"Доказано, ч\", last_action_local:\"Последнее действие\", last_action:\"Окно / действие\", evidence_events:\"Подтверждений\"})",
|
"query": "import \"date\"\nimport \"strings\"\nimport \"timezone\"\noption location = timezone.location(name: \"Europe/Moscow\")\ntoday = strings.substring(v: string(v: date.add(d: 3h, to: date.truncate(t: now(), unit: 1d))), start: 0, end: 10)\nbase = from(bucket: \"aw_metrics\")\n |> range(start: -3d)\n |> filter(fn: (r) => r._measurement == \"aw_true_active_app_daily\" and r.host == \"${host}\" and r.report_date == today)\n\nnums = base\n |> filter(fn: (r) => r._field == \"proved_work_seconds\" or r._field == \"evidence_events\")\n |> group(columns:[\"application\",\"_field\"])\n |> last()\n |> group()\n |> pivot(rowKey:[\"application\",\"report_date\"], columnKey:[\"_field\"], valueColumn:\"_value\")\n\ntexts = base\n |> filter(fn: (r) => r._field == \"last_action\" or r._field == \"last_action_local\")\n |> group(columns:[\"application\",\"_field\"])\n |> last()\n |> group()\n |> pivot(rowKey:[\"application\",\"report_date\"], columnKey:[\"_field\"], valueColumn:\"_value\")\n\njoin(tables: {n: nums, t: texts}, on: [\"application\", \"report_date\"])\n |> map(fn:(r)=>({ r with hours: float(v:r.proved_work_seconds) / 3600.0 }))\n |> sort(columns:[\"proved_work_seconds\"], desc:true)\n |> group()\n |> keep(columns:[\"report_date\",\"application\",\"hours\",\"last_action_local\",\"last_action\",\"evidence_events\"])\n |> rename(columns:{report_date:\"Дата\", application:\"Приложение\", hours:\"Доказано, ч\", last_action_local:\"Последнее действие\", last_action:\"Окно / действие\", evidence_events:\"Подтверждений\"})",
|
||||||
"refId": "A"
|
"refId": "A"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -4,33 +4,8 @@ set -euo pipefail
|
|||||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
TARGET_ROOT="${CARGO_TARGET_DIR:-$ROOT_DIR/adk-rust/target}"
|
TARGET_ROOT="${CARGO_TARGET_DIR:-$ROOT_DIR/adk-rust/target}"
|
||||||
RELEASE_DIR="$TARGET_ROOT/release"
|
RELEASE_DIR="$TARGET_ROOT/release"
|
||||||
SCOPE="${CHECK_DETMIR_RUST_RELEASE_SCOPE:-prod-runtime}"
|
|
||||||
|
|
||||||
prod_runtime_bins=(
|
required_bins=(
|
||||||
aw-1c-ingest
|
|
||||||
aw-hayabusa-autoprocess-rust
|
|
||||||
aw-rus-healthd
|
|
||||||
aw-slo-monitor
|
|
||||||
aw-workforce-ingest
|
|
||||||
detmir-auto
|
|
||||||
detmir-portal
|
|
||||||
detmir-readiness
|
|
||||||
dlp-aggregator
|
|
||||||
dlp-case-management
|
|
||||||
dlp-cef-exporter
|
|
||||||
dlp-compliance
|
|
||||||
dlp-influx-exporter
|
|
||||||
dlp-policy-engine
|
|
||||||
dlp-syslog-forwarder
|
|
||||||
dlp-webhook-sender
|
|
||||||
worktime-api
|
|
||||||
worktime-autoheal
|
|
||||||
worktime-influx-exporter
|
|
||||||
worktime-prewarm
|
|
||||||
worktime-ui-bridge
|
|
||||||
)
|
|
||||||
|
|
||||||
workspace_bins=(
|
|
||||||
detmir-status
|
detmir-status
|
||||||
detmir-adk-status
|
detmir-adk-status
|
||||||
detmir-check
|
detmir-check
|
||||||
@@ -86,23 +61,8 @@ workspace_bins=(
|
|||||||
aw-hayabusa-from-windows-rust
|
aw-hayabusa-from-windows-rust
|
||||||
aw-hayabusa-autoprocess-rust
|
aw-hayabusa-autoprocess-rust
|
||||||
aw-1c-ingest
|
aw-1c-ingest
|
||||||
containment-engine
|
|
||||||
security-finding-inbox
|
|
||||||
)
|
)
|
||||||
|
|
||||||
case "$SCOPE" in
|
|
||||||
prod-runtime)
|
|
||||||
required_bins=("${prod_runtime_bins[@]}")
|
|
||||||
;;
|
|
||||||
workspace)
|
|
||||||
required_bins=("${workspace_bins[@]}")
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unsupported CHECK_DETMIR_RUST_RELEASE_SCOPE=$SCOPE; expected prod-runtime or workspace" >&2
|
|
||||||
exit 2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
missing=0
|
missing=0
|
||||||
for bin in "${required_bins[@]}"; do
|
for bin in "${required_bins[@]}"; do
|
||||||
if [[ -x "$RELEASE_DIR/$bin" ]]; then
|
if [[ -x "$RELEASE_DIR/$bin" ]]; then
|
||||||
@@ -116,7 +76,7 @@ done
|
|||||||
if (( missing != 0 )); then
|
if (( missing != 0 )); then
|
||||||
cat >&2 <<EOF
|
cat >&2 <<EOF
|
||||||
|
|
||||||
Missing DetMir Rust release artifacts for scope: $SCOPE.
|
Missing DetMir Rust release artifacts.
|
||||||
Build them with:
|
Build them with:
|
||||||
cd "$ROOT_DIR/adk-rust"
|
cd "$ROOT_DIR/adk-rust"
|
||||||
CARGO_TARGET_DIR="$TARGET_ROOT" cargo build --release --workspace
|
CARGO_TARGET_DIR="$TARGET_ROOT" cargo build --release --workspace
|
||||||
@@ -124,4 +84,4 @@ EOF
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "detmir rust release artifacts: OK scope=$SCOPE ($RELEASE_DIR)"
|
echo "detmir rust release artifacts: OK ($RELEASE_DIR)"
|
||||||
|
|||||||
@@ -1,260 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
ENABLED="${AW_DLP_GUARD_ENABLED:-true}"
|
|
||||||
PROFILE="${AW_DLP_PROFILE:-light}"
|
|
||||||
STATE_DIR="${AW_DLP_GUARD_STATE_DIR:-/var/lib/activitywatch/health}"
|
|
||||||
STATE_FILE="${AW_DLP_GUARD_STATE_FILE:-${STATE_DIR}/dlp-light-guard-state.json}"
|
|
||||||
STATE_HISTORY_DIR="${AW_DLP_GUARD_HISTORY_DIR:-${STATE_DIR}/dlp-light-guard-history}"
|
|
||||||
CONTROL_BIN="${AW_DLP_CONTROL_BIN:-/usr/local/bin/detmir-dlp-runtime-control}"
|
|
||||||
LOAD_RATIO="${AW_DLP_GUARD_LOAD_RATIO:-1.50}"
|
|
||||||
MEM_AVAILABLE_PCT_MIN="${AW_DLP_GUARD_MEM_AVAILABLE_PCT_MIN:-15}"
|
|
||||||
IOWAIT_PCT_MAX="${AW_DLP_GUARD_IOWAIT_PCT_MAX:-20}"
|
|
||||||
STRIKES_REQUIRED="${AW_DLP_GUARD_STRIKES_REQUIRED:-3}"
|
|
||||||
|
|
||||||
DLP_GUARDED_UNITS=(
|
|
||||||
aw-dlp-influx-exporter.timer
|
|
||||||
aw-dlp-influx-exporter.service
|
|
||||||
activitywatch-dlp-aggregator.timer
|
|
||||||
activitywatch-dlp-aggregator.service
|
|
||||||
aw-dlp-report-scheduler.timer
|
|
||||||
aw-dlp-report-scheduler.service
|
|
||||||
aw-dlp-syslog-forwarder.timer
|
|
||||||
aw-dlp-syslog-forwarder.service
|
|
||||||
aw-dlp-webhook-sender.timer
|
|
||||||
aw-dlp-webhook-sender.service
|
|
||||||
aw-dlp-cef-exporter.timer
|
|
||||||
aw-dlp-cef-exporter.service
|
|
||||||
aw-dlp-ioc-refresh.timer
|
|
||||||
aw-dlp-ioc-refresh.service
|
|
||||||
aw-dlp-policy-engine.service
|
|
||||||
aw-dlp-case-management.service
|
|
||||||
detmir-portal-evidence.service
|
|
||||||
)
|
|
||||||
|
|
||||||
json_string() {
|
|
||||||
python3 -c 'import json,sys; print(json.dumps(sys.argv[1], ensure_ascii=False))' "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
number_or_null() {
|
|
||||||
local value="${1:-}"
|
|
||||||
if [[ "$value" =~ ^-?[0-9]+([.][0-9]+)?$ ]]; then
|
|
||||||
printf '%s' "$value"
|
|
||||||
else
|
|
||||||
printf 'null'
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
active_dlp_units_json() {
|
|
||||||
local first=1 unit
|
|
||||||
printf '['
|
|
||||||
if command -v systemctl >/dev/null 2>&1; then
|
|
||||||
for unit in "${DLP_GUARDED_UNITS[@]}"; do
|
|
||||||
if systemctl is-active --quiet "$unit" 2>/dev/null; then
|
|
||||||
[[ "$first" -eq 1 ]] || printf ','
|
|
||||||
first=0
|
|
||||||
json_string "$unit"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
printf ']'
|
|
||||||
}
|
|
||||||
|
|
||||||
active_dlp_unit_count() {
|
|
||||||
local count=0 unit
|
|
||||||
if command -v systemctl >/dev/null 2>&1; then
|
|
||||||
for unit in "${DLP_GUARDED_UNITS[@]}"; do
|
|
||||||
if systemctl is-active --quiet "$unit" 2>/dev/null; then
|
|
||||||
count=$((count + 1))
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
printf '%s\n' "$count"
|
|
||||||
}
|
|
||||||
|
|
||||||
read_load1() {
|
|
||||||
awk '{print $1}' /proc/loadavg 2>/dev/null || printf '0'
|
|
||||||
}
|
|
||||||
|
|
||||||
read_cpu_count() {
|
|
||||||
local cores
|
|
||||||
cores="$(getconf _NPROCESSORS_ONLN 2>/dev/null || printf '1')"
|
|
||||||
if [[ ! "$cores" =~ ^[0-9]+$ || "$cores" -lt 1 ]]; then
|
|
||||||
cores=1
|
|
||||||
fi
|
|
||||||
printf '%s\n' "$cores"
|
|
||||||
}
|
|
||||||
|
|
||||||
read_mem_available_pct() {
|
|
||||||
awk '
|
|
||||||
/^MemTotal:/ { total=$2 }
|
|
||||||
/^MemAvailable:/ { available=$2 }
|
|
||||||
END {
|
|
||||||
if (total > 0) {
|
|
||||||
printf "%.2f", (available * 100.0 / total)
|
|
||||||
} else {
|
|
||||||
printf "0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
' /proc/meminfo 2>/dev/null || printf '0'
|
|
||||||
}
|
|
||||||
|
|
||||||
read_cpu_sample() {
|
|
||||||
awk '/^cpu / {
|
|
||||||
idle=$5
|
|
||||||
iowait=$6
|
|
||||||
total=0
|
|
||||||
for (i=2; i<=NF; i++) total += $i
|
|
||||||
printf "%s %s\n", total, iowait
|
|
||||||
exit
|
|
||||||
}' /proc/stat 2>/dev/null || printf '0 0'
|
|
||||||
}
|
|
||||||
|
|
||||||
read_iowait_pct() {
|
|
||||||
local total1 wait1 total2 wait2 dtotal dwait
|
|
||||||
read -r total1 wait1 < <(read_cpu_sample)
|
|
||||||
sleep 1
|
|
||||||
read -r total2 wait2 < <(read_cpu_sample)
|
|
||||||
dtotal=$((total2 - total1))
|
|
||||||
dwait=$((wait2 - wait1))
|
|
||||||
if [[ "$dtotal" -le 0 || "$dwait" -lt 0 ]]; then
|
|
||||||
printf '0'
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
awk -v wait="$dwait" -v total="$dtotal" 'BEGIN { printf "%.2f", wait * 100.0 / total }'
|
|
||||||
}
|
|
||||||
|
|
||||||
is_over_threshold() {
|
|
||||||
local value="$1"
|
|
||||||
local threshold="$2"
|
|
||||||
awk -v value="$value" -v threshold="$threshold" 'BEGIN { exit !(value > threshold) }'
|
|
||||||
}
|
|
||||||
|
|
||||||
is_under_threshold() {
|
|
||||||
local value="$1"
|
|
||||||
local threshold="$2"
|
|
||||||
awk -v value="$value" -v threshold="$threshold" 'BEGIN { exit !(value < threshold) }'
|
|
||||||
}
|
|
||||||
|
|
||||||
write_state() {
|
|
||||||
local action="$1"
|
|
||||||
local reason="$2"
|
|
||||||
local load1="$3"
|
|
||||||
local cores="$4"
|
|
||||||
local load_threshold="$5"
|
|
||||||
local mem_pct="$6"
|
|
||||||
local iowait_pct="$7"
|
|
||||||
local active_count="$8"
|
|
||||||
local active_units_json="$9"
|
|
||||||
local control_exit="${10}"
|
|
||||||
local strikes="${11:-0}"
|
|
||||||
local now stamp tmp history
|
|
||||||
|
|
||||||
now="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
||||||
stamp="$(date -u +%Y%m%dT%H%M%SZ)"
|
|
||||||
mkdir -p "$STATE_DIR" "$STATE_HISTORY_DIR"
|
|
||||||
tmp="$(mktemp "${STATE_FILE}.tmp.XXXXXX")"
|
|
||||||
{
|
|
||||||
printf '{'
|
|
||||||
printf '"generated_at_utc":%s,' "$(json_string "$now")"
|
|
||||||
printf '"profile":%s,' "$(json_string "$PROFILE")"
|
|
||||||
printf '"guard_enabled":%s,' "$(json_string "$ENABLED")"
|
|
||||||
printf '"action":%s,' "$(json_string "$action")"
|
|
||||||
printf '"reason":%s,' "$(json_string "$reason")"
|
|
||||||
printf '"consecutive_overload_count":%s,' "$(number_or_null "$strikes")"
|
|
||||||
printf '"consecutive_overload_required":%s,' "$(number_or_null "$STRIKES_REQUIRED")"
|
|
||||||
printf '"control_bin":%s,' "$(json_string "$CONTROL_BIN")"
|
|
||||||
printf '"control_exit":%s,' "$(number_or_null "$control_exit")"
|
|
||||||
printf '"metrics":{'
|
|
||||||
printf '"load1":%s,' "$(number_or_null "$load1")"
|
|
||||||
printf '"cpu_count":%s,' "$(number_or_null "$cores")"
|
|
||||||
printf '"load_threshold":%s,' "$(number_or_null "$load_threshold")"
|
|
||||||
printf '"mem_available_pct":%s,' "$(number_or_null "$mem_pct")"
|
|
||||||
printf '"mem_available_pct_min":%s,' "$(number_or_null "$MEM_AVAILABLE_PCT_MIN")"
|
|
||||||
printf '"iowait_pct":%s,' "$(number_or_null "$iowait_pct")"
|
|
||||||
printf '"iowait_pct_max":%s' "$(number_or_null "$IOWAIT_PCT_MAX")"
|
|
||||||
printf '},'
|
|
||||||
printf '"active_dlp_unit_count":%s,' "$(number_or_null "$active_count")"
|
|
||||||
printf '"active_dlp_units":%s' "$active_units_json"
|
|
||||||
printf '}\n'
|
|
||||||
} >"$tmp"
|
|
||||||
mv "$tmp" "$STATE_FILE"
|
|
||||||
history="${STATE_HISTORY_DIR}/dlp-light-guard-${stamp}.json"
|
|
||||||
cp -a "$STATE_FILE" "$history"
|
|
||||||
printf 'dlp guard action=%s reason=%s state=%s history=%s\n' "$action" "$reason" "$STATE_FILE" "$history"
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
|
||||||
local load1 cores load_threshold mem_pct iowait_pct active_count active_units_json overloaded reason control_exit strikes prev_strikes
|
|
||||||
|
|
||||||
load1="$(read_load1)"
|
|
||||||
cores="$(read_cpu_count)"
|
|
||||||
load_threshold="$(awk -v cores="$cores" -v ratio="$LOAD_RATIO" 'BEGIN { printf "%.2f", cores * ratio }')"
|
|
||||||
mem_pct="$(read_mem_available_pct)"
|
|
||||||
iowait_pct="$(read_iowait_pct)"
|
|
||||||
active_units_json="$(active_dlp_units_json)"
|
|
||||||
active_count="$(active_dlp_unit_count)"
|
|
||||||
overloaded=0
|
|
||||||
reason="within_thresholds"
|
|
||||||
prev_strikes="$(
|
|
||||||
python3 - "$STATE_FILE" <<'PY' 2>/dev/null || true
|
|
||||||
import json, sys
|
|
||||||
try:
|
|
||||||
print(int(json.load(open(sys.argv[1])).get("consecutive_overload_count", 0)))
|
|
||||||
except Exception:
|
|
||||||
print(0)
|
|
||||||
PY
|
|
||||||
)"
|
|
||||||
[[ "$prev_strikes" =~ ^[0-9]+$ ]] || prev_strikes=0
|
|
||||||
strikes=0
|
|
||||||
|
|
||||||
if is_over_threshold "$load1" "$load_threshold"; then
|
|
||||||
overloaded=1
|
|
||||||
reason="load1_above_threshold"
|
|
||||||
elif is_under_threshold "$mem_pct" "$MEM_AVAILABLE_PCT_MIN"; then
|
|
||||||
overloaded=1
|
|
||||||
reason="mem_available_below_threshold"
|
|
||||||
elif is_over_threshold "$iowait_pct" "$IOWAIT_PCT_MAX"; then
|
|
||||||
overloaded=1
|
|
||||||
reason="iowait_above_threshold"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$ENABLED" != "true" && "$ENABLED" != "1" && "$ENABLED" != "yes" ]]; then
|
|
||||||
write_state "skipped" "guard_disabled" "$load1" "$cores" "$load_threshold" "$mem_pct" "$iowait_pct" "$active_count" "$active_units_json" "0" "0"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$overloaded" -eq 0 ]]; then
|
|
||||||
write_state "none" "$reason" "$load1" "$cores" "$load_threshold" "$mem_pct" "$iowait_pct" "$active_count" "$active_units_json" "0" "0"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
strikes=$((prev_strikes + 1))
|
|
||||||
|
|
||||||
if [[ "$strikes" -lt "$STRIKES_REQUIRED" ]]; then
|
|
||||||
write_state "observe_overload" "$reason" "$load1" "$cores" "$load_threshold" "$mem_pct" "$iowait_pct" "$active_count" "$active_units_json" "0" "$strikes"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$active_count" -eq 0 ]]; then
|
|
||||||
write_state "none" "${reason}_but_no_active_dlp_units" "$load1" "$cores" "$load_threshold" "$mem_pct" "$iowait_pct" "$active_count" "$active_units_json" "0" "$strikes"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -x "$CONTROL_BIN" ]]; then
|
|
||||||
write_state "failed" "${reason}_control_bin_missing" "$load1" "$cores" "$load_threshold" "$mem_pct" "$iowait_pct" "$active_count" "$active_units_json" "127" "$strikes"
|
|
||||||
printf 'DLP guard cannot disable overloaded DLP: executable not found: %s\n' "$CONTROL_BIN" >&2
|
|
||||||
return 127
|
|
||||||
fi
|
|
||||||
|
|
||||||
control_exit=0
|
|
||||||
AW_DLP_DISABLED_REASON="auto_disabled_by_dlp_load_guard:${reason}" "$CONTROL_BIN" set-profile core_only || control_exit=$?
|
|
||||||
if [[ "$control_exit" -eq 0 ]]; then
|
|
||||||
write_state "auto_disabled" "$reason" "$load1" "$cores" "$load_threshold" "$mem_pct" "$iowait_pct" "$active_count" "$active_units_json" "$control_exit" "$strikes"
|
|
||||||
else
|
|
||||||
write_state "failed" "${reason}_control_exit_${control_exit}" "$load1" "$cores" "$load_threshold" "$mem_pct" "$iowait_pct" "$active_count" "$active_units_json" "$control_exit" "$strikes"
|
|
||||||
fi
|
|
||||||
return "$control_exit"
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
@@ -1,269 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
ACTION="${1:-status}"
|
|
||||||
PROFILE="${2:-${AW_DLP_PROFILE:-core_only}}"
|
|
||||||
AW_BASE="${AW_DLP_CONTROL_AW_BASE:-http://127.0.0.1:5600}"
|
|
||||||
HOSTNAME_FILTER="${AW_DLP_CONTROL_HOSTNAME:-${AW_LOGICAL_HOST_ID:-${AW_MONITORED_WINDOWS_HOSTNAME:-HOST-EXAMPLE}}}"
|
|
||||||
STATE_DIR="${AW_DLP_CONTROL_STATE_DIR:-/var/lib/activitywatch/health}"
|
|
||||||
STATE_FILE="${AW_DLP_CONTROL_STATE_FILE:-${STATE_DIR}/dlp-runtime-state.json}"
|
|
||||||
STATE_HISTORY_DIR="${AW_DLP_CONTROL_HISTORY_DIR:-${STATE_DIR}/dlp-runtime-history}"
|
|
||||||
ROLLBACK_FILE="${AW_DLP_CONTROL_ROLLBACK_FILE:-${STATE_DIR}/dlp-runtime-rollback.state}"
|
|
||||||
REASON="${AW_DLP_DISABLED_REASON:-dlp_runtime_profile_control}"
|
|
||||||
|
|
||||||
DLP_UNITS=(
|
|
||||||
aw-dlp-influx-exporter.timer
|
|
||||||
aw-dlp-influx-exporter.service
|
|
||||||
activitywatch-dlp-aggregator.timer
|
|
||||||
activitywatch-dlp-aggregator.service
|
|
||||||
aw-dlp-report-scheduler.timer
|
|
||||||
aw-dlp-report-scheduler.service
|
|
||||||
aw-dlp-syslog-forwarder.timer
|
|
||||||
aw-dlp-syslog-forwarder.service
|
|
||||||
aw-dlp-webhook-sender.timer
|
|
||||||
aw-dlp-webhook-sender.service
|
|
||||||
aw-dlp-cef-exporter.timer
|
|
||||||
aw-dlp-cef-exporter.service
|
|
||||||
aw-dlp-ioc-refresh.timer
|
|
||||||
aw-dlp-ioc-refresh.service
|
|
||||||
aw-dlp-policy-engine.service
|
|
||||||
aw-dlp-case-management.service
|
|
||||||
detmir-portal-evidence.service
|
|
||||||
)
|
|
||||||
|
|
||||||
DLP_BUCKET_PREFIXES=(
|
|
||||||
aw-dlp-endpoint-signals
|
|
||||||
aw-dlp-incidents
|
|
||||||
aw-dlp-review
|
|
||||||
aw-dlp-rules
|
|
||||||
)
|
|
||||||
|
|
||||||
DLP_LIGHT_UNITS=(
|
|
||||||
activitywatch-dlp-aggregator.timer
|
|
||||||
aw-dlp-ioc-refresh.timer
|
|
||||||
)
|
|
||||||
|
|
||||||
DLP_ON_DEMAND_UNITS=(
|
|
||||||
aw-dlp-ioc-refresh.timer
|
|
||||||
aw-dlp-policy-engine.service
|
|
||||||
aw-dlp-case-management.service
|
|
||||||
detmir-portal-evidence.service
|
|
||||||
)
|
|
||||||
|
|
||||||
json_escape() {
|
|
||||||
local value="$1"
|
|
||||||
python3 -c 'import json,sys; print(json.dumps(sys.argv[1], ensure_ascii=False))' "$value"
|
|
||||||
}
|
|
||||||
|
|
||||||
unit_json() {
|
|
||||||
local first=1 unit active enabled load
|
|
||||||
printf '['
|
|
||||||
for unit in "${DLP_UNITS[@]}"; do
|
|
||||||
load="$(systemctl show -p LoadState --value "$unit" 2>/dev/null || true)"
|
|
||||||
if [[ "$load" == "not-found" || -z "$load" ]]; then
|
|
||||||
active="not-found"
|
|
||||||
enabled="not-found"
|
|
||||||
else
|
|
||||||
active="$(systemctl is-active "$unit" 2>/dev/null || true)"
|
|
||||||
enabled="$(systemctl is-enabled "$unit" 2>/dev/null || true)"
|
|
||||||
fi
|
|
||||||
[[ "$first" -eq 1 ]] || printf ','
|
|
||||||
first=0
|
|
||||||
printf '{"unit":%s,"load":%s,"active":%s,"enabled":%s}' \
|
|
||||||
"$(json_escape "$unit")" \
|
|
||||||
"$(json_escape "${load:-not-found}")" \
|
|
||||||
"$(json_escape "${active:-unknown}")" \
|
|
||||||
"$(json_escape "${enabled:-unknown}")"
|
|
||||||
done
|
|
||||||
printf ']'
|
|
||||||
}
|
|
||||||
|
|
||||||
bucket_json() {
|
|
||||||
local first=1 prefix bucket url payload ts count
|
|
||||||
printf '['
|
|
||||||
for prefix in "${DLP_BUCKET_PREFIXES[@]}"; do
|
|
||||||
bucket="${prefix}_${HOSTNAME_FILTER}"
|
|
||||||
url="${AW_BASE%/}/api/0/buckets/${bucket}/events?limit=1"
|
|
||||||
payload="$(curl -sS --connect-timeout 3 --max-time 8 "$url" 2>/dev/null || true)"
|
|
||||||
ts="$(printf '%s' "$payload" | jq -r '.[0].timestamp // ""' 2>/dev/null || true)"
|
|
||||||
count="$(printf '%s' "$payload" | jq -r 'if type == "array" then length else 0 end' 2>/dev/null || printf '0')"
|
|
||||||
[[ "$first" -eq 1 ]] || printf ','
|
|
||||||
first=0
|
|
||||||
printf '{"bucket":%s,"sample_count":%s,"latest_timestamp":%s}' \
|
|
||||||
"$(json_escape "$bucket")" \
|
|
||||||
"${count:-0}" \
|
|
||||||
"$(json_escape "$ts")"
|
|
||||||
done
|
|
||||||
printf ']'
|
|
||||||
}
|
|
||||||
|
|
||||||
unit_exists() {
|
|
||||||
local unit="$1"
|
|
||||||
systemctl list-unit-files "$unit" --no-legend 2>/dev/null | grep -q . || systemctl status "$unit" >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
stop_disable_all_dlp() {
|
|
||||||
local unit
|
|
||||||
for unit in "${DLP_UNITS[@]}"; do
|
|
||||||
if unit_exists "$unit"; then
|
|
||||||
systemctl stop "$unit" >/dev/null 2>&1 || true
|
|
||||||
systemctl disable "$unit" >/dev/null 2>&1 || true
|
|
||||||
systemctl reset-failed "$unit" >/dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
enable_start_units() {
|
|
||||||
local unit
|
|
||||||
for unit in "$@"; do
|
|
||||||
if unit_exists "$unit"; then
|
|
||||||
systemctl enable --now "$unit" >/dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
capture_rollback_state() {
|
|
||||||
local tmp unit load active enabled
|
|
||||||
mkdir -p "$STATE_DIR"
|
|
||||||
tmp="$(mktemp "${ROLLBACK_FILE}.tmp.XXXXXX")"
|
|
||||||
{
|
|
||||||
printf '# generated_at_utc=%s\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
||||||
printf '# reason=pre_profile_change\n'
|
|
||||||
for unit in "${DLP_UNITS[@]}"; do
|
|
||||||
load="$(systemctl show -p LoadState --value "$unit" 2>/dev/null || true)"
|
|
||||||
if [[ "$load" == "not-found" || -z "$load" ]]; then
|
|
||||||
active="not-found"
|
|
||||||
enabled="not-found"
|
|
||||||
else
|
|
||||||
active="$(systemctl is-active "$unit" 2>/dev/null || true)"
|
|
||||||
enabled="$(systemctl is-enabled "$unit" 2>/dev/null || true)"
|
|
||||||
fi
|
|
||||||
printf '%s|%s|%s|%s\n' "$unit" "${load:-not-found}" "$active" "$enabled"
|
|
||||||
done
|
|
||||||
} >"$tmp"
|
|
||||||
mv "$tmp" "$ROLLBACK_FILE"
|
|
||||||
}
|
|
||||||
|
|
||||||
write_stats() {
|
|
||||||
local mode="${1:-current}" now stamp tmp history_file
|
|
||||||
now="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
||||||
stamp="$(date -u +%Y%m%dT%H%M%SZ)"
|
|
||||||
mkdir -p "$STATE_DIR" "$STATE_HISTORY_DIR"
|
|
||||||
tmp="$(mktemp "${STATE_FILE}.tmp.XXXXXX")"
|
|
||||||
{
|
|
||||||
printf '{'
|
|
||||||
printf '"generated_at_utc":%s,' "$(json_escape "$now")"
|
|
||||||
printf '"mode":%s,' "$(json_escape "$mode")"
|
|
||||||
printf '"profile":%s,' "$(json_escape "${AW_DLP_PROFILE:-$PROFILE}")"
|
|
||||||
printf '"reason":%s,' "$(json_escape "$REASON")"
|
|
||||||
printf '"aw_base":%s,' "$(json_escape "$AW_BASE")"
|
|
||||||
printf '"hostname":%s,' "$(json_escape "$HOSTNAME_FILTER")"
|
|
||||||
printf '"units":'
|
|
||||||
unit_json
|
|
||||||
printf ',"buckets":'
|
|
||||||
bucket_json
|
|
||||||
printf '}\n'
|
|
||||||
} >"$tmp"
|
|
||||||
mv "$tmp" "$STATE_FILE"
|
|
||||||
history_file="${STATE_HISTORY_DIR}/dlp-runtime-${mode}-${stamp}.json"
|
|
||||||
cp -a "$STATE_FILE" "$history_file"
|
|
||||||
printf 'latest=%s\nhistory=%s\n' "$STATE_FILE" "$history_file"
|
|
||||||
}
|
|
||||||
|
|
||||||
apply_profile() {
|
|
||||||
local target_profile="$1"
|
|
||||||
capture_rollback_state
|
|
||||||
case "$target_profile" in
|
|
||||||
core_only|disabled|off)
|
|
||||||
PROFILE="core_only"
|
|
||||||
stop_disable_all_dlp
|
|
||||||
AW_DLP_PROFILE="core_only" write_stats "disabled"
|
|
||||||
;;
|
|
||||||
light)
|
|
||||||
PROFILE="light"
|
|
||||||
stop_disable_all_dlp
|
|
||||||
enable_start_units "${DLP_LIGHT_UNITS[@]}"
|
|
||||||
AW_DLP_PROFILE="light" write_stats "enabled_light"
|
|
||||||
;;
|
|
||||||
on_demand)
|
|
||||||
PROFILE="on_demand"
|
|
||||||
stop_disable_all_dlp
|
|
||||||
enable_start_units "${DLP_ON_DEMAND_UNITS[@]}"
|
|
||||||
AW_DLP_PROFILE="on_demand" write_stats "enabled_on_demand"
|
|
||||||
;;
|
|
||||||
full|enabled|on)
|
|
||||||
PROFILE="full"
|
|
||||||
stop_disable_all_dlp
|
|
||||||
enable_start_units "${DLP_LIGHT_UNITS[@]}"
|
|
||||||
enable_start_units \
|
|
||||||
aw-dlp-influx-exporter.timer \
|
|
||||||
activitywatch-dlp-aggregator.timer \
|
|
||||||
aw-dlp-report-scheduler.timer \
|
|
||||||
aw-dlp-syslog-forwarder.timer \
|
|
||||||
aw-dlp-webhook-sender.timer \
|
|
||||||
aw-dlp-cef-exporter.timer \
|
|
||||||
aw-dlp-policy-engine.service \
|
|
||||||
aw-dlp-case-management.service \
|
|
||||||
detmir-portal-evidence.service
|
|
||||||
AW_DLP_PROFILE="full" write_stats "enabled_full"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
printf 'unsupported DLP profile: %s\n' "$target_profile" >&2
|
|
||||||
printf 'supported profiles: core_only, light, on_demand, full\n' >&2
|
|
||||||
exit 2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
disable_dlp() {
|
|
||||||
apply_profile "core_only"
|
|
||||||
}
|
|
||||||
|
|
||||||
enable_dlp() {
|
|
||||||
apply_profile "full"
|
|
||||||
}
|
|
||||||
|
|
||||||
rollback_dlp() {
|
|
||||||
local unit load active enabled
|
|
||||||
if [[ ! -s "$ROLLBACK_FILE" ]]; then
|
|
||||||
printf 'rollback state not found: %s\n' "$ROLLBACK_FILE" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
stop_disable_all_dlp
|
|
||||||
while IFS='|' read -r unit load active enabled; do
|
|
||||||
[[ -n "${unit:-}" && "${unit:0:1}" != "#" ]] || continue
|
|
||||||
[[ "$load" != "not-found" ]] || continue
|
|
||||||
if [[ "$enabled" == "enabled" ]]; then
|
|
||||||
systemctl enable "$unit" >/dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
if [[ "$active" == "active" ]]; then
|
|
||||||
systemctl start "$unit" >/dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
done <"$ROLLBACK_FILE"
|
|
||||||
write_stats "rollback"
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$ACTION" in
|
|
||||||
status|stats)
|
|
||||||
write_stats "current"
|
|
||||||
;;
|
|
||||||
profile)
|
|
||||||
printf '%s\n' "${AW_DLP_PROFILE:-$PROFILE}"
|
|
||||||
;;
|
|
||||||
set-profile)
|
|
||||||
apply_profile "$PROFILE"
|
|
||||||
;;
|
|
||||||
disable)
|
|
||||||
disable_dlp
|
|
||||||
;;
|
|
||||||
enable)
|
|
||||||
enable_dlp
|
|
||||||
;;
|
|
||||||
rollback)
|
|
||||||
rollback_dlp
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
printf 'Usage: %s [status|stats|profile|set-profile <core_only|light|on_demand|full>|disable|enable|rollback]\n' "$0" >&2
|
|
||||||
exit 2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
SOURCE_HOST="${AW_DLP_WAREHOUSE_SOURCE_HOST:-igor@10.10.10.13}"
|
|
||||||
SOURCE_PATH="${AW_DLP_WAREHOUSE_SOURCE_PATH:-/var/lib/activitywatch/dlp_warehouse.sqlite}"
|
|
||||||
DEST_PATH="${AW_DLP_WAREHOUSE_DEST_PATH:-/var/lib/activitywatch/dlp_warehouse.sqlite}"
|
|
||||||
STATE_DIR="${AW_DLP_WAREHOUSE_SYNC_STATE_DIR:-/var/lib/activitywatch/health}"
|
|
||||||
STATE_FILE="${AW_DLP_WAREHOUSE_SYNC_STATE_FILE:-${STATE_DIR}/dlp-warehouse-sync-state.json}"
|
|
||||||
SSH_OPTS="${AW_DLP_WAREHOUSE_SSH_OPTS:--o BatchMode=yes -o ConnectTimeout=5}"
|
|
||||||
REMOTE_TMP="/tmp/dlp_warehouse_sync_$$.sqlite"
|
|
||||||
LOCAL_TMP=""
|
|
||||||
|
|
||||||
json_string() {
|
|
||||||
python3 -c 'import json,sys; print(json.dumps(sys.argv[1], ensure_ascii=False))' "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
write_state() {
|
|
||||||
local status="$1"
|
|
||||||
local message="$2"
|
|
||||||
local rows="${3:-}"
|
|
||||||
local bytes="${4:-}"
|
|
||||||
local now tmp
|
|
||||||
now="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
||||||
mkdir -p "$STATE_DIR"
|
|
||||||
tmp="$(mktemp "${STATE_FILE}.tmp.XXXXXX")"
|
|
||||||
{
|
|
||||||
printf '{'
|
|
||||||
printf '"generated_at_utc":%s,' "$(json_string "$now")"
|
|
||||||
printf '"status":%s,' "$(json_string "$status")"
|
|
||||||
printf '"message":%s,' "$(json_string "$message")"
|
|
||||||
printf '"source_host":%s,' "$(json_string "$SOURCE_HOST")"
|
|
||||||
printf '"source_path":%s,' "$(json_string "$SOURCE_PATH")"
|
|
||||||
printf '"dest_path":%s,' "$(json_string "$DEST_PATH")"
|
|
||||||
if [[ "$rows" =~ ^[0-9]+$ ]]; then
|
|
||||||
printf '"dlp_events":%s,' "$rows"
|
|
||||||
else
|
|
||||||
printf '"dlp_events":null,'
|
|
||||||
fi
|
|
||||||
if [[ "$bytes" =~ ^[0-9]+$ ]]; then
|
|
||||||
printf '"bytes":%s' "$bytes"
|
|
||||||
else
|
|
||||||
printf '"bytes":null'
|
|
||||||
fi
|
|
||||||
printf '}\n'
|
|
||||||
} >"$tmp"
|
|
||||||
mv "$tmp" "$STATE_FILE"
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup_remote() {
|
|
||||||
ssh $SSH_OPTS "$SOURCE_HOST" "rm -f '$REMOTE_TMP'" >/dev/null 2>&1 || true
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
|
||||||
local dest_dir rows bytes
|
|
||||||
dest_dir="$(dirname "$DEST_PATH")"
|
|
||||||
mkdir -p "$dest_dir" "$STATE_DIR"
|
|
||||||
LOCAL_TMP="$(mktemp "${DEST_PATH}.tmp.XXXXXX")"
|
|
||||||
trap 'rm -f "${LOCAL_TMP:-}"; cleanup_remote' EXIT
|
|
||||||
|
|
||||||
ssh $SSH_OPTS "$SOURCE_HOST" \
|
|
||||||
"set -euo pipefail; if command -v sqlite3 >/dev/null 2>&1; then sqlite3 '$SOURCE_PATH' \".backup '$REMOTE_TMP'\" || cp -f '$SOURCE_PATH' '$REMOTE_TMP'; else cp -f '$SOURCE_PATH' '$REMOTE_TMP'; fi; test -s '$REMOTE_TMP'"
|
|
||||||
scp $SSH_OPTS "$SOURCE_HOST:$REMOTE_TMP" "$LOCAL_TMP"
|
|
||||||
chmod 0644 "$LOCAL_TMP"
|
|
||||||
mv "$LOCAL_TMP" "$DEST_PATH"
|
|
||||||
|
|
||||||
bytes="$(stat -c %s "$DEST_PATH" 2>/dev/null || printf '')"
|
|
||||||
rows="$(sqlite3 "$DEST_PATH" 'select count(*) from dlp_events;' 2>/dev/null || printf '')"
|
|
||||||
write_state "ok" "synced" "$rows" "$bytes"
|
|
||||||
printf 'dlp warehouse synced: source=%s:%s dest=%s rows=%s bytes=%s\n' \
|
|
||||||
"$SOURCE_HOST" "$SOURCE_PATH" "$DEST_PATH" "${rows:-unknown}" "${bytes:-unknown}"
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
@@ -53,26 +53,6 @@ done
|
|||||||
log() { printf "%s %s\n" "$(date +"%F %T")" "$*" >&2; }
|
log() { printf "%s %s\n" "$(date +"%F %T")" "$*" >&2; }
|
||||||
die() { log "ERROR: $*"; exit 1; }
|
die() { log "ERROR: $*"; exit 1; }
|
||||||
|
|
||||||
is_truthy() {
|
|
||||||
case "${1:-}" in
|
|
||||||
1|true|TRUE|yes|YES|on|ON) return 0 ;;
|
|
||||||
*) return 1 ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
require_real_value() {
|
|
||||||
local name="$1"
|
|
||||||
local value="${!name:-}"
|
|
||||||
if [[ -z "$value" ]]; then
|
|
||||||
die "missing required variable: $name"
|
|
||||||
fi
|
|
||||||
case "$value" in
|
|
||||||
*192.0.2.*|*198.51.100.*|*203.0.113.*|*HOST-EXAMPLE*|*.example*)
|
|
||||||
die "refusing placeholder value for $name: $value"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
command -v ansible >/dev/null 2>&1 || die "ansible not found"
|
command -v ansible >/dev/null 2>&1 || die "ansible not found"
|
||||||
command -v ansible-playbook >/dev/null 2>&1 || die "ansible-playbook not found"
|
command -v ansible-playbook >/dev/null 2>&1 || die "ansible-playbook not found"
|
||||||
[[ -f "$INVENTORY" ]] || die "inventory not found: $INVENTORY"
|
[[ -f "$INVENTORY" ]] || die "inventory not found: $INVENTORY"
|
||||||
@@ -88,14 +68,10 @@ restart_server_components() {
|
|||||||
"activitywatch-server"
|
"activitywatch-server"
|
||||||
"aw-worktime-api"
|
"aw-worktime-api"
|
||||||
"aw-worktime-ui-bridge.timer"
|
"aw-worktime-ui-bridge.timer"
|
||||||
|
"aw-dlp-policy-engine.service"
|
||||||
|
"aw-dlp-aggregator.timer"
|
||||||
|
"activitywatch-dlp-aggregator.timer"
|
||||||
)
|
)
|
||||||
if is_truthy "${DETMIR_DLP_ENABLED:-${AW_DLP_ENABLED:-false}}"; then
|
|
||||||
units+=(
|
|
||||||
"aw-dlp-policy-engine.service"
|
|
||||||
"aw-dlp-aggregator.timer"
|
|
||||||
"activitywatch-dlp-aggregator.timer"
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
for unit in "${units[@]}"; do
|
for unit in "${units[@]}"; do
|
||||||
if ansible -i "$INVENTORY" aw_server -b -m ansible.builtin.command -a "systemctl status ${unit}" >/dev/null 2>&1; then
|
if ansible -i "$INVENTORY" aw_server -b -m ansible.builtin.command -a "systemctl status ${unit}" >/dev/null 2>&1; then
|
||||||
ansible -i "$INVENTORY" aw_server -b -m ansible.builtin.systemd -a "name=${unit} state=restarted enabled=true" || true
|
ansible -i "$INVENTORY" aw_server -b -m ansible.builtin.systemd -a "name=${unit} state=restarted enabled=true" || true
|
||||||
@@ -104,32 +80,24 @@ restart_server_components() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
seed_server_dlp_events() {
|
seed_server_dlp_events() {
|
||||||
if ! is_truthy "${ALLOW_DLP_SEED_EVENTS:-0}"; then
|
|
||||||
log "Skipping DLP freshness seeding; set ALLOW_DLP_SEED_EVENTS=1 with real DETMIR_HOSTNAME/DETMIR_AW_SERVER_HOST to allow it."
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
require_real_value DETMIR_HOSTNAME
|
|
||||||
require_real_value DETMIR_AW_SERVER_HOST
|
|
||||||
log "Seeding DLP freshness events on aw_server..."
|
log "Seeding DLP freshness events on aw_server..."
|
||||||
local ts host server_host
|
local ts
|
||||||
ts="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
ts="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||||
host="${DETMIR_HOSTNAME}"
|
|
||||||
server_host="${DETMIR_AW_SERVER_HOST}"
|
|
||||||
ansible -i "$INVENTORY" aw_server -b -m ansible.builtin.shell -a "cat >/tmp/aw-endpoint-seed.json <<'JSON'
|
ansible -i "$INVENTORY" aw_server -b -m ansible.builtin.shell -a "cat >/tmp/aw-endpoint-seed.json <<'JSON'
|
||||||
{\"timestamp\":\"${ts}\",\"duration\":0.0,\"data\":{\"hostname\":\"${host}\",\"signalType\":\"self_test\",\"source\":\"diag_and_manual_restart\",\"username\":\"system\",\"queueDepth\":0,\"eventsEnqueued\":0,\"eventsFlushed\":0,\"sendFailures\":0}}
|
{\"timestamp\":\"${ts}\",\"duration\":0.0,\"data\":{\"hostname\":\"HOST-EXAMPLE\",\"signalType\":\"self_test\",\"source\":\"diag_and_manual_restart\",\"username\":\"system\",\"queueDepth\":0,\"eventsEnqueued\":0,\"eventsFlushed\":0,\"sendFailures\":0}}
|
||||||
JSON
|
JSON
|
||||||
cat >/tmp/aw-fileops-seed-host.json <<'JSON'
|
cat >/tmp/aw-fileops-seed-host.json <<'JSON'
|
||||||
{\"timestamp\":\"${ts}\",\"duration\":0.0,\"data\":{\"hostname\":\"${host}\",\"operation\":\"self_test\",\"source\":\"diag_and_manual_restart\"}}
|
{\"timestamp\":\"${ts}\",\"duration\":0.0,\"data\":{\"hostname\":\"HOST-EXAMPLE\",\"operation\":\"self_test\",\"source\":\"diag_and_manual_restart\"}}
|
||||||
JSON
|
JSON
|
||||||
cat >/tmp/aw-fileops-seed-server.json <<'JSON'
|
cat >/tmp/aw-fileops-seed-server.json <<'JSON'
|
||||||
{\"timestamp\":\"${ts}\",\"duration\":0.0,\"data\":{\"hostname\":\"${server_host}\",\"operation\":\"self_test\",\"source\":\"diag_and_manual_restart\"}}
|
{\"timestamp\":\"${ts}\",\"duration\":0.0,\"data\":{\"hostname\":\"192.0.2.13\",\"operation\":\"self_test\",\"source\":\"diag_and_manual_restart\"}}
|
||||||
JSON
|
JSON
|
||||||
curl -sS -X POST 'http://127.0.0.1:5600/api/0/buckets/aw-dlp-endpoint-signals_${host}' -H 'Content-Type: application/json' -d '{\"client\":\"aw-dlp-endpoint-signals\",\"type\":\"aw.dlp.endpoint.signal\",\"hostname\":\"${host}\"}' >/dev/null 2>&1 || true
|
curl -sS -X POST 'http://127.0.0.1:5600/api/0/buckets/aw-dlp-endpoint-signals_HOST-EXAMPLE' -H 'Content-Type: application/json' -d '{\"client\":\"aw-dlp-endpoint-signals\",\"type\":\"aw.dlp.endpoint.signal\",\"hostname\":\"HOST-EXAMPLE\"}' >/dev/null 2>&1 || true
|
||||||
curl -sS -X POST 'http://127.0.0.1:5600/api/0/buckets/aw-file-operations_${host}' -H 'Content-Type: application/json' -d '{\"client\":\"aw-file-operations\",\"type\":\"aw.file.operation\",\"hostname\":\"${host}\"}' >/dev/null 2>&1 || true
|
curl -sS -X POST 'http://127.0.0.1:5600/api/0/buckets/aw-file-operations_HOST-EXAMPLE' -H 'Content-Type: application/json' -d '{\"client\":\"aw-file-operations\",\"type\":\"aw.file.operation\",\"hostname\":\"HOST-EXAMPLE\"}' >/dev/null 2>&1 || true
|
||||||
curl -sS -X POST 'http://127.0.0.1:5600/api/0/buckets/aw-file-operations_${server_host}' -H 'Content-Type: application/json' -d '{\"client\":\"aw-file-operations\",\"type\":\"aw.file.operation\",\"hostname\":\"${server_host}\"}' >/dev/null 2>&1 || true
|
curl -sS -X POST 'http://127.0.0.1:5600/api/0/buckets/aw-file-operations_192.0.2.13' -H 'Content-Type: application/json' -d '{\"client\":\"aw-file-operations\",\"type\":\"aw.file.operation\",\"hostname\":\"192.0.2.13\"}' >/dev/null 2>&1 || true
|
||||||
curl -sS -X POST 'http://127.0.0.1:5600/api/0/buckets/aw-dlp-endpoint-signals_${host}/heartbeat?pulsetime=30' -H 'Content-Type: application/json' --data-binary @/tmp/aw-endpoint-seed.json >/dev/null
|
curl -sS -X POST 'http://127.0.0.1:5600/api/0/buckets/aw-dlp-endpoint-signals_HOST-EXAMPLE/heartbeat?pulsetime=30' -H 'Content-Type: application/json' --data-binary @/tmp/aw-endpoint-seed.json >/dev/null
|
||||||
curl -sS -X POST 'http://127.0.0.1:5600/api/0/buckets/aw-file-operations_${host}/heartbeat?pulsetime=30' -H 'Content-Type: application/json' --data-binary @/tmp/aw-fileops-seed-host.json >/dev/null
|
curl -sS -X POST 'http://127.0.0.1:5600/api/0/buckets/aw-file-operations_HOST-EXAMPLE/heartbeat?pulsetime=30' -H 'Content-Type: application/json' --data-binary @/tmp/aw-fileops-seed-host.json >/dev/null
|
||||||
curl -sS -X POST 'http://127.0.0.1:5600/api/0/buckets/aw-file-operations_${server_host}/heartbeat?pulsetime=30' -H 'Content-Type: application/json' --data-binary @/tmp/aw-fileops-seed-server.json >/dev/null
|
curl -sS -X POST 'http://127.0.0.1:5600/api/0/buckets/aw-file-operations_192.0.2.13/heartbeat?pulsetime=30' -H 'Content-Type: application/json' --data-binary @/tmp/aw-fileops-seed-server.json >/dev/null
|
||||||
" >/dev/null
|
" >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,14 +107,8 @@ restart_windows_collectors() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
seed_windows_dlp_events() {
|
seed_windows_dlp_events() {
|
||||||
if ! is_truthy "${ALLOW_DLP_SEED_EVENTS:-0}"; then
|
|
||||||
log "Skipping Windows DLP freshness seeding; set ALLOW_DLP_SEED_EVENTS=1 with real DETMIR_HOSTNAME/DETMIR_AW_API to allow it."
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
require_real_value DETMIR_HOSTNAME
|
|
||||||
require_real_value DETMIR_AW_API
|
|
||||||
log "Seeding endpoint/file-ops events from aw_windows..."
|
log "Seeding endpoint/file-ops events from aw_windows..."
|
||||||
ansible -i "$INVENTORY" aw_windows -m ansible.windows.win_shell -a "powershell -NoProfile -ExecutionPolicy Bypass -Command \"\$ErrorActionPreference = 'Stop'; \$ts = (Get-Date).ToUniversalTime().ToString('o'); \$api='${DETMIR_AW_API}'; \$hostName='${DETMIR_HOSTNAME}'; \$endpointBucket=\$api + '/buckets/aw-dlp-endpoint-signals_' + \$hostName; \$fileopsBucket=\$api + '/buckets/aw-file-operations_' + \$hostName; \$endpoint=@{timestamp=\$ts;duration=0.0;data=@{hostname=\$hostName;signalType='self_test';source='diag_and_manual_restart';username=\$env:USERNAME;queueDepth=0;eventsEnqueued=0;eventsFlushed=0;sendFailures=0}} | ConvertTo-Json -Depth 8 -Compress; \$fileops=@{timestamp=\$ts;duration=0.0;data=@{hostname=\$hostName;operation='self_test';source='diag_and_manual_restart';username=\$env:USERNAME}} | ConvertTo-Json -Depth 8 -Compress; Invoke-RestMethod -Method Post -Uri \$endpointBucket -ContentType 'application/json' -Body (@{client='aw-dlp-endpoint-signals';type='aw.dlp.endpoint.signal';hostname=\$hostName} | ConvertTo-Json -Compress) -TimeoutSec 15 -DisableKeepAlive -ErrorAction SilentlyContinue | Out-Null; Invoke-RestMethod -Method Post -Uri \$fileopsBucket -ContentType 'application/json' -Body (@{client='aw-file-operations';type='aw.file.operation';hostname=\$hostName} | ConvertTo-Json -Compress) -TimeoutSec 15 -DisableKeepAlive -ErrorAction SilentlyContinue | Out-Null; Invoke-RestMethod -Method Post -Uri (\$endpointBucket + '/heartbeat?pulsetime=30') -ContentType 'application/json' -Body \$endpoint -TimeoutSec 15 -DisableKeepAlive | Out-Null; Invoke-RestMethod -Method Post -Uri (\$fileopsBucket + '/heartbeat?pulsetime=30') -ContentType 'application/json' -Body \$fileops -TimeoutSec 15 -DisableKeepAlive | Out-Null; Write-Output 'windows-dlp-seeded'\""
|
ansible -i "$INVENTORY" aw_windows -m ansible.windows.win_shell -a "powershell -NoProfile -ExecutionPolicy Bypass -Command \"\$ErrorActionPreference = 'Stop'; \$ts = (Get-Date).ToUniversalTime().ToString('o'); \$api='http://192.0.2.13:5600/api/0'; \$endpoint=@{timestamp=\$ts;duration=0.0;data=@{hostname='HOST-EXAMPLE';signalType='self_test';source='diag_and_manual_restart';username=\$env:USERNAME;queueDepth=0;eventsEnqueued=0;eventsFlushed=0;sendFailures=0}} | ConvertTo-Json -Depth 8 -Compress; \$fileops=@{timestamp=\$ts;duration=0.0;data=@{hostname='HOST-EXAMPLE';operation='self_test';source='diag_and_manual_restart';username=\$env:USERNAME}} | ConvertTo-Json -Depth 8 -Compress; Invoke-RestMethod -Method Post -Uri \$api'/buckets/aw-dlp-endpoint-signals_HOST-EXAMPLE' -ContentType 'application/json' -Body '{\\\"client\\\":\\\"aw-dlp-endpoint-signals\\\",\\\"type\\\":\\\"aw.dlp.endpoint.signal\\\",\\\"hostname\\\":\\\"HOST-EXAMPLE\\\"}' -TimeoutSec 15 -DisableKeepAlive -ErrorAction SilentlyContinue | Out-Null; Invoke-RestMethod -Method Post -Uri \$api'/buckets/aw-file-operations_HOST-EXAMPLE' -ContentType 'application/json' -Body '{\\\"client\\\":\\\"aw-file-operations\\\",\\\"type\\\":\\\"aw.file.operation\\\",\\\"hostname\\\":\\\"HOST-EXAMPLE\\\"}' -TimeoutSec 15 -DisableKeepAlive -ErrorAction SilentlyContinue | Out-Null; Invoke-RestMethod -Method Post -Uri \$api'/buckets/aw-dlp-endpoint-signals_HOST-EXAMPLE/heartbeat?pulsetime=30' -ContentType 'application/json' -Body \$endpoint -TimeoutSec 15 -DisableKeepAlive | Out-Null; Invoke-RestMethod -Method Post -Uri \$api'/buckets/aw-file-operations_HOST-EXAMPLE/heartbeat?pulsetime=30' -ContentType 'application/json' -Body \$fileops -TimeoutSec 15 -DisableKeepAlive | Out-Null; Write-Output 'windows-dlp-seeded'\""
|
||||||
}
|
}
|
||||||
|
|
||||||
confirm_restart() {
|
confirm_restart() {
|
||||||
|
|||||||
@@ -4,29 +4,14 @@ set -euo pipefail
|
|||||||
DAY=""
|
DAY=""
|
||||||
FROM=""
|
FROM=""
|
||||||
TO=""
|
TO=""
|
||||||
AW_BASE_URL="${AW_BASE_URL:-}"
|
AW_BASE_URL="${AW_BASE_URL:-http://192.0.2.13:5600/api/0}"
|
||||||
AW_WORKTIME_HOST="${AW_WORKTIME_HOST:-}"
|
AW_WORKTIME_HOST="${AW_WORKTIME_HOST:-HOST-EXAMPLE}"
|
||||||
AW_WORKTIME_DEFAULT_SAMPLE_SECONDS="${AW_WORKTIME_DEFAULT_SAMPLE_SECONDS:-30}"
|
AW_WORKTIME_DEFAULT_SAMPLE_SECONDS="${AW_WORKTIME_DEFAULT_SAMPLE_SECONDS:-30}"
|
||||||
AW_WORKTIME_MAX_SAMPLE_SECONDS="${AW_WORKTIME_MAX_SAMPLE_SECONDS:-300}"
|
AW_WORKTIME_MAX_SAMPLE_SECONDS="${AW_WORKTIME_MAX_SAMPLE_SECONDS:-300}"
|
||||||
OUT_DIR="${OUT_DIR:-reports}"
|
OUT_DIR="${OUT_DIR:-reports}"
|
||||||
TARGET_ROOT="${CARGO_TARGET_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/adk-rust/target}"
|
TARGET_ROOT="${CARGO_TARGET_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/adk-rust/target}"
|
||||||
RUST_BIN="${RDP_WORKTIME_REPORT_RUST:-}"
|
RUST_BIN="${RDP_WORKTIME_REPORT_RUST:-}"
|
||||||
|
|
||||||
require_live_value() {
|
|
||||||
local name="$1"
|
|
||||||
local value="${!name:-}"
|
|
||||||
if [[ -z "$value" ]]; then
|
|
||||||
echo "Missing required variable: $name" >&2
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
case "$value" in
|
|
||||||
*192.0.2.*|*198.51.100.*|*203.0.113.*|*HOST-EXAMPLE*|*.example*)
|
|
||||||
echo "Refusing placeholder value for $name: $value" >&2
|
|
||||||
exit 2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage:
|
Usage:
|
||||||
@@ -67,9 +52,6 @@ if [[ -z "$FROM" || -z "$TO" ]]; then
|
|||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
require_live_value AW_BASE_URL
|
|
||||||
require_live_value AW_WORKTIME_HOST
|
|
||||||
|
|
||||||
mkdir -p "$OUT_DIR"
|
mkdir -p "$OUT_DIR"
|
||||||
CSV_OUT="${OUT_DIR}/rdp-worktime-${FROM}_${TO}.csv"
|
CSV_OUT="${OUT_DIR}/rdp-worktime-${FROM}_${TO}.csv"
|
||||||
JSON_OUT="${OUT_DIR}/rdp-worktime-${FROM}_${TO}.json"
|
JSON_OUT="${OUT_DIR}/rdp-worktime-${FROM}_${TO}.json"
|
||||||
@@ -98,9 +80,7 @@ import urllib.request
|
|||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
base, host, default_sample, max_sample, from_d, to_d, csv_out, json_out = sys.argv[1:9]
|
base, host, default_sample, max_sample, from_d, to_d, csv_out, json_out = sys.argv[1:9]
|
||||||
if not base:
|
base = (base or "http://192.0.2.13:5600").rstrip("/")
|
||||||
raise SystemExit("AW_BASE_URL is required")
|
|
||||||
base = base.rstrip("/")
|
|
||||||
if not base.endswith("/api/0"):
|
if not base.endswith("/api/0"):
|
||||||
base = base + "/api/0"
|
base = base + "/api/0"
|
||||||
default_sample = max(1.0, float(default_sample))
|
default_sample = max(1.0, float(default_sample))
|
||||||
|
|||||||
@@ -43,27 +43,11 @@ configure_detmir_env() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export DETMIR_DLP_ENABLED="${DETMIR_DLP_ENABLED:-${AW_DLP_ENABLED:-false}}"
|
export DETMIR_AW_API="${DETMIR_AW_API:-http://192.0.2.13:5600/api/0}"
|
||||||
require_live_value DETMIR_AW_API
|
export DETMIR_WORKTIME_URL="${DETMIR_WORKTIME_URL:-http://192.0.2.13:5610}"
|
||||||
require_live_value DETMIR_WORKTIME_URL
|
export DETMIR_ONE_C_URL="${DETMIR_ONE_C_URL:-http://192.0.2.2:8710}"
|
||||||
require_live_value DETMIR_ONE_C_URL
|
export DETMIR_RDP_HOST="${DETMIR_RDP_HOST:-198.51.100.18}"
|
||||||
require_live_value DETMIR_RDP_HOST
|
export DETMIR_HOSTNAME="${DETMIR_HOSTNAME:-HOST-EXAMPLE}"
|
||||||
require_live_value DETMIR_HOSTNAME
|
|
||||||
}
|
|
||||||
|
|
||||||
require_live_value() {
|
|
||||||
local name="$1"
|
|
||||||
local value="${!name:-}"
|
|
||||||
if [[ -z "${value}" ]]; then
|
|
||||||
printf 'Missing required live contour variable: %s. Set it in %s or the environment.\n' "${name}" "${ENV_FILE}" >&2
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
case "${value}" in
|
|
||||||
*192.0.2.*|*198.51.100.*|*203.0.113.*|*HOST-EXAMPLE*|*.example*)
|
|
||||||
printf 'Refusing placeholder value for %s: %s\n' "${name}" "${value}" >&2
|
|
||||||
exit 2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
write_summary() {
|
write_summary() {
|
||||||
@@ -80,7 +64,6 @@ write_summary() {
|
|||||||
printf 'DETMIR_HOSTNAME=%s\n' "${DETMIR_HOSTNAME}"
|
printf 'DETMIR_HOSTNAME=%s\n' "${DETMIR_HOSTNAME}"
|
||||||
printf 'DETMIR_GATEWAY_HOST=%s\n' "${DETMIR_GATEWAY_HOST}"
|
printf 'DETMIR_GATEWAY_HOST=%s\n' "${DETMIR_GATEWAY_HOST}"
|
||||||
printf 'DETMIR_PORTAL_URL=%s\n' "${DETMIR_PORTAL_URL}"
|
printf 'DETMIR_PORTAL_URL=%s\n' "${DETMIR_PORTAL_URL}"
|
||||||
printf 'DETMIR_DLP_ENABLED=%s\n' "${DETMIR_DLP_ENABLED}"
|
|
||||||
printf 'DETMIR_DLP_COMMAND=%s\n' "${DETMIR_DLP_COMMAND}"
|
printf 'DETMIR_DLP_COMMAND=%s\n' "${DETMIR_DLP_COMMAND}"
|
||||||
printf 'DETMIR_DISABLE_PORTAL_CHECK=%s\n' "${DETMIR_DISABLE_PORTAL_CHECK:-0}"
|
printf 'DETMIR_DISABLE_PORTAL_CHECK=%s\n' "${DETMIR_DISABLE_PORTAL_CHECK:-0}"
|
||||||
printf 'DETMIR_DISABLE_DLP_HEALTH_CHECK=%s\n' "${DETMIR_DISABLE_DLP_HEALTH_CHECK:-0}"
|
printf 'DETMIR_DISABLE_DLP_HEALTH_CHECK=%s\n' "${DETMIR_DISABLE_DLP_HEALTH_CHECK:-0}"
|
||||||
@@ -198,12 +181,5 @@ if [[ "${RUN_REGISTRY_CHECK:-0}" == "1" ]] && [[ -x "${REPO_ROOT}/scripts/regist
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${RUN_RESILIENCE_CHECK:-0}" == "1" ]] && [[ -f "${REPO_ROOT}/scripts/detmir_resilience_check.sh" ]]; then
|
|
||||||
resilience_mode="${RESILIENCE_CHECK_MODE:-repo}"
|
|
||||||
if ! run_and_log "detmir-resilience-check" bash "${REPO_ROOT}/scripts/detmir_resilience_check.sh" "--${resilience_mode}"; then
|
|
||||||
status=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf 'final_status: %s\n' "$([[ "${status}" -eq 0 ]] && printf ok || printf fail)" | tee -a "${OUTPUT_DIR}/SUMMARY.md"
|
printf 'final_status: %s\n' "$([[ "${status}" -eq 0 ]] && printf ok || printf fail)" | tee -a "${OUTPUT_DIR}/SUMMARY.md"
|
||||||
exit "${status}"
|
exit "${status}"
|
||||||
|
|||||||
Reference in New Issue
Block a user