Skip to content

Commit 2575aee

Browse files
committed
Merge branch '1.8.0-branch' into 'main'
Refactor import statements in advanced_search_using_network_indicators notebook See merge request integrations/sdk/reversinglabs-sdk-cookbook!6
2 parents da986bc + 942f71c commit 2575aee

File tree

1 file changed

+55
-61
lines changed

1 file changed

+55
-61
lines changed

Scenarios and Workflows/advanced_search_using_network_indicators.ipynb

Lines changed: 55 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
},
2727
{
2828
"cell_type": "code",
29-
"execution_count": null,
29+
"execution_count": 1,
3030
"id": "59ab69c2",
3131
"metadata": {},
3232
"outputs": [],
3333
"source": [
34-
"from ReversingLabs.SDK.helper import *\n",
35-
"from ReversingLabs.SDK.ticloud import AdvancedSearch, AdvancedActions"
34+
"from ReversingLabs.SDK.ticloud import AdvancedSearch\n",
35+
"from ReversingLabs.SDK.advanced import AdvancedActions"
3636
]
3737
},
3838
{
@@ -51,7 +51,7 @@
5151
},
5252
{
5353
"cell_type": "code",
54-
"execution_count": null,
54+
"execution_count": 2,
5555
"id": "66ed0816",
5656
"metadata": {},
5757
"outputs": [],
@@ -80,7 +80,7 @@
8080
},
8181
{
8282
"cell_type": "code",
83-
"execution_count": null,
83+
"execution_count": 3,
8484
"id": "791783de",
8585
"metadata": {},
8686
"outputs": [],
@@ -102,7 +102,7 @@
102102
},
103103
{
104104
"cell_type": "code",
105-
"execution_count": null,
105+
"execution_count": 4,
106106
"id": "dbdf8739",
107107
"metadata": {},
108108
"outputs": [],
@@ -130,7 +130,7 @@
130130
},
131131
{
132132
"cell_type": "code",
133-
"execution_count": null,
133+
"execution_count": 5,
134134
"id": "067c7c95",
135135
"metadata": {},
136136
"outputs": [],
@@ -154,11 +154,18 @@
154154
"id": "ae7e378c",
155155
"metadata": {},
156156
"source": [
157-
"# 6. Main Execution Function\n",
157+
"# 6. Main Execution Function, results processing and output\n",
158158
"- Performs the search using the ReversingLabs SDK\n",
159159
"- Processes each sample to extract basic information\n",
160160
"- Attempts to enrich each sample and extract relevant URLs\n",
161-
"- Handles errors gracefully, continuing even if enrichment fails for some samples"
161+
"- Handles errors gracefully, continuing even if enrichment fails for some samples\n",
162+
"\n",
163+
" Results Processing and output:\n",
164+
"- Groups samples by the extracted URLs\n",
165+
"- Creates a default group if no URLs are found\n",
166+
"- Builds the final report structure \n",
167+
"- Writes the grouped results to a JSON file\n",
168+
"- Provides summary statistics on the console"
162169
]
163170
},
164171
{
@@ -246,68 +253,47 @@
246253
" \n",
247254
" minimal_results.append(minimal_data)\n",
248255
"\n",
249-
" print(f\"Found URLs in {urls_found_count} samples\")"
250-
]
251-
},
252-
{
253-
"cell_type": "markdown",
254-
"id": "3f59c5f7",
255-
"metadata": {},
256-
"source": [
257-
"# 7. Results Processing and output\n",
258-
"- Groups samples by the extracted URLs\n",
259-
"- Creates a default group if no URLs are found\n",
260-
"- Builds the final report structure \n",
261-
"- Writes the grouped results to a JSON file\n",
262-
"- Provides summary statistics on the console"
263-
]
264-
},
265-
{
266-
"cell_type": "code",
267-
"execution_count": null,
268-
"id": "5680ca67",
269-
"metadata": {},
270-
"outputs": [],
271-
"source": [
272-
"url_groups = {}\n",
273-
"for sample in minimal_results:\n",
274-
" for url in sample.get(\"extracted_urls\", []):\n",
275-
" if url not in url_groups:\n",
276-
" url_groups[url] = []\n",
277-
" url_groups[url].append(sample)\n",
256+
" print(f\"Found URLs in {urls_found_count} samples\")\n",
278257
"\n",
279-
"if not url_groups and minimal_results:\n",
280-
" print(\"No URLs found in any samples. Creating a default group for all samples.\")\n",
281-
" default_url = f\"{url_prefix}[no_specific_url_found]\"\n",
282-
" url_groups[default_url] = minimal_results\n",
258+
" url_groups = {}\n",
259+
" for sample in minimal_results:\n",
260+
" for url in sample.get(\"extracted_urls\", []):\n",
261+
" if url not in url_groups:\n",
262+
" url_groups[url] = []\n",
263+
" url_groups[url].append(sample)\n",
283264
"\n",
284-
"grouped_output = {\"urls\": []}\n",
285-
"for url, samples in url_groups.items():\n",
286-
" hashes = [sample[\"hashes\"][\"sha1\"] for sample in samples]\n",
287-
" \n",
288-
" grouped_output[\"urls\"].append({\n",
289-
" \"value\": url,\n",
290-
" \"hashes\": hashes,\n",
291-
" \"samples\": samplesđ\n",
292-
" })\n",
293-
"output_file = \"report.json\"\n",
294-
"try:\n",
295-
" with open(output_file, \"w\") as f:\n",
296-
" json.dump(grouped_output, f, indent=2)\n",
297-
" print(f\"Grouped report written to {output_file}\")\n",
298-
"except Exception as e:\n",
299-
" print(\"Error exporting report:\", e)\n",
265+
" if not url_groups and minimal_results:\n",
266+
" print(\"No URLs found in any samples. Creating a default group for all samples.\")\n",
267+
" default_url = f\"{url_prefix}[no_specific_url_found]\"\n",
268+
" url_groups[default_url] = minimal_results\n",
269+
"\n",
270+
" grouped_output = {\"urls\": []}\n",
271+
" for url, samples in url_groups.items():\n",
272+
" hashes = [sample[\"hashes\"][\"sha1\"] for sample in samples]\n",
273+
" \n",
274+
" grouped_output[\"urls\"].append({\n",
275+
" \"value\": url,\n",
276+
" \"hashes\": hashes,\n",
277+
" \"samples\": samples\n",
278+
" })\n",
279+
" output_file = \"report.json\"\n",
280+
" try:\n",
281+
" with open(output_file, \"w\") as f:\n",
282+
" json.dump(grouped_output, f, indent=2)\n",
283+
" print(f\"Grouped report written to {output_file}\")\n",
284+
" except Exception as e:\n",
285+
" print(\"Error exporting report:\", e)\n",
300286
"\n",
301287
"if __name__ == \"__main__\":\n",
302-
" main()"
288+
" main()"
303289
]
304290
},
305291
{
306292
"cell_type": "markdown",
307293
"id": "6bee59fe",
308294
"metadata": {},
309295
"source": [
310-
"# 8. Results example"
296+
"# 7. Results example"
311297
]
312298
},
313299
{
@@ -546,8 +532,16 @@
546532
"name": "python3"
547533
},
548534
"language_info": {
535+
"codemirror_mode": {
536+
"name": "ipython",
537+
"version": 3
538+
},
539+
"file_extension": ".py",
540+
"mimetype": "text/x-python",
549541
"name": "python",
550-
"version": "3.x"
542+
"nbconvert_exporter": "python",
543+
"pygments_lexer": "ipython3",
544+
"version": "3.13.0"
551545
}
552546
},
553547
"nbformat": 4,

0 commit comments

Comments
 (0)