Skip to content
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

[Bug][API] GET /projects exposes GitLab token in the gitextractor plugin #7597

Closed
2 of 3 tasks
richard-fletcher opened this issue Jun 7, 2024 · 1 comment · Fixed by #7622
Closed
2 of 3 tasks
Assignees
Labels
pr-type/bug-fix This PR fixes a bug severity/p1 This bug affects functionality or significantly affect ux type/bug This issue is a bug

Comments

@richard-fletcher
Copy link
Contributor

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

When calling GET /blueprints/{blueprintId} access tokens are correctly masked for gitextractor GitLab connections. When calling GET /projects/{projectName} the token is not masked in the Blueprint response.

What do you expect to happen

The token to be masked in the response from GET /projects/{projectName}

How to reproduce

  • Add a project with a GitLab connection
  • Retrieve the project from the API

Anything else

No response

Version

v0.21.0

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@richard-fletcher richard-fletcher added the type/bug This issue is a bug label Jun 7, 2024
@dosubot dosubot bot added pr-type/bug-fix This PR fixes a bug severity/p1 This bug affects functionality or significantly affect ux labels Jun 7, 2024
Copy link

dosubot bot commented Jun 7, 2024

Hey there, @richard-fletcher! 👋 I'm here to help you with bugs, questions, and becoming a contributor. I'm a bot, but I can assist while you wait for a human maintainer.

To ensure that the GitLab token is masked in the response from the GET /projects/{projectName} endpoint, you can use the Sanitize method defined in the GitlabConn and GitlabConnection structs. This method replaces the token with a sanitized version.

Here is the relevant code snippet that shows how the Sanitize method is used:

func (conn *GitlabConn) Sanitize() GitlabConn {
    conn.Token = utils.SanitizeString(conn.Token)
    return *conn
}

func (connection GitlabConnection) Sanitize() GitlabConnection {
    connection.GitlabConn = connection.GitlabConn.Sanitize()
    return connection
}

To ensure the token is masked in the response, you should call the Sanitize method on the GitlabConnection object before returning it in the response of the GET /projects/{projectName} endpoint. Here is an example of how you might do this:

func GetProjectHandler(w http.ResponseWriter, r *http.Request) {
    // Assume you have a function to get the GitlabConnection object
    connection := getGitlabConnectionFromRequest(r)

    // Sanitize the connection to mask the token
    sanitizedConnection := connection.Sanitize()

    // Return the sanitized connection in the response
    json.NewEncoder(w).Encode(sanitizedConnection)
}

This ensures that the token is masked in the response, protecting sensitive information [1].

To continue talking to Dosu, mention @dosu.

@d4x1 d4x1 self-assigned this Jun 14, 2024
@d4x1 d4x1 changed the title [Bug][API] GET /projects exposes GitLab token in the gitextractor plugi [Bug][API] GET /projects exposes GitLab token in the gitextractor plugin Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-type/bug-fix This PR fixes a bug severity/p1 This bug affects functionality or significantly affect ux type/bug This issue is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants