RFC: https_proxy extension: initial commit
Description
This is a draft/wip for adding https proxy caching. This is especially designed for machines hosting lots of github runners to reduce their bandwidth usage by sacrificing disk space. http caching has been merged already and only needed minor changes.
Caching https however is way more complicated. Encryption needs to be broken and rewrapped and then obviously downloads will fail due to cert issues. Classic MITM. So a new certificate authority (CA) needs to be put in place to allow these "fake" certs.
Why is this even necessary? Well one major part is downloads from upstream apt repositories. The other major part is downloading 3rd party repositories and artifacts from OCI/ORAS/whatever the correct name for that system is. They do not allow plain http downloads but redirect to https. So in order to cache these encryption must be broken on the fly.
On custom runs this works already with the mentioned extension. However when the build framework is used within a GH Actions Runner environment it would need to detect this and enable the extension automatically. No clue how to do that or overall if it is worth diving even deeper into this topic. Therefore this RFC to collect feedback.
Also lots of fail-safe checks are missing.
Sometimes I had to mix run_host_command_logged and chroot_sdcard since pipes don't work using latter.
Documentation summary for feature / change
Yes, this would need documentation.
How Has This Been Tested?
- [x] custom builds with
ENABLE_EXTENSION - [ ] Test B
Checklist:
- [no idea] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] My changes generate no new warnings
- [ ] Any dependent changes have been merged and published in downstream modules
Walkthrough
A new Bash script, https_proxy.sh, has been added to manage HTTPS proxy configuration using Squid with SSL bumping and a self-signed certificate. The script introduces three main functions: one to prepare the host system by installing the Squid CA certificate, another to set up the certificate inside a chroot environment before image customization, and a third to clean up the certificate from the chroot after customization. The script utilizes helper functions for command execution and logging, and includes comments regarding prerequisites and future improvements. A function for host certificate removal is present but commented out.
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🧪 Generate Unit Tests
- [ ] Create PR with Unit Tests
- [ ] Commit Unit Tests in branch
https - [ ] Post Copyable Unit Tests in Comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>, please review it. -
Explain this complex logic. -
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:-
@coderabbitai explain this code block. -
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase. -
@coderabbitai read src/utils.ts and explain its main purpose. -
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format. -
@coderabbitai help me debug CodeRabbit configuration file.
-
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai generate docstringsto generate docstrings for this PR. -
@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR. -
@coderabbitai auto-generate unit teststo generate unit tests for this PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
@coderabbitai review
✅ Actions performed
Review triggered.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
I very much support this idea!
I suggest you have a look at how apt-cacher-ng does this. Essentially, you tell your build host to connect to the proxy instance over http but the proxy then connects to the proper server over https. That way, the artifacts are cacheable. It might even make sense for armbian to set up an artifact cache somewhere on the internet specifically to be served over http instead of https. Artifacts of course should then be protected with hashes.
I also suggest to look into making this work more easily out of the box with detection of LAN proxies the way that squid-deb-proxy-client does it via Avahi zeroconf.
I did not work on this since then. Caching apt packages is good enough for me for now which does not need any adjustments except passing some env variables. Feel free to dig further (and ideally come up with something not totally messy and hacked together lol)