Currently, this just uses Python's unittest module to autodiscover
tests, which may skip some, but is better than nothing. TODO: move tests
to their own module and let the zenmap_check target test them directly.
Replaced instances of this pattern:
if 'key' in somedict:
var = somedict['key']
else:
var = ""
...with this much simpler pattern:
var = somedict.get('key', "")
Some variations, like returning None if the key is not found were also
replaced.
Using the pep8 tool (https://pypi.python.org/pypi/pep8), fixed the
following style issues:
Count Issue
11 E201 whitespace after '['
8 E203 whitespace before ','
41 E211 whitespace before '('
11 E221 multiple spaces before operator
61 E225 missing whitespace around operator
237 E231 missing whitespace after ':'
91 E251 no spaces around keyword / parameter equals
19 E261 at least two spaces before inline comment
41 E301 expected 1 blank line, found 0
200 E302 expected 2 blank lines, found 1
356 E303 too many blank lines (2)
563 E501 line too long (106 characters)
39 E701 multiple statements on one line (colon)
13 E702 multiple statements on one line (semicolon)
4 W291 trailing whitespace
2 W293 blank line contains whitespace
8 W391 blank line at end of file
21 W601 .has_key() is deprecated, use 'in'
2 W602 deprecated form of raising exception
The remaining issues are long lines due to very deep data structures. I
chose not to alter them, as it would involve backslash-continuation
where whitespace is not permitted:
./zenmapGUI/ScanInterface.py:323:80: E501 line too long (90 characters)
./zenmapGUI/ScanInterface.py:456:80: E501 line too long (84 characters)
./zenmapGUI/ScanInterface.py:464:80: E501 line too long (84 characters)
./zenmapGUI/ScanInterface.py:472:80: E501 line too long (122 characters)
./zenmapGUI/ScanInterface.py:479:80: E501 line too long (122 characters)
./zenmapGUI/ScanInterface.py:920:80: E501 line too long (94 characters)
./zenmapGUI/ScanInterface.py:923:80: E501 line too long (93 characters)
./zenmapGUI/MainWindow.py:575:80: E501 line too long (99 characters)
./zenmapGUI/MainWindow.py:906:80: E501 line too long (99 characters)
When configuring --without-ncat, "make check" was trying to run Ncat's
test suite. This commit splits the check target into ncat_check and
nsock_check, and makes each conditional on that subsystem's configure
status.
Please read the documentation. This is a way to add unit testing to NSE
libraries (not scripts, yet). Please add tests to your libraries!
Examples to come in further commits.
Instead of erroring, just use tostring to handle functions, userdata,
etc. This works for booleans and numbers, too, so no need for special
handling there.
Also switched from a string-concatenation model to a table-building one,
with a final concatenation. This could prevent catastrophic slowness
with representing large tables due to continuous reallocation of
strings.
Just run "sh checklibs.sh". Currently checks liblua, libpcre, libpcap,
and prints the latest version of liblinear (no version info is in the
copy we have). Requires perl, curl, and a C compiler (cc).
Classes that inherit __hash__ and comparison functions like __eq__ (e.g.
from object) but only override one of them will break under Python 3.
This is because a class shouldn't use one criterion for equality and a
different one for hashing. Explicitly discarding the inherited __hash__
method disables this warning and makes the class unhashable (not a
problem in this case).
d33tah noticed that the # in "Fingerprint OpenBSD 5.0 GENERIC#43 i386"
was being interpreted as a comment, resulting in matches for "OpenBSD
5.0 GENERIC". Looking at this, it appears that no other OS fingerprints
put the build number in the Fingerprint line, and this fingerprint
closely matches another OpenBSD 5.0 fingerprint. Changed to drop
everything after GENERIC.
CPPFLAGS is for the C Pre-Processor, and should be used for -I flags. In
a couple cases (nping, nmap) this was resulting in duplicate -Ilibpcap
arguments.