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

Add HTTPS proxy functionality #850

Merged
merged 1 commit into from
Aug 10, 2022
Merged

Conversation

fhopfensperger
Copy link
Contributor

According to the Octokit documentation it's necessary to add ProxyAgent to the request to be able to connect to GitHub using a corporate HTTP proxy.

I tested it successfully in our restricted environment using the following snippet

      - name: Create changelog
        id: changelog
        if: ${{ github.ref == 'refs/heads/main' }}
        uses: mikepenz/release-changelog-builder-action@<new-test-version>
        with:
          baseUrl: https://github-enterprise.corp.net/api/v3
        env:
          HTTPS_PROXY: http://proxy.corp.net:8888

PS: Please bare with me, it's my first PR to a npm/node based project.

Signed-off-by: Florian Hopfensperger florian.hopfensperger@allianz.de

Copy link
Owner

@mikepenz mikepenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for your PR @fhopfensperger

Definitely a great addition to the action.
And all node / ts related aspects look good. Just had a few comments on some aspects.

Happy to assist with adjusting any of these.


For working on actions - I love to use GitHub code spaces - started super quick - and then gives me a full set-up Visual Code environment - including debug support.

README.md Outdated
@@ -178,6 +178,8 @@ jobs:

> **Note**: By default not specifying `fromTag` or `toTag` will resolve `toTag` from either the `ref` or alternatively fallback to the latest tag from the git API. `fromTag` is resolved by sorting tags using [semver](https://semver.org/). Check the [configuration](#configuration-specification) for alternatives.

> **Note**: If you behind a corporate HTTP proxy you might set the `HTTPS_PROXY` environment variable to the proxy URL.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please link to the docs from octokit here - so people can read up on this environment variable.

Comment on lines 49 to 58
request: {
agent: new ProxyAgent()
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if we only set-up the ProxyAgent() in case it is configured to be used - can have a look into this.

package.json Outdated
@@ -38,6 +38,7 @@
"@octokit/rest": "^19.0.3",
"@types/semver": "^7.3.10",
"moment": "^2.29.4",
"proxy-agent": "^5.0.0",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that the used dependency is suggested by the octokit docs - but the latest version has some unpatched issues open - TooTallNate/node-proxy-agent#74

Need to see if there are alternatives.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked into it, all search results in this one 🤔 seems that there is really no real alternative than using that package.

GitHub uses it themself for a wrapper package which is meant to handle this for GitHub actions. https://github.com/octokit/action.js#proxy-servers

@mikepenz
Copy link
Owner

mikepenz commented Aug 9, 2022

Had a look into the above noted comments.

Seems the node-proxy-agent is really one of the only packages doing that, but it adds a ton of other sub-packages including dependencies which seem to require updates due to security fixes.

As such I'd propose to limit the scope to HTTPS proxies only for now: f7a5ecd

Also only setting it up if the specific ENV variable is provided.

@fhopfensperger
Copy link
Contributor Author

Thanks for looking into it! Honestly, I'm a bit confused now, where did you point the commit to? What should I do :-)

We can also leave this PR open until the proxy agent issues are fixed and then come back and merge it?

@mikepenz
Copy link
Owner

Thanks for looking into it! Honestly, I'm a bit confused now, where did you point the commit to? What should I do :-)

We can also leave this PR open until the proxy agent issues are fixed and then come back and merge it?

The commit was on a new branch, as I can't push to your branch, but instead of just merging - I figured to give you the opportunity to look into it first.

Currently it seems there has not been a lot of movement on the dependency recently. At least lowering the scope to only the HTTPS module seems to significantly reduce the code introduced too.

Signed-off-by: Florian Hopfensperger <florian.hopfensperger@allianz.de>

- lower proxy functionality to Https for now (the general proxy package adds a ton of dependencies - which are difficult to review)

Add octokit documentation

Signed-off-by: Florian Hopfensperger <florian.hopfensperger@allianz.de>

Lint & build & packaged

Signed-off-by: Florian Hopfensperger <florian.hopfensperger@allianz.de>
@fhopfensperger
Copy link
Contributor Author

I merged your changes into my branch, did a rebase, lint, build, packaged and pushed the latest changes to the branch :-)

Thank you very much for your review. If there are other things you would like to change, please let me know. I will be happy to make the changes.

@mikepenz
Copy link
Owner

Thank you very much @fhopfensperger - Will check to get it reviewed and in as soon as possible

@mikepenz mikepenz changed the title Add HTTP proxy functionality Add HTTPS proxy functionality Aug 10, 2022
@mikepenz mikepenz merged commit 97db2b0 into mikepenz:develop Aug 10, 2022
@mikepenz
Copy link
Owner

The checks failed because of the token not offering the required permissions -> also there was another change required, which I included in the final merge

@mikepenz
Copy link
Owner

It's released as v3.3.0 (haven't yet moved the v3 tag to monitor things first)

@fhopfensperger
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants