docs(public): sanitize release materials
This commit is contained in:
@@ -60,7 +60,7 @@ pct exec "$CT_ID" -- bash -lc '
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update
|
||||
apt-get install -y curl ca-certificates bash unzip xz-utils jq
|
||||
mkdir -p /root/bootstrap /etc/activitywatch
|
||||
mkdir -p /opt/detmir/bootstrap /etc/activitywatch
|
||||
'
|
||||
|
||||
echo "CT $CT_ID created and bootstrapped"
|
||||
|
||||
@@ -64,12 +64,12 @@ function build_csc_index_by_common_name(array $entries): array {
|
||||
function default_csc_template(): array {
|
||||
return [
|
||||
'custom_options' => '',
|
||||
'local_network' => '10.0.0.0/8, 172.16.0.0/12, 192.168.100.0/24',
|
||||
'local_network' => '10.0.0.0/8, 172.16.0.0/12, 198.51.100.0/24',
|
||||
'local_networkv6' => '',
|
||||
'remote_network' => '',
|
||||
'remote_networkv6' => '',
|
||||
'dns_server1' => '192.168.100.1',
|
||||
'dns_server2' => '192.168.100.250',
|
||||
'dns_server1' => '198.51.100.1',
|
||||
'dns_server2' => '198.51.100.250',
|
||||
'dns_server3' => '',
|
||||
'dns_server4' => '',
|
||||
'push_blockoutsidedns' => '',
|
||||
|
||||
@@ -17,7 +17,7 @@ ENV_FILE="${1:-$DEFAULT_ENV_FILE}"
|
||||
|
||||
: "${CT_ID:?missing CT_ID}"
|
||||
|
||||
pct exec "$CT_ID" -- mkdir -p /root/bootstrap
|
||||
pct exec "$CT_ID" -- mkdir -p /opt/detmir/bootstrap
|
||||
|
||||
for file_name in \
|
||||
install_aw_server.sh \
|
||||
@@ -28,12 +28,12 @@ for file_name in \
|
||||
aw-sw-cleanup.js \
|
||||
aw-host-groups.json
|
||||
do
|
||||
pct push "$CT_ID" "$PROJECT_ROOT/aw-server/$file_name" "/root/bootstrap/$file_name"
|
||||
pct push "$CT_ID" "$PROJECT_ROOT/aw-server/$file_name" "/opt/detmir/bootstrap/$file_name"
|
||||
done
|
||||
|
||||
pct exec "$CT_ID" -- mkdir -p /root/bootstrap/settings
|
||||
pct push "$CT_ID" "$PROJECT_ROOT/aw-server/settings/classes-worktime.json" "/root/bootstrap/settings/classes-worktime.json"
|
||||
pct push "$CT_ID" "$PROJECT_ROOT/aw-server/settings/views-default.json" "/root/bootstrap/settings/views-default.json"
|
||||
pct exec "$CT_ID" -- mkdir -p /opt/detmir/bootstrap/settings
|
||||
pct push "$CT_ID" "$PROJECT_ROOT/aw-server/settings/classes-worktime.json" "/opt/detmir/bootstrap/settings/classes-worktime.json"
|
||||
pct push "$CT_ID" "$PROJECT_ROOT/aw-server/settings/views-default.json" "/opt/detmir/bootstrap/settings/views-default.json"
|
||||
|
||||
if [ -n "${AW_SERVER_VERSION:-}" ] &&
|
||||
[ -n "${AW_SERVER_DOWNLOAD_URL:-}" ] &&
|
||||
@@ -64,4 +64,4 @@ else
|
||||
echo "WARN: AW_SERVER_* variables are incomplete in $ENV_FILE; /etc/activitywatch/aw-server.env was not updated" >&2
|
||||
fi
|
||||
|
||||
echo "Bootstrap artifacts pushed to CT $CT_ID:/root/bootstrap"
|
||||
echo "Bootstrap artifacts pushed to CT $CT_ID:/opt/detmir/bootstrap"
|
||||
|
||||
@@ -79,8 +79,8 @@ def make_slo_cycle_bot(summary):
|
||||
|
||||
class TsjGuardianBotTests(unittest.TestCase):
|
||||
def test_new_incident_auto_resolved_before_notification_stays_silent(self):
|
||||
check_out = "2026-05-24 10:01:18 [FAIL] node_13: curl failed: http://10.10.10.13:5600/\n"
|
||||
heal_out = "2026-05-24 10:01:21 [OK] node_13: HTTP 200 OK: http://10.10.10.13:5600/api/0/info\n"
|
||||
check_out = "2026-05-24 10:01:18 [FAIL] node_13: curl failed: http://192.0.2.13:5600/\n"
|
||||
heal_out = "2026-05-24 10:01:21 [OK] node_13: HTTP 200 OK: http://192.0.2.13:5600/api/0/info\n"
|
||||
bot = make_bot(check_rc=1, check_out=check_out, heal_rc=0, heal_out=heal_out)
|
||||
|
||||
bot._handle_check_cycle()
|
||||
@@ -90,8 +90,8 @@ class TsjGuardianBotTests(unittest.TestCase):
|
||||
self.assertTrue(any("auto-resolved before operator notification" in msg for _, msg in bot._logs))
|
||||
|
||||
def test_transient_failure_is_suppressed_until_quorum(self):
|
||||
check_out = "2026-05-24 10:01:18 [FAIL] node_13: curl failed: http://10.10.10.13:5600/\n"
|
||||
heal_out = "2026-05-24 10:01:40 [FAIL] node_13: curl failed: http://10.10.10.13:5600/\n"
|
||||
check_out = "2026-05-24 10:01:18 [FAIL] node_13: curl failed: http://192.0.2.13:5600/\n"
|
||||
heal_out = "2026-05-24 10:01:40 [FAIL] node_13: curl failed: http://192.0.2.13:5600/\n"
|
||||
bot = make_bot(check_rc=1, check_out=check_out, heal_rc=1, heal_out=heal_out)
|
||||
bot.incident_failure_quorum_checks = 2
|
||||
|
||||
@@ -121,8 +121,8 @@ class TsjGuardianBotTests(unittest.TestCase):
|
||||
self.assertTrue(bot._notifications)
|
||||
|
||||
def test_new_incident_notifies_only_after_autoheal_failure(self):
|
||||
check_out = "2026-05-24 10:01:18 [FAIL] node_13: curl failed: http://10.10.10.13:5600/\n"
|
||||
heal_out = "2026-05-24 10:01:40 [FAIL] node_13: curl failed: http://10.10.10.13:5600/\n"
|
||||
check_out = "2026-05-24 10:01:18 [FAIL] node_13: curl failed: http://192.0.2.13:5600/\n"
|
||||
heal_out = "2026-05-24 10:01:40 [FAIL] node_13: curl failed: http://192.0.2.13:5600/\n"
|
||||
bot = make_bot(check_rc=1, check_out=check_out, heal_rc=1, heal_out=heal_out)
|
||||
|
||||
bot._handle_check_cycle()
|
||||
@@ -388,7 +388,7 @@ class TelegramApiDocumentTests(unittest.TestCase):
|
||||
class OpenVpnHelperTests(unittest.TestCase):
|
||||
def test_load_pfsense_readonly_env_uses_instance_override_path(self):
|
||||
env_text = """
|
||||
PFSENSE_URL=https://10.10.10.1:8443
|
||||
PFSENSE_URL=https://192.0.2.1:8443
|
||||
PFSENSE_API_KEY=test-key
|
||||
VERIFY_SSL=false
|
||||
"""
|
||||
@@ -397,7 +397,7 @@ VERIFY_SSL=false
|
||||
bot.pfsense_env_path = "/tmp/pfsense.env.readonly"
|
||||
base_url, api_key, verify_ssl = MODULE.TSJGuardianBot._load_pfsense_readonly_env(bot)
|
||||
|
||||
self.assertEqual((base_url, api_key, verify_ssl), ("https://10.10.10.1:8443", "test-key", False))
|
||||
self.assertEqual((base_url, api_key, verify_ssl), ("https://192.0.2.1:8443", "test-key", False))
|
||||
read_mock.assert_called_once_with(encoding="utf-8")
|
||||
|
||||
def test_parse_openvpn_helper_result_returns_config_bytes(self):
|
||||
@@ -410,7 +410,7 @@ VERIFY_SSL=false
|
||||
"cert_created": True,
|
||||
"csc_created": True,
|
||||
"config_b64": MODULE.base64.b64encode(
|
||||
b"client\nremote 10.10.10.1 1194 udp\n<ca>\nX\n</ca>\n"
|
||||
b"client\nremote 192.0.2.1 1194 udp\n<ca>\nX\n</ca>\n"
|
||||
).decode("ascii"),
|
||||
}
|
||||
)
|
||||
@@ -421,7 +421,7 @@ VERIFY_SSL=false
|
||||
self.assertIn("planshet", summary)
|
||||
self.assertIn("10.0.13.22/24", summary)
|
||||
self.assertIn("сертификат создан: да", summary)
|
||||
self.assertEqual(config_bytes, b"client\nremote 10.10.10.1 1194 udp\n<ca>\nX\n</ca>\n")
|
||||
self.assertEqual(config_bytes, b"client\nremote 192.0.2.1 1194 udp\n<ca>\nX\n</ca>\n")
|
||||
|
||||
def test_parse_openvpn_helper_result_rejects_invalid_config(self):
|
||||
bot = object.__new__(MODULE.TSJGuardianBot)
|
||||
@@ -439,8 +439,8 @@ VERIFY_SSL=false
|
||||
inventory = """
|
||||
### 2. pfSense
|
||||
|
||||
- SSH LAN: `10.10.10.1:2022`
|
||||
- Web UI: `10.10.10.1:8443`
|
||||
- SSH LAN: `192.0.2.1:2022`
|
||||
- Web UI: `192.0.2.1:8443`
|
||||
- Admin login: `admin`
|
||||
- Admin password: `admin-secret`
|
||||
- Root login: `root`
|
||||
@@ -453,13 +453,13 @@ VERIFY_SSL=false
|
||||
bot.pfsense_inventory_path = "/tmp/inventory.md"
|
||||
host, port, user, password = MODULE.TSJGuardianBot._load_pfsense_inventory_access(bot)
|
||||
|
||||
self.assertEqual((host, port, user, password), ("10.10.10.1", 2022, "root", "secret"))
|
||||
self.assertEqual((host, port, user, password), ("192.0.2.1", 2022, "root", "secret"))
|
||||
|
||||
def test_load_pfsense_web_access_parses_web_values(self):
|
||||
inventory = """
|
||||
### 2. pfSense
|
||||
|
||||
- Web UI: `10.10.10.1:8443`
|
||||
- Web UI: `192.0.2.1:8443`
|
||||
- Admin login: `admin`
|
||||
- Admin password: `admin-secret`
|
||||
|
||||
@@ -470,7 +470,7 @@ VERIFY_SSL=false
|
||||
bot.pfsense_inventory_path = "/tmp/inventory.md"
|
||||
base_url, user, password = MODULE.TSJGuardianBot._load_pfsense_web_access(bot)
|
||||
|
||||
self.assertEqual((base_url, user, password), ("https://10.10.10.1:8443", "admin", "admin-secret"))
|
||||
self.assertEqual((base_url, user, password), ("https://192.0.2.1:8443", "admin", "admin-secret"))
|
||||
|
||||
def test_extract_pfsense_csrf_token(self):
|
||||
token = MODULE.TSJGuardianBot._extract_pfsense_csrf_token('var csrfMagicToken = "abc123";')
|
||||
@@ -491,8 +491,8 @@ class WorktimeCsvParseTests(unittest.TestCase):
|
||||
def test_parse_worktime_today_csv_uses_named_active_seconds_column(self):
|
||||
csv_text = (
|
||||
"user,user_id,active_seconds,active_hhmm\n"
|
||||
"user1,SHARKON2025\\\\user1,155,00:02\n"
|
||||
"администратор,SHARKON2025\\\\Администратор,9330,02:35\n"
|
||||
"user1,HOST-EXAMPLE\\\\user1,155,00:02\n"
|
||||
"администратор,HOST-EXAMPLE\\\\Администратор,9330,02:35\n"
|
||||
)
|
||||
|
||||
rows = MODULE.TSJGuardianBot._parse_worktime_today_csv(csv_text)
|
||||
@@ -515,11 +515,11 @@ class WorktimeCsvParseTests(unittest.TestCase):
|
||||
timeout_exc = MODULE.requests.exceptions.ReadTimeout("read timeout")
|
||||
response = mock.Mock()
|
||||
response.raise_for_status.return_value = None
|
||||
response.text = "user,user_id,active_seconds\nuser1,SHARKON2025\\\\user1,155\n"
|
||||
response.text = "user,user_id,active_seconds\nuser1,HOST-EXAMPLE\\\\user1,155\n"
|
||||
get_mock.side_effect = [timeout_exc, response]
|
||||
|
||||
bot = object.__new__(MODULE.TSJGuardianBot)
|
||||
bot.aw_rus_worktime_base = "http://10.10.10.13:5610"
|
||||
bot.aw_rus_worktime_base = "http://192.0.2.13:5610"
|
||||
|
||||
csv_text = MODULE.TSJGuardianBot._fetch_worktime_today_csv(bot, timeout_sec=3, attempts=2)
|
||||
|
||||
@@ -546,15 +546,15 @@ class AwRusDlpProbeTests(unittest.TestCase):
|
||||
if url.endswith("/buckets"):
|
||||
return response(
|
||||
{
|
||||
"aw-worktime-sessions_SHARKON2025": {"metadata": {"end": fresh_worktime}},
|
||||
"aw-watcher-window_SHARKON2025": {"metadata": {"end": fresh_watcher}},
|
||||
"aw-watcher-afk_SHARKON2025": {"metadata": {"end": fresh_watcher}},
|
||||
"aw-dlp-endpoint-signals_SHARKON2025": {"metadata": {"end": stale_endpoint}},
|
||||
"aw-file-operations_SHARKON2025": {"metadata": {"end": fresh_fileops}},
|
||||
"aw-file-operations_10.10.10.13": {"metadata": {"end": fresh_fileops}},
|
||||
"aw-worktime-sessions_HOST-EXAMPLE": {"metadata": {"end": fresh_worktime}},
|
||||
"aw-watcher-window_HOST-EXAMPLE": {"metadata": {"end": fresh_watcher}},
|
||||
"aw-watcher-afk_HOST-EXAMPLE": {"metadata": {"end": fresh_watcher}},
|
||||
"aw-dlp-endpoint-signals_HOST-EXAMPLE": {"metadata": {"end": stale_endpoint}},
|
||||
"aw-file-operations_HOST-EXAMPLE": {"metadata": {"end": fresh_fileops}},
|
||||
"aw-file-operations_192.0.2.13": {"metadata": {"end": fresh_fileops}},
|
||||
}
|
||||
)
|
||||
if "aw-rus-collector-guard_SHARKON2025/events" in url:
|
||||
if "aw-rus-collector-guard_HOST-EXAMPLE/events" in url:
|
||||
return response(
|
||||
[
|
||||
{
|
||||
@@ -563,41 +563,41 @@ class AwRusDlpProbeTests(unittest.TestCase):
|
||||
}
|
||||
]
|
||||
)
|
||||
if "aw-worktime-sessions_SHARKON2025/events" in url:
|
||||
if "aw-worktime-sessions_HOST-EXAMPLE/events" in url:
|
||||
return response([{"timestamp": fresh_worktime, "data": {"active": True}}])
|
||||
if "aw-watcher-window_SHARKON2025/events" in url:
|
||||
if "aw-watcher-window_HOST-EXAMPLE/events" in url:
|
||||
return response([{"timestamp": fresh_watcher, "data": {}}])
|
||||
if "aw-watcher-afk_SHARKON2025/events" in url:
|
||||
if "aw-watcher-afk_HOST-EXAMPLE/events" in url:
|
||||
return response([{"timestamp": fresh_watcher, "data": {}}])
|
||||
if "aw-dlp-endpoint-signals_SHARKON2025/events" in url:
|
||||
if "aw-dlp-endpoint-signals_HOST-EXAMPLE/events" in url:
|
||||
return response([{"timestamp": stale_endpoint, "data": {"signalType": "self_test"}}])
|
||||
if "aw-file-operations_SHARKON2025/events" in url:
|
||||
if "aw-file-operations_HOST-EXAMPLE/events" in url:
|
||||
return response([{"timestamp": fresh_fileops, "data": {}}])
|
||||
if "aw-file-operations_10.10.10.13/events" in url:
|
||||
if "aw-file-operations_192.0.2.13/events" in url:
|
||||
return response([{"timestamp": fresh_fileops, "data": {}}])
|
||||
if url.endswith("/buckets/aw-watcher-window_SHARKON2025"):
|
||||
if url.endswith("/buckets/aw-watcher-window_HOST-EXAMPLE"):
|
||||
return response({"metadata": {"end": fresh_watcher}})
|
||||
if url.endswith("/buckets/aw-watcher-afk_SHARKON2025"):
|
||||
if url.endswith("/buckets/aw-watcher-afk_HOST-EXAMPLE"):
|
||||
return response({"metadata": {"end": fresh_watcher}})
|
||||
if url.endswith("/buckets/aw-dlp-endpoint-signals_SHARKON2025"):
|
||||
if url.endswith("/buckets/aw-dlp-endpoint-signals_HOST-EXAMPLE"):
|
||||
return response({"metadata": {"end": stale_endpoint}})
|
||||
if url.endswith("/buckets/aw-file-operations_SHARKON2025"):
|
||||
if url.endswith("/buckets/aw-file-operations_HOST-EXAMPLE"):
|
||||
return response({"metadata": {"end": fresh_fileops}})
|
||||
if url.endswith("/buckets/aw-file-operations_10.10.10.13"):
|
||||
if url.endswith("/buckets/aw-file-operations_192.0.2.13"):
|
||||
return response({"metadata": {"end": fresh_fileops}})
|
||||
raise AssertionError(f"unexpected url {url}")
|
||||
|
||||
get_mock.side_effect = fake_get
|
||||
|
||||
bot = object.__new__(MODULE.TSJGuardianBot)
|
||||
bot.aw_rus_api_base = "http://10.10.10.13:5600/api/0"
|
||||
bot.aw_rus_worktime_base = "http://10.10.10.13:5610"
|
||||
bot.aw_rus_host = "SHARKON2025"
|
||||
bot.aw_rus_api_base = "http://192.0.2.13:5600/api/0"
|
||||
bot.aw_rus_worktime_base = "http://192.0.2.13:5610"
|
||||
bot.aw_rus_host = "HOST-EXAMPLE"
|
||||
bot.aw_rus_stale_sec = 900
|
||||
bot.aw_rus_primary_user = "user1"
|
||||
bot._fetch_worktime_today_csv = lambda timeout_sec=20, attempts=2: (
|
||||
"user,user_id,active_seconds\n"
|
||||
"user1,SHARKON2025\\\\user1,120\n"
|
||||
"user1,HOST-EXAMPLE\\\\user1,120\n"
|
||||
)
|
||||
|
||||
with mock.patch("proxmox.tsj_guardian_bot.datetime") as dt_mock:
|
||||
@@ -625,8 +625,8 @@ class AwRusDlpProbeTests(unittest.TestCase):
|
||||
|
||||
def fake_get(url, timeout=20):
|
||||
if url.endswith("/buckets"):
|
||||
return response({"aw-worktime-sessions_SHARKON2025": {"metadata": {"end": fresh_worktime}}})
|
||||
if "aw-rus-collector-guard_SHARKON2025/events" in url:
|
||||
return response({"aw-worktime-sessions_HOST-EXAMPLE": {"metadata": {"end": fresh_worktime}}})
|
||||
if "aw-rus-collector-guard_HOST-EXAMPLE/events" in url:
|
||||
return response(
|
||||
[
|
||||
{
|
||||
@@ -635,35 +635,35 @@ class AwRusDlpProbeTests(unittest.TestCase):
|
||||
}
|
||||
]
|
||||
)
|
||||
if "aw-worktime-sessions_SHARKON2025/events" in url:
|
||||
if "aw-worktime-sessions_HOST-EXAMPLE/events" in url:
|
||||
return response([{"timestamp": fresh_worktime, "data": {"active": False}}])
|
||||
if "aw-watcher-window_SHARKON2025/events" in url:
|
||||
if "aw-watcher-window_HOST-EXAMPLE/events" in url:
|
||||
return response([{"timestamp": fresh_watcher, "data": {}}])
|
||||
if "aw-watcher-afk_SHARKON2025/events" in url:
|
||||
if "aw-watcher-afk_HOST-EXAMPLE/events" in url:
|
||||
return response([{"timestamp": fresh_watcher, "data": {}}])
|
||||
if "aw-dlp-endpoint-signals_SHARKON2025/events" in url:
|
||||
if "aw-dlp-endpoint-signals_HOST-EXAMPLE/events" in url:
|
||||
return response([{"timestamp": stale_endpoint, "data": {"signalType": "self_test"}}])
|
||||
if "aw-file-operations_SHARKON2025/events" in url:
|
||||
if "aw-file-operations_HOST-EXAMPLE/events" in url:
|
||||
return response([])
|
||||
if "aw-file-operations_10.10.10.13/events" in url:
|
||||
if "aw-file-operations_192.0.2.13/events" in url:
|
||||
return response([])
|
||||
if url.endswith("/buckets/aw-file-operations_SHARKON2025"):
|
||||
if url.endswith("/buckets/aw-file-operations_HOST-EXAMPLE"):
|
||||
return response({"metadata": {"end": stale_endpoint}})
|
||||
if url.endswith("/buckets/aw-file-operations_10.10.10.13"):
|
||||
if url.endswith("/buckets/aw-file-operations_192.0.2.13"):
|
||||
return response({"metadata": {"end": stale_endpoint}})
|
||||
raise AssertionError(f"unexpected url {url}")
|
||||
|
||||
get_mock.side_effect = fake_get
|
||||
|
||||
bot = object.__new__(MODULE.TSJGuardianBot)
|
||||
bot.aw_rus_api_base = "http://10.10.10.13:5600/api/0"
|
||||
bot.aw_rus_worktime_base = "http://10.10.10.13:5610"
|
||||
bot.aw_rus_host = "SHARKON2025"
|
||||
bot.aw_rus_api_base = "http://192.0.2.13:5600/api/0"
|
||||
bot.aw_rus_worktime_base = "http://192.0.2.13:5610"
|
||||
bot.aw_rus_host = "HOST-EXAMPLE"
|
||||
bot.aw_rus_stale_sec = 900
|
||||
bot.aw_rus_primary_user = "user1"
|
||||
bot._fetch_worktime_today_csv = lambda timeout_sec=20, attempts=2: (
|
||||
"user,user_id,active_seconds\n"
|
||||
"user1,SHARKON2025\\\\user1,0\n"
|
||||
"user1,HOST-EXAMPLE\\\\user1,0\n"
|
||||
)
|
||||
|
||||
with mock.patch("proxmox.tsj_guardian_bot.datetime") as dt_mock:
|
||||
@@ -691,8 +691,8 @@ class AwRusDlpProbeTests(unittest.TestCase):
|
||||
|
||||
def fake_get(url, timeout=20):
|
||||
if url.endswith("/buckets"):
|
||||
return response({"aw-worktime-sessions_SHARKON2025": {"metadata": {"end": fresh_worktime}}})
|
||||
if "aw-rus-collector-guard_SHARKON2025/events" in url:
|
||||
return response({"aw-worktime-sessions_HOST-EXAMPLE": {"metadata": {"end": fresh_worktime}}})
|
||||
if "aw-rus-collector-guard_HOST-EXAMPLE/events" in url:
|
||||
return response(
|
||||
[
|
||||
{
|
||||
@@ -701,30 +701,30 @@ class AwRusDlpProbeTests(unittest.TestCase):
|
||||
}
|
||||
]
|
||||
)
|
||||
if "aw-worktime-sessions_SHARKON2025/events" in url:
|
||||
if "aw-worktime-sessions_HOST-EXAMPLE/events" in url:
|
||||
return response([{"timestamp": fresh_worktime, "data": {"active": False}}])
|
||||
if "aw-watcher-window_SHARKON2025/events" in url:
|
||||
if "aw-watcher-window_HOST-EXAMPLE/events" in url:
|
||||
return response([{"timestamp": fresh_watcher, "data": {}}])
|
||||
if "aw-watcher-afk_SHARKON2025/events" in url:
|
||||
if "aw-watcher-afk_HOST-EXAMPLE/events" in url:
|
||||
return response([{"timestamp": fresh_watcher, "data": {}}])
|
||||
if "aw-dlp-endpoint-signals_SHARKON2025/events" in url:
|
||||
if "aw-dlp-endpoint-signals_HOST-EXAMPLE/events" in url:
|
||||
return response([{"timestamp": fresh_watcher, "data": {"signalType": "self_test"}}])
|
||||
if "aw-file-operations_SHARKON2025/events" in url:
|
||||
if "aw-file-operations_HOST-EXAMPLE/events" in url:
|
||||
return response([])
|
||||
if "aw-file-operations_10.10.10.13/events" in url:
|
||||
if "aw-file-operations_192.0.2.13/events" in url:
|
||||
return response([])
|
||||
if url.endswith("/buckets/aw-file-operations_SHARKON2025"):
|
||||
if url.endswith("/buckets/aw-file-operations_HOST-EXAMPLE"):
|
||||
return response({"metadata": {"end": fresh_watcher}})
|
||||
if url.endswith("/buckets/aw-file-operations_10.10.10.13"):
|
||||
if url.endswith("/buckets/aw-file-operations_192.0.2.13"):
|
||||
return response({"metadata": {"end": fresh_watcher}})
|
||||
raise AssertionError(f"unexpected url {url}")
|
||||
|
||||
get_mock.side_effect = fake_get
|
||||
|
||||
bot = object.__new__(MODULE.TSJGuardianBot)
|
||||
bot.aw_rus_api_base = "http://10.10.10.13:5600/api/0"
|
||||
bot.aw_rus_worktime_base = "http://10.10.10.13:5610"
|
||||
bot.aw_rus_host = "SHARKON2025"
|
||||
bot.aw_rus_api_base = "http://192.0.2.13:5600/api/0"
|
||||
bot.aw_rus_worktime_base = "http://192.0.2.13:5610"
|
||||
bot.aw_rus_host = "HOST-EXAMPLE"
|
||||
bot.aw_rus_stale_sec = 900
|
||||
bot.aw_rus_primary_user = "user1"
|
||||
bot._fetch_worktime_today_csv = mock.Mock(side_effect=MODULE.requests.exceptions.ReadTimeout("read timeout"))
|
||||
|
||||
+14
-14
@@ -372,9 +372,9 @@ class TSJGuardianBot:
|
||||
self.check_script = os.getenv(
|
||||
"CHECK_SCRIPT", f"{self.infra_admin_root}/scripts/system_self_support.sh --check"
|
||||
)
|
||||
self.aw_rus_api_base = os.getenv("AW_RUS_API_BASE", "http://10.10.10.13:5600/api/0").strip()
|
||||
self.aw_rus_worktime_base = os.getenv("AW_RUS_WORKTIME_BASE", "http://10.10.10.13:5610").strip()
|
||||
self.aw_dlp_policy_api_base = os.getenv("AW_DLP_POLICY_API_BASE", "http://10.10.10.13:5601/api/0").strip()
|
||||
self.aw_rus_api_base = os.getenv("AW_RUS_API_BASE", "http://192.0.2.13:5600/api/0").strip()
|
||||
self.aw_rus_worktime_base = os.getenv("AW_RUS_WORKTIME_BASE", "http://192.0.2.13:5610").strip()
|
||||
self.aw_dlp_policy_api_base = os.getenv("AW_DLP_POLICY_API_BASE", "http://192.0.2.13:5601/api/0").strip()
|
||||
self.aw_dlp_policy_actor = os.getenv("AW_DLP_POLICY_ACTOR", "tsj-guardian-bot").strip() or "tsj-guardian-bot"
|
||||
self.aw_rus_worktime_heal_cmd = os.getenv(
|
||||
"AW_RUS_WORKTIME_HEAL_CMD",
|
||||
@@ -384,13 +384,13 @@ class TSJGuardianBot:
|
||||
"AW_RUS_DLP_HEAL_CMD",
|
||||
"",
|
||||
).strip()
|
||||
self.aw_rus_case_api_base = os.getenv("AW_RUS_CASE_API_BASE", "http://10.10.10.13:5602").strip()
|
||||
self.aw_rus_case_api_base = os.getenv("AW_RUS_CASE_API_BASE", "http://192.0.2.13:5602").strip()
|
||||
self.aw_rus_hayabusa_enabled = env_bool("AW_RUS_HAYABUSA_ENABLED", True)
|
||||
self.aw_rus_hayabusa_ssh_cmd = os.getenv(
|
||||
"AW_RUS_HAYABUSA_SSH_CMD",
|
||||
"",
|
||||
).strip()
|
||||
self.aw_rus_host = os.getenv("AW_RUS_HOST", "SHARKON2025").strip()
|
||||
self.aw_rus_host = os.getenv("AW_RUS_HOST", "HOST-EXAMPLE").strip()
|
||||
self.aw_rus_primary_user = os.getenv("AW_RUS_PRIMARY_USER", "USER1").strip()
|
||||
self.aw_rus_stale_sec = max(60, env_int("AW_RUS_STALE_SEC", 900))
|
||||
self.aw_rus_slo_enabled = env_bool("AW_RUS_SLO_ENABLED", True)
|
||||
@@ -401,7 +401,7 @@ class TSJGuardianBot:
|
||||
"AW_RUS_SLO_SUMMARY_CMD",
|
||||
"",
|
||||
).strip()
|
||||
self.aw_rus_windows_host = os.getenv("AW_RUS_WINDOWS_HOST", "192.168.100.18").strip() or "192.168.100.18"
|
||||
self.aw_rus_windows_host = os.getenv("AW_RUS_WINDOWS_HOST", "198.51.100.18").strip() or "198.51.100.18"
|
||||
self.aw_rus_windows_ssh_user = os.getenv("AW_RUS_WINDOWS_SSH_USER", "Администратор").strip() or "Администратор"
|
||||
self.aw_rus_windows_ssh_password = os.getenv("AW_RUS_WINDOWS_SSH_PASSWORD", "").strip()
|
||||
self.aw_rus_windows_config_path = os.getenv(
|
||||
@@ -418,7 +418,7 @@ class TSJGuardianBot:
|
||||
).strip() or r"C:\ProgramData\AWatch-rus\worktime-session-collector.ps1"
|
||||
launch_tasks_raw = os.getenv(
|
||||
"AW_RUS_WINDOWS_LAUNCH_TASKS",
|
||||
"ActivityWatch Launch [SHARKON2025_Администратор];ActivityWatch Launch [SHARKON2025_user5]",
|
||||
"ActivityWatch Launch [HOST-EXAMPLE_Администратор];ActivityWatch Launch [HOST-EXAMPLE_user5]",
|
||||
)
|
||||
self.aw_rus_windows_launch_tasks = [item.strip() for item in launch_tasks_raw.split(";") if item.strip()]
|
||||
self.aw_rus_windows_policy_path = os.getenv(
|
||||
@@ -2637,20 +2637,20 @@ class TSJGuardianBot:
|
||||
if "proxmox_api" in text:
|
||||
suggestions.append("Перезапустить pveproxy/pvedaemon/pve-cluster и проверить порт 8006.")
|
||||
if "pfsense_web" in text:
|
||||
suggestions.append("Проверить доступность pfSense 10.10.10.1:8443, перезапустить WebGUI/nginx.")
|
||||
suggestions.append("Проверить доступность pfSense 192.0.2.1:8443, перезапустить WebGUI/nginx.")
|
||||
if "pfsense_mcp" in text:
|
||||
suggestions.append("Проверить локальный pfsense-mcp-server.service, bearer token и endpoint 127.0.0.1:3010/mcp.")
|
||||
if "influxdb" in text:
|
||||
suggestions.append("Проверить контейнер InfluxDB и restart сервиса influxdb.")
|
||||
if "grafana" in text:
|
||||
suggestions.append("Проверить grafana-server и NO_PROXY для 10.10.10.0/24.")
|
||||
suggestions.append("Проверить grafana-server и NO_PROXY для 192.0.2.0/24.")
|
||||
if "loki" in text or "alloy" in text:
|
||||
suggestions.append("Проверить LXC логов и restart сервисов loki/alloy.")
|
||||
if "aw-rus:watcher-" in text or "aw-rus:worktime:" in text:
|
||||
suggestions.append("Проверить Windows collector recovery: worktime-session-collector, ActivityWatch Recovery и Launch tasks на 192.168.100.18.")
|
||||
suggestions.append("Проверить Windows collector recovery: worktime-session-collector, ActivityWatch Recovery и Launch tasks на 198.51.100.18.")
|
||||
suggestions.append("После Windows recovery проверить server-side aw-worktime-autoheal/ui-bridge для пересборки afk/window bucket'ов.")
|
||||
if "aw-rus:dlp-" in text:
|
||||
suggestions.append("Проверить DLP endpoint/fileops collectors и server-side DLP transport на 10.10.10.13.")
|
||||
suggestions.append("Проверить DLP endpoint/fileops collectors и server-side DLP transport на 192.0.2.13.")
|
||||
if "filesystem_usage" in text:
|
||||
suggestions.append("Проверить самые большие каталоги: du -x /var /srv /home, журналы в /var/log и apt cache.")
|
||||
suggestions.append("Проверить давление по снапшотам/хранилищу Proxmox и решить: очистка, ротация или расширение диска.")
|
||||
@@ -3490,7 +3490,7 @@ class TSJGuardianBot:
|
||||
|
||||
fileops_checks = [
|
||||
(f"aw-file-operations_{host}", "dlp-fileops-host", host),
|
||||
("aw-file-operations_10.10.10.13", "dlp-fileops-server", "10.10.10.13"),
|
||||
("aw-file-operations_192.0.2.13", "dlp-fileops-server", "192.0.2.13"),
|
||||
]
|
||||
for bucket_id, label, bucket_host in fileops_checks:
|
||||
if worktime_activity is None:
|
||||
@@ -3604,12 +3604,12 @@ class TSJGuardianBot:
|
||||
bucket_defs = {
|
||||
f"aw-dlp-endpoint-signals_{host}": ("aw.dlp.endpoint.signal", "aw-dlp-endpoint-signals", host),
|
||||
f"aw-file-operations_{host}": ("aw.file.operation", "aw-file-operations", host),
|
||||
"aw-file-operations_10.10.10.13": ("aw.file.operation", "aw-file-operations", "10.10.10.13"),
|
||||
"aw-file-operations_192.0.2.13": ("aw.file.operation", "aw-file-operations", "192.0.2.13"),
|
||||
}
|
||||
map_fail_to_bucket = {
|
||||
"dlp-endpoint": f"aw-dlp-endpoint-signals_{host}",
|
||||
"dlp-fileops-host": f"aw-file-operations_{host}",
|
||||
"dlp-fileops-server": "aw-file-operations_10.10.10.13",
|
||||
"dlp-fileops-server": "aw-file-operations_192.0.2.13",
|
||||
}
|
||||
|
||||
selected = []
|
||||
|
||||
Reference in New Issue
Block a user