Exemple #1
0
 def make_ioc(self,
              name=None,
              description='Automatically generated IOC',
              author='IOC_api',
              links=None,
              keywords=None,
              id=None):
     '''
     This generates all parts of an IOC, but without any definition.
     
     It allows the caller to then add IndicatorItems/Indicator nodes to the 
     top level OR statement.
     
     This does not need to be called if using the IOC class to create an IOC
     
     input
         name:   string, Name of the ioc
         description:    string, description of the iocs
         author: string, author name/email address
         links:  list of tuples.  Each tuple should be in the form 
             (rel, href, value).
         keywords:   string.  This is normally a space delimited string of
             values that may be used as keywords
         id: GUID for the IOC.  This should not be specified under normal
             circumstances.
     
     returns
         a tuple containing three elementTree Element objects
         The first element, the root, contains the entire IOC itself.
         The second element, the top level OR indicator, allows the user to add
             additional IndicatorItem or Indicator nodes to the IOC easily.
         The third element, the parameters node, allows the user to quickly
             parse the parameters.
         
     '''
     root = ioc_et.make_IOC_root(id)
     root.append(ioc_et.make_metadata_node(name, description, author,
                                           links))
     metadata_node = root.find('metadata')
     top_level_indicator = make_Indicator_node('OR')
     parameters_node = (ioc_et.make_parameters_node())
     root.append(ioc_et.make_criteria_node(top_level_indicator))
     root.append(parameters_node)
     ioc_et.set_root_lastmodified(root)
     return (root, metadata_node, top_level_indicator, parameters_node)
Exemple #2
0
 def make_ioc(self,
             name = None, 
             description = 'Automatically generated IOC', 
             author = 'IOC_api', 
             links = None,
             keywords = None,
             id = None):
     '''
     This generates all parts of an IOC, but without any definition.
     
     It allows the caller to then add IndicatorItems/Indicator nodes to the 
     top level OR statement.
     
     This does not need to be called if using the IOC class to create an IOC
     
     input
         name:   string, Name of the ioc
         description:    string, description of the iocs
         author: string, author name/email address
         links:  list of tuples.  Each tuple should be in the form 
             (rel, href, value).
         keywords:   string.  This is normally a space delimited string of
             values that may be used as keywords
         id: GUID for the IOC.  This should not be specified under normal
             circumstances.
     
     returns
         a tuple containing three elementTree Element objects
         The first element, the root, contains the entire IOC itself.
         The second element, the top level OR indicator, allows the user to add
             additional IndicatorItem or Indicator nodes to the IOC easily.
         The third element, the parameters node, allows the user to quickly
             parse the parameters.
         
     '''
     root = ioc_et.make_IOC_root(id)
     root.append(ioc_et.make_metadata_node(name, description, author, links))
     metadata_node = root.find('metadata')
     top_level_indicator = make_Indicator_node('OR')
     parameters_node = (ioc_et.make_parameters_node())
     root.append(ioc_et.make_criteria_node(top_level_indicator))
     root.append(parameters_node)
     ioc_et.set_root_lastmodified(root)
     return (root, metadata_node, top_level_indicator, parameters_node)
Exemple #3
0
 def set_lastmodified_date(self, date=None):
     '''
     Set the last modified date of a IOC to the current date.
     User may specify the date they want to set as well.
     
     input
         date:   Date value to set the last modified date to.  This should be
             in the xsdDate form.
             This defaults to the current date if it is not provided.
             xsdDate Form: YYYY-MM-DDTHH:MM:SS
         
     output:
         returns True
     '''
     if date:
         match = re.match(date_regex, date)
         if not match:
             raise IOCParseError('last-modified date is not valid.  Must be in the form YYYY-MM-DDTHH:MM:SS')
     ioc_et.set_root_lastmodified(self.root, date)
     return True
Exemple #4
0
 def set_lastmodified_date(self, date=None):
     '''
     Set the last modified date of a IOC to the current date.
     User may specify the date they want to set as well.
     
     input
         date:   Date value to set the last modified date to.  This should be
             in the xsdDate form.
             This defaults to the current date if it is not provided.
             xsdDate Form: YYYY-MM-DDTHH:MM:SS
         
     output:
         returns True
     '''
     if date:
         match = re.match(date_regex, date)
         if not match:
             raise IOCParseError(
                 'last-modified date is not valid.  Must be in the form YYYY-MM-DDTHH:MM:SS'
             )
     ioc_et.set_root_lastmodified(self.root, date)
     return True