Skip to content

Commit f7940e2

Browse files
committed
Changed cache names to datastore. Retaining functions for backwards compatibility
1 parent 8aabd79 commit f7940e2

File tree

2 files changed

+158
-41
lines changed

2 files changed

+158
-41
lines changed

shuffle-tools/1.2.0/api.yaml

Lines changed: 148 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -61,41 +61,7 @@ actions:
6161
schema:
6262
type: string
6363

64-
- name: check_cache_contains
65-
description: Checks Shuffle cache whether a user-provided key contains a value. Returns ALL the values previously appended.
66-
parameters:
67-
- name: key
68-
description: The key to get
69-
required: true
70-
multiline: false
71-
example: "alert_ids"
72-
schema:
73-
type: string
74-
- name: value
75-
description: The value to check for and append if applicable
76-
required: true
77-
multiline: false
78-
example: "1208301599081"
79-
schema:
80-
type: string
81-
- name: append
82-
description: Whether to auto-append the value if it doesn't exist in the cache
83-
required: true
84-
options:
85-
- true
86-
- false
87-
multiline: false
88-
example: "timestamp"
89-
schema:
90-
type: string
91-
- name: category
92-
description: The category to get the value from. Not required.
93-
required: false
94-
multiline: false
95-
example: "tickets"
96-
schema:
97-
type: string
98-
- name: get_cache_value
64+
- name: get_datastore_value
9965
description: Get a value saved to your organization in Shuffle
10066
parameters:
10167
- name: key
@@ -115,7 +81,7 @@ actions:
11581
returns:
11682
schema:
11783
type: string
118-
- name: set_cache_value
84+
- name: set_datastore_value
11985
description: Set a value to be saved to your organization in Shuffle.
12086
parameters:
12187
- name: key
@@ -142,7 +108,8 @@ actions:
142108
returns:
143109
schema:
144110
type: string
145-
- name: delete_cache_value
111+
112+
- name: delete_datastore_value
146113
description: Delete a value saved to your organization in Shuffle
147114
parameters:
148115
- name: key
@@ -569,6 +536,13 @@ actions:
569536
example: "EventID,username\n4137,frikky"
570537
schema:
571538
type: string
539+
- name: category
540+
description: The category the file belongs to
541+
required: false
542+
multiline: false
543+
example: "yara-rules"
544+
schema:
545+
type: string
572546
- name: download_remote_file
573547
description: Downloads a file from a URL
574548
parameters:
@@ -1269,6 +1243,143 @@ actions:
12691243
returns:
12701244
schema:
12711245
type: string
1246+
1247+
- name: check_datastore_contains
1248+
description: We recommend "Search datastore category" instead. Checks Shuffle datastore whether a user-provided key contains a value. Returns ALL the values previously appended.
1249+
parameters:
1250+
- name: key
1251+
description: The key to get
1252+
required: true
1253+
multiline: false
1254+
example: "alert_ids"
1255+
schema:
1256+
type: string
1257+
- name: value
1258+
description: The value to check for and append if applicable
1259+
required: true
1260+
multiline: false
1261+
example: "1208301599081"
1262+
schema:
1263+
type: string
1264+
- name: append
1265+
description: Whether to auto-append the value if it doesn't exist in the cache
1266+
required: true
1267+
options:
1268+
- true
1269+
- false
1270+
multiline: false
1271+
example: "timestamp"
1272+
schema:
1273+
type: string
1274+
- name: category
1275+
description: The category to get the value from. Not required.
1276+
required: false
1277+
multiline: false
1278+
example: "tickets"
1279+
schema:
1280+
type: string
1281+
- name: get_cache_value
1282+
description: Get a value saved to your organization in Shuffle. Deprecated for "get_datastore_value"
1283+
parameters:
1284+
- name: key
1285+
description: The key to get
1286+
required: true
1287+
multiline: false
1288+
example: "timestamp"
1289+
schema:
1290+
type: string
1291+
- name: category
1292+
description: The category to get the value from. Not required.
1293+
required: false
1294+
multiline: false
1295+
example: "tickets"
1296+
schema:
1297+
type: string
1298+
returns:
1299+
schema:
1300+
type: string
1301+
- name: delete_cache_value
1302+
description: Delete a value saved to your organization in Shuffle. Deprecated for "delete_datastore_value"
1303+
parameters:
1304+
- name: key
1305+
description: The key to delete
1306+
required: true
1307+
multiline: false
1308+
example: "timestamp"
1309+
schema:
1310+
type: string
1311+
- name: category
1312+
description: The category to get the value from. Not required.
1313+
required: false
1314+
multiline: false
1315+
example: "tickets"
1316+
schema:
1317+
type: string
1318+
returns:
1319+
schema:
1320+
type: string
1321+
1322+
- name: set_cache_value
1323+
description: Set a value to be saved to your organization in Shuffle. Deprecated for "set_datastore_value"
1324+
parameters:
1325+
- name: key
1326+
description: The key to set the value for
1327+
required: true
1328+
multiline: false
1329+
example: "timestamp"
1330+
schema:
1331+
type: string
1332+
- name: value
1333+
description: The value to set
1334+
required: true
1335+
multiline: true
1336+
example: "1621959545"
1337+
schema:
1338+
type: string
1339+
- name: category
1340+
description: The category to get the value from. Not required.
1341+
required: false
1342+
multiline: false
1343+
example: "tickets"
1344+
schema:
1345+
type: string
1346+
returns:
1347+
schema:
1348+
type: string
1349+
- name: check_cache_contains
1350+
description: Checks Shuffle cache whether a user-provided key contains a value. Returns ALL the values previously appended. Deprecated for "check datastore contains"
1351+
parameters:
1352+
- name: key
1353+
description: The key to get
1354+
required: true
1355+
multiline: false
1356+
example: "alert_ids"
1357+
schema:
1358+
type: string
1359+
- name: value
1360+
description: The value to check for and append if applicable
1361+
required: true
1362+
multiline: false
1363+
example: "1208301599081"
1364+
schema:
1365+
type: string
1366+
- name: append
1367+
description: Whether to auto-append the value if it doesn't exist in the cache
1368+
required: true
1369+
options:
1370+
- true
1371+
- false
1372+
multiline: false
1373+
example: "timestamp"
1374+
schema:
1375+
type: string
1376+
- name: category
1377+
description: The category to get the value from. Not required.
1378+
required: false
1379+
multiline: false
1380+
example: "tickets"
1381+
schema:
1382+
type: string
12721383
#- name: parse_ioc_new
12731384
# description: Parse IOC's based on https://github.com/fhightower/ioc-finder
12741385
# parameters:

