Skip to content

Add modules utils under mix_utils folder to avoid duplication in JSON… #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5466c19
Add modules utils under mix_utils folder to avoid duplication in JSON…
fabrizio-turchi Feb 19, 2024
6a14af9
Fix #22 issue, adding BrowserBookmarkFacet to observable module
fabrizio-turchi Feb 20, 2024
f33a8f5
Fix #3 issue, changing uco-tool:creator property as a reference to an…
fabrizio-turchi Feb 20, 2024
bb70ee7
Fix #13 issue, replacing EventFacet class with EventRecordFacet class
fabrizio-turchi Feb 20, 2024
fc0ac4d
Change .gitignore to ignore the .pyc files nad the __pycache__ folder
fabrizio-turchi Feb 20, 2024
1e33b70
Add type checking to mix_utils/util-py module
fabrizio-turchi Feb 21, 2024
0a491b8
Remove AdjustDate class, useful only for UFED parser, and white spac…
fabrizio-turchi Feb 21, 2024
ea81a41
Change structure mix_utils/utils.py module. Add test_duplicate.py for…
fabrizio-turchi Feb 23, 2024
1d97f40
Enable CI on pull requests
ajnelson-nist Feb 23, 2024
6ebfcc7
Apply formatting
ajnelson-nist Feb 23, 2024
169c32b
Fix #12 issue, changing FacetUrlHistory and UrlHistoryEntry classes
fabrizio-turchi Feb 26, 2024
df8c25e
Reformatted example.py
fabrizio-turchi Feb 27, 2024
e888d6f
Apply formatting
ajnelson-nist Feb 28, 2024
05d7684
Deactivate validation report
ajnelson-nist Feb 28, 2024
26a516f
Fix data typing
ajnelson-nist Feb 28, 2024
2d48c7f
Reformatted line by Flake by CI action
fabrizio-turchi Feb 29, 2024
fb64867
Apply Python and JSON-LD type-review for coordinates
ajnelson-nist Mar 12, 2024
947307d
Change argument-list type
ajnelson-nist Mar 12, 2024
3123a35
Type-annotate mix_utils directory
ajnelson-nist Mar 12, 2024
e72002e
Link Issue
ajnelson-nist Mar 12, 2024
6aaa572
Regenerate Make-managed file
ajnelson-nist Mar 12, 2024
491c4f8
Integrate mix_utils directory into package
ajnelson-nist Mar 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Continuous Integration

on:
push:
pull_request:

jobs:
build:
Expand Down Expand Up @@ -42,10 +43,6 @@ jobs:
case-path: ./
case-version: "case-1.3.0"
extension-filter: "jsonld"
report-in-pr: "true"
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
pull-request: ${{ github.event.pull_request.number }}

# Always build the package as a sanity check to ensure no issues with the build system
# exist as part of the CI process
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
.venv/
venv/

# Wing IDE
*wpr
*wpu

__pycache__/
*.pyc

