From 27f13194e36dea7f98fce227a620b0a3474e7f51 Mon Sep 17 00:00:00 2001
From: Michal Kostenec <kostenec@cesnet.cz>
Date: Wed, 13 May 2015 11:55:36 +0200
Subject: [PATCH] Option 'secret' overwrites client's configuration

---
 warden3/contrib/connectors/hp-kippo/README                  | 3 +++
 warden3/contrib/connectors/hp-kippo/warden3-kippo-sender.py | 5 +++++
 warden3/contrib/connectors/hp-kippo/warden_client-kippo.cfg | 1 +
 3 files changed, 9 insertions(+)

diff --git a/warden3/contrib/connectors/hp-kippo/README b/warden3/contrib/connectors/hp-kippo/README
index 57ed860..80edc22 100644
--- a/warden3/contrib/connectors/hp-kippo/README
+++ b/warden3/contrib/connectors/hp-kippo/README
@@ -39,6 +39,9 @@ D. Configuration
    warden_client-kippo.cfg
     warden - path to warden-client config, e.g. 'warden/warden_client.cfg'
     name - sensor's source id used as a source of events, e.g. 'cz.cesnet.server.kippo'
+    secret - secret to authenticate client
+           - if 'secret' is non empty, is used instead of value in client's configuration
+           - useful while using more sensors with single client's configuration 
 
     anonymised - no | yes | omit
                - no (default value)
diff --git a/warden3/contrib/connectors/hp-kippo/warden3-kippo-sender.py b/warden3/contrib/connectors/hp-kippo/warden3-kippo-sender.py
index 69eb7f4..b2fe61f 100644
--- a/warden3/contrib/connectors/hp-kippo/warden3-kippo-sender.py
+++ b/warden3/contrib/connectors/hp-kippo/warden3-kippo-sender.py
@@ -22,6 +22,7 @@ DEFAULT_NAME = 'org.example.warden.test'
 DEFAULT_AWIN = 5
 DEFAULT_ANONYMISED = 'no'
 DEFAULT_TARGET_NET = '0.0.0.0/0'
+DEFAULT_SECRET = ''
 
 
 def gen_event_idea(client_name, detect_time, win_start_time, win_end_time, conn_count, src_ip, dst_ip, aggr_win, anonymised, target_net):
@@ -72,6 +73,10 @@ def main():
   awin = aconfig.get('awin', DEFAULT_AWIN) * 60
   wconfig['name'] = aname
 
+  asecret = aconfig.get('secret', DEFAULT_SECRET)
+  if asecret:
+    wconfig['secret'] = asecret
+
   wclient = Client(**wconfig)   
 
   aanonymised = aconfig.get('anonymised', DEFAULT_ANONYMISED)
diff --git a/warden3/contrib/connectors/hp-kippo/warden_client-kippo.cfg b/warden3/contrib/connectors/hp-kippo/warden_client-kippo.cfg
index 9a274a7..3faadf5 100644
--- a/warden3/contrib/connectors/hp-kippo/warden_client-kippo.cfg
+++ b/warden3/contrib/connectors/hp-kippo/warden_client-kippo.cfg
@@ -1,6 +1,7 @@
 {
     "warden": "warden_client.cfg",
     "name": "cz.cesnet.server.kippo",
+    "secret": "",
 
     "anonymised": "no",
     "target_net": "195.113.0.0/16",
-- 
GitLab