def delete(self): app.logger.info("Trying to delete scanner...") Deployer(self.ov_deployment_id).delete() if self.session["ov_scan_id"] and self.session["ov_target_id"] and not Utils.is_gcp(): # Cleanup OpenVAS scan/target manually if local environment self.conn.delete_scan(self.session["ov_scan_id"]) self.conn.delete_target(self.session["ov_target_id"]) app.logger.info("Completed to delete scanner.")
def create(self): ov_server = Deployer(self.ov_deployment_id).create() self.session = { "ov_deployment_id": ov_server["uid"], "ov_host": ov_server["host"], "ov_port": ov_server["port"], "ov_scan_id": None, "ov_target_id": None, "target": None, } return self.session
def check_status(self): if Deployer(self.session["ov_deployment_id"]).is_restarted(): return ScanStatus.FAILED status = self.conn.get_scan_status(self.session["ov_scan_id"]) app.logger.info("Current scan progress={}, session={}".format( status, self.session)) # See https://github.com/greenbone/gvmd/blob/577f1b463f5861794bb97066dd0c9c4ab6c223df/src/manage.c#L1482 if status in ["New", "Running", "Requested"]: return ScanStatus.RUNNING elif status in ["Done"]: return ScanStatus.STOPPED else: return ScanStatus.FAILED
def __init__(self, session=None): self.ov_deployment_id = None self.ov_host = None self.ov_port = None self.user = os.getenv("OPENVAS_OMP_USERNAME", "admin") self.password = os.getenv("OPENVAS_OMP_PASSWORD", "admin") self.profile = os.getenv("OPENVAS_PROFILE", "Full and very deep") self.alive_test = os.getenv("OPENVAS_ALIVE_TEST", "Consider Alive") self.session = session if session: # Restore previous scanner session self.ov_deployment_id = session.get("ov_deployment_id") self.ov_host = session.get("ov_host") self.ov_port = session.get("ov_port") if self.ov_host and self.ov_port and Deployer(session["ov_deployment_id"]).is_ready(): self.conn = self._connect()
def is_ready(self): return Deployer(self.session["ov_deployment_id"]).is_ready()