Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

## Unreleased

### Host Posture

- New `limacharlie host-posture` command group for the `ext-host-posture`
extension. `rules` (`list`, `get`, `set`, `delete`, `enable`, `disable`,
`tag`) manages the new `host_posture_rule` hive; the server validates every
rule. `install-defaults` writes LimaCharlie's default pack into the hive with
your own permissions: the extension's `pack_status` decides each rule's fate
(`new`, `current`, `update_available`, `edited`, `org_newer`) and the CLI
computes no digest. It never overwrites silently, `--update` replaces only
unedited rules the pack has a newer version of (etag-safe), `--force` also
replaces edited and newer-than-pack ones, `--dry-run` writes nothing. `scan --sid` checks one
online sensor, `sweep [--tag]` sweeps with reliable tasking, and `results`
(`summary`, `hosts`, `host`, `rules`, `rule-hosts`, `standards`) reads the
per-host results with server-side filters and paging. `status` reports the
extension's health.
- `host_posture_rule` is listed by `hive list-types` and synced by `sync pull` /
`sync push` with `--hive-host-posture-rule` (and by `--all`; SDK
`Configs.ALL_HIVES`). New SDK class `limacharlie.sdk.host_posture.HostPosture`.
- `--all` now includes `host_posture_rule`, like every other hive. A forced
`sync push --all` of a config file pulled before this change has no
`host_posture_rule` key, so pull again first.
- Saving, enabling or disabling a rule needs `host_posture.set` and
`sensor.task`; deleting needs `host_posture.set`.

### Sync - includes are merged in a fixed order

- `sync push` resolved `include:` through an unordered set, so when two
Expand Down
1 change: 1 addition & 0 deletions NEW_CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,7 @@ Features in the API gateway that are **NOT** in the current CLI and are **added
| `external_adapter` | External adapter configs | Third-party integrations |
| `app_control_policy` | Application Control policies | Endpoint application control |
| `app_control_rule` | Application Control allow/deny rules | Endpoint application control |
| `host_posture_rule` | Host Posture rules | Endpoint misconfiguration checks |
| `sop` | Standard Operating Procedures | Runbooks |
| `note` | Organization notes | Documentation |

Expand Down
1 change: 1 addition & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
| [Data & Query](cli/data-query.md) | search, ioc, event, stream |
| [Platform Administration](cli/platform-admin.md) | org, user, group, api-key, ingestion-key, billing, audit |
| [Hive & Data Stores](cli/hive-data.md) | hive, secret, lookup, playbook, note, sop, app-control, adapter, cloud-sensor, extension |
| [Host Posture](cli/host-posture.md) | host-posture |
| [Infrastructure](cli/infrastructure.md) | sync, output, artifact, payload, yara, integrity, logging, exfil |
| [Cloud Security & Code Security](cli/cloud-security.md) | cloudsec (findings, inventory, graph, compliance, CAASM, code lane, container images, fleet, exports) |
| [Investigation Engine](cli/investigation-engine.md) | investigate (authoring kit, templates, dry runs on past alerts, runs, waves, approvals, policy) |
Expand Down
1 change: 1 addition & 0 deletions doc/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ limacharlie schema dr create
| [Data & Query](data-query.md) | search, ioc, event, stream |
| [Platform Administration](platform-admin.md) | org, user, group, api-key, ingestion-key, billing, audit |
| [Hive & Data Stores](hive-data.md) | hive, secret, lookup, playbook, note, sop, app-control, adapter, cloud-sensor, extension |
| [Host Posture](host-posture.md) | host-posture (rules, default pack, scans and sweeps, per-host results) |
| [Infrastructure](infrastructure.md) | sync, output, artifact, payload, yara, integrity, logging, exfil |
| [Cloud Security & Code Security](cloud-security.md) | cloudsec (findings, inventory, graph, compliance, CAASM, code lane, container images, fleet, exports) |
| [Email Security](email-security.md) | mailsec (onboarding, coverage, triage, EML, remediation, campaigns, reports, sample submission, rules, tenant purge) |
Expand Down
1 change: 1 addition & 0 deletions doc/cli/hive-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ There is no dedicated command for Stories or ACL resources; to accept a partial
| `dr-mail` | Email detection and verdict rules |
| `app_control_policy` | Application Control policies |
| `app_control_rule` | Application Control allow and deny rules |
| `host_posture_rule` | Host Posture rules (see [Host Posture](host-posture.md)) |

Store provider credentials in `secret` records and reference them with `hive://secret/<key>`. Most hives default new records to disabled; `cloudsec_policy`, `acl` and the app-control hives default them to enabled. Pass `--enabled` or `--disabled` to be explicit. See the [Cloud Security](cloud-security.md) and [Email Security](email-security.md) onboarding guides before creating connections.

