Skip to content

Commit 34e17e9

Browse files
committed
updated documentation. fixed sphinx.rst errors.
1 parent 7e7ca42 commit 34e17e9

12 files changed

Lines changed: 83 additions & 49 deletions

File tree

MANIFEST

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# file GENERATED by distutils, do NOT edit
2+
CHANGES.txt
3+
LICENSE.txt
4+
README.rst
5+
TODO
6+
setup.py
7+
docs/diff.rst
8+
docs/index.rst
9+
docs/objects.rst
10+
docs/parser.rst
11+
docs/plugins_s3.rst
12+
docs/process.rst
13+
libnmap/__init__.py
14+
libnmap/diff.py
15+
libnmap/parser.py
16+
libnmap/process.py
17+
libnmap/reportjson.py
18+
libnmap/objects/__init__.py
19+
libnmap/objects/cpe.py
20+
libnmap/objects/host.py
21+
libnmap/objects/os.py
22+
libnmap/objects/report.py
23+
libnmap/objects/service.py
24+
libnmap/plugins/__init__.py
25+
libnmap/plugins/backendplugin.py
26+
libnmap/plugins/backendpluginFactory.py
27+
libnmap/plugins/mongodb.py
28+
libnmap/plugins/s3.py
29+
libnmap/plugins/sql.py

docs/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ libnmap is a python toolkit for manipulating nmap. It currently offers the follo
1111
- report: enables you to manipulate a parsed scan result and de/serialize scan results in a json format
1212
- diff: enables you to see what changed between two scans
1313
- objects: contains basic nmap objects like NmapHost and NmapService. It is to note that each object can be "diff()ed" with another similar object.
14+
15+
- report: contains NmapReport class definition
16+
- host: contains NmapHost class definition
17+
- service: contains NmapService class definition
18+
- os: contains NmapOSFingerprint class definition and some other classes like NmapOSMatch, NmapOSClass,...
19+
- cpe: contains CPE class defdinition
20+
1421
- plugins: enables you to support datastores for your scan results directly in the "NmapReport" object from report module
1522

