Allow configuring the github-token used#60
Conversation
|
thanks for your contribution, can you please do a small change? I need to do it for other inputs as well but since you are changing this one let's start from the good :) |
|
Great point, I was aware of that practice and should've known. IIRC, I think you're not supposed to clobber that actual env var name, but I'll look into it on Monday and make the change one way or another. |
Interpolating inputs directly is an injection vector; passing through environment variables is a security best-practice[^1]. [^1]: https://docs.github.com/en/enterprise-cloud@latest/enterprise-onboarding/github-actions-for-your-enterprise/security-hardening-for-github-actions#using-an-intermediate-environment-variable
|
Done. I couldn't find any documentation that said to avoid making your own variables named |
brokenpip3
left a comment
There was a problem hiding this comment.
Thanks for your contribution
|
Do you actually need |
|
I think it's common for actions to use |
|
Well, yes but then you're still forced to supply a valid github token, which you might not necessarily have if you're working on other platforms like forgejo. Perhaps it could be made entirely optional? |
Indeed we should add it there as well, I mean in general, not only in case of forgejo |
if you pass |
|
Sure, but if a user wants to use unauthenticated requests and risk rate limiting, it's their choice, isn't it? Also note that the rate limits are for API requests, not for other types of requests. https://github.com/bats-core/bats-action/blob/main/action.yaml#L145 this requests is done against the API, true, but later requests like eg https://github.com/bats-core/bats-action/blob/main/action.yaml#L218 are not against the API. The curl that runs against the api is used, in essence, to determine the latest available version of bats; if the bats-version input is supplied, that curl isn't even performed and the tar.gz is downloaded (here https://github.com/bats-core/bats-action/blob/main/action.yaml#L152) without calling the API, so strictly speaking it doesn't need the token either. In the end, I doubt that a user could reach the max 60 API requests per hour (a single run of bats-action already probably takes more than one minute), and even then, if they want to risk, it should be their choice, IMHO. |
|
I think |
|
Yes, but even so, it's never empty, since by default it's set to |
|
Just to be clear, I'm not suggesting to remove the use of the token altogther; in fact, I would leave the default as it is now, which is good; only offer an optional way to opt-out from using the token if the user knows what they're doing. |
|
And to be clearer, I'm asking if this feature can be accepted; if so, I can do it myself and submit a PR. |
unfortunately this is not true, github introduced rate limits everywhere, even by visiting a web page, they called it "secondary rate limit"
why not, make sense, I'm happy to provide more freedom to the users
happy to review it, I believe the best way could be:
|
|
For completeness, you can also get the latest release without invoking the API, by calling eg |
|
Also I'm not really sure that just adding the token to a non-API request (ie one against |
yes indeed you are right to underline this, we should use the tarball api everywhere, for instance |
This is a pretty common pattern, so I don't know that it requires much justification, but for additional context I needed it to get this action working on a Forgejo Actions runner.
Those runners spoof the
githubcontext, meaning thegithub.tokenvalue is actually a token for interacting with the Forgejo repository, which of course results in a 401 when it's used to pull the GitHub artifacts (even though they're public). Being able to swap in my own GitHub token gets things working.