fix(activity): restore real window watchers and isolate rdp bridge

This commit is contained in:
igor04091968
2026-05-14 20:02:46 +03:00
parent 59e93c1c69
commit 76d1377736
6 changed files with 69 additions and 36 deletions
+1
View File
@@ -100,6 +100,7 @@
- email-outbound-collector.ps1 - email-outbound-collector.ps1
- file-operations-collector.ps1 - file-operations-collector.ps1
- worktime-session-collector.ps1 - worktime-session-collector.ps1
- export-evtx-for-hayabusa.ps1
- migrate-awatch-rus-paths.ps1 - migrate-awatch-rus-paths.ps1
- deploy-domain-users.ps1 - deploy-domain-users.ps1
- deploy-ensemble.ps1 - deploy-ensemble.ps1
+2 -2
View File
@@ -32,8 +32,8 @@ aw_windows_policy_engine_host: "{{ aw_windows_server_host }}"
aw_windows_policy_engine_port: 5601 aw_windows_policy_engine_port: 5601
aw_windows_policy_engine_scheme: "http" aw_windows_policy_engine_scheme: "http"
aw_windows_afk_enabled: false aw_windows_afk_enabled: true
aw_windows_window_enabled: false aw_windows_window_enabled: true
aw_windows_file_ops_enabled: true aw_windows_file_ops_enabled: true
aw_windows_email_collector_enabled: true aw_windows_email_collector_enabled: true
aw_windows_email_collector_mode: "both" aw_windows_email_collector_mode: "both"
+57 -27
View File
@@ -1581,6 +1581,9 @@
let applyPatchScheduled = false; let applyPatchScheduled = false;
let networkPatchesInstalled = false; let networkPatchesInstalled = false;
let dlpOverlayFailureCount = 0; let dlpOverlayFailureCount = 0;
let applyPatchInFlight = false;
let observerAttached = false;
let staticPatchRouteKey = "";
function getTrendsHostFromSettings(settings) { function getTrendsHostFromSettings(settings) {
if (!settings || typeof settings !== "object") return ""; if (!settings || typeof settings !== "object") return "";
@@ -1818,38 +1821,63 @@
}); });
} }
function detachObserver() {
if (!observerAttached) return;
observer.disconnect();
observerAttached = false;
}
function attachObserver() {
if (observerAttached || !document.body) return;
observer.observe(document.body, { childList: true, subtree: true });
observerAttached = true;
}
function applyPatch() { function applyPatch() {
enforceSafeActivityViewForPveHost(); if (applyPatchInFlight || !document.body) return;
ensureSettingsHost(); applyPatchInFlight = true;
ensureHostGroupsData().catch(function () {}); detachObserver();
normalizeCategoryBuilderUnknownHostRefs(); try {
installCategoryBuilderNetworkPatch(); const routeKey = window.location.hash || "#";
injectStyles(); const routeChanged = routeKey !== staticPatchRouteKey;
walk(document.body); enforceSafeActivityViewForPveHost();
translateAttributes(document.body); ensureSettingsHost();
hideNoiseNavigation(document.body); ensureHostGroupsData().catch(function () {});
patchActivityHeading(document.body); normalizeCategoryBuilderUnknownHostRefs();
patchCategoryBuilderHostLabel(document.body); installCategoryBuilderNetworkPatch();
injectPveAuditCenter(document.body); injectStyles();
injectDlpNavigation(document.body); if (routeChanged) {
if (isDlpSignalBucketRoute() && dlpOverlayFailureCount === 0) { walk(document.body);
try { translateAttributes(document.body);
injectDlpReviewCenter(document.body); hideNoiseNavigation(document.body);
} catch (error) { patchActivityHeading(document.body);
dlpOverlayFailureCount += 1; patchCategoryBuilderHostLabel(document.body);
const existing = document.body.querySelector("[data-aw-ru-dlp-center='1']"); staticPatchRouteKey = routeKey;
if (existing && existing.parentElement) existing.parentElement.removeChild(existing);
} }
} else if (!isDlpSignalBucketRoute()) { injectPveAuditCenter(document.body);
injectDlpReviewCenter(document.body); injectDlpNavigation(document.body);
if (isDlpSignalBucketRoute() && dlpOverlayFailureCount === 0) {
try {
injectDlpReviewCenter(document.body);
} catch (error) {
dlpOverlayFailureCount += 1;
const existing = document.body.querySelector("[data-aw-ru-dlp-center='1']");
if (existing && existing.parentElement) existing.parentElement.removeChild(existing);
}
} else if (!isDlpSignalBucketRoute()) {
injectDlpReviewCenter(document.body);
}
injectDlpAlertsCenter(document.body);
injectHostGroupsCenter(document.body).catch(function () {});
redirectBareTrendsRoute();
} finally {
applyPatchInFlight = false;
attachObserver();
} }
injectDlpAlertsCenter(document.body);
injectHostGroupsCenter(document.body).catch(function () {});
redirectBareTrendsRoute();
} }
function scheduleApplyPatch() { function scheduleApplyPatch() {
if (applyPatchScheduled) return; if (applyPatchScheduled || applyPatchInFlight) return;
applyPatchScheduled = true; applyPatchScheduled = true;
window.setTimeout(function () { window.setTimeout(function () {
applyPatchScheduled = false; applyPatchScheduled = false;
@@ -1858,15 +1886,17 @@
} }
const observer = new MutationObserver(function () { const observer = new MutationObserver(function () {
if (applyPatchInFlight) return;
scheduleApplyPatch(); scheduleApplyPatch();
}); });
window.addEventListener("load", function () { window.addEventListener("load", function () {
applyPatch(); applyPatch();
observer.observe(document.body, { childList: true, subtree: true }); attachObserver();
}); });
window.addEventListener("hashchange", function () { window.addEventListener("hashchange", function () {
redirectBareTrendsRoute(); redirectBareTrendsRoute();
staticPatchRouteKey = "";
scheduleApplyPatch(); scheduleApplyPatch();
}); });
})(); })();
+3 -3
View File
@@ -27,7 +27,7 @@ need_heal="$("$PYTHON_BIN" - <<'PY'
import json, urllib.request, datetime, os, sys import json, urllib.request, datetime, os, sys
AW=os.environ.get("AW_URL","http://127.0.0.1:5600") AW=os.environ.get("AW_URL","http://127.0.0.1:5600")
host=os.environ.get("HOST","SHARKON2025") host=os.environ.get("HOST","SHARKON2025")
bucket=f"aw-watcher-window_{host}" bucket=f"aw-rdp-window_{host}"
msk=datetime.timezone(datetime.timedelta(hours=3)) msk=datetime.timezone(datetime.timedelta(hours=3))
start=datetime.datetime.now(msk).replace(hour=0,minute=0,second=0,microsecond=0).astimezone(datetime.timezone.utc) start=datetime.datetime.now(msk).replace(hour=0,minute=0,second=0,microsecond=0).astimezone(datetime.timezone.utc)
@@ -75,8 +75,8 @@ import json, urllib.request, datetime, os
AW=os.environ.get("AW_URL","http://127.0.0.1:5600") AW=os.environ.get("AW_URL","http://127.0.0.1:5600")
host=os.environ.get("HOST","SHARKON2025") host=os.environ.get("HOST","SHARKON2025")
sb=f"aw-worktime-sessions_{host}" sb=f"aw-worktime-sessions_{host}"
afk=f"aw-watcher-afk_{host}" afk=f"aw-rdp-afk_{host}"
win=f"aw-watcher-window_{host}" win=f"aw-rdp-window_{host}"
msk=datetime.timezone(datetime.timedelta(hours=3)) msk=datetime.timezone(datetime.timedelta(hours=3))
start=datetime.datetime.now(msk).replace(hour=0,minute=0,second=0,microsecond=0).astimezone(datetime.timezone.utc) start=datetime.datetime.now(msk).replace(hour=0,minute=0,second=0,microsecond=0).astimezone(datetime.timezone.utc)
+2 -2
View File
@@ -16,8 +16,8 @@ TIMEOUT = float(os.environ.get("AW_WORKTIME_UI_BRIDGE_TIMEOUT", "20"))
SESSIONS_BUCKET = f"aw-worktime-sessions_{HOST}" SESSIONS_BUCKET = f"aw-worktime-sessions_{HOST}"
AFK_BUCKET = f"aw-watcher-afk_{HOST}" AFK_BUCKET = f"aw-rdp-afk_{HOST}"
WINDOW_BUCKET = f"aw-watcher-window_{HOST}" WINDOW_BUCKET = f"aw-rdp-window_{HOST}"
def _req(method: str, path: str, payload=None): def _req(method: str, path: str, payload=None):
+4 -2
View File
@@ -21,6 +21,8 @@ param(
[bool]$IncidentScreenshotEnabled, [bool]$IncidentScreenshotEnabled,
[string]$IncidentArtifactsRoot, [string]$IncidentArtifactsRoot,
[string]$EvtxExportRoot, [string]$EvtxExportRoot,
[int]$EvtxRetentionDays,
[string[]]$EvtxChannels,
[bool]$LogonMarkerEnabled, [bool]$LogonMarkerEnabled,
[string]$AwHostname, [string]$AwHostname,
[string]$CustomRulesPath, [string]$CustomRulesPath,
@@ -86,8 +88,8 @@ $effectiveIncidentCaptureEnabled = if ($PSBoundParameters.ContainsKey('IncidentC
$effectiveIncidentScreenshotEnabled = if ($PSBoundParameters.ContainsKey('IncidentScreenshotEnabled')) { [bool]$IncidentScreenshotEnabled } elseif ($existingConfig -and $existingConfig.PSObject.Properties.Name -contains 'incidentCapture' -and $existingConfig.incidentCapture.PSObject.Properties.Name -contains 'screenshotEnabled') { [bool]$existingConfig.incidentCapture.screenshotEnabled } else { $true } $effectiveIncidentScreenshotEnabled = if ($PSBoundParameters.ContainsKey('IncidentScreenshotEnabled')) { [bool]$IncidentScreenshotEnabled } elseif ($existingConfig -and $existingConfig.PSObject.Properties.Name -contains 'incidentCapture' -and $existingConfig.incidentCapture.PSObject.Properties.Name -contains 'screenshotEnabled') { [bool]$existingConfig.incidentCapture.screenshotEnabled } else { $true }
$effectiveIncidentArtifactsRoot = if ($PSBoundParameters.ContainsKey('IncidentArtifactsRoot') -and $IncidentArtifactsRoot) { $IncidentArtifactsRoot } elseif ($existingConfig -and $existingConfig.PSObject.Properties.Name -contains 'incidentCapture' -and $existingConfig.incidentCapture.PSObject.Properties.Name -contains 'artifactsRoot') { [string]$existingConfig.incidentCapture.artifactsRoot } else { Join-Path $effectiveStateRoot 'incident-artifacts' } $effectiveIncidentArtifactsRoot = if ($PSBoundParameters.ContainsKey('IncidentArtifactsRoot') -and $IncidentArtifactsRoot) { $IncidentArtifactsRoot } elseif ($existingConfig -and $existingConfig.PSObject.Properties.Name -contains 'incidentCapture' -and $existingConfig.incidentCapture.PSObject.Properties.Name -contains 'artifactsRoot') { [string]$existingConfig.incidentCapture.artifactsRoot } else { Join-Path $effectiveStateRoot 'incident-artifacts' }
$effectiveEvtxExportRoot = if ($PSBoundParameters.ContainsKey('EvtxExportRoot') -and $EvtxExportRoot) { $EvtxExportRoot } elseif ($existingConfig -and $existingConfig.PSObject.Properties.Name -contains 'forensics' -and $existingConfig.forensics.PSObject.Properties.Name -contains 'evtxExportRoot') { [string]$existingConfig.forensics.evtxExportRoot } else { Join-Path $effectiveStateRoot 'forensics\evtx-exports' } $effectiveEvtxExportRoot = if ($PSBoundParameters.ContainsKey('EvtxExportRoot') -and $EvtxExportRoot) { $EvtxExportRoot } elseif ($existingConfig -and $existingConfig.PSObject.Properties.Name -contains 'forensics' -and $existingConfig.forensics.PSObject.Properties.Name -contains 'evtxExportRoot') { [string]$existingConfig.forensics.evtxExportRoot } else { Join-Path $effectiveStateRoot 'forensics\evtx-exports' }
$effectiveEvtxRetentionDays = if ($existingConfig -and $existingConfig.PSObject.Properties.Name -contains 'forensics' -and $existingConfig.forensics.PSObject.Properties.Name -contains 'retentionDays') { [int]$existingConfig.forensics.retentionDays } else { 14 } $effectiveEvtxRetentionDays = if ($PSBoundParameters.ContainsKey('EvtxRetentionDays')) { [int]$EvtxRetentionDays } elseif ($existingConfig -and $existingConfig.PSObject.Properties.Name -contains 'forensics' -and $existingConfig.forensics.PSObject.Properties.Name -contains 'retentionDays') { [int]$existingConfig.forensics.retentionDays } else { 14 }
$effectiveEvtxChannels = if ($existingConfig -and $existingConfig.PSObject.Properties.Name -contains 'forensics' -and $existingConfig.forensics.PSObject.Properties.Name -contains 'evtxChannels') { @($existingConfig.forensics.evtxChannels) } else { @() } $effectiveEvtxChannels = if ($PSBoundParameters.ContainsKey('EvtxChannels')) { @($EvtxChannels) } elseif ($existingConfig -and $existingConfig.PSObject.Properties.Name -contains 'forensics' -and $existingConfig.forensics.PSObject.Properties.Name -contains 'evtxChannels') { @($existingConfig.forensics.evtxChannels) } else { @() }
$effectiveLogonMarkerEnabled = if ($PSBoundParameters.ContainsKey('LogonMarkerEnabled')) { [bool]$LogonMarkerEnabled } elseif ($existingConfig -and $existingConfig.PSObject.Properties.Name -contains 'sessionEvents' -and $existingConfig.sessionEvents.PSObject.Properties.Name -contains 'logonEnabled') { [bool]$existingConfig.sessionEvents.logonEnabled } else { $true } $effectiveLogonMarkerEnabled = if ($PSBoundParameters.ContainsKey('LogonMarkerEnabled')) { [bool]$LogonMarkerEnabled } elseif ($existingConfig -and $existingConfig.PSObject.Properties.Name -contains 'sessionEvents' -and $existingConfig.sessionEvents.PSObject.Properties.Name -contains 'logonEnabled') { [bool]$existingConfig.sessionEvents.logonEnabled } else { $true }
$effectiveAwHostname = if ($PSBoundParameters.ContainsKey('AwHostname') -and -not [string]::IsNullOrWhiteSpace($AwHostname)) { [string]$AwHostname } elseif ($existingConfig -and $existingConfig.PSObject.Properties.Name -contains 'awHostname' -and -not [string]::IsNullOrWhiteSpace([string]$existingConfig.awHostname)) { [string]$existingConfig.awHostname } else { [string]$env:COMPUTERNAME } $effectiveAwHostname = if ($PSBoundParameters.ContainsKey('AwHostname') -and -not [string]::IsNullOrWhiteSpace($AwHostname)) { [string]$AwHostname } elseif ($existingConfig -and $existingConfig.PSObject.Properties.Name -contains 'awHostname' -and -not [string]::IsNullOrWhiteSpace([string]$existingConfig.awHostname)) { [string]$existingConfig.awHostname } else { [string]$env:COMPUTERNAME }
$effectiveVersion = if ($Version) { $Version } elseif ($existingConfig) { [string]$existingConfig.package.version } else { 'v0.13.2' } $effectiveVersion = if ($Version) { $Version } elseif ($existingConfig) { [string]$existingConfig.package.version } else { 'v0.13.2' }