-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gosec: reorganize filepath validation
We recently added filepath sanitization before to feed it in the `os.ReadFile`. Turns out the linter was still unhappy because it seems it can't track the variable sanitization across function calls bonundaries. With this change we rework the validation to have them in the same function block of the `ReadFile` call. This is arguably (much) more wasteful (in relative terms) because we redo multiple times redundant validations, for example when we handle the config file directory. Still, this makes the linter demonstrably happier and it's (hopefully) safer because we can't call ReadFile by mistake with unsanitized input. In addition, configfile reading is done once at runtime, so the extra cost should be amortized. X-Gosec-Scan: 2.21.4 Signed-off-by: Francesco Romani <[email protected]>
- Loading branch information
Showing
3 changed files
with
22 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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