# Build Artifacts
build/
dist/
155 changes: 127 additions & 28 deletions case.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@
"uco-core:hasFacet": [
{
"@id": "0f0b71e7-39a8-5249-83a5-b52888d5c8b7",
"@type": "uco-observable:PhoneAccountFacet",
"uco-observable:phoneNumber": "123456"
"@type": "uco-observable:URLFacet",
"uco-observable:fullValue": "www.docker.com/howto"
}
]
},
Expand All @@ -306,77 +306,176 @@
"uco-core:hasFacet": [
{
"@id": "d5797860-8d73-5a53-a6fc-660a4e8c64e2",
"@type": "uco-observable:ApplicationFacet",
"uco-core:name": "Safari"
}
]
},
{
"@id": "997f05df-f309-588d-829f-c20e3cbadb57",
"@type": "uco-observable:ObservableObject",
"uco-core:hasFacet": [
{
"@id": "697d25c6-00bd-571e-aebd-5a96e34ea4b5",
"@type": "uco-observable:URLHistoryFacet",
"uco-observable:browserInformation": {
"@id": "9af4324d-cb7b-54d7-aba4-95714396435e"
},
"uco-observable:urlHistoryEntry": [
{
"@id": "641fc5c4-49a3-573e-bdb2-d6d8dc000fee",
"@type": "uco-observable:URLHistoryEntry",
"uco-observable:browserUserProfile": "Jill",
"uco-observable:expirationTime": {
"@type": "xsd:dateTime",
"@value": "2024-12-27T14:55:01+00:00"
},
"uco-observable:firstVisit": {
"@type": "xsd:dateTime",
"@value": "2024-01-02T15:55:01+00:00"
},
"uco-observable:hostname": "case_test",
"uco-observable:keywordSearchTerm": "docker",
"uco-observable:lastVisit": {
"@type": "xsd:dateTime",
"@value": "2024-02-10T10:55:01+00:00"
},
"uco-observable:manuallyEnteredCount": {
"@type": "xsd:nonNegativeInteger",
"@value": "10"
},
"uco-observable:pageTitle": "Docker tutorial",
"uco-observable:url": {
"@id": "41bc2540-fdd8-5753-864c-00a5de7d0d2e"
},
"uco-observable:visitCount": {
"@type": "xsd:integer",
"@value": "18"
}
},
{
"@id": "5860f49a-8471-5984-9610-402672d63f56",
"@type": "uco-observable:URLHistoryEntry",
"uco-observable:browserUserProfile": "Tamasin",
"uco-observable:expirationTime": {
"@type": "xsd:dateTime",
"@value": "2024-12-27T14:55:01+00:00"
},
"uco-observable:firstVisit": {
"@type": "xsd:dateTime",
"@value": "2024-01-02T15:55:01+00:00"
},
"uco-observable:hostname": "case_test",
"uco-observable:keywordSearchTerm": "git actions",
"uco-observable:lastVisit": {
"@type": "xsd:dateTime",
"@value": "2024-02-10T10:55:01+00:00"
},
"uco-observable:manuallyEnteredCount": {
"@type": "xsd:nonNegativeInteger",
"@value": "21"
},
"uco-observable:pageTitle": "GitHub actions tutorial",
"uco-observable:url": {
"@id": "41bc2540-fdd8-5753-864c-00a5de7d0d2e"
},
"uco-observable:visitCount": {
"@type": "xsd:integer",
"@value": "38"
}
}
]
}
]
},
{
"@id": "6e0ac6ce-6afc-58c6-b4b6-501fa5de2699",
"@type": "uco-observable:ObservableObject",
"uco-core:hasFacet": [
{
"@id": "00f08d34-2abd-53e3-b758-cd5ba00300c9",
"@type": "uco-observable:PhoneAccountFacet",
"uco-observable:phoneNumber": "123456"
}
]
},
{
"@id": "3d6f634e-7c5d-5ff8-b996-8d738bb2793a",
"@type": "uco-observable:ObservableObject",
"uco-core:hasFacet": [
{
"@id": "17525359-a042-5503-ad5f-f8f9bcd53472",
"@type": "uco-observable:PhoneAccountFacet",
"uco-observable:phoneNumber": "987654"
}
]
},
{
"@id": "997f05df-f309-588d-829f-c20e3cbadb57",
"@id": "1c09087a-0577-5025-a23b-c3e0155a5bf7",
"@type": "uco-observable:ObservableObject",
"uco-core:hasFacet": [
{
"@id": "5860f49a-8471-5984-9610-402672d63f56",
"@id": "0336f3a3-ff74-5e34-97bb-14534316f393",
"@type": "uco-observable:MessageFacet",
"uco-observable:messageText": "Are you free this weekend?",
"uco-observable:sentTime": {
"@type": "xsd:dateTime",
"@value": "2023-01-01T01:08:08.000008+00:00"
},
"uco-observable:from": {
"@id": "41bc2540-fdd8-5753-864c-00a5de7d0d2e"
"@id": "6e0ac6ce-6afc-58c6-b4b6-501fa5de2699"
},
"uco-observable:to": [
{
"@id": "41bc2540-fdd8-5753-864c-00a5de7d0d2e"
"@id": "6e0ac6ce-6afc-58c6-b4b6-501fa5de2699"
},
{
"@id": "9af4324d-cb7b-54d7-aba4-95714396435e"
"@id": "3d6f634e-7c5d-5ff8-b996-8d738bb2793a"
}
],
"uco-observable:application": {
"@id": "697d25c6-00bd-571e-aebd-5a96e34ea4b5"
"@id": "80c8f41b-e720-51db-b650-1df11b5f2acb"
}
}
]
},
{
"@id": "697d25c6-00bd-571e-aebd-5a96e34ea4b5",
"@id": "80c8f41b-e720-51db-b650-1df11b5f2acb",
"@type": "uco-observable:ObservableObject",
"uco-core:hasFacet": [
{
"@id": "641fc5c4-49a3-573e-bdb2-d6d8dc000fee",
"@id": "35fb4ae9-6e55-59b7-a797-6aff1494a314",
"@type": "uco-observable:ApplicationFacet",
"uco-core:name": "WhatsApp"
}
]
},
{
"@id": "6e0ac6ce-6afc-58c6-b4b6-501fa5de2699",
"@id": "6d5906a1-df3f-5aa3-8c0d-c76c570d8b96",
"@type": "uco-identity:Identity",
"uco-core:hasFacet": [
{
"@id": "3d6f634e-7c5d-5ff8-b996-8d738bb2793a",
"@id": "742d8932-3fe2-5c0f-afc4-9dd2e20533e3",
"@type": "uco-identity:BirthInformationFacet",
"uco-identity:birthdate": {
"@type": "xsd:dateTime",
"@value": "1993-01-08T01:09:09.000009+00:00"
}
},
{
"@id": "00f08d34-2abd-53e3-b758-cd5ba00300c9",
"@id": "24cd8876-1c97-5fce-9976-8733f6e901f6",
"@type": "uco-identity:SimpleNameFacet",
"uco-identity:givenName": "Davey",
"uco-identity:familyName": "Jones"
}
]
},
{
"@id": "17525359-a042-5503-ad5f-f8f9bcd53472",
"@id": "32599b39-84d2-5471-9452-c494171897fd",
"@type": "uco-location:Location",
"uco-core:hasFacet": [
{
"@id": "1c09087a-0577-5025-a23b-c3e0155a5bf7",
"@id": "6f716a17-3a29-513a-9e21-8bf6112c1d50",
"@type": "uco-location:LatLongCoordinatesFacet",
"uco-location:latitude": {
"@type": "xsd:decimal",
Expand All @@ -390,7 +489,7 @@
]
},
{
"@id": "80c8f41b-e720-51db-b650-1df11b5f2acb",
"@id": "3344007e-c9c4-5437-9766-4001fc9f3af5",
"@type": "case-investigation:Investigation",
"uco-core:name": "Crime A",
"case-investigation:focus": "Transfer of Illicit Materials",
Expand Down Expand Up @@ -510,7 +609,7 @@
]
},
{
"@id": "0336f3a3-ff74-5e34-97bb-14534316f393",
"@id": "bb9cd337-eb51-50dd-9cee-00f9e9acbf94",
"@type": "uco-observable:Message",
"uco-observable:state": "some state",
"uco-observable:hasChanged": {
Expand All @@ -521,59 +620,59 @@
"olo:slot": null,
"uco-core:hasFacet": [
{
"@id": "6d5906a1-df3f-5aa3-8c0d-c76c570d8b96",
"@id": "73af707b-f00e-5327-8fd4-83467b4441c4",
"@type": "uco-observable:MessageFacet"
}
]
},
{
"@id": "24cd8876-1c97-5fce-9976-8733f6e901f6",
"@id": "7c4d5cff-deb0-5031-b881-c572d6ef2fd7",
"@type": "uco-observable:Message",
"olo:length": null,
"olo:slot": null,
"uco-core:hasFacet": [
{
"@id": "742d8932-3fe2-5c0f-afc4-9dd2e20533e3",
"@id": "551338f3-0bb6-5325-a63a-f164f8750a17",
"@type": "uco-observable:MessageFacet"
}
]
},
{
"@id": "32599b39-84d2-5471-9452-c494171897fd",
"@id": "09b10c04-d04b-5808-a1b6-0392dd3a00e8",
"@type": "uco-observable:Message",
"olo:length": null,
"olo:slot": null,
"uco-core:hasFacet": [
{
"@id": "6f716a17-3a29-513a-9e21-8bf6112c1d50",
"@id": "a19e1e1f-3953-5fb9-92b6-2b46f85752b2",
"@type": "uco-observable:MessageFacet"
}
]
},
{
"@id": "35fb4ae9-6e55-59b7-a797-6aff1494a314",
"@id": "562c20c5-bef7-5919-a969-6c820a80e0d3",
"@type": "uco-observable:MessageThread",
"uco-core:hasFacet": [
{
"@id": "3344007e-c9c4-5437-9766-4001fc9f3af5",
"@id": "6f79d4ae-d92c-5cad-bbe5-a0afde6f475a",
"@type": "uco-observable:MessageThreadFacet",
"uco-observable:displayName": "some name",
"uco-observable:messageThread": {
"@id": "562c20c5-bef7-5919-a969-6c820a80e0d3",
"@id": "56f74818-1d3d-51f9-8cb1-d6bdc8ecee60",
"@type": "uco-types:Thread",
"co:size": {
"@type": "xsd:nonNegativeInteger",
"@value": "3"
},
"co:element": [
{
"@id": "0336f3a3-ff74-5e34-97bb-14534316f393"
"@id": "09b10c04-d04b-5808-a1b6-0392dd3a00e8"
},
{
"@id": "24cd8876-1c97-5fce-9976-8733f6e901f6"
"@id": "7c4d5cff-deb0-5031-b881-c572d6ef2fd7"
},
{
"@id": "32599b39-84d2-5471-9452-c494171897fd"
"@id": "bb9cd337-eb51-50dd-9cee-00f9e9acbf94"
}
]
}
Expand Down
37 changes: 37 additions & 0 deletions case_mapping/mix_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from typing import Any, Callable


def check_value(
*args: Any,
value: str,
list_values: list[str],
list_objects: list[dict[str, Any]],
observable_generating_f: Callable[..., dict[str, Any]]
) -> dict[str, Any]:
"""It checks if a specific value has been already generated related to an ObservableObject relying on
the list of its values. This is meant to avoid duplication in the JSON/CASE file generated by the
parsers (UFED, AXIOM etc.).
If the value is not in the list_values, a new ObservableObject is generated by using the function
observable_generating_f that returns, as a result, the new ObservableObject (e.g. uco-observable:ApplicationFacet,
uco-observable:AccountFacet, uco-location:LatLongCoordinatesFacet: drafting:SearchedItemFacet, "uco-observable:URLFacet,
uco-observable:ApplicationAccountFacet, uco-observable:DigitalAccountFacet, uco-observable:PhoneAccountFacet).

Finally the new ObservableObject is added to the list_objects (any kind of ObservableObject maintains a different list).
If the value is already in the list_values, the ObservableObject list_objects[index] is returned.

:param value: the value to be checked within the list_values
:param list_values: the current list of values
:param list_objects: the current list of a specific kind of ObservableObject
:param observable_generating_f: the function that will generate the corresponding kind of ObservableObject
:param *args: the actual parameter of the observable_generating_f function
:return: an Observableobject of a specific kind depending by the actual parameters
"""
if value in list_values:
idx = list_values.index(value)
observable_app = list_objects[idx]
else:
observable_app = observable_generating_f(*args)
list_values.append(value)
list_objects.append(observable_app)

return observable_app
Loading