firewall-objects
firewall-objects is a lightweight Rust framework for describing firewall entities—networks, transport services, and application indicators—so you can plug the building blocks into any policy engine, API, or control plane.
Highlights
- Network primitives – Parse hosts, CIDR ranges, IP spans, and FQDNs with deterministic ordering and doc-tested examples.
- Service catalog – Represent TCP/UDP/ICMP/IP entries, extend well-known aliases, and go from strings to strongly typed objects.
- Application descriptors – Express Layer-7 indicators (DNS suffixes, TLS SNI, HTTP hosts) with matching helpers and a sample catalog.
- Object store – Optional in-memory registry with JSON import/export (via the
serdefeature) for CRUD-style workflows.
Installation
[]
= "0.1.3"
# Optional JSON support
= { = "0.1.1", = ["serde"] }
Features
serde(optional) – Enables serialization for all public structs/enums and activates JSON helpers in theobjectsmodule.
Networks: parsing and normalization
Use the ip module to normalize user input. Each call produces a deterministic Network variant.
use Network;
use FromStr;
let host = from_str.unwrap;
let cidr = from_str.unwrap;
assert!; // ordering is stable
Services: transport definitions and aliases
TransportService represents TCP, UDP, ICMP, and IP protocol entries. Lookup helpers cover common aliases.
use ;
use FromStr;
let https = lookup.unwrap;
assert_eq!;
let custom = from_str.unwrap;
assert_eq!;
Applications: indicators and catalog lookups
Describe application behavior by combining DNS, TLS, and HTTP hints. The sample catalog is optional—bring your own definitions if you prefer.
use ;
let github = find_application.unwrap;
let metadata = ApplicationMatchInput ;
assert!;
Object store: managing firewall objects
The objects module provides a small storage layer with create/read/update/delete helpers. Everything is strongly typed; JSON I/O is available when the serde feature is enabled. Helper methods keep the API approachable.
use ObjectStore;
use NetworkObj;
let mut store = new;
store
.insert_network
.unwrap;
let network = store.network.unwrap;
println!;
To serialize/deserialize via JSON (requires the serde feature):
# use ;
# use ;
#
let mut store = new;
#
Applications can be stored and matched as well:
use ObjectStore;
use ;
let mut store = new;
let app = ApplicationObj ;
store.insert_application.unwrap;
let stored = store.application.unwrap;
assert!;
// Extend the catalog with your own definitions
pub const MY_APPS: & = &;
Builder mode: rapid prototyping with dotted notation
For quick scripts or CLI playgrounds, the builder module offers ergonomic helpers that turn dotted notation into fully typed objects. Use address(name, value) for networks, builder::service::* helpers for transports, fluent service_group()/network_group() builders, and builder::application() for Layer-7 entries.
use ;
use ObjectStore;
let mut store = new;
for entry in
let allowed = service_group
.unwrap
.with_service
.unwrap
.with_service
.unwrap
.with_service
.unwrap
.build
.unwrap;
store.add.unwrap;
let zoom = application
.unwrap
.transport.unwrap
.transport.unwrap
.dns_suffix
.tls_sni_suffix
.http_host
.build;
store.add.unwrap;
Module Overview
ip– Network entities and parsing utilities.service– Transport services, registries, and application descriptors.objects– Optional storage helpers with CRUD-style operations.error– Shared error type and result alias.
License
MIT. Contributions and feedback are always welcome!