- Products
- Learn
- Local User Groups
- Partners
- More
Policy Insights and Policy Auditor in Action
19 November @ 5pm CET / 11am ET
Access Control and Threat Prevention Best Practices
Watch HereOverlap in Security Validation
Help us to understand your needs better
CheckMates Go:
Maestro Madness
updating checkpoint firewall rules comments based on rule UID
Hello Mates,
I have task to update the comments in the list of firewall rules based on rule UID. Is there any through to perform this activity through management server console CLI or any other way. I am asking this query because i need to update around 1600 rule comments based on UID. Here Comment is same for all the rules.
After updating the comments, i want to disable these rules. Please suggest how to proceed.
Thank you very much in advance.
thanks
That shouldn't be too complex. Assuming you have a flat file with the UID's, you can use the Management API to iterate through that file, set the comment and disable the rule.
https://sc1.checkpoint.com/documents/latest/APIs/#cli/set-access-rule~v1.9%20
Your syntax would be something like this.
#!/bin/bash
file_path="path/uid_list.txt"
i=0
mgmt_cli login user "username" password "password" --format json > sessionid.json
while IFS= read -r uid; do
((i++))
mgmt_cli set access-rule layer YourLayerName uid $uid enabled False comments "your comment" --format json -s sessionid.json
if [ $i -eq 100 ]; then
echo "100 iterations reached, publishing"
mgmt_cli publish --format json -s sessionid.json
i=0
fi
done < "$file_path"
mgmt_cli publish --format json -s sessionid.json
mgmt_cli logout --format json -s sessionid.json
rm sessionid.json
You will need to find the uid or name of the layer as it is a mandatory parameter.
This can be done via the API/CLI, yes.
The relevant endpoint is set access-rule: https://sc1.checkpoint.com/documents/latest/APIs/index.html#cli/set-access-rule~v1.9.1%20
You can set the comment and disable the rule in the same call.
A "publish" action is recommended every 100 or so actions.
It is unclear what you are trying to achieve
Should be possible using Management API, see in API / CLI discussions and the documentation !
That shouldn't be too complex. Assuming you have a flat file with the UID's, you can use the Management API to iterate through that file, set the comment and disable the rule.
https://sc1.checkpoint.com/documents/latest/APIs/#cli/set-access-rule~v1.9%20
Your syntax would be something like this.
#!/bin/bash
file_path="path/uid_list.txt"
i=0
mgmt_cli login user "username" password "password" --format json > sessionid.json
while IFS= read -r uid; do
((i++))
mgmt_cli set access-rule layer YourLayerName uid $uid enabled False comments "your comment" --format json -s sessionid.json
if [ $i -eq 100 ]; then
echo "100 iterations reached, publishing"
mgmt_cli publish --format json -s sessionid.json
i=0
fi
done < "$file_path"
mgmt_cli publish --format json -s sessionid.json
mgmt_cli logout --format json -s sessionid.json
rm sessionid.json
You will need to find the uid or name of the layer as it is a mandatory parameter.
One note: this may need to be modified if the management is set to require a session name or description. I wrote a BASH framework for running an arbitrary number of management API commands locally on a system. You name and describe the session once at the top, then it handles publishing every X commands and setting up the new session.
Do you have any comments in affected rules? If so, would you like to save the existing comments ? If you dont care if and what is/was the comment in affected rules, then just follow steps provided by Alex. If there was any existing comment, the script will overwrite them with new comment.
If you need to add a new comments to the existing ones, little bit of more lines within the script will be needed (first check what is comment, store it and add new comment with added text at the end).
This can be done via the API/CLI, yes.
The relevant endpoint is set access-rule: https://sc1.checkpoint.com/documents/latest/APIs/index.html#cli/set-access-rule~v1.9.1%20
You can set the comment and disable the rule in the same call.
A "publish" action is recommended every 100 or so actions.
Fair point about publishing at intervals given the size of the rules to modify, I've added a conditional check in the script to publish every 100 iterations.
@JozkoMrkvicka Correct about the comment, given OP's message it appears the rules are already defined anyway to have a standardised comment and be disabled. Otherwise the comment first need to be extracted with show access-rulebase, saved in a variable and then append whatever the final comment should be.
If you are asking about adding comments between existing rules, then yes this can be done, and rules can be disabled. I generally use mgmt_cli commands to do this as I'm not really a scripter.
See example below, may not be exactly what you need but should help:
session=`mgmt_cli -r true login --format json| jq -r '.sid'`
# Create new rule - with a section heading, note the order.
mgmt_cli --session-id $session add access-rule name "Test Rule" layer "<POLICYFILE NAME> <Layer Name>" position.below "a4a975d6-3e42-490a-90a2-c2ab96xxxxx" source.1 "<src objectname>" destination.1 "<dst objectname>" action "accept" service.1 "http" track "log" comments "New Rule"
mgmt_cli --session-id $session add access-section layer "<POLICYFILE NAME> <Layer Name>" position.below "a4a975d6-3e42-490a-90a2-c2ab96xxxxx" name "Section related to new test rules"
# Publish changes made
mgmt_cli --session-id $session publish
session=`mgmt_cli -r true login --format json| jq -r '.sid'`
# Push policy - Single GWs
mgmt_cli --session-id $session install-policy policy-package "<POLICYFILE NAME>" access true threat-prevention true
Leaderboard
Epsum factorial non deposit quid pro quo hic escorol.
| User | Count |
|---|---|
| 42 | |
| 18 | |
| 12 | |
| 11 | |
| 9 | |
| 7 | |
| 6 | |
| 5 | |
| 5 | |
| 5 |
Wed 19 Nov 2025 @ 11:00 AM (EST)
TechTalk: Improve Your Security Posture with Threat Prevention and Policy InsightsThu 20 Nov 2025 @ 05:00 PM (CET)
Hacking LLM Applications: latest research and insights from our LLM pen testing projects - AMERThu 20 Nov 2025 @ 10:00 AM (CST)
Hacking LLM Applications: latest research and insights from our LLM pen testing projects - EMEAWed 26 Nov 2025 @ 12:00 PM (COT)
Panama City: Risk Management a la Parrilla: ERM, TEM & Meat LunchWed 19 Nov 2025 @ 11:00 AM (EST)
TechTalk: Improve Your Security Posture with Threat Prevention and Policy InsightsThu 20 Nov 2025 @ 05:00 PM (CET)
Hacking LLM Applications: latest research and insights from our LLM pen testing projects - AMERThu 20 Nov 2025 @ 10:00 AM (CST)
Hacking LLM Applications: latest research and insights from our LLM pen testing projects - EMEAThu 04 Dec 2025 @ 12:30 PM (SGT)
End-of-Year Event: Securing AI Transformation in a Hyperconnected World - APACThu 04 Dec 2025 @ 03:00 PM (CET)
End-of-Year Event: Securing AI Transformation in a Hyperconnected World - EMEAWed 26 Nov 2025 @ 12:00 PM (COT)
Panama City: Risk Management a la Parrilla: ERM, TEM & Meat LunchAbout CheckMates
Learn Check Point
Advanced Learning
YOU DESERVE THE BEST SECURITY