예제 #1
0
    def test_get_filenames_and_oids(self, mock_redis):
        ctx = mock_redis.return_value
        ctx.keys.return_value = ['nvt:1', 'nvt:2']
        ctx.lindex.side_effect = ['aa', 'ab']

        ret = OpenvasDB.get_filenames_and_oids(ctx)

        self.assertEqual(list(ret), [('aa', '1'), ('ab', '2')])
예제 #2
0
    def get_oids(self) -> Iterator[Tuple[str, str]]:
        """Get the list of NVT file names and OIDs.

        Returns:
            A i. Each single list contains the filename
            as first element and the oid as second one.
        """
        return OpenvasDB.get_filenames_and_oids(self.ctx)
예제 #3
0
    def get_oids(self) -> Iterator[Tuple[str, str]]:
        """Get the list of NVT file names and OIDs.

        Returns:
            An iterable of tuples of file name and oid.
        """
        if self.notus:
            for f, oid in self.notus.get_filenames_and_oids():
                yield (f, oid)
        if self.ctx:
            for f, oid in OpenvasDB.get_filenames_and_oids(self.ctx):
                if not self.notus or not self.notus.exists(oid):
                    yield (f, oid)
예제 #4
0
    def test_get_filenames_and_oids_error(self, mock_redis):
        ctx = mock_redis.return_value

        with self.assertRaises(RequiredArgument):
            OpenvasDB.get_filenames_and_oids(None)