Giter VIP home page Giter VIP logo

pytenable's Introduction

Welcome to pyTenable's documentation!

https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Ftenable%2FpyTenable%2Fbadge&label=build https://img.shields.io/badge/python-3.7%203.8%203.9%203.10%203.11-blue https://img.shields.io/pypi/dm/pytenable https://sonarcloud.io/api/project_badges/measure?project=tenable_pyTenable&metric=alert_status

pyTenable is intended to be a pythonic interface into the Tenable application APIs. Further by providing a common interface and a common structure between all of the various applications, we can ease the transition from the vastly different APIs between some of the products.

Installation

To install the most recent published version to pypi, its simply a matter of installing via pip:

pip install pytenable

If you're looking for bleeding-edge, then feel free to install directly from the github repository like so:

pip install git+git://github.com/tenable/pytenable.git#egg=pytenable

Getting Started

Lets assume that we want to get the list of scans that have been run on our Tenable.io application. Performing this action is as simple as the following:

from tenable.io import TenableIO
tio = TenableIO('TIO_ACCESS_KEY', 'TIO_SECRET_KEY')
for scan in tio.scans.list():
   print('{status}: {id}/{uuid} - {name}'.format(**scan))

Getting started with Tenable.sc is equally as easy:

from tenable.sc import TenableSC
sc = TenableSC('SECURITYCENTER_NETWORK_ADDRESS')
sc.login('SC_USERNAME', 'SC_PASSWORD')
for vuln in sc.analysis.vulns():
   print('{ip}:{pluginID}:{pluginName}'.format(**vuln))

For more detailed information on whats available, please refer to the pyTenable Documentation

Logging

Enabling logging for pyTenable is a simple matter of enabling debug logs through the python logging package. An easy example is detailed here:

import logging
logging.basicConfig(level=logging.DEBUG)

License

The project is licensed under the MIT license.

pytenable's People

Contributors

adabala-durga avatar alpesh-te avatar anilkumarg-delixus avatar archer31 avatar aseemsavio avatar bhavin-te avatar bkizer-tenable avatar dandamudi1414 avatar dheerajrp avatar hex052 avatar inayathulla avatar kalidor avatar lanz avatar levwais avatar mrtiz avatar mvalliammal avatar nkeuning avatar paulewog avatar rboergertenable avatar saizinbud avatar sifters avatar slallum avatar snyk-bot avatar starblast avatar stevemcgrath avatar streckc avatar tecnobabble avatar tushar-balwani avatar varap11 avatar widnyana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pytenable's Issues

Can't install on RHEL7 machine, pip issue with 'requests' module

Describe the bug
When attempting to install on a RHEL7 machine, we get the following error:

Installing collected packages: requests, python-dateutil, lxml, pytenable
Found existing installation: requests 2.6.0
Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

The pip version installed is 8.1.2-6, from EPEL, as package python2-pip

To Reproduce
Steps to reproduce the behavior:

  1. pip install pytenable
  2. See error

delete scan throws an error

Describe the bug
when deleting a scan, the scan deletes but it throws an error

To Reproduce
new = sc.scans.create(name=name, repo=repoID, policy_id=policy_id,
targets=[target_ip], description=description, max_time=max_time)

new_scan_id = int(new['id'])

running = sc.scans.launch(new_scan_id)
print('The Scan Result ID is {}'.format(running['scanResult']['id']))
sc.scans.delete(id=new_scan_id)

Expected behavior
the scan does delete, it just throws the following error

Screenshots
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tenable/sc/scans.py", line 424, in delete
).json()['response']['scans']

System Information (please complete the following information):
bash-3.2# uname -a
Darwin tns4361l.local 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar 5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64

Additional context
Add any other context about the problem here.

Document certificate based authentication for SC

Is your feature request related to a problem? Please describe.
SecurityCenter supports authenticating with only certificates, we need to support this for the Splunk app and federal customers

Describe the solution you'd like
The ability to authenticate using certificates rather than username/password.

Describe alternatives you've considered
Writing our own wrappers to do this.

Additional context
Heavily used in the fed sector and if implemented should let us swap out custom code for this library in the Tenable Add-On for Splunk. ๐Ÿ’ฏ

TSC AssetAPI

the asset_lists.py module should handle the Asset and Asset Template APIs. These APIs should be fully tested.

TSC BlackoutWindowAPI

the blackouts.py module should support the Blackout Windows API endpoints and by fully tested.

TSC ScannerAPI & ScanZoneAPI

The following Endpoints shall be pythonized and reside within the sensors.py module. These methods shall also be fully tested.

  • Scanners
  • Scan Zones

TSC SystemAPI & StatusAPI

The following API Endpoints shall be pythonized and reside within the system.py module. These methods shall be fully tested.

  • System
  • Status

Add latest vuln export filters to exports vulns function

Is your feature request related to a problem? Please describe.
I need the ability to use the latest filter fields available for the vuln export apis.

Describe the solution you'd like
Update exports.vulns to supports all new filter fields.

Describe alternatives you've considered
Writing my own wrapper to test all this.

Additional context
RDC-3860

TSC Reporting API Endpoints

the reports.py module should support the API endpoints noted below and be fully tested out.

  • Report
  • Report Definition
  • Report Image
  • Report Template
  • Style
  • StyleFamily

TSC TicketAPI

