Skip to content

Commit

Permalink
added the notification feature
Browse files Browse the repository at this point in the history
  • Loading branch information
umair-rhl committed Nov 14, 2023
1 parent 041540b commit c56722f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from bs4 import BeautifulSoup
from pdf2image import convert_from_path
from PIL import Image
import webhook, octopii

def truncate(local_location):
characters_per_file = 1232500
Expand Down Expand Up @@ -142,6 +143,8 @@ def append_to_output_file(data, file_name):

with open(file_name, 'w') as write_file:
loaded_json.append(data)
if octopii.notifyURL is not None:
webhook.push_data(json.dumps(loaded_json, indent=4), octopii.notifyURL)
write_file.write(json.dumps(loaded_json, indent=4))

except:
Expand Down
12 changes: 10 additions & 2 deletions octopii.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"""

output_file = "output.json"
notifyURL = ""

import json, textract, sys, urllib, cv2, os, json, shutil, traceback
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
Expand Down Expand Up @@ -116,9 +117,16 @@ def search_pii(file_path):
print_logo()
help_screen()
exit(-1)

else:
location = sys.argv[1]
location = sys.argv[1]

# Check for the -notify flag
notify_index = sys.argv.index('-notify') if '-notify' in sys.argv else -1

if notify_index != -1 and notify_index + 1 < len(sys.argv):
notifyURL = sys.argv[notify_index + 1]
else:
notifyURL = None

rules=text_utils.get_regexes()

Expand Down
5 changes: 4 additions & 1 deletion webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@

def push_data(data: str, url: str):
headers = {'Content-type': 'application/json'}
data = f"{"text":'{data}'}"
if "discord" in url:
data = f"{'content':'{data}'}"
else:
data = f"{'text':'{data}'}"

req = requests.post (
url, # Example: https://hooks.slack.com/services/<>/<>/<>
Expand Down

0 comments on commit c56722f

Please sign in to comment.