<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic updating checkpoint firewall rules comments based on rule UID in General Topics</title>
    <link>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201503#M33583</link>
    <description>&lt;P&gt;updating checkpoint firewall rules comments based on rule UID&lt;/P&gt;&lt;P&gt;Hello Mates,&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;After updating the comments, i want to disable these rules. Please suggest how to proceed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
    <pubDate>Tue, 26 Dec 2023 07:25:10 GMT</pubDate>
    <dc:creator>Vardhan</dc:creator>
    <dc:date>2023-12-26T07:25:10Z</dc:date>
    <item>
      <title>updating checkpoint firewall rules comments based on rule UID</title>
      <link>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201503#M33583</link>
      <description>&lt;P&gt;updating checkpoint firewall rules comments based on rule UID&lt;/P&gt;&lt;P&gt;Hello Mates,&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;After updating the comments, i want to disable these rules. Please suggest how to proceed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2023 07:25:10 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201503#M33583</guid>
      <dc:creator>Vardhan</dc:creator>
      <dc:date>2023-12-26T07:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: updating checkpoint firewall rules comments based on rule UID</title>
      <link>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201669#M33597</link>
      <description>&lt;P&gt;It is unclear what you are trying to achieve&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 08:05:13 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201669#M33597</guid>
      <dc:creator>_Val_</dc:creator>
      <dc:date>2023-12-28T08:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: updating checkpoint firewall rules comments based on rule UID</title>
      <link>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201671#M33599</link>
      <description>&lt;P&gt;Should be possible using Management API, see in API / CLI discussions and the documentation !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 08:29:43 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201671#M33599</guid>
      <dc:creator>G_W_Albrecht</dc:creator>
      <dc:date>2023-12-28T08:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: updating checkpoint firewall rules comments based on rule UID</title>
      <link>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201677#M33603</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;A href="https://sc1.checkpoint.com/documents/latest/APIs/#cli/set-access-rule~v1.9%20" target="_blank" rel="noopener"&gt;https://sc1.checkpoint.com/documents/latest/APIs/#cli/set-access-rule~v1.9%20&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Your syntax would be something like this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#!/bin/bash

file_path="path/uid_list.txt"
i=0
mgmt_cli login user "username" password "password" --format json &amp;gt; 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 &amp;lt; "$file_path"

mgmt_cli publish --format json -s sessionid.json
mgmt_cli logout --format json -s sessionid.json
rm sessionid.json&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will need to find the uid or name of the layer as it is a mandatory parameter.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2023 03:34:58 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201677#M33603</guid>
      <dc:creator>Alex-</dc:creator>
      <dc:date>2023-12-29T03:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: updating checkpoint firewall rules comments based on rule UID</title>
      <link>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201684#M33604</link>
      <description>&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;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).&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 11:01:56 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201684#M33604</guid>
      <dc:creator>JozkoMrkvicka</dc:creator>
      <dc:date>2023-12-28T11:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: updating checkpoint firewall rules comments based on rule UID</title>
      <link>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201714#M33607</link>
      <description>&lt;P&gt;This can be done via the API/CLI, yes.&lt;BR /&gt;The relevant endpoint is set access-rule:&amp;nbsp;&lt;A href="https://sc1.checkpoint.com/documents/latest/APIs/index.html#cli/set-access-rule~v1.9.1%20" target="_blank"&gt;https://sc1.checkpoint.com/documents/latest/APIs/index.html#cli/set-access-rule~v1.9.1%20&lt;/A&gt;&lt;BR /&gt;You can set the comment and disable the rule in the same call.&lt;BR /&gt;A "publish" action is recommended every 100 or so actions.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 14:40:35 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201714#M33607</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2023-12-28T14:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: updating checkpoint firewall rules comments based on rule UID</title>
      <link>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201721#M33608</link>
      <description>&lt;P&gt;If you are asking about adding comments between existing rules, then yes this can be done, and rules can be disabled.&amp;nbsp; I generally use mgmt_cli commands to do this as I'm not really a scripter.&lt;/P&gt;
&lt;P&gt;See example below, may not be exactly what you need but should help:&lt;/P&gt;
&lt;P&gt;session=`mgmt_cli -r true login --format json| jq -r '.sid'`&lt;/P&gt;
&lt;P&gt;# Create new rule - with a section heading, note the order.&lt;BR /&gt;mgmt_cli --session-id $session add access-rule name "Test Rule" layer "&amp;lt;POLICYFILE NAME&amp;gt; &amp;lt;Layer Name&amp;gt;" position.below "a4a975d6-3e42-490a-90a2-c2ab96xxxxx" source.1 "&amp;lt;src objectname&amp;gt;" destination.1 "&amp;lt;dst objectname&amp;gt;" action "accept" service.1 "http" track "log" comments "New Rule"&lt;BR /&gt;mgmt_cli --session-id $session add access-section layer "&amp;lt;POLICYFILE NAME&amp;gt; &amp;lt;Layer Name&amp;gt;" position.below "a4a975d6-3e42-490a-90a2-c2ab96xxxxx" name "Section related to new test rules"&lt;/P&gt;
&lt;P&gt;# Publish changes made&lt;BR /&gt;mgmt_cli --session-id $session publish&lt;BR /&gt;session=`mgmt_cli -r true login --format json| jq -r '.sid'`&lt;/P&gt;
&lt;P&gt;# Push policy - Single GWs&lt;BR /&gt;mgmt_cli --session-id $session install-policy policy-package "&amp;lt;POLICYFILE NAME&amp;gt;" access true threat-prevention true&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2023 11:43:58 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201721#M33608</guid>
      <dc:creator>genisis__</dc:creator>
      <dc:date>2023-12-29T11:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: updating checkpoint firewall rules comments based on rule UID</title>
      <link>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201733#M33609</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.checkpoint.com/t5/user/viewprofilepage/user-id/1702"&gt;@JozkoMrkvicka&lt;/a&gt;&amp;nbsp;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.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 18:21:41 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201733#M33609</guid>
      <dc:creator>Alex-</dc:creator>
      <dc:date>2023-12-28T18:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: updating checkpoint firewall rules comments based on rule UID</title>
      <link>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201746#M33610</link>
      <description>&lt;P&gt;One note: this may need to be modified if the management is set to require a session name or description. I wrote a &lt;A href="https://community.checkpoint.com/t5/API-CLI-Discussion/BASH-Framework-for-Management-API-Commands/m-p/195822/highlight/true#M8097" target="_self"&gt;BASH framework&lt;/A&gt; 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.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2023 22:05:58 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/General-Topics/updating-checkpoint-firewall-rules-comments-based-on-rule-UID/m-p/201746#M33610</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2023-12-28T22:05:58Z</dc:date>
    </item>
  </channel>
</rss>

