GithubHelp home page GithubHelp logo

Comments (15)

frakman1 avatar frakman1 commented on July 21, 2024 1

If you only want to see the failures, you can use the -m show_fail option

from kernel-hardening-checker.

a13xp0p0v avatar a13xp0p0v commented on July 21, 2024 1

Thanks @frakman1 !

I would propose creating a function colorize_result() and call several times to avoid copying the code.

from kernel-hardening-checker.

frakman1 avatar frakman1 commented on July 21, 2024 1

Done.
#86

from kernel-hardening-checker.

harisphnx avatar harisphnx commented on July 21, 2024

If so, I can make the change and create a PR

from kernel-hardening-checker.

a13xp0p0v avatar a13xp0p0v commented on July 21, 2024

Yes, it would be nice.
Looking forward to your PR.

from kernel-hardening-checker.

frakman1 avatar frakman1 commented on July 21, 2024

Has anyone done this yet?
I made a hacky attempt of this last year before the sysctl support was added. I added different colors for the two sections too:

image

I just tried to overlay it onto the latest code but it's too different now. My changes were in kconfig_hardened_check/__init__.py but everything has moved since then. Unfortunately, not an easy merge.

from kernel-hardening-checker.

a13xp0p0v avatar a13xp0p0v commented on July 21, 2024

@frakman1 thanks, it looks nice.
Could you give a link to your commit? I'll help to rebase it.

from kernel-hardening-checker.

frakman1 avatar frakman1 commented on July 21, 2024

Thank you @a13xp0p0v.
I just checked and my changes were based on this commit:

* 899752c - (Sun Oct 2 21:45:13 2022 +0300) Also check 'nospectre_v2' with 'spectre_v2' - <Alexander Popov> (HEAD -> master, origin/master, origin/HEAD)

Unfortunately, I never commited it and just stashed it before doing a git pull

Original File (rename to .py):
init.txt

Colored File (rename to .py):
init.color.txt

I created a patch file using:

git diff --no-index --patch --output=color.diff __init__.py __init__.color.py

patch file (optionally rename to .diff):
color.txt

from kernel-hardening-checker.

a13xp0p0v avatar a13xp0p0v commented on July 21, 2024

Thanks, I see the approach.

Let's print OK results in green and FAIL results in red.

We need to modify the table_print() method of classes in engine.py.

I would recommend something like that:

  1. defining ANSI escape sequences at the beginning of the file:
GREEN_COLOR = '\x1b[32m'
RED_COLOR = '\x1b[31m'
COLOR_END = '\x1b[0m'
  1. modify printing methods this way:
if with_results:
    if self.result.startswith('OK'):
        color = GREEN_COLOR
    elif self.result.startswith('FAIL:'):
        color = RED_COLOR
    else:
        assert(False), f'unexpected result "{self.result}"'
    colored_result = f'{color}{self.result}{COLOR_END}'
    print(f'| {colored_result}', end='')

What do you think?
Would you like to prepare a pull request?

Thanks!

from kernel-hardening-checker.

trclst avatar trclst commented on July 21, 2024

I would only going to color OK and FAIL not full line.
Besides, I don't know if there aren't more important things a | grep FAIL can do.
Maybe it is better to keep the code small, the information is still there whether in color or not.
Anyway hope it looks fancy.

from kernel-hardening-checker.

frakman1 avatar frakman1 commented on July 21, 2024

What do you think? Would you like to prepare a pull request?

I like it. Thank you for the guidance. I just attempted it and it seems I have to repeat that logic in three places before I could get all the prints.

sample output:

image

Diffs located in my fork here

@a13xp0p0v Let me know if that looks good. If so, I will issue a pull request.

from kernel-hardening-checker.

frakman1 avatar frakman1 commented on July 21, 2024

I've updated the code with your recommendations. See changes here

from kernel-hardening-checker.

a13xp0p0v avatar a13xp0p0v commented on July 21, 2024

I've left some comments. The main point: it's better to leave printing inside of the table_print() method. The colorize_result() function should only return the colored string.

from kernel-hardening-checker.

frakman1 avatar frakman1 commented on July 21, 2024

Changes applied here

from kernel-hardening-checker.

a13xp0p0v avatar a13xp0p0v commented on July 21, 2024

Good!

Please remove the unneeded whitespaces and send the pull request.

Looking forward to it.

from kernel-hardening-checker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.