Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0elliot committed May 26, 2024
2 parents 6190f89 + e75fc9f commit c14f229
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
19 changes: 18 additions & 1 deletion email/1.3.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,19 +556,36 @@ def analyze_headers(self, headers):

analyzed_headers = {
"success": True,
"sender": "",
"receiver": "",
"subject": "",
"date": "",
"details": {
"spf": "",
"dkim": "",
"dmarc": "",
"spoofed": "",
}
},
}

for item in headers:
if "name" in item:
item["key"] = item["name"]

item["key"] = item["key"].lower()

# Handle sender/receiver
if item["key"] == "from" or item["key"] == "sender" or item["key"] == "delivered-to":
analyzed_headers["sender"] = item["value"]

if item["key"] == "to" or item["key"] == "receiver" or item["key"] == "delivered-to":
analyzed_headers["receiver"] = item["value"]

if item["key"] == "subject" or item["key"] == "title":
analyzed_headers["subject"] = item["value"]

if item["key"] == "date":
analyzed_headers["date"] = item["value"]

if "spf" in item["key"]:
analyzed_headers["details"]["spf"] = spf
Expand Down
15 changes: 11 additions & 4 deletions shuffle-ai/1.0.0/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ def gpt(self, input_text):
}

def run_schemaless(self, category, action, app_name="", fields=""):
self.logger.info("[DEBUG] Running schemaless action with category '%s' and action label '%s'" % (category, action))

"""
action := shuffle.CategoryAction{
Label: step.Name,
Expand Down Expand Up @@ -253,6 +255,12 @@ def run_schemaless(self, category, action, app_name="", fields=""):
})

else:
fields = str(fields).strip()
if not fields.startswith("{") and not fields.startswith("["):
fields = json.dumps({
"data": fields,
})

try:
loadedfields = json.loads(fields)
for key, value in loadedfields.items():
Expand All @@ -262,19 +270,18 @@ def run_schemaless(self, category, action, app_name="", fields=""):
})

except Exception as e:
print("[ERROR] Failed to load fields as JSON: %s" % e)
self.logger.info("[ERROR] Failed to load fields as JSON: %s" % e)
return json.dumps({
"success": False,
"reason": "Ensure Fields are valid JSON",
"type": type(fields),
"reason": "Ensure 'Fields' are valid JSON",
"details": "%s" % e,
})


baseurl = "%s/api/v1/apps/categories/run" % self.base_url
baseurl += "?execution_id=%s&authorization=%s" % (self.current_execution_id, self.authorization)

print("[DEBUG] Running schemaless action with URL '%s', category %s and action label %s" % (baseurl, category, action))
self.logger.info("[DEBUG] Running schemaless action with URL '%s', category %s and action label %s" % (baseurl, category, action))

headers = {}
request = requests.post(
Expand Down

0 comments on commit c14f229

Please sign in to comment.