Skip to content

Commit 4ad2ddb

Browse files
Merge pull request #36 from fabrizio-turchi/main
Add modules utils under mix_utils folder to avoid duplication in JSON…
2 parents 643fb21 + 491c4f8 commit 4ad2ddb

File tree

8 files changed

+588
-103
lines changed

8 files changed

+588
-103
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Continuous Integration
22

33
on:
44
push:
5+
pull_request:
56

67
jobs:
78
build:
@@ -42,10 +43,6 @@ jobs:
4243
case-path: ./
4344
case-version: "case-1.3.0"
4445
extension-filter: "jsonld"
45-
report-in-pr: "true"
46-
github-token: ${{ secrets.GITHUB_TOKEN }}
47-
repository: ${{ github.repository }}
48-
pull-request: ${{ github.event.pull_request.number }}
4946

5047
# Always build the package as a sanity check to ensure no issues with the build system
5148
# exist as part of the CI process

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
.venv/
1010
venv/
1111

12+
# Wing IDE
13+
*wpr
14+
*wpu
15+
16+
__pycache__/
17+
*.pyc
18+
1219
# Build Artifacts
1320
build/
1421
dist/

case.jsonld

Lines changed: 127 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@
295295
"uco-core:hasFacet": [
296296
{
297297
"@id": "0f0b71e7-39a8-5249-83a5-b52888d5c8b7",
298-
"@type": "uco-observable:PhoneAccountFacet",
299-
"uco-observable:phoneNumber": "123456"
298+
"@type": "uco-observable:URLFacet",
299+
"uco-observable:fullValue": "www.docker.com/howto"
300300
}
301301
]
302302
},
@@ -306,77 +306,176 @@
306306
"uco-core:hasFacet": [
307307
{
308308
"@id": "d5797860-8d73-5a53-a6fc-660a4e8c64e2",
309+
"@type": "uco-observable:ApplicationFacet",
310+
"uco-core:name": "Safari"
311+
}
312+
]
313+
},
314+
{
315+
"@id": "997f05df-f309-588d-829f-c20e3cbadb57",
316+
"@type": "uco-observable:ObservableObject",
317+
"uco-core:hasFacet": [
318+
{
319+
"@id": "697d25c6-00bd-571e-aebd-5a96e34ea4b5",
320+
"@type": "uco-observable:URLHistoryFacet",
321+
"uco-observable:browserInformation": {
322+
"@id": "9af4324d-cb7b-54d7-aba4-95714396435e"
323+
},
324+
"uco-observable:urlHistoryEntry": [
325+
{
326+
"@id": "641fc5c4-49a3-573e-bdb2-d6d8dc000fee",
327+
"@type": "uco-observable:URLHistoryEntry",
328+
"uco-observable:browserUserProfile": "Jill",
329+
"uco-observable:expirationTime": {
330+
"@type": "xsd:dateTime",
331+
"@value": "2024-12-27T14:55:01+00:00"
332+
},
333+
"uco-observable:firstVisit": {
334+
"@type": "xsd:dateTime",
335+
"@value": "2024-01-02T15:55:01+00:00"
336+
},
337+
"uco-observable:hostname": "case_test",
338+
"uco-observable:keywordSearchTerm": "docker",
339+
"uco-observable:lastVisit": {
340+
"@type": "xsd:dateTime",
341+
"@value": "2024-02-10T10:55:01+00:00"
342+
},
343+
"uco-observable:manuallyEnteredCount": {
344+
"@type": "xsd:nonNegativeInteger",
345+
"@value": "10"
346+
},
347+
"uco-observable:pageTitle": "Docker tutorial",
348+
"uco-observable:url": {
349+
"@id": "41bc2540-fdd8-5753-864c-00a5de7d0d2e"
350+
},
351+
"uco-observable:visitCount": {
352+
"@type": "xsd:integer",
353+
"@value": "18"
354+
}
355+
},
356+
{
357+
"@id": "5860f49a-8471-5984-9610-402672d63f56",
358+
"@type": "uco-observable:URLHistoryEntry",
359+
"uco-observable:browserUserProfile": "Tamasin",
360+
"uco-observable:expirationTime": {
361+
"@type": "xsd:dateTime",
362+
"@value": "2024-12-27T14:55:01+00:00"
363+
},
364+
"uco-observable:firstVisit": {
365+
"@type": "xsd:dateTime",
366+
"@value": "2024-01-02T15:55:01+00:00"
367+
},
368+
"uco-observable:hostname": "case_test",
369+
"uco-observable:keywordSearchTerm": "git actions",
370+
"uco-observable:lastVisit": {
371+
"@type": "xsd:dateTime",
372+
"@value": "2024-02-10T10:55:01+00:00"
373+
},
374+
"uco-observable:manuallyEnteredCount": {
375+
"@type": "xsd:nonNegativeInteger",
376+
"@value": "21"
377+
},
378+
"uco-observable:pageTitle": "GitHub actions tutorial",
379+
"uco-observable:url": {
380+
"@id": "41bc2540-fdd8-5753-864c-00a5de7d0d2e"
381+
},
382+
"uco-observable:visitCount": {
383+
"@type": "xsd:integer",
384+
"@value": "38"
385+
}
386+
}
387+
]
388+
}
389+
]
390+
},
391+
{
392+
"@id": "6e0ac6ce-6afc-58c6-b4b6-501fa5de2699",
393+
"@type": "uco-observable:ObservableObject",
394+
"uco-core:hasFacet": [
395+
{
396+
"@id": "00f08d34-2abd-53e3-b758-cd5ba00300c9",
397+
"@type": "uco-observable:PhoneAccountFacet",
398+
"uco-observable:phoneNumber": "123456"
399+
}
400+
]
401+
},
402+
{
403+
"@id": "3d6f634e-7c5d-5ff8-b996-8d738bb2793a",
404+
"@type": "uco-observable:ObservableObject",
405+
"uco-core:hasFacet": [
406+
{
407+
"@id": "17525359-a042-5503-ad5f-f8f9bcd53472",
309408
"@type": "uco-observable:PhoneAccountFacet",
310409
"uco-observable:phoneNumber": "987654"
311410
}
312411
]
313412
},
314413
{
315-
"@id": "997f05df-f309-588d-829f-c20e3cbadb57",
414+
"@id": "1c09087a-0577-5025-a23b-c3e0155a5bf7",
316415
"@type": "uco-observable:ObservableObject",
317416
"uco-core:hasFacet": [
318417
{
319-
"@id": "5860f49a-8471-5984-9610-402672d63f56",
418+
"@id": "0336f3a3-ff74-5e34-97bb-14534316f393",
320419
"@type": "uco-observable:MessageFacet",
321420
"uco-observable:messageText": "Are you free this weekend?",
322421
"uco-observable:sentTime": {
323422
"@type": "xsd:dateTime",
324423
"@value": "2023-01-01T01:08:08.000008+00:00"
325424
},
326425
"uco-observable:from": {
327-
"@id": "41bc2540-fdd8-5753-864c-00a5de7d0d2e"
426+
"@id": "6e0ac6ce-6afc-58c6-b4b6-501fa5de2699"
328427
},
329428
"uco-observable:to": [
330429
{
331-
"@id": "41bc2540-fdd8-5753-864c-00a5de7d0d2e"
430+
"@id": "6e0ac6ce-6afc-58c6-b4b6-501fa5de2699"
332431
},
333432
{
334-
"@id": "9af4324d-cb7b-54d7-aba4-95714396435e"
433+
"@id": "3d6f634e-7c5d-5ff8-b996-8d738bb2793a"
335434
}
336435
],
337436
"uco-observable:application": {
338-
"@id": "697d25c6-00bd-571e-aebd-5a96e34ea4b5"
437+
"@id": "80c8f41b-e720-51db-b650-1df11b5f2acb"
339438
}
340439
}
341440
]
342441
},
343442
{
344-
"@id": "697d25c6-00bd-571e-aebd-5a96e34ea4b5",
443+
"@id": "80c8f41b-e720-51db-b650-1df11b5f2acb",
345444
"@type": "uco-observable:ObservableObject",
346445
"uco-core:hasFacet": [
347446
{
348-
"@id": "641fc5c4-49a3-573e-bdb2-d6d8dc000fee",
447+
"@id": "35fb4ae9-6e55-59b7-a797-6aff1494a314",
349448
"@type": "uco-observable:ApplicationFacet",
350449
"uco-core:name": "WhatsApp"
351450
}
352451
]
353452
},
354453
{
355-
"@id": "6e0ac6ce-6afc-58c6-b4b6-501fa5de2699",
454+
"@id": "6d5906a1-df3f-5aa3-8c0d-c76c570d8b96",
356455
"@type": "uco-identity:Identity",
357456
"uco-core:hasFacet": [
358457
{
359-
"@id": "3d6f634e-7c5d-5ff8-b996-8d738bb2793a",
458+
"@id": "742d8932-3fe2-5c0f-afc4-9dd2e20533e3",
360459
"@type": "uco-identity:BirthInformationFacet",
361460
"uco-identity:birthdate": {
362461
"@type": "xsd:dateTime",
363462
"@value": "1993-01-08T01:09:09.000009+00:00"
364463
}
365464
},
366465
{
367-
"@id": "00f08d34-2abd-53e3-b758-cd5ba00300c9",
466+
"@id": "24cd8876-1c97-5fce-9976-8733f6e901f6",
368467
"@type": "uco-identity:SimpleNameFacet",
369468
"uco-identity:givenName": "Davey",
370469
"uco-identity:familyName": "Jones"
371470
}
372471
]
373472
},
374473
{
375-
"@id": "17525359-a042-5503-ad5f-f8f9bcd53472",
474+
"@id": "32599b39-84d2-5471-9452-c494171897fd",
376475
"@type": "uco-location:Location",
377476
"uco-core:hasFacet": [
378477
{
379-
"@id": "1c09087a-0577-5025-a23b-c3e0155a5bf7",
478+
"@id": "6f716a17-3a29-513a-9e21-8bf6112c1d50",
380479
"@type": "uco-location:LatLongCoordinatesFacet",
381480
"uco-location:latitude": {
382481
"@type": "xsd:decimal",
@@ -390,7 +489,7 @@
390489
]
391490
},
392491
{
393-
"@id": "80c8f41b-e720-51db-b650-1df11b5f2acb",
492+
"@id": "3344007e-c9c4-5437-9766-4001fc9f3af5",
394493
"@type": "case-investigation:Investigation",
395494
"uco-core:name": "Crime A",
396495
"case-investigation:focus": "Transfer of Illicit Materials",
@@ -510,7 +609,7 @@
510609
]
511610
},
512611
{
513-
"@id": "0336f3a3-ff74-5e34-97bb-14534316f393",
612+
"@id": "bb9cd337-eb51-50dd-9cee-00f9e9acbf94",
514613
"@type": "uco-observable:Message",
515614
"uco-observable:state": "some state",
516615
"uco-observable:hasChanged": {
@@ -521,59 +620,59 @@
521620
"olo:slot": null,
522621
"uco-core:hasFacet": [
523622
{
524-
"@id": "6d5906a1-df3f-5aa3-8c0d-c76c570d8b96",
623+
"@id": "73af707b-f00e-5327-8fd4-83467b4441c4",
525624
"@type": "uco-observable:MessageFacet"
526625
}
527626
]
528627
},
529628
{
530-
"@id": "24cd8876-1c97-5fce-9976-8733f6e901f6",
629+
"@id": "7c4d5cff-deb0-5031-b881-c572d6ef2fd7",
531630
"@type": "uco-observable:Message",
532631
"olo:length": null,
533632
"olo:slot": null,
534633
"uco-core:hasFacet": [
535634
{
536-
"@id": "742d8932-3fe2-5c0f-afc4-9dd2e20533e3",
635+
"@id": "551338f3-0bb6-5325-a63a-f164f8750a17",
537636
"@type": "uco-observable:MessageFacet"
538637
}
539638
]
540639
},
541640
{
542-
"@id": "32599b39-84d2-5471-9452-c494171897fd",
641+
"@id": "09b10c04-d04b-5808-a1b6-0392dd3a00e8",
543642
"@type": "uco-observable:Message",
544643
"olo:length": null,
545644
"olo:slot": null,
546645
"uco-core:hasFacet": [
547646
{
548-
"@id": "6f716a17-3a29-513a-9e21-8bf6112c1d50",
647+
"@id": "a19e1e1f-3953-5fb9-92b6-2b46f85752b2",
549648
"@type": "uco-observable:MessageFacet"
550649
}
551650
]
552651
},
553652
{
554-
"@id": "35fb4ae9-6e55-59b7-a797-6aff1494a314",
653+
"@id": "562c20c5-bef7-5919-a969-6c820a80e0d3",
555654
"@type": "uco-observable:MessageThread",
556655
"uco-core:hasFacet": [
557656
{
558-
"@id": "3344007e-c9c4-5437-9766-4001fc9f3af5",
657+
"@id": "6f79d4ae-d92c-5cad-bbe5-a0afde6f475a",
559658
"@type": "uco-observable:MessageThreadFacet",
560659
"uco-observable:displayName": "some name",
561660
"uco-observable:messageThread": {
562-
"@id": "562c20c5-bef7-5919-a969-6c820a80e0d3",
661+
"@id": "56f74818-1d3d-51f9-8cb1-d6bdc8ecee60",
563662
"@type": "uco-types:Thread",
564663
"co:size": {
565664
"@type": "xsd:nonNegativeInteger",
566665
"@value": "3"
567666
},
568667
"co:element": [
569668
{
570-
"@id": "0336f3a3-ff74-5e34-97bb-14534316f393"
669+
"@id": "09b10c04-d04b-5808-a1b6-0392dd3a00e8"
571670
},
572671
{
573-
"@id": "24cd8876-1c97-5fce-9976-8733f6e901f6"
672+
"@id": "7c4d5cff-deb0-5031-b881-c572d6ef2fd7"
574673
},
575674
{
576-
"@id": "32599b39-84d2-5471-9452-c494171897fd"
675+
"@id": "bb9cd337-eb51-50dd-9cee-00f9e9acbf94"
577676
}
578677
]
579678
}

case_mapping/mix_utils.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from typing import Any, Callable
2+
3+
4+
def check_value(
5+
*args: Any,
6+
value: str,
7+
list_values: list[str],
8+
list_objects: list[dict[str, Any]],
9+
observable_generating_f: Callable[..., dict[str, Any]]
10+
) -> dict[str, Any]:
11+
"""It checks if a specific value has been already generated related to an ObservableObject relying on
12+
the list of its values. This is meant to avoid duplication in the JSON/CASE file generated by the
13+
parsers (UFED, AXIOM etc.).
14+
If the value is not in the list_values, a new ObservableObject is generated by using the function
15+
observable_generating_f that returns, as a result, the new ObservableObject (e.g. uco-observable:ApplicationFacet,
16+
uco-observable:AccountFacet, uco-location:LatLongCoordinatesFacet: drafting:SearchedItemFacet, "uco-observable:URLFacet,
17+
uco-observable:ApplicationAccountFacet, uco-observable:DigitalAccountFacet, uco-observable:PhoneAccountFacet).
18+
19+
Finally the new ObservableObject is added to the list_objects (any kind of ObservableObject maintains a different list).
20+
If the value is already in the list_values, the ObservableObject list_objects[index] is returned.
21+
22+
:param value: the value to be checked within the list_values
23+
:param list_values: the current list of values
24+
:param list_objects: the current list of a specific kind of ObservableObject
25+
:param observable_generating_f: the function that will generate the corresponding kind of ObservableObject
26+
:param *args: the actual parameter of the observable_generating_f function
27+
:return: an Observableobject of a specific kind depending by the actual parameters
28+
"""
29+
if value in list_values:
30+
idx = list_values.index(value)
31+
observable_app = list_objects[idx]
32+
else:
33+
observable_app = observable_generating_f(*args)
34+
list_values.append(value)
35+
list_objects.append(observable_app)
36+
37+
return observable_app

0 commit comments

Comments
 (0)