Expand Down
103 changes: 103 additions & 0 deletions doc/cli/host-posture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
[Documentation](../README.md) > [CLI](README.md) > Host Posture

# Host Posture

Host Posture (`ext-host-posture`) checks Windows, macOS and Linux sensors for misconfigurations. The checks are rules in the organization's `host_posture_rule` hive, one record per rule. The extension ships no rules: install LimaCharlie's default pack, then edit, disable or add your own. Every rule is equally trusted, whoever wrote it.

Subscribe first: `limacharlie extension subscribe --name ext-host-posture`.

| Command | What it does |
|---|---|
| `host-posture install-defaults` | Write the default pack into the rule hive. |
| `host-posture rules ...` | The rule hive: `list`, `get`, `set`, `delete`, `enable`, `disable`, `tag`. |
| `host-posture scan --sid SID` | Check one online sensor now. |
| `host-posture sweep [--tag TAG]` | Sweep sensors now, including offline ones when they return. |
| `host-posture results ...` | Per-host results: `summary`, `hosts`, `host`, `rules`, `rule-hosts`, `standards`. |
| `host-posture status` | Extension health: build, pack version, rule counts. |

## Permissions

- `host_posture.get` reads rules and results. `host_posture.set` writes rules.
- Saving a rule (`rules set`), and `rules enable` and `rules disable`, also need `sensor.task`, because a rule runs on your sensors.
- `rules delete` needs only `host_posture.set`.

## install-defaults

```bash
limacharlie host-posture install-defaults
limacharlie host-posture install-defaults --dry-run
limacharlie host-posture install-defaults --update
limacharlie host-posture install-defaults --id lc.windows.network.smb1-server --disabled
```

The command reads the pack from the extension and writes each rule into your hive with **your** permissions. The extension decides what each rule needs (`pack_status`); the CLI computes nothing itself. Nothing is overwritten silently:

| State | Meaning | What the command does |
|---|---|---|
| `new` | No record for it. | Creates it, enabled (`--disabled` creates it disabled). Creation is conditional, so a record that appears in the meantime is not replaced. |
| `current` | Your record is the pack's rule, unedited, at the same version. | Nothing. |
| `update_available` | Unedited, and the pack has a newer version. | Replaces it with `--update`. The state is checked again after the record is read, and the write is conditional on that read's etag. Enabled state, expiry, other tags, `ui_actions` and your own comment are kept. |
| `edited` | Your record differs from what the pack installed, or has no digest tag. Checked first. | Skips it unless `--force`. |
| `org_newer` | Your record is unedited but its version is higher than the pack's. | Skips it unless `--force`. |

If a write finds the record changed meanwhile (a new rule that appeared, an update that lost the etag race), nothing is retried: the rule is skipped and `pack_status` is read again, so the entry reports `state_now`.

`--force` implies `--update`. `--id` (repeatable) installs only those rules. `--dry-run` writes nothing.

Records the command writes carry the tag `lc:default-pack`, a tag `lc:pack-sha256:<digest>` with the digest exactly as the extension returned it with the pack, and a comment naming the pack version. The extension compares that digest with the record as it is now to tell an edited rule from an unedited one. A record without the tag counts as edited.

The output has `pack_version`, `created`, `updated`, `skipped` (each with a `reason`) and `failed`. The command exits 1 when a write failed.

## rules

```bash
limacharlie host-posture rules list
limacharlie host-posture rules get --key lc.linux.kernel.ptrace-scope
limacharlie host-posture rules set --key acme.linux.fs.protected-symlinks --input-file rule.yaml --enabled
limacharlie host-posture rules disable --key lc.linux.kernel.ptrace-scope
limacharlie host-posture rules delete --key acme.linux.fs.protected-symlinks --confirm
```

A record (`data`):

```yaml
data:
rule: # one lc-posture/v1 rule document
apiVersion: lc-posture/v1
kind: Signature
id: acme.linux.fs.protected-symlinks # must equal the record key
version: 1
# ... probes, violation, evidence, remediation, tests
scope: # optional
sensor_tags: [prod] # run only on sensors with one of these tags
exclude_sensor_tags: [kiosk] # skip sensors with any of these (wins)
```

