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

[CI] Migrate bots to use Authorization HTTP Header #28043

Closed
hramos opened this issue Feb 12, 2020 · 7 comments
Closed

[CI] Migrate bots to use Authorization HTTP Header #28043

hramos opened this issue Feb 12, 2020 · 7 comments
Labels
Good first issue Interested in collaborating? Take a stab at fixing one of these issues. Resolution: Locked This issue was locked by the bot. RN Team

Comments

@hramos
Copy link
Contributor

hramos commented Feb 12, 2020

Tracking issue raised by GitHub's API regarding our CI bots script (bots/code-analysis-bot.js):

On February 12th, 2020 at 21:09 (UTC) your personal access token (public_repo) using octokit.js/16.43.1 Node.js/12.15.0 (Linux 4.15; x64) was used as part of a query parameter to access an endpoint through the GitHub API.

Please use the Authorization HTTP header instead, as using the access_token query parameter is deprecated and will be removed July 1st, 2020.

Depending on your API usage, we'll be sending you this email reminder once every 3 days for each token and User-Agent used in API calls made on your behalf.
Just one URL that was accessed with a token and User-Agent combination will be listed in the email reminder, not all.

Visit https://developer.github.com/changes/2019-11-05-deprecated-passwords-and-authorizations-api/#authenticating-using-query-parameters for more information.

The access token is publicly available in .circleci/config.yml.

@hramos hramos added Good first issue Interested in collaborating? Take a stab at fixing one of these issues. RN Team labels Feb 12, 2020
@ykabusalah
Copy link

Can I tackle this?

@fabOnReact
Copy link
Contributor

fabOnReact commented Apr 16, 2020

maybe this was solved with #28050 as I can not reproduce. I monitored https request with mitmproxy

nodejs code

const {Octokit} = require('@octokit/rest');
const octokit = new Octokit({
  auth: process.env.GITHUB_TOKEN,
});
octokit.pulls.get({owner: 'facebook', repo: 'react-native', pull_number: '28651'})

The token is not passed on the url, but in the authorization header.
After quickly reviewing the code, I could not find any code logic not using the octokit instance to perform github request like https://api.github.com/user?access_token=token_string

Screenshot from 2020-04-16 17-05-34
Screenshot from 2020-04-16 17-07-01

I have to review the circleci/config.yml jobs.

@wambu-i
Copy link

wambu-i commented May 18, 2020

Hello!

Can I take this as my first issue?
Thanks.

@daschaa
Copy link
Contributor

daschaa commented Jan 14, 2022

I'm proposing to update the user agent and octokit version to see if this issue is still occuring in the tracker. What do you think 🧐
#32891

@cortinico
Copy link
Contributor

I'm proposing to update the user agent and octokit version to see if this issue is still occuring in the tracker. What do you think 🧐
#32891

Is this needed? As @fabriziobertoglio1987 mentioned I believe this is already solved:

maybe this was solved with #28050 as I can not reproduce

So i think we can just close this issue

@daschaa
Copy link
Contributor

daschaa commented Jan 15, 2022

@cortinico No it is not needed, but imho it is good if we change the user agent of the octokit request. 🤔

1.) It is recommended in the octokit documentation (I have linked it in the PR).
2.) We can identify if the problem is solved by checking if the tracker has the specific (new) user agent mentioned.

So I see it as kind of flag that shows the current version of the code analysis bot.

What's your opinion on that @cortinico ? 😊

And yeah, I agree that we can close the issue 💯

facebook-github-bot referenced this issue Jan 26, 2022
#32891)

Summary:
As stated in [https://github.com/facebook/react-native/issues/28043](https://github.com/facebook/react-native/issues/28043) the requests with the `Octokit` lib is not optimal since tracking issues were raised. Since the issue could not be reproduced (see comments in the mentioned issue) I'm proposing to update the `Octokit` package to the newest version and add the required fields as stated [in the documentation](https://octokit.github.io/rest.js/v18#authentication).

## Changelog

[Internal] [Changed] - Changed requests of the internal code analysis

Pull Request resolved: #32891

Test Plan:
Ran the code analysis bot manually

```
cat <(echo eslint; npm run lint --silent -- --format=json; echo flow; npm run flow-check-ios --silent --json; echo flow; npm run flow-check-android --silent --json; echo google-java-format; node scripts/lint-java.js --diff) | GITHUB_PR_NUMBER="$CIRCLE_PR_NUMBER" node bots/code-analysis-bot.js

Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
```

Reviewed By: christophpurrer

Differential Revision: D33793194

Pulled By: cortinico

fbshipit-source-id: 21b5f9f3911dd82e3254ab009637ab63aa36d30c
@cortinico
Copy link
Contributor

Fixed by #32891

@facebook facebook locked as resolved and limited conversation to collaborators Jan 26, 2023
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jan 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Good first issue Interested in collaborating? Take a stab at fixing one of these issues. Resolution: Locked This issue was locked by the bot. RN Team
Projects
None yet
Development

No branches or pull requests

7 participants