giampaolo / psutil

Cross-platform lib for process and system monitoring in Python
BSD 3-Clause "New" or "Revised" License
10.08k stars 1.37k forks source link

[Windows] recognize "Secure System" process name #2338

Open giampaolo opened 6 months ago

giampaolo commented 6 months ago

Github CI has some failures due to a process called "Secure System". A google search reveals this process has to do with virtualization: https://www.elevenforum.com/t/secure-system-process-what-is-it.6810/.

$ tasklist
Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
System Idle Process              0 Services                   0          8 K
System                           4 Services                   0        148 K
Secure System                   56 Services                   0     38,872 K
...

Other than fixing the test failure, it would be nice if psutil recognized this process name() and returned "Secure System" instead of an empty string as it does right now. The failure:

2023-12-17T23:45:42.4088536Z ======================================================================
2023-12-17T23:45:42.4089296Z FAIL: psutil.tests.test_contracts.TestFetchAllProcesses.test_all
2023-12-17T23:45:42.4090008Z ----------------------------------------------------------------------
2023-12-17T23:45:42.4090436Z Traceback (most recent call last):
2023-12-17T23:45:42.4096739Z   File "D:\a\psutil\psutil\psutil\tests\test_contracts.py", line 455, in test_all
2023-12-17T23:45:42.4097401Z     raise self.fail(''.join(failures))
2023-12-17T23:45:42.4097992Z AssertionError:     
2023-12-17T23:45:42.4098300Z     ======================================================================
2023-12-17T23:45:42.4098691Z     FAIL: name=test_name, pid=56, ret=''
2023-12-17T23:45:42.4101743Z     info={'pid': 56, 'nice': <Priority.NORMAL_PRIORITY_CLASS: 32>, 'status': 'stopped', 'connections': [], 'cpu_affinity': [0, 1, 2, 3], 'name': '', 'num_handles': 0, 'threads': [], 'memory_info': pmem(rss=77824, vms=172032, num_page_faults=30, peak_wset=81920, wset=77824, peak_paged_pool=8552, paged_pool=8552, peak_nonpaged_pool=272, nonpaged_pool=272, pagefile=172032, peak_pagefile=172032, private=172032), 'username': 'NT AUTHORITY\\SYSTEM', 'cpu_times': pcputimes(user=0.0, system=0.0, children_user=0.0, children_system=0.0), 'num_threads': 0, 'num_ctx_switches': pctxsw(voluntary=0, involuntary=0), 'create_time': 1702854161.5116239, 'io_counters': pio(read_count=0, write_count=0, read_bytes=0, write_bytes=0, other_count=0, other_bytes=0), 'exe': '', 'ionice': <IOPriority.IOPRIO_NORMAL: 2>, 'ppid': 4}
2023-12-17T23:45:42.4104979Z     ----------------------------------------------------------------------
2023-12-17T23:45:42.4105610Z     Traceback (most recent call last):
2023-12-17T23:45:42.4106184Z       File "D:\a\psutil\psutil\psutil\tests\test_contracts.py", line 442, in test_all
2023-12-17T23:45:42.4106695Z         meth(value, info)
2023-12-17T23:45:42.4107152Z       File "D:\a\psutil\psutil\psutil\tests\test_contracts.py", line 496, in name
2023-12-17T23:45:42.4107626Z         assert ret, repr(ret)
2023-12-17T23:45:42.4107894Z     AssertionError: ''
2023-12-17T23:45:42.4108120Z     
2023-12-17T23:45:42.4108344Z     ======================================================================
2023-12-17T23:45:42.4108737Z     FAIL: name=test_num_threads, pid=56, ret=0
2023-12-17T23:45:42.4112536Z     info={'pid': 56, 'nice': <Priority.NORMAL_PRIORITY_CLASS: 32>, 'status': 'stopped', 'connections': [], 'cpu_affinity': [0, 1, 2, 3], 'name': '', 'num_handles': 0, 'threads': [], 'memory_info': pmem(rss=77824, vms=172032, num_page_faults=30, peak_wset=81920, wset=77824, peak_paged_pool=8552, paged_pool=8552, peak_nonpaged_pool=272, nonpaged_pool=272, pagefile=172032, peak_pagefile=172032, private=172032), 'username': 'NT AUTHORITY\\SYSTEM', 'cpu_times': pcputimes(user=0.0, system=0.0, children_user=0.0, children_system=0.0), 'num_threads': 0, 'num_ctx_switches': pctxsw(voluntary=0, involuntary=0), 'create_time': 1702854161.5116239, 'io_counters': pio(read_count=0, write_count=0, read_bytes=0, write_bytes=0, other_count=0, other_bytes=0), 'exe': '', 'ionice': <IOPriority.IOPRIO_NORMAL: 2>, 'ppid': 4}
2023-12-17T23:45:42.4115526Z     ----------------------------------------------------------------------
2023-12-17T23:45:42.4115922Z     Traceback (most recent call last):
2023-12-17T23:45:42.4116455Z       File "D:\a\psutil\psutil\psutil\tests\test_contracts.py", line 442, in test_all
2023-12-17T23:45:42.4116946Z         meth(value, info)
2023-12-17T23:45:42.4117424Z       File "D:\a\psutil\psutil\psutil\tests\test_contracts.py", line 567, in num_threads
2023-12-17T23:45:42.4117958Z         self.assertGreaterEqual(ret, 1)
2023-12-17T23:45:42.4118843Z       File "C:\Users\runneradmin\AppData\Local\pypa\cibuildwheel\Cache\nuget-cpython\python.3.6.8\tools\lib\unittest\case.py", line 1227, in assertGreaterEqual
2023-12-17T23:45:42.4119734Z         self.fail(self._formatMessage(msg, standardMsg))
2023-12-17T23:45:42.4120586Z       File "C:\Users\runneradmin\AppData\Local\pypa\cibuildwheel\Cache\nuget-cpython\python.3.6.8\tools\lib\unittest\case.py", line 670, in fail
2023-12-17T23:45:42.4121377Z         raise self.failureException(msg)
2023-12-17T23:45:42.4121762Z     AssertionError: 0 not greater than or equal to 1
giampaolo commented 6 months ago

Failing tests skipped in 8e574ff2.