Skip to content

RFE: Output uniformity #33

Description

@iranzo

Currently, scan.sh (as an example) gets this output:

bash -x scan.sh 
+ go run main.go -i rules/platform/etcd-cert-file.yaml
Ensure the etcd client certificate is set: true
+ go run main.go -i rules/platform/token-based-authentication-disabled.yaml
Verify that auth-token-files is not set in the openshfit-kube-apiserver configmap: true
+ go run main.go -i rules/platform/scc-required-drop-capabilities.yaml
Verify there is at least one Security Context Constraint that drops all container capabilities: true
+ go run main.go -i rules/platform/image-provenance.yaml
Warning: no such key: registrySources in images/cluster
Evaluation result: false
+ go run main.go -i rules/platform/identity-provider-google.yaml
Warning: no such key: identityProviders in oauths/cluster
Evaluation result: false
+ go run main.go -i rules/platform/identity-provider-configuration.yaml
Warning: no such key: identityProviders in oauths/cluster
Evaluation result: false
+ go run main.go -i rules/platform/network-policy.yaml
panic: the server could not find the requested resource

goroutine 1 [running]:
main.collect(0xc000334070)
        /root/cel-scanner-poc/main.go:230 +0x7e5
main.main()
        /root/cel-scanner-poc/main.go:54 +0x45
exit status 2

Return code for all the scripts is "0" except in the last case which is printed 'exit status 2' but return code on shell is 1.

In the cases that there's no data to process, there's a printed warning but it's sent to stdout instead of stderr:

image

It would be better to separate script output from other errors and use different return codes on shell depending on success, failure or panic (https://www.redhat.com/sysadmin/linux-shell-command-exit-codes)

https://pkg.go.dev/os#Exit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions