Allow using system trusted store by PREK_NATIVE_TLS#959
Conversation
update reqwest cargo import to add feature rustls-tls-native-roots Signed-off-by: Steven Taylor <steven@taylormuff.co.uk>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #959 +/- ##
==========================================
- Coverage 90.15% 90.10% -0.06%
==========================================
Files 66 66
Lines 12244 12289 +45
==========================================
+ Hits 11039 11073 +34
- Misses 1205 1216 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📦 Cargo Bloat ComparisonBinary size change: +0.62% (16.1 MiB → 16.2 MiB) Expand for cargo-bloat outputPR Branch ResultsBase Branch Results |
|
I noticed that in |
use native tls if environment variable SSL_CERT_FILE is populated and the file exists or the environment variable PREK_NATIVE_TLS exists and set to true Signed-off-by: Steven Taylor <steven@taylormuff.co.uk>
45a4bb4 to
c6b5633
Compare
Signed-off-by: Steven Taylor <steven@taylormuff.co.uk>
|
the PR that was highlighted is no longer used in UV, however, looked at the UV code and have used a similer method to what is current in use. If SSL_CERT_FILE is set to a file that exists or PREK_NATIVE_TLS is set to true then system tls trust store will be used, if these are not set it will fall back to webpki-roots. the change has dropped the test coverage level, however to put some meaninful tests on this change we would need to update the environment table during testing which would require making the test single threaded. |
Since we call prek in a subprocess during integration tests, I assume it's safe to use subprocess-specific environment variables here? Could you also document the new environment variables in |
|
Sorry, struggling a little with this, to be honest this change should be covered using unit test which as we should really be testing that the returned client can access an https end point when configured in different ways, which is only possible if the unit tests are single threaded as the mutation of the environment table is not safe, could do some stuff with extra locks if the EnvVars type was in the same scope as the main binary code. Testing this within integration tests, not really sure how to make this work, within the integration test cannot construct a reqwest client instance so would have to set-up multiple language tests just to trigger downloads, which seems somewhat excessive. What i could do is move the reqwest client creation and resource downloading code into a lib, in the same way EnvVars is, in this way it can be tested independently of the rest of the code. Thoughts? |
PREK_NATIVE_TLS
|
I extracted the env var reading from And I took the opportunity to do a bit more refactoring by making the client a global shared instance - hope that makes sense. |
|
Nice, had been messing about moving the client / download_and_extract to a lib which also works well from a test perspective, but yours is cleaner. if your happy with it then i am. its really hard to get reqwest to error even when you want it to! |
* Do not check for `script` subprocess status (#964) * Update README * Allow using system trusted store by `PREK_NATIVE_TLS` (#959) * Fix compatibility with older luarocks (#967) * support isolated hook environments for `language: deno` - Implement Deno language handler with dependency isolation - Support npm packages via `additional_dependencies` - Add 8 tests covering basic usage, dependencies, and error cases - example config showing deno fmt, lint, and npm eslint hook usage * support Deno auto installation Implement full-fledged Deno language support with automatic version management, mirroring the installation patterns used for Node.js and Go. - **installer.rs**: New DenoInstaller that downloads and installs Deno versions - Downloads from GitHub releases (https://github.com/denoland/deno/releases) - Searches installed versions in $PREK_HOME/tools/deno - Falls back to system Deno if version matches - Supports all platforms: Linux, macOS, Windows (x86_64, aarch64) - Uses file locking to prevent concurrent installations - Implements proper binary extraction and permission setup - **version.rs**: New DenoVersion and DenoRequest types - Supports version specifications: exact (1.40.0), major (1), major.minor (1.40) - Supports semver ranges: ">= 1.40, < 1.50" - Handles "deno", "deno@version", "latest", "system" formats - Supports local path specifications - Comprehensive unit tests for version parsing - **deno.rs**: Updated to use DenoInstaller - Removed manual system-only detection - Integrated with DenoInstaller for automatic downloads - Simplified installation flow - Proper health checks with version validation * Update language support status (#970) * Update language support status * Tweak * Fix DenoRequest parsing * Generate cli reference * Fail windows CI when an error occured (#971) * Fail windows CI when an error occured * Fix tests * Use global client * delete outdated test, deno auto-installs after 2nd commit addresses #968 (comment) * refactor(deno): symlink deno executable into hook bin dir and use PATH resolution - Create bin/ directory in hook environment with symlinked deno executable - Prepend bin/ to PATH during install and run, matching Node implementation - Use entry.resolve() to find commands in PATH instead of manual replacement - Enables shell scripts to call `deno` directly with correct isolated version - add test verifying deno is available in PATH for shell scripts addresses #968 (comment) * refactor(deno): simplify install logic and add dependency caching - Simplify find_script_to_cache() using functional approach - Fix is_cacheable_script() to only match JS/TS files (prevents caching shell scripts) - Add support for .mjs, .tsx, .jsx extensions - Extract deno_bin variable to reduce duplication - Consolidate PATH setup to single location - Simplify deno.json creation logic - Add deno cache call during install for offline hook execution --------- Co-authored-by: Jo <10510431+j178@users.noreply.github.com> Co-authored-by: Steven Taylor <steven@taylormuff.co.uk>
update reqwest cargo import to add feature rustls-tls-native-roots, this allow prek to work in an enviroment where additional system level trusted certificates are required, feature rustls-tls-native-roots respected the SSL_CERT_FILE env var.
Verified on macos / linux only.