<?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: Mail alert with variable in Firewall and Security Management</title>
    <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Mail-alert-with-variable/m-p/173567#M69200</link>
    <description>&lt;P&gt;The log entry should be passed as input to the script.&lt;BR /&gt;It should contain this information.&lt;/P&gt;</description>
    <pubDate>Sat, 04 Mar 2023 00:23:44 GMT</pubDate>
    <dc:creator>PhoneBoy</dc:creator>
    <dc:date>2023-03-04T00:23:44Z</dc:date>
    <item>
      <title>Mail alert with variable</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Mail-alert-with-variable/m-p/173488#M69197</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I know how to create an email alert when a rule is hit.&lt;BR /&gt;Now I want to add a variable in the script so I know which rule has been hit.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Is this possible?&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2023-03-03 12_04_49-Window.png" style="width: 724px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/19916i232CA21705493EC2/image-size/large?v=v2&amp;amp;px=999" role="button" title="2023-03-03 12_04_49-Window.png" alt="2023-03-03 12_04_49-Window.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 11:05:55 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Mail-alert-with-variable/m-p/173488#M69197</guid>
      <dc:creator>Jeroen_Deckers</dc:creator>
      <dc:date>2023-03-03T11:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Mail alert with variable</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Mail-alert-with-variable/m-p/173494#M69198</link>
      <description>&lt;P&gt;If it's only three different rules you could define three different UserDefined 1,2,3 mail alerts and assign these to the different rules.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 11:46:20 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Mail-alert-with-variable/m-p/173494#M69198</guid>
      <dc:creator>Danny</dc:creator>
      <dc:date>2023-03-03T11:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: Mail alert with variable</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Mail-alert-with-variable/m-p/173499#M69199</link>
      <description>&lt;P&gt;No, the thing is, I want to add for example the rule name as varialbe in the mail alert.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 12:17:28 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Mail-alert-with-variable/m-p/173499#M69199</guid>
      <dc:creator>Jeroen_Deckers</dc:creator>
      <dc:date>2023-03-03T12:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: Mail alert with variable</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Mail-alert-with-variable/m-p/173567#M69200</link>
      <description>&lt;P&gt;The log entry should be passed as input to the script.&lt;BR /&gt;It should contain this information.&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2023 00:23:44 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Mail-alert-with-variable/m-p/173567#M69200</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2023-03-04T00:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Mail alert with variable</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Mail-alert-with-variable/m-p/173580#M69201</link>
      <description>&lt;P&gt;Hi PhoneBoy,&lt;BR /&gt;Thanks for your answer.&lt;BR /&gt;How can I pass the log entry as input in the script?&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2023 12:41:52 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Mail-alert-with-variable/m-p/173580#M69201</guid>
      <dc:creator>Jeroen_Deckers</dc:creator>
      <dc:date>2023-03-04T12:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Mail alert with variable</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Mail-alert-with-variable/m-p/173744#M69202</link>
      <description>&lt;P&gt;It's already being passed via stdin.&lt;BR /&gt;I confirmed this by writing a very simple script that merely echoes the input received to an output file.&lt;BR /&gt;You should get a line that looks something like this:&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier"&gt;HeaderDateHour: 6Mar2023 11:08:28; ContentVersion: 5; HighLevelLogKey: N/A; Uuid: {0x64061e0b,0x10000,0xe5624173,0xcec9fff8}; SequenceNum: -1; Action: accept; Origin: MyGateway; IfDir: &amp;gt;; InterfaceName: eth0; Alert: alert; OriginSicName: cn=cp_mgmt,o=MyGateway..3o8s6z; inzone: External; outzone: Local; service_id: https; src: x.y.z.w; dst: MyGateway; proto: tcp; security_inzone: ExternalZone; security_outzone: ; user: ; src_user_name: ; src_machine_name: ; src_user_dn: ; snid: ; dst_user_name: ; dst_machine_name: ; dst_user_dn: ; UP_match_table: TABLE_START; ROW_START: 0; match_id: 1; layer_uuid: 6a5b4108-a94e-4f5d-974b-8d8c431fdd5f; layer_name: Network; rule_uid: eda54453-4aee-4358-9f2c-0da5c29dc16d; rule_name: ; ROW_END: 0; UP_match_table: TABLE_END; UP_alert_table: TABLE_START; ROW_START: 0; alert: alert; ROW_END: 0; UP_alert_table: TABLE_END; ProductName: VPN-1 &amp;amp; FireWall-1; svc: https; sport_svc: 51585; ProductFamily: Network&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Note: the actual data received will depend on the log entry in question.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 17:14:49 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Mail-alert-with-variable/m-p/173744#M69202</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2023-03-06T17:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: Mail alert with variable</title>
      <link>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Mail-alert-with-variable/m-p/173764#M69203</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know you can do this via Python and CheckPoint API, But I do not know how to perform this via SmartConsole.&lt;/P&gt;&lt;P&gt;I will share it below, it may be helpful for you friend.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import requests
import json
import time

from requests.packages.urllib3.exceptions import InsecureRequestWarning

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

url = 'https://XXX.XXX.XXX.XXX/web_api/login'

headers = {"Content-Type": "application/json"}
credentials = {"apiuser" : 'APIKEY'}
data = json.dumps(credentials)
payload = requests.post(url=url, headers=headers, data=data, verify=False)
json_response = json.loads(payload.text)

sid = json_response['sid']
#print("\nThe ID of session is: ", sid)

url = 'https://XXX.XXX.XXX.XXX/web_api/show-package'

headers = {"Content-Type": "application/json", "X-chkp-sid": sid}
package = {'name' : 'Standard'}
data = json.dumps(package)
payload = requests.post(url=url, headers=headers, data=data, verify=False)
json_response = json.loads(payload.text)

for package in json_response["access-layers"]:
    package_name = package['name']
    package_uid = package['uid']

print("\nThe name of the packet show-package is: ", package_name)
print("The UID of package show-package is: ", package_uid, "\n")

url = 'https://XXX.XXX.XXX.XXX/web_api/show-access-rulebase'

headers = {"Content-Type": "application/json", "X-chkp-sid": sid}
filter = {'uid' : package_uid, 'show-hits' : 'true',}
data = json.dumps(filter)
payload = requests.post(url=url, headers=headers, data=data, verify=False)
json_response = json.loads(payload.text)

for policy in json_response["rulebase"]:

    name_policy = policy["name"]
    hits = policy['hits']

    if hits['value'] &amp;gt; 740000:

        hitsNumber =  hits['value']

        email_subject = "Alert: Rule violated in Check Point policy"
        email_message = "The '{0}' rule was hit with {1} hits.".format(name_policy,hitsNumber)

        print(email_subject)
        print(email_message,"\n")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is worth remembering that it is necessary to change some information, such as IP, user, password, name of policies and etc.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 20:25:32 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/Firewall-and-Security-Management/Mail-alert-with-variable/m-p/173764#M69203</guid>
      <dc:creator>guilhermevi</dc:creator>
      <dc:date>2023-03-06T20:25:32Z</dc:date>
    </item>
  </channel>
</rss>