The Ticket endpoint shall be pythonized and reside within the tickets.py module. The methods shall be fully tested.

Add logging

Is your feature request related to a problem? Please describe.
Add logging everywhere that allows a developer to collect information about what is happening within there app based on this code for debugging

Describe the solution you'd like
Null logger by default that others could import/add to their apps logging to ensure proper debug logs can be provided. I.E. This is a must have for the splunk app. Most importantly is logging export UUID, but there are tons of other cases.

Describe alternatives you've considered
N/A

Additional context
Log all the things ๐Ÿฅ‡

TSC Dashboarding API Endpoints

The dashboards.py module should handle the following endpoints and be fully tested out:

  • Dashboard Tabs
  • Dashboard Templates
  • Dashboard Components

Policy Configure & Create should merge instead of being atomic.

tio.policies.configure and tio.policies.create both assume that the user will provide the full policy document. While this is possible, the user should net be forced down this path, and should instead only be forced to provide the details that they would like to modify on top of an existing template or policy (just like how scans works).

TSC ARC APIs

The SecurityCenter ARC and ARCTemplates APIs should be housed under the arcs.py module and by fully tested.

Add customizable app name for the UA string.

Is your feature request related to a problem? Please describe.
its hard to understand what apps are making what calls.

Describe the solution you'd like
The ability to specify the app name & version in the ua string

Describe alternatives you've considered
NA

Additional context
NA

Cannot import library in python 2.7 running on Mac OS X

Describe the bug
On Mac OS X running python 2.7.10, when trying to import the library it cannot find the module named tenable.io

To Reproduce

$ python
Python 2.7.10
>>> from tenable.io import TenableIO
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named tenable.io

Expected behavior
The module should be found and imported. It works fine in Python 3 on the same Mac OS X system:

Python 3.7.1 
Type "help", "copyright", "credits" or "license" for more information.
>>> from tenable.io import TenableIO
>>>

System Information (please complete the following information):

  • OS: Mac OS X running
  • Architecture 64 bit
  • Version python 2.7.10

Error in Analysis API

Describe the bug
Calling sc.analysis.scan(scan_id) throws the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/lib/python3.5/site-packages/tenable/sc/analysis.py", line 490, in scan
    return self.vuln(*filters, **kw)
AttributeError: 'AnalysisAPI' object has no attribute 'vuln'

Looks like perhaps it should be vulns()?

To reproduce
Steps to reproduce the behavior:

  1. Create a TenableSC object and authenticate with login()
  2. Call analysis.scan(scan_id)
  3. See error

Expected behavior
Vulnerability data from the provided scan_id is returned

System information (please complete the following information):

  • OS: Ubuntu 16.04
  • Architecture: 64bit
  • Version: pyTenable 0.3.6

Error in calling list with a datetime in the ScanAPI

Describe the bug
If the code calls scans.list with last_modified set to a datetime object as per the documentation and the _check in the code. It will error with the message "TypeError: Tuple or struct_time argument required"

To Reproduce
Steps to reproduce the behavior:
Example Code:

from datetime import datetime, timedelta
from tenable.tenable_io import TenableIO
thedate = datetime.now()
connector = TenableIO('key', 'pkey')
result = connector.scans.list(last_modified=thedate)
print(json.dumps(result, indent=4))

Expected behavior
No error and information be returned with with only scans that have been modified since the time specified

System Information (please complete the following information):

  • OS: Windows
  • Architecture 64-Bit
  • Version 3.5.2
  • Memory 16G

Error in Scans API

Describe the bug
Calling sc.scans.create() with a specified target(s) fails due to an apparent typo.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/tenable/sc/scans.py", line 301, in create
    scan = self._constructor(**kw)
  File "/usr/local/lib/python3.5/dist-packages/tenable/sc/scans.py", line 112, in _constructor
    del(kw['trargets'])
KeyError: 'trargets'

To Reproduce
Steps to reproduce the behavior:

  1. Create a TenableSC object and authenticate with login()
  2. Call create()
    • e.g. sc.scans.create(name="myName", repo=1, targets=[target_ip])
  3. See error

Expected behavior
The scan is created successfully.

System Information (please complete the following information):

  • OS: Windows 10
  • Architecture: 64bit
  • Memory: 12GB

SecurityCenter Scan Policy API Endpoints

The following API endpoints shall by pythonized and reside within the policies.py module. These methods shall be fully tested:

  • Scan Policy
  • Scan Policy Templates

TSC UserAPI

The User, Group, and Role API Endpoints shall be pythonized and reside within the user.py module. The methods within this module shall be fully tested.

Filters list is not added to query dictionary

Filters list is not added to query
sc.analysis in _analysis method for every filter tuple a dictionary object is created, but it's never added to query params, thus filters passed to sc.analysis.vulns are ignored and never passed to API, which always returns full unfiltered list of vulnerabilities.

To Reproduce
Assuming we have a list of vulnerabilities with both exploitAvailable=True and exploitAvailable=False. Steps to reproduce the behavior:

  1. run:
data = sc.analysis.vulns()
print(len(data))
  1. run:
data = sc.analysis.vulns(('exploitAvailable', '=', 'true'))
print(len(data))
  1. compare number of returned results

Expected behavior
data = sc.analysis.vulns(('exploitAvailable', '=', 'true')) data has only list of vulnerabilities with exploitAvailable=True

Bugfix
#42

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.