Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions stetl/etl.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,15 @@ def __init__(self, options_dict, args_dict=None):
if args_dict:
log.info("Substituting %d args in config file from args_dict: %s" % (len(args_names), str(args_names)))

# Do replacements see http://docs.python.org/2/library/string.html#formatstrings
# and render substituted config string
config_str = config_str.format(**args_dict)
# Do replacements. Use regex instead of str.format so that
# literal braces in config values (e.g. converter_args dicts)
# are not mistaken for format placeholders.
for key, value in args_dict.items():
config_str = re.sub(
r'\{%s\}' % re.escape(key),
str(value),
config_str
)

log.info("Substituting args OK")

Expand Down
3 changes: 2 additions & 1 deletion stetl/inputs/httpinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def add_authorization(self, request):
# Basic auth: http://mozgovipc.blogspot.nl/2012/06/python-http-basic-authentication-with.html
# base64 encode username and password
# write the Authorization header like: 'Basic base64encode(username + ':' + password)
auth_val = base64.encodestring('%s:%s' % (auth_creds['user'], auth_creds['password']))
creds = '%s:%s' % (auth_creds['user'], auth_creds['password'])
auth_val = base64.b64encode(creds.encode('utf-8')).decode('utf-8')
auth_val = "Basic %s" % auth_val
elif auth_type == 'token':
# Bearer Type, see eg. https://tools.ietf.org/html/rfc6750
Expand Down
5 changes: 3 additions & 2 deletions stetl/outputs/httpoutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ def post(self, packet, payload):
# basic auth: http://mozgovipc.blogspot.nl/2012/06/python-http-basic-authentication-with.html
# base64 encode the username and password
# write the Authorization header like: 'Basic base64encode(username + ':' + password)
if self.user is not None:
auth = base64.encodestring('%s:%s' % (self.user, self.password)).replace('\n', '')
if self.user is not None and self.password is not None:
creds = '%s:%s' % (self.user, self.password)
auth = base64.b64encode(creds.encode('utf-8')).decode('utf-8')
webservice.putheader("Authorization", "Basic %s" % auth)

webservice.endheaders()
Expand Down