Tenable ContainerSecurity simple pyTenable examplescript to list vulns associated with scanned containers

If you want or need to pull data of Tenables ContainerSecurity Solution which is part of the Tenable.io offering and aim to use the pyTenalbe API Wrapper then you might have stumbled over the fact that the associated documentation for the pyTenable Wrapper is not aimed at beginners and is not providing any complete example Scripts at all.

Search no more! Here is an example-script how to import the ContainerSecurity Wrapper, authenticate to Tenable.io/ContainerSecurity and pull all reports / vulns for all scanned containers:

#!/usr/bin/env python3

from tenable.cs import ContainerSecurity 

yourAccessKey = "xxx"
yourSecretKey = "xxx"

cs = ContainerSecurity(access_key=yourAccessKey, secret_key=yourSecretKey)

image = cs.images
for image in cs.images.list():
    report = cs.reports.report(image['digest'])
    print(image)
    print(report)

Hope this helps anybode out there starting to automate their vulnerability management process!

Props to Josh!

About SebastianB

read it in my blog
This entry was posted in miscellaneous and tagged , , , , , . Bookmark the permalink.