Skip to content

Commit

Permalink
Merge pull request #509 from Patrowl/ARS-487-nmap-bug-hostname-ptr
Browse files Browse the repository at this point in the history
ARS-487 - nmap - avoid PTR hostname during parsing
  • Loading branch information
sebastien-powl authored Jul 19, 2024
2 parents 587f31a + 80f1754 commit b754474
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 19 deletions.
20 changes: 10 additions & 10 deletions engines/nmap/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM alpine:3.16.3
LABEL Name="Nmap\ \(Patrowl engine\)" Version="1.5.0"
LABEL Name="Nmap\ \(Patrowl engine\)" Version="1.5.1"

# Set the working directory
RUN mkdir -p /opt/patrowl-engines/nmap
Expand All @@ -19,15 +19,15 @@ COPY libs/ libs/

# Install any needed packages specified in requirements.txt
RUN apk add --update \
linux-headers \
libffi-dev \
#sudo \
python3 \
python3-dev \
py3-pip \
build-base \
nmap \
nmap-scripts \
linux-headers \
libffi-dev \
#sudo \
python3 \
python3-dev \
py3-pip \
build-base \
nmap \
nmap-scripts \
#&& adduser -u 1000 -G wheel -D alpine \
&& rm -rf /var/cache/apk/*

Expand Down
2 changes: 1 addition & 1 deletion engines/nmap/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.0
1.5.1
10 changes: 5 additions & 5 deletions engines/nmap/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

__title__ = 'patrowl_engine_nmap'
__version__ = '1.5.0'
__author__ = 'Nicolas MATTIOCCO'
__license__ = 'AGPLv3'
__copyright__ = 'Copyright (C) 2018-2022 Nicolas Mattiocco - @MaKyOtOx'
__title__ = "patrowl_engine_nmap"
__version__ = "1.5.1"
__author__ = "Nicolas MATTIOCCO"
__license__ = "AGPLv3"
__copyright__ = "Copyright (C) 2018-2024 Nicolas Mattiocco - @MaKyOtOx"
17 changes: 15 additions & 2 deletions engines/nmap/engine-nmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ def clean():
@app.route("/engines/nmap/clean/<scan_id>")
def clean_scan(scan_id):
"""Clean scan identified by id."""
if scan_id not in engine.scans.keys():
return (
jsonify(
{
"status": "error",
"reason": f"Error 1002: scan_id '{scan_id}' not found",
}
),
503,
)
return engine.clean_scan(scan_id)


Expand Down Expand Up @@ -568,7 +578,8 @@ def _parse_report(filename, scan_id):
# Find hostnames
for hostnames in host.findall("hostnames"):
for hostname in list(hostnames):
if hostname.get("type") in ["user", "PTR"]:
# if hostname.get("type") in ["user", "PTR"]:
if hostname.get("type") == "user":
has_hostnames = True
addr = hostname.get("name")
addr_list.append(hostname.get("name"))
Expand All @@ -592,6 +603,8 @@ def _parse_report(filename, scan_id):
if has_hostnames:
for hostnames in host.findall("hostnames"):
for hostname in list(hostnames):
if hostname.get("type") != "user":
continue
ip_address = str(host.find("address").get("addr"))
issues.append(
deepcopy(
Expand Down Expand Up @@ -1049,7 +1062,7 @@ def getfindings(scan_id):
os.remove(hosts_filename)

# remove the scan from the active scan list
engine.clean_scan(scan_id)
# engine.clean_scan(scan_id)

res.update({"summary": summary, "issues": issues, "status": "success"})
return jsonify(res)
Expand Down
2 changes: 1 addition & 1 deletion engines/nmap/nmap.json.sample
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Nmap",
"version": "1.5.0",
"version": "1.5.1",
"description": "Network Scanner",
"path": "/usr/bin/nmap",
"allowed_asset_types": ["ip", "domain", "fqdn", "url", "ip-range", "ip-subnet"],
Expand Down

0 comments on commit b754474

Please sign in to comment.