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

server: un-disable gosec #157

Merged
merged 1 commit into from
Mar 20, 2021
Merged

server: un-disable gosec #157

merged 1 commit into from
Mar 20, 2021

Conversation

chloenayon
Copy link
Contributor

Previously contained gosec overrides for G304 and G307, amend code so that the
overrides can be safely removed without triggering gosec violations. Clean
filepaths before calling os.Open and remove instances of deferring f.Close
so that errors can be caught before return.

var d DistributionFile
err = json.NewDecoder(f).Decode(&d)
if err != nil {
return err
}
err = f.Close()
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, if the decoding errors out the file will never be closed now. I think what's best is to change the defer function a little, see securego/gosec#512 (comment) ; wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that makes sense - thanks for pointing that out! I'll make changes

Previously contained gosec overrides for G304 and G307, amend code so that the
overrides can be safely removed without triggering gosec violations. Clean
filepaths before calling os.Open and remove instances of deferring f.Close
so that errors can be caught before return.
Copy link
Member

@teg teg left a comment

Choose a reason for hiding this comment

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

Really nice cleanups :)

@teg teg merged commit 34f544c into osbuild:main Mar 20, 2021
@croissanne croissanne mentioned this pull request Apr 27, 2021
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.

None yet

3 participants