From: Shivani Bhardwaj Date: Wed, 5 Dec 2018 17:37:22 +0000 (+0530) Subject: Add header option to add source command X-Git-Tag: 1.1.0rc1~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0e58bb69c6be6ed263fcd98a8e8bcd2e3042ff1;p=thirdparty%2Fsuricata-update.git Add header option to add source command Facilitates addition of a header per source while adding the source. Usage: ``` $ ./bin/suricata-update add-source --header "Auth: Basic" ``` --- diff --git a/suricata/update/commands/addsource.py b/suricata/update/commands/addsource.py index 902c1b3..6dbf400 100644 --- a/suricata/update/commands/addsource.py +++ b/suricata/update/commands/addsource.py @@ -32,10 +32,12 @@ def register(parser): parser.add_argument("name", metavar="", nargs="?", help="Name of source") parser.add_argument("url", metavar="", nargs="?", help="Source URL") + parser.add_argument("--header", metavar="
", help="HTTP Header") parser.set_defaults(func=add_source) def add_source(): args = config.args() + header = None if args.name: name = args.name @@ -57,5 +59,8 @@ def add_source(): if url: break - source_config = sources.SourceConfiguration(name, url=url) + if args.header: + header = args.header + + source_config = sources.SourceConfiguration(name, header=header, url=url) sources.save_source_config(source_config) diff --git a/suricata/update/sources.py b/suricata/update/sources.py index d786063..d00193e 100644 --- a/suricata/update/sources.py +++ b/suricata/update/sources.py @@ -77,10 +77,11 @@ def save_source_config(source_config): class SourceConfiguration: - def __init__(self, name, url=None, params={}): + def __init__(self, name, header, url=None, params={}): self.name = name self.url = url self.params = params + self.header = header def dict(self): d = { @@ -90,6 +91,8 @@ class SourceConfiguration: d["url"] = self.url if self.params: d["params"] = self.params + if self.header: + d["header"] = self.header return d class Index: