<?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 [API]PYTHON  PANDEVICE - SET SECURITY PROFILE in General Topics</title>
    <link>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/256363#M72727</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using PaloAlto's API for the first time.&lt;/P&gt;&lt;P&gt;My idea is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;- for each rule, I would like to apply a security profile based on the service setted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reading some docs online i wrote this pseudocode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;HOSTNAME = '192.168.55.10'
API_KEY = 'My_Api_Key'

fw = pandevice.firewall.Firewall(hostname=HOSTNAME, api_key=API_KEY)
rulebase = pandevice.policies.Rulebase()
fw.add(rulebase)
rules = pandevice.policies.SecurityRule.refreshall(rulebase)

for rule in rules:

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (rule.service is ugual to any):

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//set security_profile (like av,URL Filtering Profiles,Vulnerability Protection Profiles,etc...)

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;rule.apply()

fw.commit(sync=True)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Do you have any ideas ? Could you help me?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advice!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Sep 2019 14:45:18 GMT</pubDate>
    <dc:creator>Chango</dc:creator>
    <dc:date>2019-09-23T14:45:18Z</dc:date>
    <item>
      <title>[API]PYTHON  PANDEVICE - SET SECURITY PROFILE</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/256363#M72727</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using PaloAlto's API for the first time.&lt;/P&gt;&lt;P&gt;My idea is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;- for each rule, I would like to apply a security profile based on the service setted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reading some docs online i wrote this pseudocode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;HOSTNAME = '192.168.55.10'
API_KEY = 'My_Api_Key'

fw = pandevice.firewall.Firewall(hostname=HOSTNAME, api_key=API_KEY)
rulebase = pandevice.policies.Rulebase()
fw.add(rulebase)
rules = pandevice.policies.SecurityRule.refreshall(rulebase)

for rule in rules:

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (rule.service is ugual to any):

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//set security_profile (like av,URL Filtering Profiles,Vulnerability Protection Profiles,etc...)

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;rule.apply()

fw.commit(sync=True)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Do you have any ideas ? Could you help me?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advice!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 14:45:18 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/256363#M72727</guid>
      <dc:creator>Chango</dc:creator>
      <dc:date>2019-09-23T14:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: [API]PYTHON  PANDEVICE - SET SECURITY PROFILE</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/256374#M72732</link>
      <description>&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/110362"&gt;@Chango&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;My advice would be to really learn the api before you even attempt to do something that actually makes changes to your policy. Spend some time messing around and reading the docs before you attempt to modify your rulebase, and when you start modifing the rulebase focus on modifying a set rule instead of attempting such a brod modfication as your first script.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2019 19:45:21 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/256374#M72732</guid>
      <dc:creator>BPry</dc:creator>
      <dc:date>2019-04-05T19:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: [API]PYTHON  PANDEVICE - SET SECURITY PROFILE</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/256379#M72737</link>
      <description>&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/43480"&gt;@BPry&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi BPri, thanks for the answer.&lt;BR /&gt;Yes sure, i know. I will try it in a test environment.&lt;BR /&gt;If possible I'd like to have some advice aboute the code.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Apr 2019 10:13:54 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/256379#M72737</guid>
      <dc:creator>Chango</dc:creator>
      <dc:date>2019-04-06T10:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: [API]PYTHON  PANDEVICE - SET SECURITY PROFILE</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/256481#M72765</link>
      <description>&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/110362"&gt;@Chango&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't give any support for code unless I've directly supplied it to address a users issues; this is a long-standing policy I've had in this forum to avoid any potential issues due to untested code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only thing I'll mention is that your script as written will 100% not work as expected, as I'm sure you are already fully aware. For starters,&amp;nbsp; where you have "if (service is equal to any):" you'll simply get a error since you've never defined 'service'. To get the service of the rule you would need to do something like the following:&lt;/P&gt;&lt;PRE&gt;for rule in rules:
    if (rule.service is equal to any):&lt;/PRE&gt;&lt;P&gt;That any statement also won't work due to how the value actually returns.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Apr 2019 01:47:05 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/256481#M72765</guid>
      <dc:creator>BPry</dc:creator>
      <dc:date>2019-04-07T01:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: [API]PYTHON  PANDEVICE - SET SECURITY PROFILE</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/256498#M72776</link>
      <description>&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/43480"&gt;@BPry&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes i know that my script as written&amp;nbsp;&lt;SPAN&gt;will not work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I worte a pseudocode.&amp;nbsp;I don't know what is the method that allows me to set the security profile. I didn't find it in the documentation. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could you tell me what is the method?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thanks in advice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 14:44:00 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/256498#M72776</guid>
      <dc:creator>Chango</dc:creator>
      <dc:date>2019-09-23T14:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: [API]PYTHON  PANDEVICE - SET SECURITY PROFILE</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/289576#M77001</link>
      <description>&lt;P&gt;Hi Changò,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;use this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="pl-k"&gt;for&lt;/SPAN&gt; rule &lt;SPAN class="pl-k"&gt;in&lt;/SPAN&gt; rules:
    rule.virus &lt;SPAN class="pl-k"&gt;=&lt;/SPAN&gt; &lt;SPAN class="pl-s"&gt;&lt;SPAN class="pl-pds"&gt;"&lt;/SPAN&gt;my-antivirus-profile&lt;SPAN class="pl-pds"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 14:43:06 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/289576#M77001</guid>
      <dc:creator>ECerafogli</dc:creator>
      <dc:date>2019-09-23T14:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: [API]PYTHON  PANDEVICE - SET SECURITY PROFILE</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/327319#M83303</link>
      <description>&lt;P&gt;Hi Changò,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;use this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="pl-k"&gt;for&lt;/SPAN&gt; rule &lt;SPAN class="pl-k"&gt;in&lt;/SPAN&gt; rules:
    rule.virus &lt;SPAN class="pl-k"&gt;=&lt;/SPAN&gt; &lt;SPAN class="pl-s"&gt;&lt;SPAN class="pl-pds"&gt;"&lt;/SPAN&gt;my-antivirus-profile&lt;SPAN class="pl-pds"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Regards&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 09:21:46 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/327319#M83303</guid>
      <dc:creator>EdoardoCerafogli</dc:creator>
      <dc:date>2020-05-11T09:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: [API]PYTHON  PANDEVICE - SET SECURITY PROFILE</title>
      <link>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/344345#M86160</link>
      <description>&lt;P&gt;What are the values that we need to set for the spyware,virus,vulnerability arguments in&amp;nbsp;SecurityRule ?&lt;/P&gt;&lt;P&gt;I found that the values going to be default, strict,allow,drop...etc like that by referring the below link&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.paloaltonetworks.com/pan-os/9-0/pan-os-admin/policy/security-profiles" target="_blank"&gt;https://docs.paloaltonetworks.com/pan-os/9-0/pan-os-admin/policy/security-profiles&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But also in some examples they said like this&lt;/P&gt;&lt;PRE&gt;rule.virus &lt;SPAN class="pl-k"&gt;=&lt;/SPAN&gt; &lt;SPAN class="pl-s"&gt;&lt;SPAN class="pl-pds"&gt;"&lt;/SPAN&gt;my-antivirus-profile&lt;SPAN class="pl-pds"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Which one is right ? Either we have to specify the profile of our own and give it as values or default,strict ...those acts as values ? please help me on this&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2020 11:18:01 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-topics/api-python-pandevice-set-security-profile/m-p/344345#M86160</guid>
      <dc:creator>Alpha123</dc:creator>
      <dc:date>2020-08-18T11:18:01Z</dc:date>
    </item>
  </channel>
</rss>

