Skip to content

Commit

Permalink
Adapt OR and AND checks to the new '*value*' check
Browse files Browse the repository at this point in the history
That is needed to fix these assertions:
```
  File "/home/a13x/land/develop/Linux_Kernel/kernel-hardening-checker/kernel_hardening_checker/engine.py", line 302, in check
    assert(opt.result.startswith('OK: is not off')), \
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: unexpected OK description "OK: in "lockdown,yama,integrity,apparmor,bpf,landlock""
```
and
```
  File "/home/a13x/land/develop/Linux_Kernel/kernel-hardening-checker/kernel_hardening_checker/engine.py", line 340, in check
    assert(opt.result == 'FAIL: is off, not found'), \
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: unexpected FAIL description "FAIL: not in "lockdown,yama,integrity,apparmor,bpf,landlock""
```
  • Loading branch information
a13xp0p0v committed Jan 22, 2025
1 parent 660daf6 commit d11e2ca
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel_hardening_checker/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ def check(self) -> None:
else:
if opt.result == 'OK':
self.result = f'OK: {opt.name} is "{opt.expected}"'
elif opt.result.startswith('OK: in \"'):
self.result = f'OK: "{opt.expected.strip("*")}" is in {opt.name}'
elif opt.result == 'OK: is not found':
self.result = f'OK: {opt.name} is not found'
elif opt.result == 'OK: is present':
Expand Down Expand Up @@ -330,6 +332,8 @@ def check(self) -> None:
else:
if opt.result.startswith('FAIL: \"') or opt.result == 'FAIL: is not found':
self.result = f'FAIL: {opt.name} is not "{opt.expected}"'
elif opt.result.startswith('FAIL: not in \"'):
self.result = f'FAIL: "{opt.expected.strip("*")}" is not in {opt.name}'
elif opt.result == 'FAIL: is not present':
self.result = f'FAIL: {opt.name} is not present'
elif opt.result in ('FAIL: is off', 'FAIL: is off, "0"', 'FAIL: is off, "is not set"'):
Expand Down

0 comments on commit d11e2ca

Please sign in to comment.