The server validates the whole rule, including its tests, and refuses it with the field path of every problem; the CLI does not validate. Pass `--enabled` when creating a record, as with other hives, so that the rule runs. See the [rule format](https://docs.limacharlie.io/7-administration/config-hive/host-posture-rule/) and [how to write rules](https://docs.limacharlie.io/5-integrations/extensions/limacharlie/host-posture-writing-rules/).

The rule hive also syncs with `limacharlie sync` (`--hive-host-posture-rule`, and `--all`) and works with the generic `limacharlie hive` commands (`--hive-name host_posture_rule`).

## scan and sweep

```bash
limacharlie host-posture scan --sid 11111111-2222-3333-4444-555555555555
limacharlie host-posture sweep
limacharlie host-posture sweep --tag prod --tag web
```

`scan` needs an online sensor and returns `job_id`, `sid`, `platform` and `tasks_issued`. `sweep` uses reliable tasking, so it also reaches sensors that are offline now, and returns `job_id` and `sensors_tasked`. With `--tag`, only sensors carrying at least one of the tags are swept.

## results

```bash
limacharlie host-posture results summary
limacharlie host-posture results hosts --severity high --platform windows --limit 50
limacharlie host-posture results host --sid 11111111-2222-3333-4444-555555555555
limacharlie host-posture results rules --severity critical
limacharlie host-posture results rule-hosts --rule-id lc.windows.network.smb1-server --status fail
limacharlie host-posture results standards --framework cis
```

Filtering and paging happen on the server. `--limit` is at most 200 (default 50); pass a page's `next_cursor` as `--cursor` to get the next. Statuses are `pass`, `fail`, `error`, `not_applicable` and `unsupported`; severities are `critical`, `high`, `medium`, `low` and `info`.

`results summary` reports `cloud_security` as `published`, `not_subscribed` or `error`: organizations also subscribed to Cloud Security additionally get one rolled-up finding per failing rule there.
2 changes: 1 addition & 1 deletion doc/cli/infrastructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ limacharlie sync push --config-file dr.yaml --hive-dr-general --hive-fp --dry-ru
```

Available hive flags: `--hive-cloudsec-policy`, `--hive-cloudsec-provider`,
`--hive-cloudsec-query`, `--hive-cloudsec-code-rule`, `--hive-mailsec-provider`, `--hive-dr-mail`, `--hive-mailsec-policy`, `--hive-app-control-policy`, `--hive-app-control-rule`, `--hive-acl`, `--hive-dr-general`, `--hive-dr-managed`, `--hive-dr-service`,
`--hive-cloudsec-query`, `--hive-cloudsec-code-rule`, `--hive-mailsec-provider`, `--hive-dr-mail`, `--hive-mailsec-policy`, `--hive-app-control-policy`, `--hive-app-control-rule`, `--hive-host-posture-rule`, `--hive-acl`, `--hive-dr-general`, `--hive-dr-managed`, `--hive-dr-service`,
`--hive-fp`, `--hive-cloud-sensor`, `--hive-extension-config`, `--hive-yara`,
`--hive-lookup`, `--hive-secret`, `--hive-query`, `--hive-playbook`,
`--hive-ai-agent`, `--hive-external-adapter`.
Expand Down
1 change: 1 addition & 0 deletions limacharlie/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def _wants_help() -> bool:
"help": ("help_cmd", "group"),
"hive": ("hive", "group"),
"ingestion-key": ("ingestion_key", "group"),
"host-posture": ("host_posture", "group"),
"installation-key": ("installation_key", "group"),
"investigate": ("investigate", "group"),
"integrity": ("integrity", "group"),
Expand Down
4 changes: 3 additions & 1 deletion limacharlie/commands/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def _record_from_input(key: str, data: Any) -> HiveRecord:
"dr-mail",
"app_control_policy",
"app_control_rule",
"host_posture_rule",
"dr-general",
"dr-managed",
"dr-service",
Expand Down Expand Up @@ -184,6 +185,7 @@ def group() -> None:
app - AI-generated iframe web apps
app_control_policy - Application Control policies
app_control_rule - Application Control rules (record key is the rule id)
host_posture_rule - Host Posture rules (record key is the rule id)

Each record returned contains:
data - The record payload (structure varies by hive type)
Expand Down Expand Up @@ -774,7 +776,7 @@ def rename(ctx, hive_name, key, new_name) -> None:
kind of data. Cloud Security uses cloudsec_provider, cloudsec_policy,
cloudsec_query, and cloudsec_code_rule. Email Security uses mailsec_provider,
mailsec_policy, and dr-mail. Application Control uses app_control_policy and
app_control_rule. Other known types: dr-general, dr-managed, dr-service, fp,
app_control_rule. Host Posture uses host_posture_rule. Other known types: dr-general, dr-managed, dr-service, fp,
cloud_sensor, extension_config, yara, lookup, secret, query, playbook,
ai_agent, ai_skill, ai_memory, external_adapter, sop, org_notes.

Expand Down
Loading
Loading