Skip to content

Errors not explicitly checked #160

@subpop

Description

@subpop

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions