755 permissions when creating directory #180
Merged
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.
Context
[CI-763] A customer pointed out that our plugin executables have
777
permissions which was triggering their security scanner and recommended us to change permissions to755
.We also thought why not change the directory permissions to
755
to be on the safe side as a proactive security measure.Changes
755
as a proactive security measureInvestigation
We found that directories already have
755
permission, but we don’t know how 😳Upon further inspection we found from the
bitrise-cli
we are calling theEnsureDirExist
function inpathutil.go
which callsos.MkdirAll(dir, 0777)
so we’re explicitly saying to use777
permission, but the~/.bitrise
directory is still being created with755
permission.We thought there was something happening during the image creation process, but it turns out it’s due to
umask
that the folder permissions are defaulting to755
.Decisions
We decided to avoid setting the umask using
syscall.Umask()
and instead just set the file permissions here. This will not have much of an affect since the directories are already set with755
permissions, but we want to be explicit about it.