On Friday August 14th. from 9 p.m. to 9:30 p.m., we will upgrade GitLab software and its cloud platform release. Service may not be available during this maintenance window. Please schedule your work accordingly.

Commit 8d32e83f authored by Marcello Golfieri's avatar Marcello Golfieri

added -P for purging hosts

parent e2577a3d
......@@ -132,8 +132,12 @@ class Qapi:
else:
return objectify.fromstring(response.text.encode("utf-8"))
def _post_xml(self, uri, params, headers=None, raw_output=False):
url = self.url + uri
def _post_xml(self, uri, params, headers=None, raw_output=False, get_params_mode=False):
if get_params_mode:
url = self.url + uri + "/" + self._make_get_params(params)
params={}
else:
url = self.url + uri
headers = self.headers if not headers else headers
response = requests.post(url, data=params, headers=headers, auth=self.auth)
logging.info("POST: {}, params: {}, response: {}".format(url, params, response))
......@@ -245,6 +249,11 @@ class Qapi:
)
return software_list
def purge_host(self, host):
params = {"action": "purge","ips": str(resolve_to_ip(host)), "echo_request":1}
oxml = self._post_xml("/api/2.0/fo/asset/host", params, get_params_mode=True)
return oxml.xpath("//*/text()")
def populate_agent_hosts(self):
oxml = self.get_agents_by_tag_xml(self.tag)
self.hosts = oxml.xpath("//data/HostAsset/dnsHostName")
......@@ -452,6 +461,12 @@ if __name__ == "__main__":
action="store_true",
help="shows assets info gathered via QCA, needs -H",
)
parser.add_argument(
"-P",
"--purge_host",
action="store_true",
help="Purge all data for a given host, needs -H",
)
parser.add_argument(
"-q",
"--qids",
......@@ -532,6 +547,8 @@ if __name__ == "__main__":
args.host, args.qids, args.comment, args.action, args.days_to_reopen
)
pprint(oxml.xpath("//*/text()"))
elif args.purge_host:
print(q.purge_host(args.host))
elif args.show_qca_asset_info:
print(q.get_asset_details_xml(args.host))
elif args.list_ignored_vulnerabilities:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment