-
-
Notifications
You must be signed in to change notification settings - Fork 253
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 utility functions for processing Github releases #330
base: main
Are you sure you want to change the base?
Add utility functions for processing Github releases #330
Conversation
…om github and untars it. Uses curls and standard gnu tools.
Well meant, but i think, it will probably not work. (ive not tested it yet) In addition, not all scripts are moved/copied to /opt/LXC, but there are also downloads that are located in /usr/bin or /etc. |
The idea is sound, but in my experience there's always a few repos that work differently. So this would work for maybe 50% (or more) of our cases, but definitely not all of them. Plus, we are not optimizing much, like actual code for most script is just 3-4 lines:
|
Following up on this, for me, comprehending these 5 commands is much easier and quicker than having a custom function which I have to find and understand input/output/logic/error handling etc. |
Thanks for the feedback. I hear what you all are saying about verbosity of the code. I intentionally added verboseness to make it easier to read, and error messages that could be removed. The reason I am suggesting this is so that we can reduce the amount of code in the scripts, much like the check resources functions that were added. It gives community script writers a framework on which they can and must adhere to, which means less reviewing for us. The classic 5 liner @remz1337 and @havardthom mentioned, is not hard to read, but can contain subtle errors intentional or otherwise. Consider this below, can you spot the problem immediately (do not run this code!!!)? Even if you can quickly spot it, can you trust every reviewer will also spot it?
I have also been writing a github action (will get some help from @havardthom ) to catch these kind of security problems. The 5 line pattern could be reduced to github_latest_release_extract "goauthentik" "authentik" "/opt/authentik" There is very little possibility that this could contain any hidden flaws or features. It would also allow us in the future to audit the scripts in an automated manner. I will modify my pull request to simplify the code. |
It would not matter. The reason I broke it up into two functions was so that if we wanted to do something more complicated with the tar, we could just use the download function. As I mentioned in my comment above, I will modify this code with feedback. |
If we are using the latest github release to install and update, I don't think it can work differently. If the project does not use releases, then of course it wouldn't be applicable. For example if they have a stable branch rather than a formal release. This would be applicable to a lot of current scripts and a significant number of future scripts. Number of files containing 'github.com/.*/releases': 71 So at least 39% of current scripts.
|
Note
We are meticulous when it comes to merging code into the main branch, so please understand that we may reject pull requests that do not meet the project's standards. It's never personal. Also, game-related scripts have a lower chance of being merged.
Description
Many scripts download github releases. This PR adds two utility functions:
download_latest_github_release(user, repo) downloads the latest release and returns (echos) the filename. It relies on the github HTTP API.
extract_github_tarball(tarball, directory) untars a github release into target directory (this is regardless of how the release is named).
This could be used to fix issue #321.
Because this modifies install.func it should be considered high risk.
These functions can be easily test, for example:
Type of change
Please check the relevant option(s):
Prerequisites
The following efforts must be made for the PR to be considered. Please check when completed: