Skip to content

Commit

Permalink
Merge branch 'tkt_223_filter_scans_by_status_completed' into 'dev'
Browse files Browse the repository at this point in the history
Fix tenable SC agent

Closes #223

See merge request faradaysec/cloud/faraday_agent_dispatcher!165
  • Loading branch information
Diego Nadares committed Jun 26, 2024
2 parents 0fb3a18 + 432eb12 commit 26e83a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG/current/223.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[FIX] Implemented scan filtering by 'completed' status in Tenable SC Agent to prevent parsing errors. #223
17 changes: 15 additions & 2 deletions faraday_agent_dispatcher/static/executors/official/tenablesc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io
import sys
import zipfile as zp

from tenable.sc import TenableSC
from faraday_plugins.plugins.repo.nessus.plugin import NessusPlugin

Expand All @@ -13,8 +14,11 @@ def log(msg):

def get_only_usable_ids(tsc, scan_ids):
tenable_scans = tsc.scan_instances.list()
usable_tenable_scans = [str(scan["id"]) for scan in tenable_scans["usable"]]
usable_tenable_scans = [str(scan["id"]) for scan in tenable_scans["usable"] if scan["status"] == "Completed"]
log("*" * 10)
log("Listing available scans ...")
log(usable_tenable_scans)
log("*" * 10)
return [_id for _id in scan_ids if str(_id) in usable_tenable_scans]


Expand Down Expand Up @@ -81,7 +85,16 @@ def main():
tsc = TenableSC(host=TENABLE_HOST, access_key=TENABLE_ACCESS_KEY, secret_key=TENABLE_SECRET_KEY)
usable_scan_ids = get_only_usable_ids(tsc, tenable_scan_ids_list)

log(usable_scan_ids)
if not usable_scan_ids:
log("*" * 10)
log("No Scan matched ...")
log("*" * 10)
exit(1)

log("*" * 10)
log("Scans matched ...")
log(f"{usable_scan_ids}")
log("*" * 10)

responses = []
for scan_id in usable_scan_ids:
Expand Down

0 comments on commit 26e83a4

Please sign in to comment.