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

Linter: gosec, Rule: G302 - Poor file permissions used with chmod. Should we enable it? #12941

Closed
zak-pawel opened this issue Mar 26, 2023 · 4 comments · Fixed by #13022
Closed
Labels

Comments

@zak-pawel
Copy link
Collaborator

Use Case

This issue starts discussion about enabling:

Rule is mapped to CWE-276: Incorrect Default Permissions.

Expected behavior

Decision if rule should be enabled or not.

Actual behavior

For this rule no findings were found in current code.

Additional info

For this rule additional configuration can be provided:

      # Maximum allowed permissions mode for os.OpenFile and os.Chmod
      # Default: "0600"
      G302: "0600"
@zak-pawel zak-pawel added feature request Requests for new plugin and for new features to existing plugins linter and removed feature request Requests for new plugin and for new features to existing plugins labels Mar 26, 2023
@zak-pawel
Copy link
Collaborator Author

With exclude-use-default: false set in .golangci.yml following findings were found for this rule:

cmd/telegraf/telegraf.go:337:13  gosec  G302: Expect file permissions to be 0600 or less
logger/logger_test.go:96:15      gosec  G302: Expect file permissions to be 0600 or less

Currently they are excluded by default by:

# EXC0009 gosec: Too many issues in popular repos
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)

@powersj
Copy link
Contributor

powersj commented Mar 27, 2023

+1 but we should talk about 640 vs 600

@zak-pawel
Copy link
Collaborator Author

640 seems better (but list of findings is the same)

@srebhan
Copy link
Member

srebhan commented Apr 3, 2023

0640 is good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants