-
-
Notifications
You must be signed in to change notification settings - Fork 291
gosec-based patches #1502
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
Open
mcepl
wants to merge
12
commits into
git-bug:trunk
Choose a base branch
from
openSUSE-Python:gosec-fixes
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
gosec-based patches #1502
Conversation
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
…e auth addtoken command Multiple cmd.RegisterFlagCompletionFunc calls in newBridgeAuthAddTokenCommand (commands/bridge/bridge_auth_addtoken.go) ignored potential error returns (G104, CWE-703). This could hide issues with flag completion registration. The fix adds explicit error checks and panics if any registration fails, ensuring that such issues are immediately visible during development. This applies to the 'target' and 'user' flags.
The http.Server in the web UI (commands/webui.go) was vulnerable to Slowloris attacks (G112, CWE-400) due to missing timeout configurations. This allowed clients to hold connections open indefinitely. The fix adds ReadHeaderTimeout, WriteTimeout, and IdleTimeout to the http.Server configuration to prevent this resource exhaustion.
The detectGitPath function was vulnerable to path traversal (G304, CWE-22). A specially crafted .git file with a 'gitdir:' entry could lead to reading arbitrary files on the filesystem if it contained an absolute path or a '..' sequence. The fix prevents absolute paths in 'gitdir:' entries and ensures that relative paths are correctly resolved relative to the .git file's location, mitigating the path traversal vulnerability.
The makeIndex function in repository/index_bleve.go used os.ModePerm (0777) when creating directories (G301, CWE-276). This is overly permissive and could lead to unintended write access. The fix changes the permissions to 0755, restricting write access to the owner while allowing read and execute for others, improving security.
…show command The cmd.RegisterFlagCompletionFunc call in newUserShowCommand (commands/user/user_show.go) ignored a potential error return (G104, CWE-703). This could hide issues with flag completion registration. The fix adds an explicit error check and panics if the registration fails, ensuring that such issues are immediately visible during development.
…command The cmd.RegisterFlagCompletionFunc call in NewUserCommand (commands/user/user.go) ignored a potential error return (G104, CWE-703). This could hide issues with flag completion registration. The fix adds an explicit error check and panics if the registration fails, ensuring that such issues are immediately visible during development.
The backend.Close() call inside t.Cleanup in newTestEnv (commands/execenv/env_testing.go) ignored a potential error return (G104, CWE-703). In a test, this can hide issues with the test itself or the code being tested during teardown. The fix adds an explicit error check within the t.Cleanup function and calls t.Errorf to report any cleanup failures, ensuring test integrity.
…how command The cmd.RegisterFlagCompletionFunc call in newBugShowCommand (commands/bug/bug_show.go) ignored a potential error return (G104, CWE-703). This could hide issues with flag completion registration. The fix adds an explicit error check and panics if the registration fails, ensuring that such issues are immediately visible during development. This also exposes a pre-existing bug where the flag 'by' was used instead of 'field' for completion.
…ommand Multiple cmd.RegisterFlagCompletionFunc calls in NewBugCommand (commands/bug/bug.go) ignored potential error returns (G104, CWE-703). This could hide issues with flag completion registration. The fix adds explicit error checks and panics if any registration fails, ensuring that such issues are immediately visible during development. This applies to the 'status', 'author', 'participant', 'actor', 'label', 'no', 'by', 'direction', and 'format' flags.
…e new command The cmd.RegisterFlagCompletionFunc call in newBridgeNewCommand (commands/bridge/bridge_new.go) ignored a potential error return (G104, CWE-703). This could hide issues with flag completion registration. The fix adds an explicit error check and panics if the registration fails, ensuring that such issues are immediately visible during development.
The LaunchEditor function was vulnerable to path traversal (G304, CWE-22). The 'fileName' parameter could be manipulated to access files outside the intended local storage root. The fix adds a check to ensure that the resolved path remains within the local storage root, preventing unauthorized file access.
The test for `detectGitPath` should not create a `.git` file containing an absolute path to the git directory. This could lead to test failures in certain environments. Signed-off-by: Matěj Cepl <mcepl@cepl.eu>
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.
I just run
gosecon thegit-bugcodebase and then asked LLM to fix those bugs. Some findings where wrong, so I skipped them, but most of them were just small perhaps mostly cosmetic issues with missing error handling etc.Feel free to reject anything, accept anything, or ask for modifications, I don’t have particularly sentimental attachment to these changes.