zerohop/blog

$ cat rewriting-a-firewall-rollout-script.md · 16 Nov 2026 · 3 min read

Rewriting a firewall rollout script without breaking it

#checkpoint#python#automation#testing

Some customers have one big firewall. Others have well over a hundred small ones, at remote sites that all look alike: the same VPN, the same objects, the same NAT rules, a few supplier-specific functions per site. Nobody configures that by hand in SmartConsole. There's a script.

This one had grown over the years. It worked, mostly. It was also one long file, with copy-pasted blocks per supplier, a publish after almost every step, and a few bugs that nobody had noticed because they only hit unusual sites. My job: make it maintainable and safer, without changing what it does.

The rules I set

The rewrite

The single file became a small package: one module for the menu, one per area (objects, NAT, VPN, gateways, policy installation, CSV import), and one for the supplier functions that differ per site.

The important change is how it talks to the management server:

New features came along too: CSV imports with a header row and a preview that shows every line as OK or with the reason it will be skipped, and policy installation in batches: one install task per firewall, a configurable number at the same time, with a result table and a CSV report at the end.

Proving it does the same thing

This is the part I'm most happy with. I wrote a fake management API that records every call instead of executing it. Then a comparison script runs the old and the new tool through the same scenarios and compares the recorded calls one by one.

text25 scenarios
22 identical, call by call
 3 different: exactly the three bug fixes, nothing else

The fixes it found were the kind you only catch this way: a third camera object that got the name of the second one, a subnet that was asked for twice but created from the first answer, and a site ID parser that turned some names into the wrong number and silently skipped those sites.

On top of that: unit tests for the new behaviour, and a smoke test that drives the real menus with simulated key presses. None of it needs a server.

Then the lab

Only after all of that did it touch a management server: a lab copy of production, with the same packages and tens of thousands of objects. Dry runs first, then a real publish on a test gateway, then the same function again to see "no changes". The lab test found two things the fake API couldn't: the login rate limit, and that picking one firewall out of a long list works better as "type part of the name first" than as one huge menu.

What I took from it

← all posts