Skip to content

Quiet warnings about integer truncation #586

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

Merged
merged 1 commit into from
Mar 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions rules/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (

type insecureConfigTLS struct {
gosec.MetaData
MinVersion int16
MaxVersion int16
MinVersion int64
MaxVersion int64
requiredType string
goodCiphers []string
actualMinVersion int16
actualMaxVersion int16
actualMinVersion int64
actualMaxVersion int64
}

func (t *insecureConfigTLS) ID() string {
Expand Down Expand Up @@ -86,7 +86,7 @@ func (t *insecureConfigTLS) processTLSConfVal(n *ast.KeyValueExpr, c *gosec.Cont

case "MinVersion":
if ival, ierr := gosec.GetInt(n.Value); ierr == nil {
t.actualMinVersion = (int16)(ival)
t.actualMinVersion = ival
} else {
if se, ok := n.Value.(*ast.SelectorExpr); ok {
if pkg, ok := se.X.(*ast.Ident); ok && pkg.Name == "tls" {
Expand All @@ -97,7 +97,7 @@ func (t *insecureConfigTLS) processTLSConfVal(n *ast.KeyValueExpr, c *gosec.Cont

case "MaxVersion":
if ival, ierr := gosec.GetInt(n.Value); ierr == nil {
t.actualMaxVersion = (int16)(ival)
t.actualMaxVersion = ival
} else {
if se, ok := n.Value.(*ast.SelectorExpr); ok {
if pkg, ok := se.X.(*ast.Ident); ok && pkg.Name == "tls" {
Expand All @@ -117,8 +117,8 @@ func (t *insecureConfigTLS) processTLSConfVal(n *ast.KeyValueExpr, c *gosec.Cont
return nil
}

func (t *insecureConfigTLS) mapVersion(version string) int16 {
var v int16
func (t *insecureConfigTLS) mapVersion(version string) int64 {
var v int64
switch version {
case "VersionTLS13":
v = tls.VersionTLS13
Expand Down