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.

root#

Folder of the database, created on first use.

Type:

Path

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 None if 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:

bool

clear_all()#

Delete the database file: cached findings and every workspace.

Returns:

Whether there was a database to delete.

Return type:

bool

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 id key and stable constraint names for migrations.

metadata: ClassVar[MetaData]#

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[registry]#

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

class fireman.store.db.CachedFirewall(**kwargs)#

One firewall’s findings, found again by the digest of its input.

id: Mapped[int]#
class fireman.store.db.Source(**kwargs)#

A file a workspace was loaded from, with its hash at load time.

id: Mapped[int]#
class fireman.store.db.Workspace(**kwargs)#

A named, validated inventory as loaded, with the files it came from.

id: Mapped[int]#