fireman.store#
Cache each firewall’s findings in SQLite.
- class fireman.store.Store(root=PosixPath('.fireman'))#
A SQLite cache of findings, one row per firewall digest.
- digest(inventory, firewall, implicit_deny)#
Hash everything that decides a firewall’s findings: version, settings, global objects, the firewall.
- digests(inventory, implicit_deny, firewalls=None)#
Digest of each firewall (all by default), dumping the global objects once.
Same hash as hashing
json.dumps({"firewall", "implicit_deny", "objects", "version"}, sort_keys=True), built from the pieces so the shared objects are not dumped per firewall.
- findings(digest)#
Policies cached for this digest, or
Noneif there are none or the row no longer validates.Rows are saved fresh, so the policies come back marked
cached=True.
- save(entries)#
Cache each firewall’s policies by digest, replacing rows already there.
- save_workspace(name, inventory, files)#
Store an inventory under a name with its files’ hashes, replacing any earlier load of that name.
- Raises:
UnreadableFileError – A file is missing, a folder or unreadable; nothing is stored.
- workspace(name)#
A stored inventory and the recorded files that changed, vanished or can’t be read since, or
None.
- clear(name)#
Forget one workspace; cached findings and other workspaces stay.
- Returns:
Whether the workspace existed.
- Return type:
- exception fireman.store.UnreadableFileError(path, reason)#
A file to record for a workspace could not be read, so nothing was stored.
- path#
The file.
- reason#
Why it could not be read, e.g.
No such file or directory.
fireman.store.db#
The SQLAlchemy tables behind the store. The schema is owned by the Alembic
migrations in fireman/store/migrations/.
Tables of the store: cached findings and loaded workspaces.
- class fireman.store.db.Base(**kwargs)#
Base of the store tables: an integer
idkey and stable constraint names for migrations.
- class fireman.store.db.CachedFirewall(**kwargs)#
One firewall’s findings, found again by the digest of its input.
- class fireman.store.db.Source(**kwargs)#
A file a workspace was loaded from, with its hash at load time.