Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
62eedad
update pip statement -- "python-libnessus"
matthillary Jan 14, 2016
176fd3a
Merge pull request #2 from matthillary/patch-1
bmx0r Jan 14, 2016
3535ead
Added Exception class file
Script-Nomad Nov 13, 2018
b709c6f
Created a new getter for cve value and also
Script-Nomad Nov 13, 2018
97c0b4f
Adjusted Travis.yml & fixed typo
Script-Nomad Nov 20, 2018
a2bfc7a
Workaround for failure to parse because of Nessus's No Creds plugin
Script-Nomad Nov 21, 2018
8227e87
Silence, travis!
Script-Nomad Jun 4, 2019
b607fdc
Fixed imports
Script-Nomad Jun 4, 2019
479d083
Moved python version up in .travis.yml
Script-Nomad Jun 4, 2019
41c8b6e
Moved python version up in .travis.yml
Script-Nomad Jun 4, 2019
51db42f
merge fix
Script-Nomad Jun 4, 2019
658d3d6
Remove python3.7 from build tests
Script-Nomad Jun 4, 2019
88bdf57
Merge pull request #3 from True-Demon/new/exception_classes
bmx0r Aug 15, 2019
d9b3967
update pipy credentials
bmx0r Aug 15, 2019
92c6ce5
update pipy credentials
bmx0r Aug 15, 2019
28ba6be
credentials....
bmx0r Aug 15, 2019
0327637
credentials....
bmx0r Aug 15, 2019
f647476
login....
bmx0r Aug 15, 2019
813da30
correct setup.py....
bmx0r Aug 15, 2019
0c4b5eb
Fixed setup installer and pypi packaging (#4)
Script-Nomad Aug 29, 2019
8c022fd
review setup.py
bmx0r Aug 29, 2019
39b5446
Move to version 1.0.0.10
bmx0r Aug 29, 2019
511c677
Fixed bug caused by a host with missing attributes. Error is raised w…
Script-Nomad Sep 2, 2019
72a6299
Fixed report logger bug & cleaned things up
Script-Nomad Sep 2, 2019
bc4ed69
Merge pull request #5 from True-Demon/bugfix/parser_missing_attribute…
Script-Nomad Oct 3, 2019
c631950
CVSS3 and Empty Solution (#6)
suidpit Feb 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
language: python
python:
- '2.6'
- '2.7'
- '3.3'
- '3.4'
- '3.5'
- '3.6'
services:
- elasticsearch
- mongodb
install:
- pip install pep8 --use-mirrors
- pip install pyflakes --use-mirrors
- pip install pep8
- pip install pyflakes
- pip install coveralls
- pip install jsonpickle
- pip install pymongo elasticsearch
- pip freeze
- python setup.py install
before_script:
- pep8 . --exclude test,docs,examples,build --ignore=W503,E123
- pyflakes libnessus/*.py
- sleep 10
script: nosetests --with-coverage --cover-package=libnessus
Expand All @@ -25,9 +24,9 @@ after_script:
after_success: coveralls
deploy:
provider: pypi
user: Michael.Boutillier
user: michael.boutillier
password:
secure: HqRFlOIZPM4GwfqetCHRIwFCorYqKN5qhk/Gfk6s17oEUz2xvuKUJ3W+TQMJzyGe57idc0U1ZQfmI2g2lcCEAvYx/CPEo9pFC1XOVfXZWbkvmnNYDUgtcDYnLNTOQ4d8JR14WK/muTjVgU2y8Pyo/+/5t7DqiLopFLikyKcNab8=
secure: GzFRAdLGSG0SYHzwSY/G1G3j+MqLLXineFEvMZYtlDfhRnGfFr9WdOiK/2NbGz0Uj6pF1iPj1ojZdKyn0INOuOyjICGQDzZCVky5gonCl8ZmulUqn1dwHGkNw5zlzfrrAz2ojjFmpE2W34j5NAUrEdfyLR9+nmtrpexAhLHRhbs=
on:
tags: true
repo: bmx0r/python-libnessus
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include TODO
include *.rst *.txt
include *.rst *.txt *.md
recursive-include docs *.rst
119 changes: 119 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
python-libnessus ==============

Code status
===========

[![Build
Status](https://travis-ci.org/bmx0r/python-libnessus.png?branch=master)](https://travis-ci.org/bmx0r/python-libnessus)
[![Coverage
Status](https://coveralls.io/repos/bmx0r/python-libnessus/badge.png?branch=master)](https://coveralls.io/r/bmx0r/python-libnessus?branch=master)
[![Code Health](https://landscape.io/github/bmx0r/python-libnessus/master/landscape.svg?style=flat)](https://landscape.io/github/bmx0r/python-libnessus/master)

Still in dev\...

About
=====

libnessue is a python library to manipulate nessus process and data.

libnessus is what you were looking for if you need to implement the
following: - manipulate nessus scans results to do reporting - compare
and diff nessus scans - store nessus scans in a datastore (mongo and
Elasticsearch supported)

In the future we might implement something to discuss with nessus API -
automate or schedule nessus scans on a regular basis - batch process
scan reports

Install
=======

Dependencies : You might need jsonpickle,elasticsearch,pymongo if you
want to use the backend plugins

You can install libnmap via pip:

pip install python-libnessus

or via git:

$ git clone https://github.com/bmx0r/python-libnessus.git
$ cd python-libnessus
$ python setup.py install

Model
=====

NessusReport:

``` {.pyton}
In [32]: report = NessusParser.parse_fromfile('/home/vagrant/python-libnessus/libnessus/test/files/nessus_forgedReport_ReportItem.nessus')
In [33]: report?
Type: NessusReport
String form: localpci 1 0:00:05
File: /home/vagrant/python-libnessus/libnessus/objects/report.py
Docstring:
This class represent a Nessus repport, it aims to manipulate
in a easy way the content, and present some metadata
Init docstring:
Description: Constructor of NessusReport
:param name: name of the report
:type name: str
:param hosts: list of NessusReportHost
:type hosts: list
:return: NessusReport
:rtype: NessusReport
```

NessusReportHost:

``` {.pyton}
In [34]: host = report.hosts[0]
In [35]: host?
Type: NessusReportHost
String form: 127.0.0.1 127.0.0.1 {'patch-summary-txt-79ed019e4b6ec5267fd968e511eccdb2': 'CentOS 6 : libtirpc ( <...> 2cda94fbf08': 'CentOS 5 / 6 : libxml2 (CESA-2013:0581): Update the affected libxml2 packages.')'} 5
File: /home/vagrant/python-libnessus/libnessus/objects/reporthost.py
Docstring: Description: Represent an object NessusReportHost in a nessus xml
```

NessusReportItem:

``` {.pyton}
In [36]: reportitem = host.get_report_items[3]
In [37]: reportitem?
Type: NessusReportItem
String form: 10544:Linux Multiple statd Packages Remote Format String 4
File: /home/vagrant/python-libnessus/libnessus/objects/reportitem.py
Docstring: This class represent a ReportItem in the nessus xml
Init docstring:
Constructor of Vulnerability
:param vuln_info: dict of vulnerabities as generated by
NessusParser.parse_reportitem
:type vuln_info: dict
```

Examples
========

Here\'s a basic example:

``` {.pyton}
# Parse a nessus report from xml and save it in Elastic search
In [1]: from libnessus.parser import NessusParser
In [3]: from libnessus.plugins.backendplugin import NessusBackendPlugin
In [4]: from libnessus.plugins.backendpluginFactory import BackendPluginFactory
In [5]: url = {'plugin_name': "es"}
In [6]: backend = BackendPluginFactory.create(\**url)
In [7]: nessus_obj_list = NessusParser.parse_fromfile('/home/vagrant/python-libnessus/libnessus/test/files/nessus_forgedReport_ReportItem.nessus')
In [8]: rc = nessus_obj_list.save(backend)
In [9]: rc
Out[9]: 2275333
In [10]: backend
Out[10]: <libnessus.plugins.es.NessusEsPlugin at 0x1dcc790>
In [11]: nessus_obj_list
Out[11]: localpci 1 0:00:05
#retrieve the report from ES
In [15]: ff = backend.get("2275333")
In [16]: ff
Out[16]: localpci 1 0:00:05
```
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ You might need jsonpickle,elasticsearch,pymongo if you want to use the backend p

You can install libnmap via pip::

pip install libnessus
pip install python-libnessus

or via git::

Expand Down
4 changes: 4 additions & 0 deletions libnessus/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class MissingAttribute(Exception):
"""Error when Nessus report items are missing essential properties"""
def __init__(self, *args, **kwargs):
Exception.__init__(self, "Report object is missing essential attributes", *args, **kwargs)
32 changes: 16 additions & 16 deletions libnessus/objects/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ class NessusReport(object):
in a easy way the content, and present some metadata
"""
def __init__(self, name, hosts):
'''
"""
Description: Constructor of NessusReport
:param name: name of the report
:type name: str
:param hosts: list of NessusReportHost
:type hosts: list
:return: NessusReport
:rtype: NessusReport
'''
"""
self.name = name
self.__hosts = hosts
self.__start = self.__compute_started(self.__hosts)
self.__end = self.__compute_ended(self.__hosts)

def __repr__(self):
'''
"""
Description: compute a string of the obj
:return: description de la valeur de retour
:rtype: str
'''
"""
return "{name} {total} {elapsed}".format(name=self.name,
total=self.hosts_total,
elapsed=self.elapsed)
Expand All @@ -43,13 +43,13 @@ def hosts(self):
return self.__hosts

def save(self, backend):
'''
"""
Description: allow to persist to a backend
:param backend: libnessus.plugins.PluginBackend object.
:type arg1: PluginBackend
:return: The primary key of the stored object is returned.
:rtype: str
'''
"""
try:
_id = backend.insert(self)
return _id
Expand All @@ -58,24 +58,24 @@ def save(self, backend):
raise

def iscomparable(self, other):
'''
"""
description: check if two obj are comparable
by checking the class name
:param other: nessusreport
:type other: nessusreport
:raises: typeerror if not comparable
'''
"""
if not isinstance(other, self.__class__):
raise TypeError(("non sense incompatibe object : ", self, other))

def __eq__(self, other):
'''
"""
Description: compare obj as equal
:param other: another report
:type other: NessusReport
:return: boolean
:rtype: boolean
'''
"""
try:
self.iscomparable(other)
rdict = self.diff(other)
Expand All @@ -89,13 +89,13 @@ def __eq__(self, other):
raise etyperr

def __ne__(self, other):
'''
"""
Description: compare obj as !=
:param other: another report
:type other: NessusReport
:return: boolean
:rtype: boolean
'''
"""
try:
self.iscomparable(other)
rdict = self.diff(other)
Expand All @@ -105,12 +105,12 @@ def __ne__(self, other):
raise etyperr

def __get_dict(self):
'''
"""
Description: get a dict representation of the object
Needed to transform the obj in a dict representation to use dictdiffer
:return: dict representation of the object
:rtype: dict
'''
"""
rdict = {}
rdict['name'] = self.name
hostitem = dict(
Expand All @@ -121,13 +121,13 @@ def __get_dict(self):
return rdict

def diff(self, other):
'''
"""
Description: diff object and provide the differences
:param other: obj to compare to
:type other: NessusReport
:return: a dict of all the differences
:rtype: dict
'''
"""
diff = DictDiffer(self.__get_dict(), other.__get_dict())
rdict = {}
rdict["removed"] = diff.removed()
Expand Down
Loading