Skip to content

--sql and gosec = G115 (CWE-190): integer overflow conversion uint -> int (Confidence: MEDIUM, Severity: HIGH) #252

@OlivierMary

Description

@OlivierMary

Hi,

Just to notify you when generate enum with --sql on func (x *Example) Scan(value interface{}) (err error) {

I got this gosec error:

Autofix:

[.....\enumsExample_enum.go:173] - G115 (CWE-190): integer overflow conversion uint -> int (Confidence: MEDIUM, Severity: HIGH)
    172:                }
  > 173:                *x = Example(*v)
    174:        case *uint64:

Autofix:

[....\enumsExample_enum.go:149] - G115 (CWE-190): integer overflow conversion uint -> int (Confidence: MEDIUM, Severity: HIGH)
    148:        case uint:
  > 149:                *x = Example(v)
    150:        case uint64:


enum file:

//go:generate go run github.com/abice/go-enum@v0.6.0 --marshal --names --noprefix --sql --lower  --values --mustparse --flag --nocamel --prefix=EXAMPLE_
package models

// ENUM(SUCCESS, FAIL, TIMEOUT, SKIPPED)
type Example int

gosec command:

go install github.com/securego/gosec/v2/cmd/gosec@latest
gosec ./...

I didn't see any way to dont generate this case (uint -> int) . Or with a full custom template...

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