Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

Commit

Permalink
Fixed exception in directory input
Browse files Browse the repository at this point in the history
  • Loading branch information
jorritfolmer committed Nov 28, 2020
1 parent 4870bbd commit 8def91c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.2.4

- Fixed exception in directory input. (Thanks to Georgi Georgiev for providing a patch)

## 3.2.3

- Added support for Splunk 8.1. (Thanks to Aaron Myers for reporting the issue)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ This add-on is maintained by Jorrit Folmer. These people and organisations have

- Aaron Myers
- Christopher G Andrews (ChristopherGAndrews)
- Georgi Georgiev
- John (john-9c54a80b)
- Martin Wright
- Mike Kolk
Expand Down
2 changes: 1 addition & 1 deletion app.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": {
"group": null,
"name": "TA-dmarc",
"version": "3.2.3"
"version": "3.2.4"
},
"author": [
{
Expand Down
12 changes: 10 additions & 2 deletions bin/dmarc/dir2splunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ def __init__(
self.tmp_dir = None
self.source_filename = ""

def myfsencode(self, file):
''' Given a filename
Return the byte version of it, depending on the Python version '''
if sys.version_info[0] < 3:
return(file)
else:
return(os.fsencode(file))

def list_incoming(self):
""" Returns a list of files for the incoming directory """
newfileslist = []
Expand Down Expand Up @@ -107,7 +115,7 @@ def filter_seen_files(self, fileslist):
encoding of the filename because mongo doesn't like slashes in the key """
seen_files = set()
for file in fileslist:
key = "%s" % base64.b64encode(file)
key = "%s" % base64.b64encode(self.myfsencode(file))
if self.helper.get_check_point(key) is not None:
seen_files.add(file)
new_files = set(fileslist) - seen_files
Expand All @@ -126,7 +134,7 @@ def save_check_point(self, file):
""" Save a filename to the KVstore with base64 encoded key because
mongo doesn't like os.sep characters in the key
"""
key = "%s" % base64.b64encode(file)
key = "%s" % base64.b64encode(self.myfsencode(file))
value = "input=dmarc_dir, file='%s'" % file
try:
self.helper.save_check_point(key, value)
Expand Down
2 changes: 1 addition & 1 deletion default/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build = 1

[launcher]
author = Jorrit Folmer
version = 3.2.3
version = 3.2.4
description = TA-dmarc add-on for Splunk

[ui]
Expand Down

0 comments on commit 8def91c

Please sign in to comment.