-
Notifications
You must be signed in to change notification settings - Fork 166
feat: add --insecure option and deprecate --allow-self-signed #1132
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
Conversation
Add the 'insecure' configuration field alongside 'allow_self_signed' to prepare for introducing the --insecure flag with clearer semantics. Issue: SCRT-5952
Add the --insecure flag to clearly communicate that SSL verification is being disabled, making the connection vulnerable to MITM attacks. This option is clearer than --allow-self-signed about what it does. Issue: SCRT-5952
Display clear warnings when SSL verification is disabled, explaining: - The security risks (MITM attacks, interception) - The recommended secure alternative (system trust store with Python >= 3.10) - A link to documentation for more information This warning appears every time a session is created with SSL verification disabled, whether through --allow-self-signed or --insecure. Issue: SCRT-5952
Update the main CLI handler to accept both --insecure and --allow-self-signed options. When either is set, both flags are enabled in the config to maintain consistency and ensure they work as aliases. This ensures backward compatibility while providing a clearer option name. Issue: SCRT-5952
Add test coverage for the new --insecure flag to ensure it works correctly and disables SSL verification as expected, matching the behavior of --allow-self-signed. Issue: SCRT-5952
Document the addition of the --insecure option and improved security warnings when SSL verification is disabled. Issue: SCRT-5952
Update create_client_from_config to check both the insecure and allow_self_signed flags when creating the API client. This ensures that either flag will correctly disable SSL verification. Issue: SCRT-5952
Fix the URL in the warning message to point to the correct documentation page (remove 'reference/' from the path). Issue: SCRT-5952
Switch from logger.warning to ui.display_warning for SSL verification warnings to properly display messages to users through ggshield's UI system rather than the logging system. This ensures warnings are properly formatted and visible to end users regardless of their logging configuration. Issue: SCRT-5952
Use curl's standard wording for the --insecure option to maintain consistency with widely-used tools and make the security implications immediately clear to users familiar with curl. Issue: SCRT-5952
Display a deprecation warning when --allow-self-signed is used, guiding users to use --insecure instead, which more accurately describes the behavior (disabling all certificate validation). The option remains functional for backward compatibility but now clearly indicates it will be removed in a future version. Issue: SCRT-5952
Display a deprecation warning when 'allow_self_signed' is used in configuration files, guiding users to use 'insecure' instead. The option remains functional for backward compatibility but now clearly indicates it will be removed in a future version. Issue: SCRT-5952
Add a Deprecated section to the changelog documenting that allow_self_signed is now deprecated in favor of the insecure option. Issue: SCRT-5952
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1132 +/- ##
==========================================
+ Coverage 91.95% 91.98% +0.02%
==========================================
Files 144 144
Lines 6166 6188 +22
==========================================
+ Hits 5670 5692 +22
Misses 496 496
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Apply black formatting and fix end-of-file for changelog. Issue: SCRT-5952
Add test to verify that the deprecation warning is properly added to deprecation_messages when allow_self_signed is used in config files. This brings the patch coverage to 100%. Issue: SCRT-5952
Implement all review feedback from @agateau-gg: - Remove allow_self_signed field from UserConfig, keep only insecure - Convert allow_self_signed to insecure during config loading - Use ui.display_warning() directly instead of deprecation_messages - Shorten all deprecation warning messages - Reorder --insecure help text (functionality before warning) - Update v1 config converter to map allow_self_signed to insecure - Simplify code by eliminating dual field state This makes the code cleaner and prevents inconsistent state where allow_self_signed and insecure could have different values. Issue: SCRT-5952
Update remaining references to allow_self_signed attribute in: - ggshield/verticals/hmsl/utils.py - ggshield/verticals/auth/oauth.py - ggshield/cmd/auth/logout.py - ggshield/cmd/auth/login.py Issue: SCRT-5952
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last change and this can go in.
The cli() function needs to accept the allow_self_signed parameter to handle the case where --allow-self-signed is placed before the subcommand (e.g., 'ggshield --allow-self-signed api-status'). Without this, the callback can't update the config at that stage because ctx.obj is None, breaking backward compatibility. Added test to verify both placements work: - ggshield api-status --allow-self-signed ✓ - ggshield --allow-self-signed api-status ✓ Issue: SCRT-5952
Updated the documentation link in the SSL verification warning message to point to the correct anchor in the public documentation. The link now points to the 'support-for-self-signed-certificates' section instead of 'allow_self_signed'. Issue: SCRT-5952
Context
We received a report about ggshield's
--allow-self-signedoption. The option name is misleading: it suggests that self-signed certificates are validated, when in reality it completely disables SSL verification, making connections vulnerable to man-in-the-middle attacks.This PR addresses the issue by:
--insecureoption (matching curl's convention)--allow-self-signedwith prominent warningsSee SCRT-5952.
What has been done
New Features
--insecureCLI option andinsecureconfiguration setting as clearer alternatives to--allow-self-signed--insecurematches curl's standard wording for consistencyDeprecation
--allow-self-signedCLI option is now deprecated with a warning displayed on every useallow_self_signedconfig setting is now deprecated with a warning displayed when loading config files--insecureinsteadImplementation Details
--insecureand--allow-self-signedset both internal flags for consistencyui.display_warning()for proper user-facing output (notlogger.warning())Validation
To validate the new
--insecureoption:Expected behavior:
--allow-self-signeddisplays a deprecation warning guiding to--insecureTo validate config file deprecation:
Expected: Deprecation warning about
allow_self_signedconfig keyPR check list
skip-changeloglabel has been added to the PR.