Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

filter and exit code #61

Closed
markuman opened this issue Jun 9, 2021 · 2 comments · Fixed by #75
Closed

filter and exit code #61

markuman opened this issue Jun 9, 2021 · 2 comments · Fixed by #75

Comments

@markuman
Copy link

markuman commented Jun 9, 2021

I'd like to use whisper similar to trivy

whisper --exit-code 1 --severity CRITICAL
in this case, whisper should only list CRITICAL findings and end its process with exit code 1

@markuman
Copy link
Author

markuman commented Jun 9, 2021

my whipser-ci.py draft. Usage e.g. python whisper-ci.py --exit-code 1 --severity CRITICAL

from whispers.cli import parse_args
from whispers.core import run
import argparse
import sys

def _run(args):
    w_args = parse_args(["--rules", args.rules, "."])
    E = 0
    for secret in run(w_args):
        if secret.severity in args.severity:
            print(secret)
            E = args.exit_code
    return int(E)

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("--exit-code", help="exit code", default=0)
    parser.add_argument("--severity", help="severity", default='LOW,MEDIUM,HIGH,CRITICAL,BLOCK,MAJOR')
    parser.add_argument("--rules", help="rules", default='aws-secret,apikey,password,privatekey,secret,sensitive-files')

    args = parser.parse_args()
    sys.exit(_run(args))

@adeptex
Copy link
Contributor

adeptex commented Jun 17, 2021

hey @markuman, thanks for posting, makes sense 👍

I will see to add these features in the future release.

@adeptex adeptex mentioned this issue Aug 18, 2021
@adeptex adeptex mentioned this issue Sep 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants