CybercentreCanada / CCCS-Yara

YARA rule metadata specification and validation utility / Spécification et validation pour les règles YARA
MIT License
98 stars 19 forks source link

Feature Request: Treat Warnings as Errors #37

Closed JohnConnorRF closed 3 years ago

JohnConnorRF commented 3 years ago

Hey guys, your tool is amazing.

I would like a feature to make warnings get treated as errors.

In my workflow, I want to allow the metadata entry "hash" but don't want to allow "hash1, hash2, etc." Right now, if hash1 is included then a warning is thrown that it is similar to hash. I want that to be treated by an error.

If theres already a way to accomplish that, I'd happily take some advice on it.

Thanks again.

cccs-gm commented 3 years ago

Thank you very much.

Just to make sure I am understanding, you would like the ability to make certain warning get treated as errors? Given that the warning you are mentioning catches a lot of other items do you only specifically want to treat hash1, hash2, etc as errors but allow say reference1, reference2, etc?

I can think of a couple of different ways to accomplish this, potentially. But it really depends on if I am understanding the comment correctly.

JohnConnorRF commented 3 years ago

I think the simplest idea in my mind is just a cli flag like -strict or something that causes warnings to be considered errors. So in my own validation workflows I can choose to have a stricter mode.

Kind of like the opposite of the current -w flag where warnings are ignored.

JohnConnorRF commented 3 years ago

I guess the important thing is when there are errors the validation process exits with an error code (https://github.com/CybercentreCanada/CCCS-Yara/blob/master/yara_validator_cli.py#L282), I want the cli flag to say if there are one or more rules with warnings exit(99) as well.

cccs-gm commented 3 years ago

Ah... I need to double check something with my colleages. I have a suspicion that may have been an oversight. I think the original intent was to return a non-zero exit code when there are any warnings if the -w flag is not provided.

At this point it might make more sense to add a strict flag though, to minimize impact to other parties.

cccs-gm commented 3 years ago

Hello @JohnConnorRF could you take a look at the "https://github.com/CybercentreCanada/CCCS-Yara/tree/feature_add_strict_option_to_cli" and let me know if that meets your needs? Currently if the -st flag is used, no errors are encountered and warnings are encountered the cli will return a non-zero exit code of 49.

JohnConnorRF commented 3 years ago

Hey sorry for the long delay. The holidays were crazy. That commit works perfectly for my team's workflow! Thank you so much.

cccs-gm commented 3 years ago

Alright I request a code review to merge this into the master branch, have a great day.

cccs-jp commented 3 years ago

Alright I request a code review to merge this into the master branch, have a great day.

Please make a PR

cccs-gm commented 3 years ago

The feature has been merged. Have a great day!