def modify_scan_config_set_nvt_preference( self, config_id: str, name: str, nvt_oid: str, *, value: Optional[str] = None, ) -> Any: """Modifies the nvt preferences of an existing scan config. Arguments: config_id: UUID of scan config to modify. name: Name for nvt preference to change. nvt_oid: OID of the NVT associated with preference to modify value: New value for the preference. None to delete the preference and to use the default instead. """ if not config_id: raise RequiredArgument( function=self.modify_scan_config_set_nvt_preference.__name__, argument="config_id", ) if not nvt_oid: raise RequiredArgument( function=self.modify_scan_config_set_nvt_preference.__name__, argument="nvt_oid", ) if not name: raise RequiredArgument( function=self.modify_scan_config_set_nvt_preference.__name__, argument="name", ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(config_id)) _xmlpref = cmd.add_element("preference") _xmlpref.add_element("nvt", attrs={"oid": nvt_oid}) _xmlpref.add_element("name", name) if value: _xmlpref.add_element("value", to_base64(value)) return self._send_xml_command(cmd)
def modify_user_setting( self, setting_id: Optional[str] = None, name: Optional[str] = None, value: Optional[str] = None, ) -> Any: """Modifies an existing user setting. Arguments: setting_id: UUID of the setting to be changed. name: The name of the setting. Either setting_id or name must be passed. value: The value of the setting. Returns: The response. See :py:meth:`send_command` for details. """ if not setting_id and not name: raise RequiredArgument( function=self.modify_user_setting.__name__, argument="setting_id or name argument", ) if value is None: raise RequiredArgument( function=self.modify_user_setting.__name__, argument="value argument", ) cmd = XmlCommand("modify_setting") if setting_id: cmd.set_attribute("setting_id", setting_id) else: cmd.add_element("name", name) cmd.add_element("value", to_base64(value)) return self._send_xml_command(cmd)
def test_to_base64(self): foo64 = to_base64("foo") self.assertEqual(b"Zm9v", foo64) bar64 = to_base64("bar") self.assertEqual(b'YmFy', bar64)
def modify_scan_config_set_scanner_preference(self, config_id: str, name: str, *, value: Optional[str] = None ) -> Any: """Modifies the scanner preferences of an existing scan config Arguments: config_id: UUID of scan config to modify. name: Name of the scanner preference to change value: New value for the preference. None to delete the preference and to use the default instead. """ if not config_id: raise RequiredArgument( function=( self.modify_scan_config_set_scanner_preference.__name__), argument="config_id", ) if not name: raise RequiredArgument( function=( self.modify_scan_config_set_scanner_preference.__name__), argument="name argument", ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(config_id)) _xmlpref = cmd.add_element("preference") _xmlpref.add_element("name", name) if value: _xmlpref.add_element("value", to_base64(value)) return self._send_xml_command(cmd)