Difference between revisions of "TruxtonEnumeration"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This class lets you enumerate things in Truxton. =Attributes and Methods= ==<code>addnote(text: str) -> boolean</code>== This adds an investigator's note. The <code>text</code...")
 
Line 30: Line 30:
 
These are the things you want to enumerate.
 
These are the things you want to enumerate.
 
It can be one of the following:
 
It can be one of the following:
* [[Type_Artifact]] -
+
* [[Type_Artifact]] - The enumeration will be [[TruxtonArtifact]] objects
* [[Type_Camera_Information]] -
+
* [[Type_Camera_Information]] - The enumeration will be [[TruxtonEXIF]] objects
 
* [[Type_Event]] - The enumeration will be [[TruxtonEvent]] objects
 
* [[Type_Event]] - The enumeration will be [[TruxtonEvent]] objects
 
* [[Type_File]] - The enumeration will be [[TruxtonFileIO]] objects
 
* [[Type_File]] - The enumeration will be [[TruxtonFileIO]] objects
* [[Type_Investigation]] -  
+
* [[Type_Investigation]] - The enumeration will be [[TruxtonInvestigation]] objects
* [[Type_Location]] -  
+
* [[Type_Location]] - The enumeration will be [[TruxtonLocation]] objects
* [[Type_Media]] -  
+
* [[Type_Media]] - The enumeration will be [[TruxtonMedia]] objects
 
* [[Type_Message_Attachment]] - The enumeration will be [[TruxtonFileIO]] objects of message attachments
 
* [[Type_Message_Attachment]] - The enumeration will be [[TruxtonFileIO]] objects of message attachments
 
* [[Type_Message_Body]] - The enumeration will be [[TruxtonFileIO]] objects of message bodies
 
* [[Type_Message_Body]] - The enumeration will be [[TruxtonFileIO]] objects of message bodies
* [[Type_Participant]] -  
+
* [[Type_Participant]] - The enumeration will be [[TruxtonMessageParticipant]] objects
* [[Type_Website_Visit]] -  
+
* [[Type_Website_Visit]] - The enumeration will be [[TruxtonUrl]] objects
  
 +
=Sample=
 +
This sample will enumerate all of the investigations in Truxton and list all media in those investigations.
 +
