@@ -78,6 +78,34 @@ def analysis_match(self, observables):
78
78
json = {"observables" : observables }
79
79
return self ._make_post ("analysis/match" , json = json )
80
80
81
+ def link_add (self , link_src , link_dst , type_src = "observable" , type_dst = "observable" , description = None , source = "API" ):
82
+ """Add link between to entities to the dataset
83
+
84
+ Args:
85
+ link_src: The internal Yeti ID for the source entity to link
86
+ link_dst: The internal Yeti ID for the destination entity to link
87
+ type_src: Type of the entity (either "observable", "entity", or "indicator")
88
+ type_dst: Type of the entity (either "observable", "entity", or "indicator")
89
+ description: A string description of the link
90
+ source: A string representing the source of the data. Defaults to "API".
91
+
92
+ Returns:
93
+ JSON representation of the created link.
94
+ """
95
+
96
+ json = {
97
+ "link_src" : link_src ,
98
+ "link_dst" : link_dst ,
99
+ "type_src" : type_src ,
100
+ "type_dst" : type_dst ,
101
+ "source" : source ,
102
+ }
103
+
104
+ if description is not None :
105
+ json ["description" ] = description
106
+
107
+ return self ._make_post ('link/' , json = json )
108
+
81
109
def observable_search (self , count = 50 , offset = 1 , regex = False , ** kwargs ):
82
110
"""Search for observables.
83
111
:param count: How many Observables you want to fetch.
@@ -287,14 +315,25 @@ def observable_file_contents(self, objectid=None, filehash=None):
287
315
else :
288
316
raise ValueError ("You need to pass an id or hash parameter." )
289
317
290
- def observable_bulk_add (self , observables , tags = None ):
291
- """Add an observables in bulk mode to the dataset
292
- :param observables: list observables to add in yeti
293
- :return JSON representation of the created observable.
318
+
319
+ def observable_bulk_add (self , observables , tags = None , context = None , source = "API" ):
320
+ """Add an observable to the dataset
321
+
322
+ Args:
323
+ observables: list of Observable value
324
+ tags: An array of strings representing tags
325
+ context: A dictionary object with context information
326
+ source: A string representing the source of the data. Defaults to
327
+ "API".
328
+
329
+ Returns:
330
+ JSON representation of the created observable.
294
331
"""
295
332
if tags is None :
296
333
tags = []
297
- json = {"observables" : [{"tags" : tags , "value" : o } for o in observables ]}
334
+ if context is None :
335
+ context = {}
336
+ json = {"observables" : [{"tags" : tags , "value" : o , "source" : source , "context" : context } for o in observables ]}
298
337
return self ._make_post ('observable/bulk' , json = json )
299
338
300
339
def get_analytic_oneshot (self , name_of_oneshot ):
0 commit comments