Skip to content

Commit

Permalink
tools: neuvector_api: fix Ruff linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pna-nca committed May 3, 2024
1 parent 907f638 commit 658b76a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions dojo/tools/neuvector_api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, tool_config=None):

self.login()


def login(self):
"""
Login on NeuVector and get token.
Expand All @@ -56,6 +57,7 @@ def login(self):
resp.status_code, resp.content.decode("utf-8")
))


def logout(self):
"""
Logout from NeuVector.
Expand All @@ -70,6 +72,7 @@ def logout(self):
}
requests.delete(url, headers=headers)


def get_all_vp(self):
"""
Returns all vulnerability profiles with 'default' name.
Expand All @@ -89,6 +92,7 @@ def get_all_vp(self):
resp.status_code, resp.content.decode("utf-8")
))


def create_vulnerability_profile(self, vp_id, name, comment, namespaces=[], images=[]):
"""
Creates a vulnerability profile in 'default' name with the provided parameters.
Expand Down Expand Up @@ -118,6 +122,7 @@ def create_vulnerability_profile(self, vp_id, name, comment, namespaces=[], imag
resp.status_code, resp.content.decode("utf-8"), json.dumps(params)
))


def update_vulnerability_profile(self, vp_id, name, comment, namespaces=[], images=[]):
"""
Updates a vulnerability profile in 'default' name with the provided parameters.
Expand Down Expand Up @@ -152,6 +157,7 @@ def update_vulnerability_profile(self, vp_id, name, comment, namespaces=[], imag
resp.status_code, resp.content.decode("utf-8"), json.dumps(params)
))


def delete_vulnerability_profile(self, vp_id):
"""
Deletes vulnerability profile in 'default' name.
Expand All @@ -171,6 +177,7 @@ def delete_vulnerability_profile(self, vp_id):
resp.status_code, resp.content.decode("utf-8")
))


def test_connection(self):
"""
Returns number of namespaces or raises error.
Expand Down
5 changes: 4 additions & 1 deletion dojo/tools/neuvector_api/updater.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import json

from django.core.exceptions import ValidationError
from dojo.tools.neuvector_api.api_client import NeuVectorAPI
from dojo.tools.neuvector.parser import NEUVECTOR_IMAGE_SCAN_ENGAGEMENT_NAME
from dojo.tools.neuvector.parser import NEUVECTOR_CONTAINER_SCAN_ENGAGEMENT_NAME
Expand All @@ -26,6 +25,7 @@ def determine_namespaces(finding):
pass
return namespaces


def determine_images(finding):
images = []
if finding.test.engagement.name != NEUVECTOR_IMAGE_SCAN_ENGAGEMENT_NAME:
Expand All @@ -45,6 +45,7 @@ def determine_images(finding):

return images


def find_free_id(client):
vps = client.get_all_vp()
if (not vps) or (len(vps) == 0):
Expand All @@ -54,6 +55,7 @@ def find_free_id(client):
vp_id += 1
return vp_id


def find_id(client, name, namespaces=[], images=[]):
ns_set_orig = set(namespaces)
im_set_orig = set(images)
Expand All @@ -64,6 +66,7 @@ def find_id(client, name, namespaces=[], images=[]):
return vp['id']
return -1


def produce_comment(finding):
comment = "risk accepted in DefectDojo"

Expand Down

0 comments on commit 658b76a

Please sign in to comment.