Skip to content
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

feat(security): Enable gosec and default linter set #1076

Merged
merged 1 commit into from
Jan 10, 2022
Merged

feat(security): Enable gosec and default linter set #1076

merged 1 commit into from
Jan 10, 2022

Conversation

bnevis-i
Copy link
Collaborator

@bnevis-i bnevis-i commented Jan 5, 2022

Fixes #1029

Signed-off-by: Bryon Nevis [email protected]

PR Checklist

Please check if your PR fulfills the following requirements:

  • I am not introducing a breaking change (if you are, flag in conventional commit message with BREAKING CHANGE: describing the break)
  • I am not introducing a new dependency (add notes below if you are)
  • I have added unit tests for the new feature or bug fix (if not, why?) N/A
  • I have fully tested (add details below) this the new feature or bug fix (if not, why?) Yes
  • I have opened a PR for the related docs change (if not, why?)
    N/A

Testing Instructions

make test

NOTE: There are two remaining issues that need advising.

lenny-goodell
lenny-goodell previously approved these changes Jan 5, 2022
Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

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

LGTM

@bnevis-i
Copy link
Collaborator Author

bnevis-i commented Jan 5, 2022

I need help resolving the following two failures:

These weren't as straightforward as the other linter warnings.

[2022-01-05T05:50:07.760Z] internal/messaging/messaging.go:84:5: S1000: should use a simple channel send/receive instead of `select` with a single case (gosimple)
[2022-01-05T05:50:07.761Z] 				select {
[2022-01-05T05:50:07.761Z] 				^
[2022-01-05T05:50:07.761Z] internal/autodiscovery/autodiscovery.go:48:4: SA2000: should call wg.Add(1) before starting the goroutine to avoid a race (staticcheck)
[2022-01-05T05:50:07.761Z] 			wg.Add(1)

@chr1shung
Copy link

I need help resolving the following two failures:

These weren't as straightforward as the other linter warnings.

[2022-01-05T05:50:07.760Z] internal/messaging/messaging.go:84:5: S1000: should use a simple channel send/receive instead of `select` with a single case (gosimple)
[2022-01-05T05:50:07.761Z] 				select {
[2022-01-05T05:50:07.761Z] 				^
[2022-01-05T05:50:07.761Z] internal/autodiscovery/autodiscovery.go:48:4: SA2000: should call wg.Add(1) before starting the goroutine to avoid a race (staticcheck)
[2022-01-05T05:50:07.761Z] 			wg.Add(1)

First one it suggests remove the select-case statement:

go func() {
	defer wg.Done()
	<-ctx.Done()
	if msgClient != nil {
		_ = msgClient.Disconnect()
	}
	lc.Infof("Disconnected from MessageBus")
}()

For the second one move the wg.Add(1) call before spawning go routine:

if runDiscovery {
    wg.Add(1)
    go func() {
        defer wg.Done()
        ...
    }()
}

@bnevis-i
Copy link
Collaborator Author

bnevis-i commented Jan 5, 2022

@hahattan

Thanks, Chris. I will get these suggestions merged and update the PR later this morning.

@bnevis-i
Copy link
Collaborator Author

bnevis-i commented Jan 5, 2022

@hahattan

Pushed. Ready for re-review.

@cloudxxx8 cloudxxx8 requested a review from chr1shung January 9, 2022 04:29
Copy link

@chr1shung chr1shung left a comment

Choose a reason for hiding this comment

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

LGTM

@bnevis-i
Copy link
Collaborator Author

Not a committer on this repo. Need someone else to merge.

@cloudxxx8 cloudxxx8 merged commit 633449d into edgexfoundry:main Jan 10, 2022
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.

Add "make lint" target and add to "make test" target
4 participants