shuffle-tools/1.2.0/src/app.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ def delete_file(self, file_id):
11251125
)
11261126
return ret.text
11271127

1128-
def create_file(self, filename, data):
1128+
def create_file(self, filename, data, category=""):
11291129
try:
11301130
if str(data).startswith("b'") and str(data).endswith("'"):
11311131
data = data[2:-1]
@@ -1144,6 +1144,7 @@ def create_file(self, filename, data):
11441144
filedata = {
11451145
"filename": filename,
11461146
"data": data,
1147+
"namespace": category,
11471148
}
11481149

11491150
fileret = self.set_files([filedata])
@@ -1158,8 +1159,9 @@ def list_file_category_ids(self, file_category):
11581159
return self.get_file_category_ids(file_category)
11591160

11601161
# Input is WAS a file, hence it didn't get the files
1161-
def get_file_value(self, filedata):
1162-
filedata = self.get_file(filedata)
1162+
# Category doesn't matter as it uses file ID, which is unique anyway
1163+
def get_file_value(self, filedata, category=""):
1164+
filedata = self.get_file(filedata, category)
11631165
if filedata is None:
11641166
return {
11651167
"success": False,
@@ -1190,7 +1192,7 @@ def get_file_value(self, filedata):
11901192
"size": len(filedata["data"]),
11911193
}
11921194

1193-
def download_remote_file(self, url, custom_filename=""):
1195+
def download_remote_file(self, url, custom_filename="", category=""):
11941196
ret = requests.get(url, verify=False) # nosec
11951197
filename = url.split("/")[-1]
11961198
if "?" in filename:
@@ -1204,6 +1206,7 @@ def download_remote_file(self, url, custom_filename=""):
12041206
{
12051207
"filename": filename,
12061208
"data": ret.content,
1209+
"namespace": category,
12071210
}
12081211
]
12091212
)
@@ -1827,6 +1830,9 @@ def escape_html(self, input_data):
18271830
result = markupsafe.escape(mapping)
18281831
return mapping
18291832

1833+
def check_datastore_contains(self, key, value, append, category=""):
1834+
return check_cache_contains(self, key, value, append, category)
1835+
18301836
def check_cache_contains(self, key, value, append, category=""):
18311837
org_id = self.full_execution["workflow"]["execution_org"]["id"]
18321838
url = "%s/api/v1/orgs/%s/get_cache" % (self.url, org_id)

0 commit comments

Comments
 (0)