- Products
- Learn
- Local User Groups
- Partners
- More
What’s New in Device Diagnostics?
Dec 2nd @ 5pm CET / 11am EST
AI Security Masters
Security in the Pace of AI:
From Threat to Force Multiplier
CPX is Back!
Join us in Las Vegas, Vienna, and/or Bangkok!
Check Point Named a Leader
The Forrester Wave:
Enterprise Firewall Solutions, Q4 2026
What’s New in Agentic Network Orchestration
CheckMates Go:
Fun Ding
I'm working on a program which interacts with Check Point's management API. As is common when programming anything substantial, I built some smaller tools to help me along the way. I thought I would share one, since it has broad applicability.
This is a script framework to abstract away some management API implementation details and concerns which annoyed me. Specifically, it handles counting how many API command you have run and publishing every 80, setting the session details after every publish, and publishing before logging out. Using it, you never need to explicitly publish. You write API commands, and they just work. I use it to add a predictable set of objects, policies, rules, and so on to new management VMs or after rebuilding my personal standalone.
#!/usr/bin/env bash
sessionName="Initial Build"
sessionDescription="Building my initial config for a new lab management."
publishEvery=80
changeCount=1
publishBatch=1
function mgmtCmd {
commandToRun=""
for element in "${@}"; do
if [[ "$element" =~ \ ]]; then
commandToRun="${commandToRun} \"${element}\""
else
commandToRun="${commandToRun} ${element}"
fi
done
echo "${commandToRun}" | xargs mgmt_cli -s session.txt
if [ $? -eq 0 ]; then
echo "Success ${publishBatch}.${changeCount}"
((changeCount+=1))
else
echo "Failed: ${commandToRun}"
fi
if [ ${changeCount} -gt ${publishEvery} ]; then
echo "Publishing..."
publish
setupSession
((publishBatch+=1))
fi
}
function publish {
mgmt_cli -s session.txt publish
}
function setupSession {
changeCount=1
mgmt_cli -s session.txt set session new-name "${sessionName}" description "${sessionDescription}" > /dev/null
}
function login {
mgmt_cli -r true login > session.txt
setupSession
}
function logout {
publish
mgmt_cli -s session.txt logout > /dev/null
rm session.txt
}
login
mgmtCmd add dns-domain name ".github.com" is-sub-domain false
mgmtCmd add network name "RFC 10/8" subnet4 "10.0.0.0" mask-length4 8 broadcast allow
mgmtCmd add tag name "Development"
...
...
...
mgmtCmd add package name "InstalledNowhere" access true
installedNowhereUuid=$(mgmt_cli -f json -s session.txt show package name "InstalledNowhere" details-level uid | jq '.uid')
mgmtCmd set generic-object uid "${installedNowhereUuid}" installationTargets "SPECIFIC_GATEWAYS"
logout
The mgmtCmd function doesn't return anything, so if you need to get output of a command (such as to find the UUID of an object you just created), you will need to call mgmt_cli directly as you can see in the last few lines.
Thx for sharing!
I made a few internal improvements.
#!/usr/bin/env bash
sessionName="Initial Build"
sessionDescription="Building my initial config for a new lab management."
publishEvery=80
changeCount=1
publishBatch=1
apiPort=$(api status | grep 'APACHE Gaia Port' | awk '{print $NF}')
sessionCookie=$(mktemp)
function mgmtCmd {
commandToRun=""
for element in "${@}"; do
if [[ "$element" =~ \ ]]; then
commandToRun="${commandToRun} \"${element}\""
else
commandToRun="${commandToRun} ${element}"
fi
done
echo "${commandToRun}" | xargs mgmt_cli --port "${apiPort}" -s "${sessionCookie}"
if [ $? -eq 0 ]; then
echo "Success ${publishBatch}.${changeCount}"
((changeCount+=1))
else
echo "Failed: ${commandToRun}"
fi
if [ ${changeCount} -gt ${publishEvery} ]; then
echo "Publishing..."
publish
setupSession
changeCount=1
((publishBatch+=1))
fi
}
function publish {
mgmt_cli --port "${apiPort}" -s "${sessionCookie}" publish
}
function setupSession {
mgmt_cli --port "${apiPort}" -s "${sessionCookie}" set session new-name "${sessionName}" description "${sessionDescription}" > /dev/null
}
function login {
mgmt_cli --port "${apiPort}" -d "${1}" -r true login > "${sessionCookie}"
setupSession
}
function logout {
publish
mgmt_cli --port "${apiPort}" -s "${sessionCookie}" logout > /dev/null
rm "${sessionCookie}"
}
login "System Data"
mgmtCmd set api-settings accepted-api-calls-from "all ip addresses that can be used for gui clients"
logout
api restart
login
mgmtCmd add dns-domain name ".github.com" is-sub-domain false
mgmtCmd add network name "RFC 10/8" subnet4 "10.0.0.0" mask-length4 8 broadcast allow
mgmtCmd add tag name "Development"
...
...
...
mgmtCmd add package name "InstalledNowhere" access true
installedNowhereUuid=$(mgmt_cli --port "${apiPort}" -f json -s "${sessionCookie}" show package name "InstalledNowhere" details-level uid | jq '.uid')
mgmtCmd set generic-object uid "${installedNowhereUuid}" installationTargets "SPECIFIC_GATEWAYS"
logout
I just found out this code is in the CCAS labs! Some notice would have been nice, but that's pretty cool.
And I just now found out (from seeing your post for the first time) where the script came from that is used in the course I have taught a number of times.
You should be given credit and it should also be explained better in the CCAS book.
I had to write a description of what the script actually does and then wondered why it got slotted into the labs where it did.
I have a slightly updated version that prompts for credentials to avoid r true for all the reasons to not use r true in the labs.
Great work. Thanks.
The reception here seemed kind of tepid, so I've been focused on other things. I've hit a few bugs related to making API calls in loops (e.g, to deal with the output of /show-unused-objects for some automated cleanup). That can allow more than 80 changes in a session, and can make it hard to tell what is being done in any individual step. Now that I know it's more broadly used, I'll try to make some time to update it.
I still use it extensively for initial builds in labs, of course. Any time I want to try a new version on my lab management, I install clean and populate my objects with a script built using this framework.
When my tools and scripts were used in the courseware, I received a notice and this contributor badge.
Leaderboard
Epsum factorial non deposit quid pro quo hic escorol.
| User | Count |
|---|---|
| 1 | |
| 1 |
Tue 24 Nov 2026 @ 01:30 PM (GMT)
La nueva realidad de los ataques DDoS: autonomía, escala y el futuro de la defensaThu 26 Nov 2026 @ 10:00 AM (CET)
The Cloud Architects Series: Cloud Security State in 2026 – Lessons Learned and a Look AheadWed 02 Dec 2026 @ 03:30 PM (GMT)
The New DDoS Reality: Autonomy, Scale, and the Future of DefenseThu 03 Dec 2026 @ 11:00 AM (EST)
Under the Hood: Check Point Cloud Firewall for Nutanix - How to Secure your AI WorkloadsTue 24 Nov 2026 @ 01:30 PM (GMT)
La nueva realidad de los ataques DDoS: autonomía, escala y el futuro de la defensaWed 02 Dec 2026 @ 03:30 PM (GMT)
The New DDoS Reality: Autonomy, Scale, and the Future of DefenseThu 03 Dec 2026 @ 11:00 AM (EST)
Under the Hood: Check Point Cloud Firewall for Nutanix - How to Secure your AI WorkloadsAbout CheckMates
Learn Check Point
Advanced Learning
WE SECURE YOUR AI TRANSFORMATION