From fcae71a7d1a88777fcec64f39593c591f65cab9e Mon Sep 17 00:00:00 2001 From: CJHarms Date: Tue, 13 Feb 2018 18:31:04 +0100 Subject: [PATCH 1/4] Added some more Logging Added more Debug Logging for the alarmHeaders --- plugins/FFAgent/FFAgent.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/FFAgent/FFAgent.py b/plugins/FFAgent/FFAgent.py index 8dcff856..fa16d762 100644 --- a/plugins/FFAgent/FFAgent.py +++ b/plugins/FFAgent/FFAgent.py @@ -132,6 +132,7 @@ def run(typ,freq,data): "selectiveCallCode": selectiveCallCode, "hmac": hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest() } + logging.debug(alarmHeaders) if globalVars.config.get("FFAgent", "live") == "1": r = requests.post(url, data=alarmData, headers=headers, verify=serverCertFile, cert=(clientCertFile, clientCertPass)) From 14df7d7fa40744cd4f873efefdc6a41ec7ab9218 Mon Sep 17 00:00:00 2001 From: CJHarms Date: Tue, 13 Feb 2018 18:31:40 +0100 Subject: [PATCH 2/4] Fixed small Typo Fixed a small Typo --- plugins/FFAgent/FFAgent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/FFAgent/FFAgent.py b/plugins/FFAgent/FFAgent.py index fa16d762..561ca869 100644 --- a/plugins/FFAgent/FFAgent.py +++ b/plugins/FFAgent/FFAgent.py @@ -135,7 +135,7 @@ def run(typ,freq,data): logging.debug(alarmHeaders) if globalVars.config.get("FFAgent", "live") == "1": - r = requests.post(url, data=alarmData, headers=headers, verify=serverCertFile, cert=(clientCertFile, clientCertPass)) + r = requests.post(url, data=alarmData, headers=alarmHeaders, verify=serverCertFile, cert=(clientCertFile, clientCertPass)) else: r = requests.post(url, data=alarmData, headers=alarmHeaders, verify=serverCertFile) From 9257cb2cfe654295ae23950e3bc57900c154ea73 Mon Sep 17 00:00:00 2001 From: CJHarms Date: Fri, 16 Feb 2018 22:07:45 +0100 Subject: [PATCH 3/4] Convert alarmHeaders to OrderedDict Used OrderedDict for the alarmHeaders to make sure the Dictionary Order is preserved to serve a correctly formated and ordered JSON when using Perl <3.6 --- plugins/FFAgent/FFAgent.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/plugins/FFAgent/FFAgent.py b/plugins/FFAgent/FFAgent.py index 561ca869..759ec192 100644 --- a/plugins/FFAgent/FFAgent.py +++ b/plugins/FFAgent/FFAgent.py @@ -18,6 +18,9 @@ #from includes.helper import timeHandler from includes.helper import configHandler +# needed for Ordered Dictionaries to serve correctly ordered JSON +from collections import OrderedDict + ## # # onLoad (init) function of plugin @@ -125,13 +128,13 @@ def run(typ,freq,data): alarmData = json.dumps(alarmData) logging.debug(alarmData) - alarmHeaders = { - "Content-Type": "application/json", - "webApiToken": webApiToken, - "accessToken": accessToken, - "selectiveCallCode": selectiveCallCode, - "hmac": hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest() - } + alarmHeaders = OrderedDict([ + ("Content-Type", "application/json"), + ("webApiToken", webApiToken), + ("accessToken", accessToken), + ("selectiveCallCode", selectiveCallCode), + ("hmac", hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest()) + ]) logging.debug(alarmHeaders) if globalVars.config.get("FFAgent", "live") == "1": From 3ed90b4a97c6c8aa39bdedf36ca0b6e3e2d4809f Mon Sep 17 00:00:00 2001 From: CJHarms Date: Mon, 19 Feb 2018 17:37:02 +0100 Subject: [PATCH 4/4] Revert "Convert alarmHeaders to OrderedDict" This reverts commit 9257cb2cfe654295ae23950e3bc57900c154ea73. --- plugins/FFAgent/FFAgent.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/plugins/FFAgent/FFAgent.py b/plugins/FFAgent/FFAgent.py index 759ec192..561ca869 100644 --- a/plugins/FFAgent/FFAgent.py +++ b/plugins/FFAgent/FFAgent.py @@ -18,9 +18,6 @@ #from includes.helper import timeHandler from includes.helper import configHandler -# needed for Ordered Dictionaries to serve correctly ordered JSON -from collections import OrderedDict - ## # # onLoad (init) function of plugin @@ -128,13 +125,13 @@ def run(typ,freq,data): alarmData = json.dumps(alarmData) logging.debug(alarmData) - alarmHeaders = OrderedDict([ - ("Content-Type", "application/json"), - ("webApiToken", webApiToken), - ("accessToken", accessToken), - ("selectiveCallCode", selectiveCallCode), - ("hmac", hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest()) - ]) + alarmHeaders = { + "Content-Type": "application/json", + "webApiToken": webApiToken, + "accessToken": accessToken, + "selectiveCallCode": selectiveCallCode, + "hmac": hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest() + } logging.debug(alarmHeaders) if globalVars.config.get("FFAgent", "live") == "1":