<?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 Re: show-access-rulebase web API call not returning UID for last rule in a section. in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/show-access-rulebase-web-API-call-not-returning-UID-for-last/m-p/23849#M1473</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As far as I’m know that is not expected behavior.&lt;/P&gt;&lt;P&gt;Will check in later releases.&lt;/P&gt;&lt;P&gt;Meanwhile I recommend opening a TAC case.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Jan 2019 18:52:44 GMT</pubDate>
    <dc:creator>PhoneBoy</dc:creator>
    <dc:date>2019-01-11T18:52:44Z</dc:date>
    <item>
      <title>show-access-rulebase web API call not returning UID for last rule in a section.</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/show-access-rulebase-web-API-call-not-returning-UID-for-last/m-p/23848#M1472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;BACKSTORY:&lt;/P&gt;&lt;P&gt;So I'm trying to do some cleanup on some firewall policies that are getting out of hand. I've already created a script to mass delete unused objects, and now I'm going after disabled rules. I want to filter out all disabled rules in each policy and store the UID into a CSV for a later script to go in and delete everything. I want to wait a month and then check again and mass delete any rules that are still disabled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROBLEM:&lt;/P&gt;&lt;P&gt;I'm using Web API version 1.2 and I'm running into an issue with the API call not returning the UID&amp;nbsp;for the last rule in each section. I see the UID for all other rules except for the last one in each section. When I query the rule directly I get it, but when I&amp;nbsp;curl&amp;nbsp;/&lt;SPAN&gt;show-access-rulebase it is not there. I want to use UID rather than rule number or name because I think it would be more accurate after a months worth of firewall changes. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;QUESTIONS:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there some reasoning for this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We are upgrading to R80.20 GA soon. Is this issue is fixed in API 1.3?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Does UID ever change on a rule?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Tony&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2019 17:59:50 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/show-access-rulebase-web-API-call-not-returning-UID-for-last/m-p/23848#M1472</guid>
      <dc:creator>Tony_Young</dc:creator>
      <dc:date>2019-01-11T17:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: show-access-rulebase web API call not returning UID for last rule in a section.</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/show-access-rulebase-web-API-call-not-returning-UID-for-last/m-p/23849#M1473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As far as I’m know that is not expected behavior.&lt;/P&gt;&lt;P&gt;Will check in later releases.&lt;/P&gt;&lt;P&gt;Meanwhile I recommend opening a TAC case.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2019 18:52:44 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/show-access-rulebase-web-API-call-not-returning-UID-for-last/m-p/23849#M1473</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2019-01-11T18:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: show-access-rulebase web API call not returning UID for last rule in a section.</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/show-access-rulebase-web-API-call-not-returning-UID-for-last/m-p/23850#M1474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't see this behavior in R80.20 GA (which is API level 1.3).&lt;/P&gt;&lt;P&gt;I also queried at API levels 1.2 and 1.1 on R80.20 GA and saw the same, expected behavior where the UID is returned.&lt;/P&gt;&lt;P&gt;The rule UID should not change.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Jan 2019 20:13:36 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/show-access-rulebase-web-API-call-not-returning-UID-for-last/m-p/23850#M1474</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2019-01-12T20:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: show-access-rulebase web API call not returning UID for last rule in a section.</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/show-access-rulebase-web-API-call-not-returning-UID-for-last/m-p/23851#M1475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So this was a human error on my side. I was reading the json output incorrectly. Apologies for crying wolf&amp;nbsp;&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://community.checkpoint.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the plus side I was able to create a script that produces the desired output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DISCLAIMER: My bash skills are mediocre at best. Your miles may vary:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#!/bin/bash&lt;/P&gt;&lt;P&gt;host="&amp;lt;OMITTED&amp;gt;"&lt;BR /&gt;&lt;SPAN&gt;baseurl="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://$host/web_api" rel="nofollow"&gt;https://$host/web_api&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;SID=`curl -k --silent --header "Content-Type: application/json" --request POST \&lt;BR /&gt; --data '{&lt;BR /&gt; "user":"&amp;lt;OMITTED&amp;gt;" ,&lt;BR /&gt; "password":"&amp;lt;OMITTED&amp;gt;"&lt;BR /&gt;}' \&lt;BR /&gt;$baseurl/login | grep sid | awk '{print $3}' | sed 's/"//g' | sed 's/,//g'`&lt;/P&gt;&lt;P&gt;curl -k --silent --header "Content-Type: application/json" --header "X-chkp-sid: $SID" --request POST \&lt;BR /&gt; --data '{&lt;BR /&gt; "offset" : 0,&lt;BR /&gt; "limit" : 500,&lt;BR /&gt; "name" : "&amp;lt;OMITTED&amp;gt;"&lt;BR /&gt;}' \&lt;BR /&gt;$baseurl/show-access-rulebase | egrep "^ \"uid\"|rule-number|enabled" | grep -B2 enabled | &lt;BR /&gt;awk '/rule-number/||NR==1{printf $0; next}{printf "\n"$0}' | awk '/enabled/||NR==1{printf $0; next}{printf "\n"$0}' | awk '{print $3,$6,$9}' | sed 's\"\\g; s\ \\g'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output is a CSV file that looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;uid,rule#,true/false&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This first two fields are self explanatory and the third field is whether or not the rule is enabled. I can then grep that file for "false" and read the UID into another script that deletes the disabled rules. Thanks for the help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2019 20:25:57 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/show-access-rulebase-web-API-call-not-returning-UID-for-last/m-p/23851#M1475</guid>
      <dc:creator>Tony_Young</dc:creator>
      <dc:date>2019-01-14T20:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: show-access-rulebase web API call not returning UID for last rule in a section.</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/show-access-rulebase-web-API-call-not-returning-UID-for-last/m-p/23852#M1476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A better way to parse the output from the API is to use jq as it natively understands JSON.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My "one liner" that gets the SID from the login event (and puts it into the environment variable SID):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;SID=`curl --silent --insecure -XPOST "&lt;/SPAN&gt;&lt;A class="unlinked"&gt;https://host/web_api/v1.3/&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;login&lt;/SPAN&gt;&lt;SPAN class=""&gt;" --data-binary "{\"user\": \"aa\", \"password\": \"aaaa\" }" -H "Content-Type: application/json" | jq -r .sid`&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Likewise, you can easily get the data from the API in the format you want as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;curl --silent --insecure -XPOST &lt;/SPAN&gt;&lt;A class="unlinked"&gt;https://host/web_api/v1.3/show-access-rulebase&lt;/A&gt;&lt;SPAN&gt; --data-binary "{ \"name\": \"Rulebase Name\" }" --data-binary "{}" -H "Content-Type: application/json" -H "X-chkp-sid: $SID" | jq -r '.rulebase[] | .uid + "," + (."rule-number"|tostring) + "," + (.enabled|tostring)'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;P class=""&gt;Personally, I'm still getting the hang of jq, but it's very powerful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2019 21:54:03 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/show-access-rulebase-web-API-call-not-returning-UID-for-last/m-p/23852#M1476</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2019-01-14T21:54:03Z</dc:date>
    </item>
  </channel>
</rss>

