Skip to content

Commit

Permalink
Add: option to enable feed signature check when using 'nasl-cli' as f…
Browse files Browse the repository at this point in the history
…eed updater (#940)
  • Loading branch information
jjnicola authored Oct 24, 2023
1 parent cdd05f9 commit 28837db
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
7 changes: 7 additions & 0 deletions ospd/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ def __init__(self, description: str) -> None:
' Default: %(default)s.'
),
)
parser.add_argument(
'-x',
'--signature-check',
default=False,
action='store_true',
help=('Enable feed signature check.' ' Default: %(default)s.'),
)

self.parser = parser

Expand Down
3 changes: 2 additions & 1 deletion ospd_openvas/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ def __init__(
)

self.feed_updater = feed_updater
self.signature_check = kwargs.get('signature_check')
self.nvti = NVTICache(self.main_db)

super().__init__(
Expand Down Expand Up @@ -647,7 +648,7 @@ def update_vts(self):
self.notus.reload_cache()
loaded = False
if self.feed_updater == "nasl-cli":
loaded = NASLCli.load_vts_into_redis()
loaded = NASLCli.load_vts_into_redis(self.signature_check)
else:
loaded = Openvas.load_vts_into_redis()

Expand Down
14 changes: 10 additions & 4 deletions ospd_openvas/openvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ class NASLCli:
"""Class for calling nasl-cli executable"""

@staticmethod
def load_vts_into_redis() -> bool:
def load_vts_into_redis(signature_check: bool) -> bool:
"""Loads all VTs into the redis database"""
try:
subprocess.check_call(
['nasl-cli', 'feed', 'update'], stdout=subprocess.DEVNULL
)
if signature_check:
subprocess.check_call(
['nasl-cli', 'feed', 'update', '-x'],
stdout=subprocess.DEVNULL,
)
else:
subprocess.check_call(
['nasl-cli', 'feed', 'update'], stdout=subprocess.DEVNULL
)
return True
except (subprocess.SubprocessError, OSError) as err:
logger.error('nasl-cli failed to load VTs. %s', err)
Expand Down

0 comments on commit 28837db

Please sign in to comment.