(bugsbash) fixes potential file inclusion via variable#1155
Closed
rahulgrover99 wants to merge 5 commits intobuildpacks:mainfrom
Closed
(bugsbash) fixes potential file inclusion via variable#1155rahulgrover99 wants to merge 5 commits intobuildpacks:mainfrom
rahulgrover99 wants to merge 5 commits intobuildpacks:mainfrom
Conversation
Signed-off-by: Rahul Grover <rahulgrover99@gmail.com>
Signed-off-by: Rahul Grover <rahulgrover99@gmail.com>
Member
|
Same issue here @rahulgrover99 (failing tests) :(. Sorry. |
dwillist
suggested changes
May 11, 2021
Contributor
dwillist
left a comment
There was a problem hiding this comment.
Hey @rahulgrover99 appreciate the PR! Looks like there are a few CI failures do to permission bits changing.
| } | ||
|
|
||
| f, err := os.OpenFile(index, os.O_APPEND|os.O_CREATE|os.O_RDWR, 0644) | ||
| f, err := os.OpenFile(filepath.Clean(index), os.O_APPEND|os.O_CREATE|os.O_RDWR, 0600) |
Contributor
There was a problem hiding this comment.
these permission changes look like they are responsible for the test failures we are seeing
| } | ||
|
|
||
| return os.Chmod(dst, 0775) | ||
| return os.Chmod(dst, 0600) |
Contributor
There was a problem hiding this comment.
Think we have tests that actually copy executable bits, 0600 is a bit too restrictive.
| err = os.Chtimes(filepath.Join(dst, fi.Name()), modifiedTime, modifiedTime) | ||
| AssertNil(t, err) | ||
| err = os.Chmod(filepath.Join(dst, fi.Name()), 0664) | ||
| err = os.Chmod(filepath.Join(dst, fi.Name()), 0600) |
Contributor
There was a problem hiding this comment.
permission change may be too restrictive
| err = os.Chtimes(dst, modifiedTime, modifiedTime) | ||
| AssertNil(t, err) | ||
| err = os.Chmod(dst, 0775) | ||
| err = os.Chmod(dst, 0600) |
Signed-off-by: Rahul Grover <rahulgrover99@gmail.com>
2d1322c to
e0b3ac4
Compare
Contributor
Author
|
I think it might be a good idea to revert the permission changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gosec was showing the following warning "Potential file inclusion via variable". This is because we are trying to open files using dynamic variables. Hence, I've cleaned the bad file paths using filepath.Clean()
Output
Before
ioutil.ReadFile(file)
After
ioutil.ReadFile(filepath.Clean(etagFile))
Documentation
Related
Resolves #___
G304 Potential file inclusion via variable