The output is [http://en.wikipedia.org/wiki/JSON JSON] format.
 +
 +
<source lang="Python" line highlight="59-61,63,68,72">
 +
import sys
 +
import json
 +
sys.path.append('C:/Program Files/Truxton/SDK')
 +
import truxton
 +
 +
trux = truxton.create()
 +
 +
media_status_names = json.loads(trux.mediastatusnames())
 +
media_type_names = json.loads(trux.mediatypenames())
 +
 +
def output_investigation(investigation: truxton.TruxtonInvestigation, instance: int) -> None:
 +
if instance > 0:
 +
  print(",")
 +
 +
d = dict()
 +
d["id"] = investigation.id.lower()
 +
d["name"] = investigation.name
 +
d["case"] = investigation.case
 +
d["description"] = investigation.description
 +
d["jurisdiction"] = str(investigation.jurisdiction)
 +
d["opened"] = F"{investigation.opened:%Y-%m-%dT%H:%M:%SZ}"
 +
d["status"] = str(investigation.status)
 +
d["type"] = str(investigation.type)
 +
 +
object_name = dict()
 +
object_name["investigation"] = d;
 +
print(json.dumps(object_name, ensure_ascii = False, sort_keys = True))
  
=Sample=
+
def output_media(media: truxton.TruxtonMedia) -> None:
<source lang="Python" highlight="3-7,9-10,19,31,36">
+
d = dict()
 +
d["id"] = media.id.lower()
 +
d["name"] = media.name
 +
d["case"] = media.case
 +
d["loadconfiguration"] = str(media.configid)
 +
d["created"] = F"{media.created:%Y-%m-%dT%H:%M:%SZ}"
 +
d["description"] = media.description
 +
d["evidencebag"] = media.evidencebag
 +
d["expires"] = F"{media.expires:%Y-%m-%dT%H:%M:%SZ}"
 +
d["generatedfolderid"] = media.generatedfolderid.lower()
 +
d["latitude"] = str(media.latitude)
 +
d["longitude"] = str(media.longitude)
 +
d["originator"] = media.originator
 +
d["percentcomplete"] = str(media.percentcomplete)
 +
d["rootid"] = media.rootid.lower()
 +
d["status"] = str(media.status)
 +
d["statusname"] = media_status_names[str(media.status)]
 +
d["type"] = str(media.type)
 +
d["typename"] = media_type_names[str(media.type)]
 +
d["updated"] = F"{media.updated:%Y-%m-%dT%H:%M:%SZ}"
 +
 
 +
object_name = dict()
 +
object_name["media"] = d;
 +
print("," + json.dumps(object_name, ensure_ascii = False, sort_keys = True))
 +
 
 +
def dump_investigation(investigation: truxton.TruxtonInvestigation, instance: int) -> None:
 +
output_investigation(investigation, instance)
 +
 
 +
investigation_media = trux.newenumerator()
 +
investigation_media.scope = truxton.Type_Investigation
 +
investigation_media.scopeid = investigation.id
 +
investigation_media.target = truxton.Type_Media
 +
 
 +
for media in investigation_media:
 +
  output_media(media)
 +
 
 +
def main():
 +
investigations = trux.newenumerator()
 +
investigations.target = truxton.Type_Investigation
 +
 
 +
print("[")
 +
instance = 0
 +
for investigation in investigations:
 +
  dump_investigation(investigation, instance)
 +
  instance += 1
 +
print("]")
 +
 
 +
if __name__ == "__main__":
 +
main()
 
</source>
 
</source>

Revision as of 10:37, 19 May 2023

This class lets you enumerate things in Truxton.

Attributes and Methods

addnote(text: str) -> boolean

This adds an investigator's note. The text parameter is the contents of the note. It will return True if the tag was associated with the communication, False on failure. The note is stored in the [InvestigatorNote] table in the database.

currentfile: TruxtonFileIO

The file that contained whatever is being enumerated.

currentinvestigation: TruxtonInvestigation

The investigation that contained whatever is being enumerated.

currentmedia: TruxtonMedia

The media that contained whatever is being enumerated.

scope: int

This sets the level at which things can be enumerated. The default is a global scope, you want to enumerate everything in Truxton. You can set it to:

  • Type_Investigation - This will tell Truxton you wish to enumerate things in a particular investigation
  • Type_Media - This will tell Truxton you wish to enumerate things in a particular piece of media

scopeid: str | UUID

This isolates the scope to the particular investigation or media you wish to enumerate.

target: int

These are the things you want to enumerate. It can be one of the following:

Sample

This sample will enumerate all of the investigations in Truxton and list all media in those investigations. The output is JSON format.

 1 import sys
 2 import json
 3 sys.path.append('C:/Program Files/Truxton/SDK')
 4 import truxton
 5 
 6 trux = truxton.create()
 7 
 8 media_status_names = json.loads(trux.mediastatusnames())
 9 media_type_names = json.loads(trux.mediatypenames())
10 
11 def output_investigation(investigation: truxton.TruxtonInvestigation, instance: int) -> None:
12  if instance > 0:
13   print(",")
14 
15  d = dict()
16  d["id"] = investigation.id.lower()
17  d["name"] = investigation.name
18  d["case"] = investigation.case
19  d["description"] = investigation.description
20  d["jurisdiction"] = str(investigation.jurisdiction)
21  d["opened"] = F"{investigation.opened:%Y-%m-%dT%H:%M:%SZ}"
22  d["status"] = str(investigation.status)
23  d["type"] = str(investigation.type)
24 
25  object_name = dict()
26  object_name["investigation"] = d;
27  print(json.dumps(object_name, ensure_ascii = False, sort_keys = True))
28 
29 def output_media(media: truxton.TruxtonMedia) -> None:
30  d = dict()
31  d["id"] = media.id.lower()
32  d["name"] = media.name
33  d["case"] = media.case
34  d["loadconfiguration"] = str(media.configid)
35  d["created"] = F"{media.created:%Y-%m-%dT%H:%M:%SZ}"
36  d["description"] = media.description
37  d["evidencebag"] = media.evidencebag
38  d["expires"] = F"{media.expires:%Y-%m-%dT%H:%M:%SZ}"
39  d["generatedfolderid"] = media.generatedfolderid.lower()
40  d["latitude"] = str(media.latitude)
41  d["longitude"] = str(media.longitude)
42  d["originator"] = media.originator
43  d["percentcomplete"] = str(media.percentcomplete)
44  d["rootid"] = media.rootid.lower()
45  d["status"] = str(media.status)
46  d["statusname"] = media_status_names[str(media.status)]
47  d["type"] = str(media.type)
48  d["typename"] = media_type_names[str(media.type)]
49  d["updated"] = F"{media.updated:%Y-%m-%dT%H:%M:%SZ}"
50 
51  object_name = dict()
52  object_name["media"] = d;
53  print("," + json.dumps(object_name, ensure_ascii = False, sort_keys = True))
54 
55 def dump_investigation(investigation: truxton.TruxtonInvestigation, instance: int) -> None:
56  output_investigation(investigation, instance)
57 
58  investigation_media = trux.newenumerator()
59  investigation_media.scope = truxton.Type_Investigation
60  investigation_media.scopeid = investigation.id
61  investigation_media.target = truxton.Type_Media
62 
63  for media in investigation_media:
64   output_media(media)
65 
66 def main():
67  investigations = trux.newenumerator()
68  investigations.target = truxton.Type_Investigation
69 
70  print("[")
71  instance = 0
72  for investigation in investigations:
73   dump_investigation(investigation, instance)
74   instance += 1
75  print("]")
76 
77 if __name__ == "__main__":
78  main()