From 90c6c80843b0c27904e53490749d65d6700eefa0 Mon Sep 17 00:00:00 2001 From: Guillaume BOURGEOIS Date: Mon, 19 Oct 2026 19:23:40 +0000 Subject: [PATCH] feat(harfanglab): instance-level tenant scope (1.8.0) An instance can carry the tenant of the client it serves, for clients sharing one multi-tenant manager. endpoint_count uses it, for the count and the fleet total beside it, when the block leaves its tenant filter empty; a tenant named on the block still wins. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TgjV26rz6VcP262dX4vBrD --- integrations/harfanglab/manifest.yaml | 12 +++++++++--- integrations/harfanglab/scripts/endpoint_count.py | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/integrations/harfanglab/manifest.yaml b/integrations/harfanglab/manifest.yaml index a51a17b..9b6e4df 100644 --- a/integrations/harfanglab/manifest.yaml +++ b/integrations/harfanglab/manifest.yaml @@ -1,8 +1,8 @@ id: harfanglab name: HarfangLab EDR -version: 1.7.3 +version: 1.8.0 description: "HarfangLab EDR — endpoint detection & response: alert/threat ingestion, endpoint enrichment, isolation, threat-intelligence (IOC/whitelist), telemetry hunting and forensic collection jobs." -changelog: "1.7.3 — Every command now retries a call HarfangLab answers with a transient error, up to three times after 1, 2 and 4 seconds. The API returns a 500 now and then on a call that passes when sent again, which failed an ingestion run or a playbook step for nothing. Reads (GET) are retried on 429, 500, 502, 503 and 504. Writes are retried only on 429, 502 and 503, answers that say the action was not run: a 500 or 504 on an isolation, a kill or a job creation may come after the action took effect, so it is reported rather than sent twice. | 1.7.1 — get_security_events, get_alerts and get_threats no longer pass on the `filters` block HarfangLab's list endpoints echo on every call: the catalogue of every filterable field, about 50 KB, unrelated to the results. One alert weighs about 10 KB, so that block alone made up most of a small fetch. The get_security_events and get_alerts mappers give an incident the rule's message (msg) as its description — what the rule detects and what to check — instead of the bare alert type, which now stands in only on alerts without a message. | 1.7.0 — New threat_security_events command: returns every security event of a threat. Since HarfangLab merged alerts and security events, a threat's events are the alerts whose threat_key is the threat id — the filter the vendor's own XSOAR integration uses. get_alerts could already filter on it but stops at one page of 100; threat_security_events pages through up to max_results (default 1000) and returns the threat's `total` with a `truncated` flag, so a cut-off list never passes for the whole threat. threat_status, threat_level and alert_tag now offer their status and level as drop-downs, and threat_status says it is where a threat is closed or marked a false positive — HarfangLab has no separate verdict field and no assignment on a threat. | 1.6.0 — New endpoint_count command: counts agents matching filters without listing them. The HarfangLab agent collection is DRF-paginated, so its `count` field already carries the filtered total; endpoint_count asks for limit=1 and reads it, instead of pulling up to 10000 agent records back through the playbook the way endpoint_search does. Filters cover the documented agent query parameters (hostname, os, version, status, isolation_state, tenant, network), add lastseen/firstseen bounds, and leave a raw `filters` escape hatch for the rest. The API silently drops a parameter it does not recognise as a filter — which turns a typo into a plausible-looking fleet-wide total — so the fleet `total` is returned next to `count` to make that case visible. | 1.5.0 — Declare the risk tier on the 71 commands that carried none: 39 read, 24 safe_write, 8 destructive. An unset risk is read as destructive by the agent approval gate, so the 63 that only read or only annotate sat behind the same prompt as the ones that change the estate. deisolate_from_threat and unquarantine_file move from safe_write to destructive in the same pass: undoing a containment mid-incident is its own decision, and is tiered like the containment it lifts. | 1.4.1 — get_alerts now maps image_name, the one process path present on every alert subtype and the only one on those carrying neither a process object nor an event log (yara, binary, ioc). HarfangLab prefixes it with the matched threat name in brackets, so both halves are split out: the clean path feeds actor.process.file.path and its basename actor.process.name, and the threat name feeds malware.name — which now surfaces on every subtype rather than only on Defender event-log detections. Each half is guarded on the bracket being present so an unprefixed path is never written into malware.name. 1.4.0 — Mapper coverage from real payloads: get_alerts now maps the Windows event-log payload sigma alerts carry (alert_subtype = eventlog), which was entirely unmapped — Defender 1116/1117 yields the malware name, classification, severity and provider, the detected file, the process that touched it and the acting user, plus the log provider and event code. Also added the agent IP, DNS domain, device type, agent version and groups, the tenant, the alert subtype and threat type, the string severity and the event time. get_threats gained the threat level (previously never reaching the OCSF document at all), the event time and the top agent's reachability. 1.3.1 — Flagged get_alerts as ingestion-ready (ingest hints: results_path/dedup/incremental on from_date) so it appears in the recommended ingestion commands when creating an instance. 1.3.0 — Response & triage expansion: kill/dump process, on-demand AV/YARA scans, file/service/scheduled-task deletion, quarantine management, threat-level isolation, job cancel/relaunch/wait; alert search (get_alerts) and full alert/threat triage (tag, comments, notes, status, level, history, details); exhaustive alert OCSF mappers; reworked get_threats mapper (fixed MITRE tactics map handling, full top-agent/user/rule and counts coverage, rule-based incident title/description). 1.2.2 — Documentation wording cleanup. 1.2.1 — Corrected the get_threats OCSF mapper to native threat fields (top_agents/top_impacted_users/top_rules/mitre_tactics) instead of enriched-only arrays; added agent.osversion to get_security_events. 1.2.0 — Added ingestion commands get_security_events (alerts) and get_threats with bundled OCSF mappers and ingest hints (results_path/dedup/incremental). 1.1.1 — Added test_connection for the instance Test button. 1.1.0 — Command names prefixed with 'harfanglab-' (e.g. harfanglab-isolate-endpoint) for easier toolbox search; command IDs unchanged. 1.0.0 — Initial release: endpoint/agent management, isolation, policy assignment, IOC & whitelist management, security-event triage, telemetry hunting (processes, network, DNS, authentications, binaries, event logs), threat hunting by hash, and forensic collection jobs (pipes, prefetch, run keys, scheduled tasks, drivers, services, processes, network, sessions, WMI, IOC scan, artifacts, RAM dump) with their result retrieval commands. Compatible with HarfangLab EDR 2.13.7+." +changelog: "1.8.0 — An instance can carry the tenant of the client it serves (tenant in its configuration), for clients sharing one multi-tenant manager: each gets its own instance with the same URL and key and its own tenant. endpoint_count is scoped to it when the block leaves its tenant filter empty, and so is the fleet total returned beside the count; a tenant named on the block still wins. A playbook bound to the run's client — a job fanned out over every client with HarfangLab — counted the whole manager for the clients that shared it. Left empty, nothing changes. 1.7.3 — Every command now retries a call HarfangLab answers with a transient error, up to three times after 1, 2 and 4 seconds. The API returns a 500 now and then on a call that passes when sent again, which failed an ingestion run or a playbook step for nothing. Reads (GET) are retried on 429, 500, 502, 503 and 504. Writes are retried only on 429, 502 and 503, answers that say the action was not run: a 500 or 504 on an isolation, a kill or a job creation may come after the action took effect, so it is reported rather than sent twice. | 1.7.1 — get_security_events, get_alerts and get_threats no longer pass on the `filters` block HarfangLab's list endpoints echo on every call: the catalogue of every filterable field, about 50 KB, unrelated to the results. One alert weighs about 10 KB, so that block alone made up most of a small fetch. The get_security_events and get_alerts mappers give an incident the rule's message (msg) as its description — what the rule detects and what to check — instead of the bare alert type, which now stands in only on alerts without a message. | 1.7.0 — New threat_security_events command: returns every security event of a threat. Since HarfangLab merged alerts and security events, a threat's events are the alerts whose threat_key is the threat id — the filter the vendor's own XSOAR integration uses. get_alerts could already filter on it but stops at one page of 100; threat_security_events pages through up to max_results (default 1000) and returns the threat's `total` with a `truncated` flag, so a cut-off list never passes for the whole threat. threat_status, threat_level and alert_tag now offer their status and level as drop-downs, and threat_status says it is where a threat is closed or marked a false positive — HarfangLab has no separate verdict field and no assignment on a threat. | 1.6.0 — New endpoint_count command: counts agents matching filters without listing them. The HarfangLab agent collection is DRF-paginated, so its `count` field already carries the filtered total; endpoint_count asks for limit=1 and reads it, instead of pulling up to 10000 agent records back through the playbook the way endpoint_search does. Filters cover the documented agent query parameters (hostname, os, version, status, isolation_state, tenant, network), add lastseen/firstseen bounds, and leave a raw `filters` escape hatch for the rest. The API silently drops a parameter it does not recognise as a filter — which turns a typo into a plausible-looking fleet-wide total — so the fleet `total` is returned next to `count` to make that case visible. | 1.5.0 — Declare the risk tier on the 71 commands that carried none: 39 read, 24 safe_write, 8 destructive. An unset risk is read as destructive by the agent approval gate, so the 63 that only read or only annotate sat behind the same prompt as the ones that change the estate. deisolate_from_threat and unquarantine_file move from safe_write to destructive in the same pass: undoing a containment mid-incident is its own decision, and is tiered like the containment it lifts. | 1.4.1 — get_alerts now maps image_name, the one process path present on every alert subtype and the only one on those carrying neither a process object nor an event log (yara, binary, ioc). HarfangLab prefixes it with the matched threat name in brackets, so both halves are split out: the clean path feeds actor.process.file.path and its basename actor.process.name, and the threat name feeds malware.name — which now surfaces on every subtype rather than only on Defender event-log detections. Each half is guarded on the bracket being present so an unprefixed path is never written into malware.name. 1.4.0 — Mapper coverage from real payloads: get_alerts now maps the Windows event-log payload sigma alerts carry (alert_subtype = eventlog), which was entirely unmapped — Defender 1116/1117 yields the malware name, classification, severity and provider, the detected file, the process that touched it and the acting user, plus the log provider and event code. Also added the agent IP, DNS domain, device type, agent version and groups, the tenant, the alert subtype and threat type, the string severity and the event time. get_threats gained the threat level (previously never reaching the OCSF document at all), the event time and the top agent's reachability. 1.3.1 — Flagged get_alerts as ingestion-ready (ingest hints: results_path/dedup/incremental on from_date) so it appears in the recommended ingestion commands when creating an instance. 1.3.0 — Response & triage expansion: kill/dump process, on-demand AV/YARA scans, file/service/scheduled-task deletion, quarantine management, threat-level isolation, job cancel/relaunch/wait; alert search (get_alerts) and full alert/threat triage (tag, comments, notes, status, level, history, details); exhaustive alert OCSF mappers; reworked get_threats mapper (fixed MITRE tactics map handling, full top-agent/user/rule and counts coverage, rule-based incident title/description). 1.2.2 — Documentation wording cleanup. 1.2.1 — Corrected the get_threats OCSF mapper to native threat fields (top_agents/top_impacted_users/top_rules/mitre_tactics) instead of enriched-only arrays; added agent.osversion to get_security_events. 1.2.0 — Added ingestion commands get_security_events (alerts) and get_threats with bundled OCSF mappers and ingest hints (results_path/dedup/incremental). 1.1.1 — Added test_connection for the instance Test button. 1.1.0 — Command names prefixed with 'harfanglab-' (e.g. harfanglab-isolate-endpoint) for easier toolbox search; command IDs unchanged. 1.0.0 — Initial release: endpoint/agent management, isolation, policy assignment, IOC & whitelist management, security-event triage, telemetry hunting (processes, network, DNS, authentications, binaries, event logs), threat hunting by hash, and forensic collection jobs (pipes, prefetch, run keys, scheduled tasks, drivers, services, processes, network, sessions, WMI, IOC scan, artifacts, RAM dump) with their result retrieval commands. Compatible with HarfangLab EDR 2.13.7+." category: endpoint # Per-instance configuration. Scripts use as the API base and call /api/... paths. @@ -15,6 +15,12 @@ config_schema: type: string description: API key (HarfangLab EDR → user settings → API key) x-soar-sensitive: true + tenant: + type: string + description: >- + Optional tenant identifier, for an instance that serves one client of a + shared multi-tenant manager. endpoint_count is scoped to it when the + block leaves its own tenant filter empty. required: - url - api_token @@ -85,7 +91,7 @@ commands: outputs_schema: { properties: {} } - id: endpoint_count name: harfanglab-endpoint-count - description: "Count endpoints (agents) matching filters, without listing them. Returns {count, total, filters}: count is the number of matching agents, total the whole fleet. An unrecognised filter is silently ignored by the API, so compare count against total before trusting a figure." + description: "Count endpoints (agents) matching filters, without listing them. Returns {count, total, filters}: count is the number of matching agents, total the whole fleet (the instance tenant's fleet when the instance carries one). An unrecognised filter is silently ignored by the API, so compare count against total before trusting a figure." risk: read inputs_schema: properties: diff --git a/integrations/harfanglab/scripts/endpoint_count.py b/integrations/harfanglab/scripts/endpoint_count.py index 94100e7..4e20dcb 100644 --- a/integrations/harfanglab/scripts/endpoint_count.py +++ b/integrations/harfanglab/scripts/endpoint_count.py @@ -86,7 +86,13 @@ def main(): "Content-Type": "application/json", } # === per-command logic === - filters = {} + # An instance bound to one tenant of a shared, multi-tenant manager carries it + # in its config: it scopes the count, and the fleet total beside it, unless the + # block names a tenant itself. + scope = {} + if not str(inputs.get("tenant") or "").strip() and str(secrets.get("tenant") or "").strip(): + scope["tenant"] = str(secrets["tenant"]).strip() + filters = dict(scope) for field in EXACT_FILTERS: value = inputs.get(field) if value is None or value == "": @@ -112,8 +118,8 @@ def main(): # The API silently drops a query parameter it does not recognise as a # filter, which yields the unfiltered total dressed up as a filtered count. # Returning the fleet total alongside makes that failure visible. - if filters: - everything = request("GET", agents + qs({"limit": 1, "offset": 0}), headers) + if filters != scope: + everything = request("GET", agents + qs(dict(scope, limit=1, offset=0)), headers) result["total"] = everything.get("count", 0) else: result["total"] = result["count"]