greenbone / ospd

OSPd is a framework for vulnerability scanners which share the same communication protocol: OSP (Open Scanner Protocol)
GNU Affero General Public License v3.0
30 stars 36 forks source link

GetMemoryUsageTestCase fails on macos #458

Closed risicle closed 3 years ago

risicle commented 3 years ago

On macos 10.15, ospd 21.4.3, python 3.8, psutil 5.8.0:

______________ GetMemoryUsageTestCase.test_with_main_process_only ______________

self = <tests.command.test_commands.GetMemoryUsageTestCase testMethod=test_with_main_process_only>

    def test_with_main_process_only(self):
        cmd = GetMemoryUsage(None)

        request = et.fromstring('<get_memory_usage />')

>       response = et.fromstring(cmd.handle_xml(request))

tests/command/test_commands.py:458: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
ospd/command/command.py:672: in handle_xml
    self._add_memory_info(process_element, current_process.pid, unit)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'ospd.command.command.GetMemoryUsage'>
process_element = <Element 'process' at 0x1098dab80>, pid = 49273, unit = None

    @classmethod
    def _add_memory_info(
        cls, process_element: Element, pid: int, unit: str = None
    ):
        try:
            ps_process = psutil.Process(pid)
        except psutil.NoSuchProcess:
            return

        memory = ps_process.memory_info()

        rss_element = Element('rss')
        rss_element.text = cls._get_memory(memory.rss, unit)

        process_element.append(rss_element)

        vms_element = Element('vms')
        vms_element.text = cls._get_memory(memory.vms, unit)

        process_element.append(vms_element)

        shared_element = Element('shared')
>       shared_element.text = cls._get_memory(memory.shared, unit)
E       AttributeError: 'pmem' object has no attribute 'shared'

ospd/command/command.py:659: AttributeError

The other GetMemoryUsageTestCase tests fail similarly. The psutil docs suggest that shared is only available on linux.

y0urself commented 3 years ago

Our System (especially https://github.com/greenbone/openvas-scanner, https://github.com/greenbone/gvm-libs, https://github.com/greenbone/gvmd) will not work on MacOS at all, so we won't fix this.