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

Using GitHub with GITHUB_TOKEN without Prefix leaks token #233

Closed
rowi1de opened this issue Nov 27, 2019 · 4 comments
Closed

Using GitHub with GITHUB_TOKEN without Prefix leaks token #233

rowi1de opened this issue Nov 27, 2019 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@rowi1de
Copy link

rowi1de commented Nov 27, 2019

import * as core from '@actions/co[GitHub](https://github.com/actions/toolkit/tree/master/packages/github) [GitHub](https://github.com/actions/toolkit/tree/master/packages/github) re';
import { context, GitHub } from '@actions/github'

//comes from {{secrets.GITHUB_TOKEN}}
const repoToken = core.getInput('repo-token', { required: true })
core.setSecret(repoToken);
const client = new GitHub(repoToken)

Full source https://github.com/rowi1de/auto-assign-review-teams/blob/master/src/main.ts

will leak the token on error:

"Could not resolve to a node with the global id of 'M....c='."

19-11-22T16:44:34.9046342Z (node:2404) UnhandledPromiseRejectionWarning: HttpError: Validation Failed: "Could not resolve to a node with the global id of 'M....c='."
2019-11-22T16:44:34.9047036Z     at /home/runner/work/_actions/rowi1de/typescript-action/master/node_modules/@octokit/request/dist-node/index.js:66:23
2019-11-22T16:44:34.9047273Z     at processTicksAndRejections (internal/process/task_queues.js:89:5)
201

see actions/typescript-action#40

@ethomson
Copy link
Contributor

ethomson commented Nov 27, 2019

I'm not sure what you mean by "without prefix"? Have you validated that the thing that you're seeing is the GITHUB_TOKEN? The message that you're posting looks like an error message from the GitHub API that's including the issue's node_id.

eg: https://github.com/octokit/rest.js/issues/531

@rowi1de
Copy link
Author

rowi1de commented Nov 27, 2019

@ethomson I mean I'm just passing
{{secrets.GITHUB_TOKEN}} into GitHub()

If I want to use the GITHUB_TOKEN for REST Calls directly, I would need to add it as the header --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
Will this be implicitly done by the used implementation?

I'm pretty sure: If I use a personal access token, put it into the Secrets of the Repo where the action is running it works without a problem.

@thboop
Copy link
Collaborator

thboop commented Apr 13, 2020

Hey @rowi1de ,
This doesn't appear to be a leaking of the GitHub token, this is an error coming from the GitHub api. I believe the "token" in question is the graphql node. The GitHub token is not in that format.

Are all of the api's failing for you? Or is only a single api failing?

If you are seeing this as a result of your comment here

You may want to start a discussion in the GitHub community forums for the api, this doesn't appear to be a toolkit issue. It appears to be an issue with that api.

@rowi1de
Copy link
Author

rowi1de commented Apr 14, 2020

Hey @thboop

you are right, I was on the wrong path when creating the issue.
It only fails when trying to assign a team to a PR.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants