Skip to content

Commit

Permalink
Add method to add a vt in cache
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed Sep 16, 2020
1 parent c6d91b2 commit 4a5f8b2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ospd_openvas/nvticache.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

from typing import List, Dict, Optional, Iterator, Tuple

from ospd.errors import RequiredArgument
from ospd_openvas.errors import OspdOpenvasError
from ospd_openvas.db import NVT_META_FIELDS, OpenvasDB, MainDB, BaseDB, RedisCtx

NVTI_CACHE_NAME = "nvticache"
Expand Down Expand Up @@ -306,3 +308,15 @@ def get_nvt_count(self) -> int:

def force_reload(self):
self._main_db.release_database(self)

def add_vt_to_cache(self, vt_id: str, vt: List[str]):
if not vt_id:
raise RequiredArgument('add_vt_to_cache', 'vt_id')
if not vt:
raise RequiredArgument('add_vt_to_cache', 'vt')
if not isinstance(vt, list) or len(vt) != 15:
raise OspdOpenvasError(
'Error trying to load the VT' ' {} in cache'
).format(vt)

OpenvasDB.add_single_list(self.ctx, vt_id, vt)

0 comments on commit 4a5f8b2

Please sign in to comment.