fireman#

The package root re-exports the names most scripts need, so from fireman import Pipeline works. Each one is documented where it is defined; the table links there. Pipeline and the builders live in fireman.pipeline and fireman.build, documented below.

Export

Documented at

Pipeline

fireman.pipeline.Pipeline

BDDManager

fireman.bdd.BDD (an alias)

compile_inventory, CompiledInventory

fireman.core.compiler.compile_inventory(), fireman.core.compiler.CompiledInventory

CompiledPolicy, State, TrafficRule

fireman.core.compiled.CompiledPolicy, fireman.core.compiled.State, fireman.core.compiled.TrafficRule

Store

fireman.store.Store

yaml_file, json_file, file_source, csv_file

fireman.load.yaml_file(), fireman.load.json_file(), fireman.load.file_source(), fireman.load.csv_file()

Source, source, Resource, resource, LoadError

fireman.load.Source, fireman.load.source(), fireman.load.Resource, fireman.load.resource(), fireman.load.LoadError

traffic, tcp, udp, icmp

fireman.build.traffic(), fireman.build.tcp(), fireman.build.udp(), fireman.build.icmp()

TCP_ANY, UDP_ANY, ICMP_ANY

fireman.build.TCP_ANY, fireman.build.UDP_ANY, fireman.build.ICMP_ANY

ANY

The string "any", which matches everything wherever a name goes

Inventory, Usage, NameUsage, Problem

fireman.model.Inventory, fireman.model.Usage, fireman.model.NameUsage, fireman.model.Problem

Finding, Anomaly, RuleId, PolicyFindings

fireman.model.Finding, fireman.model.Anomaly, fireman.model.RuleId, fireman.model.PolicyFindings

Placement, Insert, Widen, Decision, Coverage

fireman.model.Placement, fireman.model.Insert, fireman.model.Widen, fireman.model.Decision, fireman.model.Coverage

TrafficSet, PortEntry, IcmpEntry, ProtocolEntry

fireman.model.TrafficSet, fireman.model.PortEntry, fireman.model.IcmpEntry, fireman.model.ProtocolEntry

FormattedTraffic

fireman.bdd.FormattedTraffic

fireman.pipeline#

Run sources through validation and compilation.

class fireman.pipeline.Pipeline(name='default')#

Loads sources, checks them, and compiles the result.

name#

Names the workspace the commands load into and read from.

Type:

NameT

load(*sources)#

Load every source and validate the whole estate.

Raises:

LoadError – With every problem found. Bad items are reported first; the cross-checks only run once every item is valid.

run(*sources, bdd, implicit_deny=True)#

Load every source, validate the whole estate and compile it.

classify(inventory, *, make_bdd, implicit_deny=True, store=None, reuse=True)#

Classify every policy, reusing stored findings of unchanged firewalls.

With a store, firewalls that were compiled are cached; reuse=False recomputes every firewall and refreshes the cache. Each missed firewall gets a fresh manager from make_bdd, collected after compiling, so peak memory is one firewall’s.

fireman.build#

Builders for writing service entries and traffic sets by hand, in scripts, tests and requests.

fireman.build.tcp(lo, hi=None)#

TCP ports lo to hi, or just lo when hi is left out.

fireman.build.udp(lo, hi=None)#

UDP ports lo to hi, or just lo when hi is left out.

fireman.build.icmp(icmp_type=None, icmp_code=None)#

ICMP of one type and optional code, or all of ICMP when called with no type.

fireman.build.ICMP_ANY#

Every ICMP type and code, for use with traffic.

fireman.build.TCP_ANY#

Every TCP port.

fireman.build.UDP_ANY#

Every UDP port.

fireman.build.traffic(bdd, sources, destinations, *services)#

Build a traffic set from address strings and service entries.

Bind bdd once with functools.partial(traffic, bdd).

Parameters:
  • bdd (BDD) – Manager the set is built in.

  • sources (list[str]) – Network strings, e.g. ["10.0.0.0/8"]. A bare address means a /32, ANY any address.

  • destinations (list[str]) – Same as sources.

  • *services (ServiceEntryT | AnyT) – Service entries, e.g. tcp(80) or icmp(8), or ANY for any service.

Returns:

The traffic from any source to any destination on any of the services.

Raises:

ValueError – If an address is not valid IPv4 or a network has host bits set.

Return type:

TrafficSet