1623
- mongodb: only plugin implemented so far, ultra basic, for POC purpose only
@@ -35,6 +42,7 @@ The different modules are documented below:
3542
process
3643
parser
3744
objects
45+
objects/*
3846
diff
3947
plugins_s3
4048

docs/cpe.rst renamed to docs/objects/cpe.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
libnmap.objects.service
2-
=======================
1+
libnmap.objects.cpe
2+
===================
33

44
Using libnmap.objects.cpe module
55
--------------------------------
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/os.rst renamed to docs/objects/os.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@ NmapOSFingerprint methods
1616
NmapOSMatch methods
1717
-------------------
1818

19-
.. automodule:: libnmap.objects.os
2019
.. autoclass:: NmapOSMatch
2120
:members:
2221

2322
NmapOSClass methods
2423
-------------------
2524

26-
.. automodule:: libnmap.objects.os
2725
.. autoclass:: NmapOSClass
2826
:members:
2927

3028
OSFPPortUsed methods
3129
--------------------
3230

33-
.. automodule:: libnmap.objects.os
3431
.. autoclass:: OSFPPortUsed
3532
:members:

docs/process.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ Raw results of the scans will be available in the following properties:
1818
- NmapProcess.stdout: string, XML output
1919
- NmapProcess.stderr: string, text error message from nmap process
2020

21-
To instanciate a NmapProcess instance, call the constructor with appropriate parameters:
22-
.. automodule:: libnmap.process
23-
.. autoclass:: NmapProcess
24-
:members: __init__
25-
21+
To instanciate a NmapProcess instance, call the constructor with appropriate parameters
2622

2723
Processing of events
2824
--------------------
@@ -118,9 +114,10 @@ NmapProcess methods
118114
.. autoclass:: NmapProcess
119115
:members:
120116

117+
.. automethod:: __init__
118+
121119
NmapTask methods
122120
-------------------
123121

124-
.. automodule:: libnmap.process
125122
.. autoclass:: NmapTask
126123
:members:

libnmap/objects/os.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,11 @@ def get_osmatch(self, osclass_obj):
294294
object in order to respect the common interface for
295295
the nmap xml version < 1.04 and >= 1.04
296296
297-
:return: an NmapOSMatch object matching with the NmapOSClass
298-
provided in parameter (match is performed based on accuracy)
297+
This method will return an NmapOSMatch object matching with
298+
the NmapOSClass provided in parameter
299+
(match is performed based on accuracy)
300+
301+
:return: NmapOSMatch object
299302
"""
300303
rval = None
301304
for _osmatch in self.__osmatches:

libnmap/parser.py

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,21 @@ class NmapParser(object):
1111
def parse(cls, nmap_data=None, data_type='XML', incomplete=False):
1212
"""
1313
Generic class method of NmapParser class.
14+
1415
The data to be parsed does not need to be a complete nmap
1516
scan report. You can possibly give <hosts>...</hosts>
1617
or <port> XML tags.
1718
18-
:param nmap_data: any portion of nmap scan result.
19-
20-
nmap_data should always be a string representing a part
19+
:param nmap_data: any portion of nmap scan result. \
20+
nmap_data should always be a string representing a part \
2121
or a complete nmap scan report.
22-
2322
:type nmap_data: string
2423
2524
:param data_type: specifies the type of data to be parsed.
2625
:type data_type: string ("XML"|"JSON"|"YAML").
2726
28-
:param incomplete: enable you to parse interrupted nmap scans
29-
and/or incomplete nmap xml blocks by adding a </nmaprun> at
27+
:param incomplete: enable you to parse interrupted nmap scans \
28+
and/or incomplete nmap xml blocks by adding a </nmaprun> at \
3029
the end of the scan.
3130
:type incomplete: boolean
3231
@@ -51,12 +50,12 @@ def _parse_xml(cls, nmap_data=None, incomplete=False):
5150
In this case: XML. This method is called by cls.parse class
5251
method and receives nmap scan results data (in XML).
5352
54-
:param nmap_data: any portion of nmap scan result can be given
55-
as argument. nmap_data should always be a string representing
53+
:param nmap_data: any portion of nmap scan result can be given \
54+
as argument. nmap_data should always be a string representing \
5655
a part or a complete nmap scan report.
5756
:type nmap_data: string
5857
59-
This method checks which portion of a nmap scan is given
58+
This method checks which portion of a nmap scan is given \
6059
as argument.
6160
It could be:
6261
@@ -66,12 +65,12 @@ def _parse_xml(cls, nmap_data=None, incomplete=False):
6665
4. a list of hosts: <hosts/> tag (TODO)
6766
5. a list of ports: <ports/> tag
6867
69-
:param incomplete: enable you to parse interrupted nmap scans
70-
and/or incomplete nmap xml blocks by adding a </nmaprun> at
68+
:param incomplete: enable you to parse interrupted nmap scans \
69+
and/or incomplete nmap xml blocks by adding a </nmaprun> at \
7170
the end of the scan.
72-
7371
:type incomplete: boolean
74-
:return: NmapObject (NmapHost, NmapService or NmapReport)
72+
73+
:return: NmapObject (NmapHost, NmapService or NmapReport) \
7574
or a list of NmapObject
7675
"""
7776

@@ -140,19 +139,18 @@ def _parse_xml_report(cls, root=None):
140139
@classmethod
141140
def parse_fromstring(cls, nmap_data, data_type="XML", incomplete=False):
142141
"""
143-
Call generic cls.parse() method and ensure that a string is
142+
Call generic cls.parse() method and ensure that a string is \
144143
passed on as argument. If not, an exception is raised.
145144
146-
:param nmap_data: Same as for parse(), any portion of nmap scan.
147-
145+
:param nmap_data: Same as for parse(), any portion of nmap scan. \
148146
Reports could be passed as argument. Data type _must_ be a string.
149147
150148
:type nmap_data: string
151149
152150
:param data_type: Specifies the type of data passed on as argument.
153151
154-
:param incomplete: enable you to parse interrupted nmap scans
155-
and/or incomplete nmap xml blocks by adding a </nmaprun> at
152+
:param incomplete: enable you to parse interrupted nmap scans \
153+
and/or incomplete nmap xml blocks by adding a </nmaprun> at \
156154
the end of the scan.
157155
:type incomplete: boolean
158156
@@ -169,20 +167,18 @@ def parse_fromfile(cls, nmap_report_path,
169167
data_type="XML",
170168
incomplete=False):
171169
"""
172-
Call generic cls.parse() method and ensure that a correct file
170+
Call generic cls.parse() method and ensure that a correct file \
173171
path is given as argument. If not, an exception is raised.
174172
175-
:param nmap_data: Same as for parse().
176-
177-
Any portion of nmap scan reports could be passed as argument.
178-
179-
Data type _must be a valid path to a file containing
173+
:param nmap_data: Same as for parse(). \
174+
Any portion of nmap scan reports could be passed as argument. \
175+
Data type _must be a valid path to a file containing \
180176
nmap scan results.
181177
182178
:param data_type: Specifies the type of serialization in the file.
183179
184-
:param incomplete: enable you to parse interrupted nmap scans
185-
and/or incomplete nmap xml blocks by adding a </nmaprun> at
180+
:param incomplete: enable you to parse interrupted nmap scans \
181+
and/or incomplete nmap xml blocks by adding a </nmaprun> at \
186182
the end of the scan.
187183
:type incomplete: boolean
188184
@@ -200,9 +196,9 @@ def parse_fromfile(cls, nmap_report_path,
200196
@classmethod
201197
def parse_fromdict(cls, rdict):
202198
"""
203-
Strange method which transforms a python dict
204-
representation of a NmapReport and turns it into an
205-
NmapReport object.
199+
Strange method which transforms a python dict \
200+
representation of a NmapReport and turns it into an \
201+
NmapReport object. \
206202
Needs to be reviewed and possibly removed.
207203
208204
:param rdict: python dict representation of an NmapReport

0 commit comments

Comments
 (0)