Skip to content

fix linting issues#325

Open
thaJeztah wants to merge 2 commits into
microsoft:mainfrom
thaJeztah:fix_linting
Open

fix linting issues#325
thaJeztah wants to merge 2 commits into
microsoft:mainfrom
thaJeztah:fix_linting

Conversation

@thaJeztah

Copy link
Copy Markdown
Contributor

@thaJeztah
thaJeztah requested a review from a team as a code owner January 10, 2025 23:23
@thaJeztah

Copy link
Copy Markdown
Contributor Author

cc @kevpar if you have permissions to kick CI ❤️

@katiewasnothere

Copy link
Copy Markdown

@thaJeztah It looks like the CI is still failing

@thaJeztah

Copy link
Copy Markdown
Contributor Author

Yeah, I noticed; I suspect the other failures may also be with newer go versions, or updated golangci-lint.

I think they're all about integer conversion in generated code; haven't checked if they can be ignored (temporarily) or need fixing;

mode=readonly] in [] ...
  ::high file=wim/lzx/lzx.go,line=137,col=13::G115: integer overflow conversion uint32 -> uint16 (gosec)
  ::high file=wim/lzx/lzx.go,line=191,col=26::G115: integer overflow conversion uint -> uint16 (gosec)
  ::high file=wim/lzx/lzx.go,line=200,col=38::G115: integer overflow conversion int -> uint16 (gosec)
  ::high file=wim/lzx/lzx.go,line=376,col=20::G115: integer overflow conversion uint32 -> uint16 (gosec)
  ::high file=wim/lzx/lzx.go,line=377,col=20::G115: integer overflow conversion uint32 -> uint16 (gosec)
  ::high file=wim/lzx/lzx.go,line=378,col=20::G115: integer overflow conversion uint32 -> uint16 (gosec)
  ::high file=wim/lzx/lzx.go,line=526,col=51::G115: integer overflow conversion int -> uint16 (gosec)

@mat007

mat007 commented Jan 30, 2025

Copy link
Copy Markdown

I opened a separate PR to fix the «Go Generate» failure: #326

@kiashok kiashok left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is still failing

@kiashok

kiashok commented Jan 30, 2025

Copy link
Copy Markdown

@mat007 @thaJeztah looks like the CIs are still failing

@mat007

mat007 commented Jan 31, 2025

Copy link
Copy Markdown

Maybe these should be pinned versions? 🤷

GO_VERSION: "oldstable"
GOTESTSUM_VERSION: "latest"
GOLANGCILINT_VERSION: "latest"

@mat007

mat007 commented Jan 31, 2025

Copy link
Copy Markdown

There are 104 linting errors remaining, all due to conversions. I’ve looked at a few and they all seem to be similar, for instance

ed.writeUint16(uint16(len(values)))
raises

  ::high file=pkg/etw/fieldopt.go,line=165,col=24::G115: integer overflow conversion int -> uint16 (gosec)

What would be best here? To «nolint» them all?

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
It currently produces too many (false) positives in generated code, which
needs to be reviewed. For the time being, exclude this check.

    ::high file=wim/lzx/lzx.go,line=137,col=13::G115: integer overflow conversion uint32 -> uint16 (gosec)
    ::high file=wim/lzx/lzx.go,line=191,col=26::G115: integer overflow conversion uint -> uint16 (gosec)
    ::high file=wim/lzx/lzx.go,line=200,col=38::G115: integer overflow conversion int -> uint16 (gosec)
    ::high file=wim/lzx/lzx.go,line=376,col=20::G115: integer overflow conversion uint32 -> uint16 (gosec)
    ::high file=wim/lzx/lzx.go,line=377,col=20::G115: integer overflow conversion uint32 -> uint16 (gosec)
    ::high file=wim/lzx/lzx.go,line=378,col=20::G115: integer overflow conversion uint32 -> uint16 (gosec)
    ::high file=wim/lzx/lzx.go,line=526,col=51::G115: integer overflow conversion int -> uint16 (gosec)
    ::high file=wim/lzx/lzx.go,line=546,col=23::G115: integer overflow conversion int64 -> int32 (gosec)
    ::high file=wim/lzx/lzx.go,line=547,col=16::G115: integer overflow conversion uint32 -> int32 (gosec)
    ::high file=wim/lzx/lzx.go,line=555,col=53::G115: integer overflow conversion int32 -> uint32 (gosec)
    ::high file=wim/lzx/lzx.go,line=567,col=32::G115: integer overflow conversion int -> uint16 (gosec)
    ::high file=internal/stringbuffer/wstring.go,line=131,col=47::G115: integer overflow conversion int -> uint32 (gosec)
    ::high file=pkg/bindfilter/bind_filter.go,line=231,col=66::G115: integer overflow conversion int -> uint32 (gosec)
    ::high file=pkg/bindfilter/bind_filter.go,line=241,col=16::G115: integer overflow conversion int -> uint32 (gosec)
    ::high file=pkg/process/process.go,line=19,col=23::G115: integer overflow conversion int -> uint32 (gosec)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Comment thread .golangci.yml
Comment on lines +75 to +77
gosec:
excludes:
- G115 # G115: integer overflow conversion; TODO: currently too many (false) positives in generated code that need to be verified

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a global ignore for this one for now; I think most of these are likely false positives in generated code, but would have to be reviewed by someone with more understanding of those parts of the code.

@thaJeztah

Copy link
Copy Markdown
Contributor Author

Pushed some changes, but I don't have a windows machine to verify on locally, but if someone could kick CI again ❤️ @kiashok @katiewasnothere

Comment thread hvsock_test.go
if err != nil {
u.T.Helper()
u.T.Fatalf(msgJoin(msgs, "%v"), err)
u.T.Fatalf(msgJoin(msgs, err.Error()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Fatal, not Fatalf, to stay consistent with the Must fix below, any % in the error message would be misinterpreted as a format verb

Comment thread hvsock_test.go
}
case <-t.C:
u.T.Helper()
u.T.Fatalf(msgJoin(msgs, "timed out after %v"), d)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this timeout case was missed — it still uses the old Fatalf pattern while the identical case in Wait was fixed.

@AdityaMittal1306

Copy link
Copy Markdown
Contributor

This PR has outstanding merge conflicts , can you pls check these @thaJeztah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants