Difference between revisions of "Truxton child file create relation"

From truxwiki.com
Jump to navigation Jump to search
Line 1: Line 1:
 
This creates a relation object sourced from this file that you can use in the [[Truxton C API#Relation | Relation API.]]
 
This creates a relation object sourced from this file that you can use in the [[Truxton C API#Relation | Relation API.]]
A relation object is how you add records to the <code>[[Relation Table | Relation]]</code> table.
+
A relation object is how you add records to the <code><nowiki>[</nowiki>[[Relation Table|Relation]]<nowiki>]</nowiki></code> table.
 
The resulting object will automatically be associated with the file it was created from and with the media the file belongs to.
 
The resulting object will automatically be associated with the file it was created from and with the media the file belongs to.
  
 
=Syntax=
 
=Syntax=
<syntaxhighlight lang="C">
+
<source lang="C">
 
uint64_t truxton_child_file_create_relation( uint64_t child_handle );
 
uint64_t truxton_child_file_create_relation( uint64_t child_handle );
</syntaxhighlight>
+
</source>
  
 
=Parameters=
 
=Parameters=
Line 17: Line 17:
  
 
=Sample=
 
=Sample=
 
+
<source lang="C" highlight="33">
<syntaxhighlight lang="C" line highlight="33">
 
 
void add_folder(uint64_t truxton, uint64_t parent_file)
 
void add_folder(uint64_t truxton, uint64_t parent_file)
 
{
 
{
Line 72: Line 71:
 
   truxton_child_file_destroy(child);
 
   truxton_child_file_destroy(child);
 
}
 
}
</syntaxhighlight>
+
</source>

Revision as of 12:50, 4 December 2020

This creates a relation object sourced from this file that you can use in the Relation API. A relation object is how you add records to the [Relation] table. The resulting object will automatically be associated with the file it was created from and with the media the file belongs to.

Syntax

uint64_t truxton_child_file_create_relation( uint64_t child_handle );

Parameters

child_handle

The handle created by the truxton_child_file_create or truxton_file_create_child call.

Return value

A handle to relation object.

Sample

void add_folder(uint64_t truxton, uint64_t parent_file)
{
   truxton_start_adding_files(truxton);

   uint64_t child = truxton_child_file_create(truxton);

   char id[40];

   truxton_file_get_id(parent_file, id, sizeof(id));
   truxton_child_file_set_parent_id(child, id);
   truxton_child_file_set_type(child, Type_Directory);
   truxton_child_file_set_name(child, "Custom Exploits Folder");

   truxton_child_file_set_origin(child, ORIGIN_GENERATED);

   if ( truxton_child_file_save(child) == 0 )
   {
      printf( "Failed to add child to Truxton\n" );
   }

   uint64_t artifact_1 = truxton_child_file_create_artifact(child);

   truxton_artifact_set_type(artifact_1, ENTITY_TYPE_EMAIL_ADDRESS);
   truxton_artifact_set_value(artifact_1, "mdyson@cyberdynesystems.com" );
   truxton_artifact_save(artifact_1);

   uint64_t artifact_2 = truxton_child_file_create_artifact(child);

   truxton_artifact_set_type(artifact_2, ENTITY_TYPE_PERSON);
   truxton_artifact_set_value(artifact_2, "Miles Dyson" );
   truxton_artifact_save(artifact_2);

   uint64_t relation = truxton_child_file_create_relation(child_file);

   char identifier[40];

   truxton_artifact_get_id(artifact_1, identifier, sizeof(identifier));
   truxton_relation_set_a_id(relation, identifier);
   truxton_relation_set_a_type(relation, OBJECT_TYPE_ENTITY);

   truxton_artifact_get_id(artifact_2, identifier, sizeof(identifier));
   truxton_relation_set_b_id(relation, identifier);
   truxton_relation_set_b_type(relation, OBJECT_TYPE_ENTITY);

   truxton_relation_set_relation(relation, RELATION_MESSAGE_ADDRESS);

   truxton_relation_save(relation);

   truxton_relation_destroy(relation);
   truxton_artifact_destroy(artifact_1);
   truxton_artifact_destroy(artifact_2);
   truxton_child_file_destroy(child);
}