Files
Samsara/powershell/Get-ServerNetwork.ps1
oceans2alaska 610a3bb447 Privacy hardening, remote-peer IP masking and review fixes
- Add privacy projection (core/privacy.py), private report storage, bounded
  process capture; omit identities, free text and unapproved paths
- Mask remote peer IPs: only loopback/host/wildcard stay numeric, others are
  reduced to remote_scope private/public (schema + scoring updated)
- Map ss TCP states to canonical names; ASCII-only numeric fields; fix
  "Microsoft Visual C++" product matching (Python and PowerShell)
- Merge 7fed3b9: -Diagnostic switch, serialization exit code 3, PS7 module
  path, UI error detail; keep hardened task/certificate collectors
- Add audit docs, privacy docs and regression tests

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-04 18:50:24 -08:00

17 lines
1.1 KiB
PowerShell

function Get-SamsaraNetwork {
param($Result)
$processes = @{}
Invoke-SamsaraRead $Result 'Process names' {
Get-Process -ErrorAction Stop | ForEach-Object { $processes[[int]$_.Id] = [string]$_.ProcessName }
}
Invoke-SamsaraRead $Result 'TCP connections' {
$Result.data = @(Get-NetTCPConnection -ErrorAction Stop | ForEach-Object {
$processName = if ($processes.ContainsKey([int]$_.OwningProcess)) { $processes[[int]$_.OwningProcess] } else { 'Unavailable or process exited' }
[pscustomobject]@{ state = [string]$_.State; local_address = [string]$_.LocalAddress; local_port = [int]$_.LocalPort
remote_address = [string]$_.RemoteAddress; remote_port = [int]$_.RemotePort
pid = [int]$_.OwningProcess; process = Get-SamsaraPublicName 'processes' $processName ([int]$_.OwningProcess); direction = 'Unknown' }
})
}
$Result.limitations += 'Point-in-time TCP only. Connection direction, historical activity, UDP and other network compartments are unverified. Process names may race process exit or be hidden.'
}