def handle_event(self, event): CfgGenerator.handle_event(self, event) if self.data is None: return # todo: let the user specify a passphrase by name try: self.data = bruteforce_decrypt(self.data, setup=SETUP, algorithm=get_algorithm(SETUP)) except EVPError: raise PluginExecutionError("Failed to decrypt %s" % self.name)
def _instantiate(self, cls, fileobj, filepath, filename, encoding=None): plaintext = \ StringIO(bruteforce_decrypt(fileobj.read(), algorithm=get_algorithm(SETUP))) return TemplateLoader._instantiate(self, cls, plaintext, filepath, filename, encoding=encoding)
def _decrypt(self, element): """ Decrypt a single encrypted properties file element """ if not element.text.strip(): return passes = get_passphrases(SETUP) try: passphrase = passes[element.get("encrypted")] try: return ssl_decrypt(element.text, passphrase, algorithm=get_algorithm(SETUP)) except EVPError: # error is raised below pass except KeyError: # bruteforce_decrypt raises an EVPError with a sensible # error message, so we just let it propagate up the stack return bruteforce_decrypt(element.text, passphrases=passes.values(), algorithm=get_algorithm(SETUP)) raise EVPError("Failed to decrypt")
def handle_event(self, event): CfgGenerator.handle_event(self, event) if self.data is None: return # todo: let the user specify a passphrase by name try: self.data = bruteforce_decrypt(self.data, setup=SETUP, algorithm=get_algorithm(SETUP)) except EVPError: msg = "Failed to decrypt %s" % self.name LOGGER.error(msg) raise PluginExecutionError(msg)