Add signature verification plugin from conda.trust#245
Open
Conversation
2 tasks
Migrates the signature verification functionality from conda.trust module to conda-content-trust as a proper plugin. This change: - Adds verification.py with _SignatureVerification class - Adds constants.py with KEY_MGR_FILE constant - Registers CondaPostSolve hook for signature-verification - Adds comprehensive tests migrated from conda - Updates plugin.py to export both subcommand and post-solve hook The verification requires a trust root to be installed (e.g., via conda-anaconda-trust-root) to $CONDA_PREFIX/etc/conda/. Without a trust root, signature verification is disabled. Part of: conda/conda#14797
411ee31 to
5c9d3c7
Compare
- Fix av_data_dir mocking: use PropertyMock on Context class instead of patching the instance attribute (which fails because av_data_dir is a read-only property) - Fix error handling in verification.py to match original conda code: catch HTTPError specifically instead of broad Exception in key_mgr (which was swallowing SignatureError) - Import HTTPError from conda.gateways.connection - Add key_mgr_verify.json with the correct pkg_mgr key matching the repodata.json test signatures - Mock _fetch_channel_signing_data in test_signature_verification to avoid real network requests during tests - Use http:// instead of https:// for test signing metadata URL
Use stdlib monkeypatch fixtures instead of pytest-mock for all test patching in test_verification.py. This removes the pytest-mock dependency from the test suite. - Replace mocker.patch PropertyMock with monkeypatch.setattr on class properties for Context.av_data_dir and SubdirData.cache_path_base - Replace mock_fetch_channel_signing_data fixture with a simpler mock_fetch fixture using monkeypatch.setattr and a plain list for call tracking - Replace mock .call_count assertions with len(calls)
Three tests in test_root.py were missing the SSLIB_AVAILABLE skip guard that other GPG tests already had, causing failures in CI environments without securesystemslib installed.
Member
Author
|
pre-commit.ci autofix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates the signature verification functionality from
conda.trustmodule to conda-content-trust as a proper plugin.Fixes conda/conda#14847
verification.pywith_SignatureVerificationclassconstants.pywithKEY_MGR_FILEconstantCondaPostSolvehook for signature-verificationplugin.pyto export both subcommand and post-solve hookThe verification requires a trust root to be installed (e.g., via
conda-anaconda-trust-root) to$CONDA_PREFIX/etc/conda/. Without a trust root, signature verification is disabled.Related
Part of conda/conda#14797
Related PRs:
Test plan