Docs menu ▾
Scanner · Scanner / updated 2026-11-09

The scanner

Runs once, at install, as root. Reads metadata only, never file contents; chooses the places to protect from the catalog; records the baseline, which can't be rescanned; uploads the report. From here on the daemon owns the baseline.

Flow

flowchart TD
  A[main] --> B[check_host<br/>root, python3 >= 3.10, curl]
  B --> C{check_not_scanned<br/>baseline.json exists?}
  C -- yes --> X[exit 1: scan runs once]
  C -- no --> D[prepare_demo_enforcer<br/>plan_identities: stat the plan's folders]
  D --> E[ask_server / server_url]
  E --> F[fetch_bundle<br/>download, SHA-256 check, unpack]
  F --> G[python3 -m genos.phase0 scan<br/>build_profile]
  G --> H{complete?}
  H -- yes --> I[record_baseline<br/>baseline.json + enforcement.json]
  I --> J[start_demo_enforcer<br/>systemctl enable --now genos-daemon]
  H -- no --> K[no record: a later scan is allowed]
  J --> L[build_report + upload<br/>POST /baseline]
  K --> L

installer/scanner.sh.in (shipped as scanner.sh)

Function Does Fails when
check_host Checks root, python3 ≥ 3.10, curl Any is missing
check_not_scanned Exits if baseline.json exists; lists unsent reports to resend Host already scanned
prepare_demo_enforcer With GENOS_DEMO_ENFORCER=1: checks the daemon and unit are installed and stopped, then calls plan_identities Daemon missing or already running
plan_identities Builds the enforcement plan for this host (enforce_plan.build_plan) and lstats each folder it names; records path, device, inode A folder is a symlink
server_url Normalises HOST[:PORT], [IPv6]:PORT or https://HOST to a URL Not an IP or hostname
ask_server Takes GENOS_SERVER, else prompts on the terminal No terminal and no GENOS_SERVER
fetch_bundle Downloads the Python scanner tarball (or takes it from GENOS_SCANNER_SOURCE), checks its SHA-256 against the value baked into the script, unpacks it Hash mismatch
record_baseline If the profile is complete: writes enforcement.json (the plan's folders with their names from the scan's entities, unscanned = present − scanned, the listening ports from the scan's socket tables, and the actor rules: the plan's allowed programs with the device and inode found, and the programs holding each listening socket, read from /proc) and baseline.json, both 0600, O_EXCL, O_NOFOLLOW. Re-stats each folder: device and inode must not have changed during the scan Folder replaced mid-scan; non-UTF-8 or newline in a name
start_demo_enforcer systemctl enable --now genos-daemon The daemon fails to start (its self-test refuses)
build_report Streams profile.json, unmapped_queue.json and every entity into one gzipped JSON report (genos.phase0.baseline/1); on failure, the last 50 log lines —
upload POST /baseline Network error: the report is kept in /var/lib/genos-unsent/report-*.json.gz with a resend command

genos/phase0 (the Python scanner, run with python3 -S: stdlib plus a vendored jsonschema)

Function Does
__main__._run_scan Requires root; loads the vector catalog (load_index); runs build_profile; writes output with write_profile
catalog.load_index / load_catalog Loads and validates the vector catalog (JSON schemas, frozen IDs, vocabulary)
profile.build_profile The scan. Phases below. Returns entities, vectors present, coverage, header
profile._scan_test One catalog presence test: expands its paths and builds an entity for each that exists
profile._sweeps Metadata sweeps over /etc /usr /var /opt /home /root /tmp /run: setuid/setgid, capabilities, immutable flags, sockets, devices, unresolved owners, writable config. Skips pseudo and remote filesystems. Caps per root, never folds high-signal findings
profile._account_home_entities Dotfiles and autostart entries in each account's home
profile._entity One record for one path, from lstat only: owner, group, mode, size, times, symlink target, xattrs, ACL, capabilities, inode flags, parent owner/mode, mount options, package owner, non_root_writable. Never reads file contents
profile._compact_subtree_facts Folds large uniform subtrees into one summary entity
profile.canonical_hash SHA-256 of the profile minus volatile parts (entities, coverage, scan time)
profile.write_profile Writes entities.jsonl, profile.json, unmapped_queue.json, all 0600

build_profile phases:

flowchart LR
  A[identity tables<br/>passwd, group] --> B[mount table<br/>package index]
  B --> C[vector checks<br/>catalog presence tests]
  C --> D[metadata sweeps]
  D --> E[account home entries]
  E --> F[identity records]
  F --> G[compact subtrees<br/>link entities to vectors]
  G --> H[header, coverage,<br/>canonical_hash]

A probe denied, failed or timed out (3 s) marks the profile incomplete: reported, never recorded as a baseline.

Running it by hand

One script, genos_scanner_enforcer/dist/scanner.sh: downloads the pinned scanner bundle from GENOS_SERVER, scans, uploads.

sudo GENOS_SERVER=<server>[:port] GENOS_DEMO_ENFORCER=1 bash dist/scanner.sh
Variable Effect
GENOS_SERVER Server to download from and report to
GENOS_DEMO_ENFORCER=1 Also write the enforcement baseline, then start genos-daemon
GENOS_ALLOW_INCOMPLETE=1 Upload even if some checks fail. Such a scan never becomes a baseline

Needs: root, python3 3.10+, curl, tar. Tested on Ubuntu 26.10.

It runs once. To redo a host, delete baseline.json on the host and its baseline on the server (how).

If the upload fails, the report waits in /var/lib/genos-unsent/ with a curl command to resend. Resend; don't rescan.

Catalog

The catalog is the vector list the scanner checks. genossec.com publishes it:

export GENOS_CATALOG_URL=https://genossec.com/dashboard/catalog
export GENOS_CATALOG_SHA256=<from the dashboard's Catalog page>

dist/scanner.sh (0.3.0) doesn't download it: the catalog is inside the scanner tarball, which the script pins by SHA-256. The published copy is for reference, and these variables are ignored.

View this page on GitHub ↗