Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors not explicitly checked #160

Open
subpop opened this issue Sep 14, 2023 · 0 comments
Open

Errors not explicitly checked #160

subpop opened this issue Sep 14, 2023 · 0 comments
Labels
good first issue Good for newcomers

Comments

@subpop
Copy link
Collaborator

subpop commented Sep 14, 2023

Running the package through a static analyzer found the following errors not being checked:

#    29|   				fmt.Fprintf(w, "--%v\n", name)
#    30|   			} else {
#    31|-> 				fmt.Fprintf(w, "-%v\n", name)
#    32|   			}
#    33|   		}
1. rhc/yggdrasil-0.2.2/internal/util.go:29: suppressed_error: The error returned by the function "Fprintf(w, "--%v\n", name)" is not explicitly checked.
2. rhc/yggdrasil-0.2.2/internal/util.go:29: remediation: Explicitly check the return error.
#    27|   		for _, name := range flag.Names() {
#    28|   			if len(name) > 1 {
#    29|-> 				fmt.Fprintf(w, "--%v\n", name)
#    30|   			} else {
#    31|   				fmt.Fprintf(w, "-%v\n", name)
1. rhc/yggdrasil-0.2.2/internal/util.go:14: suppressed_error: The error returned by the function "Fprintf(w, "%v\n", name)" is not explicitly checked.
2. rhc/yggdrasil-0.2.2/internal/util.go:14: remediation: Explicitly check the return error.
#    12|   func BashCompleteCommand(cmd *cli.Command, w io.Writer) {
#    13|   	for _, name := range cmd.Names() {
#    14|-> 		fmt.Fprintf(w, "%v\n", name)
#    15|   	}
#    16|   
1. rhc/yggdrasil-0.2.2/cmd/yggd/main.go:167: insufficient_logging: Calling "parseCertCN". This function call creates a logging obligation.
2. rhc/yggdrasil-0.2.2/cmd/yggd/main.go:167: assign: Assigning: "err" = "parseCertCN(c.String("cert-file"))".
3. rhc/yggdrasil-0.2.2/cmd/yggd/main.go:170: insufficient_logging: This branch is missing logging after the method call.
4. rhc/yggdrasil-0.2.2/cmd/yggd/main.go:168: insufficient_logging: Condition is checking a possible error value.
5. rhc/yggdrasil-0.2.2/cmd/yggd/main.go:168: remediation: Log this issue to improve detection and response to security incidents.
#   166|   
#   167|   		ClientID, err = parseCertCN(c.String("cert-file"))
#   168|-> 		if err != nil {
#   169|   			return cli.Exit(fmt.Errorf("cannot parse certificate: %w", err), 1)
#   170|   		}
1. rhc/yggdrasil-0.2.2/cmd/ygg/register.go:177: suppressed_error: The error returned by the function "dst.Close()" is not explicitly checked.
2. rhc/yggdrasil-0.2.2/cmd/ygg/register.go:177: remediation: Explicitly check the return error.
#   175|   		}
#   176|   		src.Close()
#   177|-> 		dst.Close()
#   178|   	}
#   179|   
1. rhc/yggdrasil-0.2.2/cmd/ygg/register.go:176: suppressed_error: The error returned by the function "src.Close()" is not explicitly checked.
2. rhc/yggdrasil-0.2.2/cmd/ygg/register.go:176: remediation: Explicitly check the return error.
#   174|   			return fmt.Errorf("cannot backup rhsm.conf: %w", err)
#   175|   		}
#   176|-> 		src.Close()
#   177|   		dst.Close()
#   178|   	}
1. rhc/yggdrasil-0.2.2/cmd/ygg/main.go:248: suppressed_error: The error returned by the function "w.Flush()" is not explicitly checked.
2. rhc/yggdrasil-0.2.2/cmd/ygg/main.go:248: remediation: Explicitly check the return error.
#   246|   						fmt.Fprintf(w, "%v\t%v\n", k, facts[k])
#   247|   					}
#   248|-> 					w.Flush()
#   249|   				default:
#   250|   					return cli.Exit(fmt.Errorf("unsupported value for '--format': %v", c.String("format")), 1)
@subpop subpop added the good first issue Good for newcomers label Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant