def remove_value_from_vocab(self, value): """Removes a value from a vocab. Args: value: The value to remove. Raises: RuntimeException: A vocab is not defined or the vocab is not in the vocab list. """ if self.name not in self.settings: raise RuntimeException('{0:s} is not a defined vocabulary'.format( self.name)) if value not in self.settings[self.name]: raise RuntimeException('"{0:s}" not in vocab {1:s}'.format( value, self.name)) self.settings[self.name].remove(value) self.save()
def remove_phase_from_killchain(self, phase): """Removes a phase from a killchain. Args: phase: The phase to remove. Raises: RuntimeException: A killchain is not defined or the killchain is not in the killchain list. """ if self.name not in self.settings: raise RuntimeException('{0:s} is not a defined killchain'.format( self.name)) if phase not in self.settings[self.name]: raise RuntimeException('"{0:s}" not in killchain {1:s}'.format( phase, self.name)) self.settings[self.name].remove(phase) self.save()
def remove_value_from_field_vocab(self, field_name, value): """Removes a value from a vocab list in a field name. Args: field_name: The field name from which to remove the value. value: The value to remove. Raises: RuntimeException: A vocab for the field is not defined or the vocab is not in the vocab list. """ if field_name not in self.settings: raise RuntimeException( 'No vocab for field name: {0:s}'.format(field_name)) if value not in self.settings[field_name]: raise RuntimeException('"{0:s}" not in vocab for {1:s}'.format( value, field_name)) self.settings[field_name].remove(value) self.save()
def get_vocab(self): """Returns content of a given vocab. Raises: RuntimeException: When no vocab with that name is defined. """ if self.name not in self.settings: raise RuntimeException('{0:s} is not a defined vocabulary'.format( self.name)) return self.settings[self.name]
def get_killchain(self): """Gets a specific killchain's contents. Raises: RuntimeException: When no killchain with that name is defined. """ if self.name not in self.settings: raise RuntimeException('{0:s} is not a defined killchain'.format( self.name)) return self.settings[self.name]
def get_killchain(self, killchain_name): """Gets a specific killchain by name. Args: killchain_name: The name of the killchain to get. Raises: RuntimeException: When no killchain with that name is defined. """ if killchain_name not in self.settings: raise RuntimeException( '{0:s} is not a defined killchain'.format(killchain_name)) return self.settings[killchain_name]
def get_vocab_for_field(self, field_name): """Gets the vocabulary for a given field. Args: field_name: The name of the field to get the vocabulary for. Raises: RuntimeException: When no vocab is defined for the field. """ if field_name not in self.settings: raise RuntimeException( 'No vocab defined for field name: {0:s}'.format(field_name)) return self.settings[field_name]
def get_vocab(self, vocab_name): """Gets a specific vocab by name. Args: vocab_name: The name of the vocab to get. Raises: RuntimeException: When no vocab with that name is defined. """ if vocab_name not in self.settings: raise RuntimeException('{0:s} is not a defined vocabulary'.format( vocab_name)) return self.settings[vocab_name]