lint: Clean up golangci-lint v1.60 complaints
This cleans up the linting results by adding checks for integer underflow/overflow in several places, suppressing the error in places where it has been checked, or fixing the types when possible.
This commit is contained in:
parent
2dad1a965e
commit
0256e09031
11 changed files with 47 additions and 12 deletions
|
|
@ -144,6 +144,8 @@ func (d DirectoryCustomization) ToFsNodeDirectory() (*fsnode.Directory, error) {
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid mode %s: %v", d.Mode, err)
|
||||
}
|
||||
// modeNum is parsed as an unsigned 32 bit int
|
||||
/* #nosec G115 */
|
||||
mode = common.ToPtr(os.FileMode(modeNum))
|
||||
}
|
||||
|
||||
|
|
@ -302,6 +304,8 @@ func (f FileCustomization) ToFsNodeFile() (*fsnode.File, error) {
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid mode %s: %v", f.Mode, err)
|
||||
}
|
||||
// modeNum is parsed as an unsigned 32 bit int
|
||||
/* #nosec G115 */
|
||||
mode = common.ToPtr(os.FileMode(modeNum))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ func newNetworkNamespace() (NetNS, error) {
|
|||
return "", fmt.Errorf("cannot unshare the network namespace")
|
||||
}
|
||||
defer func() {
|
||||
// The Fd() is actually an int cast into a uintptr, so casting back to an int is fine
|
||||
/* #nosec G115 */
|
||||
err = unix.Setns(int(oldNS.Fd()), syscall.CLONE_NEWNET)
|
||||
if err != nil {
|
||||
// We cannot return to the original namespace.
|
||||
|
|
|
|||
|
|
@ -464,7 +464,13 @@ func (h *apiHandlers) getJobIDComposeStatus(jobId uuid.UUID) (ComposeStatus, err
|
|||
ImageStatuses: &buildJobStatuses,
|
||||
KojiStatus: &KojiStatus{},
|
||||
}
|
||||
/* #nosec G115 */
|
||||
buildID := int(initResult.BuildID)
|
||||
// Make sure signed integer conversion didn't underflow
|
||||
if buildID < 0 {
|
||||
err := fmt.Errorf("BuildID integer underflow: %d", initResult.BuildID)
|
||||
return ComposeStatus{}, HTTPErrorWithInternal(ErrorMalformedOSBuildJobResult, err)
|
||||
}
|
||||
if buildID != 0 {
|
||||
response.KojiStatus.BuildId = &buildID
|
||||
}
|
||||
|
|
|
|||
|
|
@ -574,7 +574,7 @@ func GSSAPICredentialsFromEnv() (*GSSAPICredentials, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
func CreateKojiTransport(relaxTimeout uint) http.RoundTripper {
|
||||
func CreateKojiTransport(relaxTimeout time.Duration) http.RoundTripper {
|
||||
// Koji for some reason needs TLS renegotiation enabled.
|
||||
// Clone the default http rt and enable renegotiation.
|
||||
rt := CreateRetryableTransport()
|
||||
|
|
@ -588,9 +588,9 @@ func CreateKojiTransport(relaxTimeout uint) http.RoundTripper {
|
|||
|
||||
// Relax timeouts a bit
|
||||
if relaxTimeout > 0 {
|
||||
transport.TLSHandshakeTimeout *= time.Duration(relaxTimeout)
|
||||
transport.TLSHandshakeTimeout *= relaxTimeout
|
||||
transport.DialContext = (&net.Dialer{
|
||||
Timeout: 30 * time.Second * time.Duration(relaxTimeout),
|
||||
Timeout: 30 * time.Second * relaxTimeout,
|
||||
KeepAlive: 30 * time.Second,
|
||||
}).DialContext
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue