Skip to content

Commit eded0ed

Browse files
authored
chore: fix false positives in CodeQL (#17138)
Clears up some false positives being surfaced by CodeQL
1 parent e1f27a7 commit eded0ed

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

agent/agentcontainers/containers_dockercli.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -491,21 +491,15 @@ func convertDockerInspect(raw []byte) ([]codersdk.WorkspaceAgentContainer, []str
491491
// "8080" -> 8080, "tcp"
492492
func convertDockerPort(in string) (uint16, string, error) {
493493
parts := strings.Split(in, "/")
494+
p, err := strconv.ParseUint(parts[0], 10, 16)
495+
if err != nil {
496+
return 0, "", xerrors.Errorf("invalid port format: %s", in)
497+
}
494498
switch len(parts) {
495499
case 1:
496500
// assume it's a TCP port
497-
p, err := strconv.Atoi(parts[0])
498-
if err != nil {
499-
return 0, "", xerrors.Errorf("invalid port format: %s", in)
500-
}
501-
// #nosec G115 - Safe conversion since Docker TCP ports are limited to uint16 range
502501
return uint16(p), "tcp", nil
503502
case 2:
504-
p, err := strconv.Atoi(parts[0])
505-
if err != nil {
506-
return 0, "", xerrors.Errorf("invalid port format: %s", in)
507-
}
508-
// #nosec G115 - Safe conversion since Docker ports are limited to uint16 range
509503
return uint16(p), parts[1], nil
510504
default:
511505
return 0, "", xerrors.Errorf("invalid port format: %s", in)

agent/ls.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func listFiles(query LSRequest) (LSResponse, error) {
7676
return LSResponse{}, xerrors.Errorf("failed to get absolute path of %q: %w", fullPathRelative, err)
7777
}
7878

79+
// codeql[go/path-injection] - The intent is to allow the user to navigate to any directory in their workspace.
7980
f, err := os.Open(absolutePathString)
8081
if err != nil {
8182
return LSResponse{}, xerrors.Errorf("failed to open directory %q: %w", absolutePathString, err)

coderd/userauth.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,7 @@ func (api *API) userOAuth2Github(rw http.ResponseWriter, r *http.Request) {
11001100
// We use AuthCodeURL from the OAuth2Config field instead of the one on
11011101
// GithubOAuth2Config because when device flow is configured, AuthCodeURL
11021102
// is overridden and returns a value that doesn't pass the URL check.
1103+
// codeql[go/constant-oauth2-state] -- We are solely using the AuthCodeURL from the OAuth2Config field in order to validate the hostname of the external auth provider.
11031104
if externalauth.IsGithubDotComURL(api.GithubOAuth2Config.OAuth2Config.AuthCodeURL("")) && user.GithubComUserID.Int64 != ghUser.GetID() {
11041105
err = api.Database.UpdateUserGithubComUserID(ctx, database.UpdateUserGithubComUserIDParams{
11051106
ID: user.ID,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy