def __post_init__(self): connection: TLSConnection = TLSConnection(hostname=self.hostname.ip, timeout=5) self.gmp: Gmp = Gmp(connection) try: response: str = self.gmp.authenticate(self.user, self.password) soup: BeautifulSoup = BeautifulSoup(response, 'xml') if int(soup.authenticate_response['status']) != 200: # print(soup.authenticate_response.attrs) self.print_and_exit(soup.authenticate_response['status_text']) except OSError: self.print_and_exit(f"Timeout connect Openvas {self.hostname.ip}") self.export = { 'PDF': 'c402cc3e-b531-11e1-9163-406186ea4fc5', 'XML': 'a994b278-1f62-11e1-96ac-406186ea4fc5', 'LATEX': 'a684c02c-b531-11e1-bdc2-406186ea4fc5', 'HTML': '6c248850-1f62-11e1-b082-406186ea4fc5' }
def create_connection(): """ **Creates the connection* This function allows user to create a connection with openvas manager using gvm. The UnixSocketConnection function takes as a parameter a path that leads to openvasmd socket file (/var/run/openvasmd.sock) that exists in the VM that runs OpenVAS manager. Read rights must be granted (sudo chmod a+rwx openvasmd.sock) :return: The connection that gives access to the OpenVAS interface. """ subprocess.call(["sudo", "./config.sh"]) connection = UnixSocketConnection(path='/var/run/gvmd.sock') # transform = EtreeTransform() gmp = Gmp(connection) # version = gmp.get_version() gmp.authenticate('admin', 'admin') return gmp
def setUp(self): self.connection = MockConnection() self.gmp = Gmp(self.connection)