예제 #1
0
 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)
예제 #2
0
 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)
예제 #3
0
 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")
예제 #4
0
 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)
예제 #5
0
 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 _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)