-
Notifications
You must be signed in to change notification settings - Fork 0
Ensure SSL_CERT_DIR messages are always shown and check for existing value #3
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
base: qodo_full_base_ensure_ssl_cert_dir_messages_are_always_shown_and_check_for_existing_value_pr3
Are you sure you want to change the base?
Changes from all commits
fade7c7
60be2ab
9fd206b
35584d7
c8ce09d
07d6e09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -355,14 +355,57 @@ protected override TrustLevel TrustCertificateCore(X509Certificate2 certificate) | |
| ? Path.Combine("$HOME", certDir[homeDirectoryWithSlash.Length..]) | ||
| : certDir; | ||
|
|
||
| if (TryGetOpenSslDirectory(out var openSslDir)) | ||
| var hasValidSslCertDir = false; | ||
|
|
||
| // Check if SSL_CERT_DIR is already set and if certDir is already included | ||
| var existingSslCertDir = Environment.GetEnvironmentVariable(OpenSslCertificateDirectoryVariableName); | ||
| if (!string.IsNullOrEmpty(existingSslCertDir)) | ||
| { | ||
| var existingDirs = existingSslCertDir.Split(Path.PathSeparator); | ||
| var certDirFullPath = Path.GetFullPath(prettyCertDir); | ||
| var isCertDirIncluded = existingDirs.Any(dir => | ||
| { | ||
| if (string.IsNullOrWhiteSpace(dir)) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| try | ||
| { | ||
| return string.Equals(Path.GetFullPath(dir), certDirFullPath, StringComparison.OrdinalIgnoreCase); | ||
| } | ||
| catch | ||
| { | ||
| // Ignore invalid directory entries in SSL_CERT_DIR | ||
| return false; | ||
| } | ||
|
Comment on lines
+373
to
+381
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Bare catch ignores exceptions • Parsing SSL_CERT_DIR entries uses a bare catch that silently ignores all exceptions from Path.GetFullPath(dir). • This can mask unexpected failures (beyond just malformed entries) and removes actionable context needed to diagnose trust issues. • Catch specific exceptions and/or log at Verbose with safe context (e.g., exception type and the offending entry) to preserve debuggability. Agent prompt
|
||
| }); | ||
|
|
||
| if (isCertDirIncluded) | ||
| { | ||
| // The certificate directory is already in SSL_CERT_DIR, no action needed | ||
| Log.UnixOpenSslCertificateDirectoryAlreadyConfigured(prettyCertDir, OpenSslCertificateDirectoryVariableName); | ||
| hasValidSslCertDir = true; | ||
| } | ||
| else | ||
| { | ||
| // SSL_CERT_DIR is set but doesn't include our directory - suggest appending | ||
| Log.UnixSuggestAppendingToEnvironmentVariable(prettyCertDir, OpenSslCertificateDirectoryVariableName); | ||
| hasValidSslCertDir = false; | ||
| } | ||
| } | ||
| else if (TryGetOpenSslDirectory(out var openSslDir)) | ||
| { | ||
| Log.UnixSuggestSettingEnvironmentVariable(prettyCertDir, Path.Combine(openSslDir, "certs"), OpenSslCertificateDirectoryVariableName); | ||
| hasValidSslCertDir = false; | ||
| } | ||
| else | ||
| { | ||
| Log.UnixSuggestSettingEnvironmentVariableWithoutExample(prettyCertDir, OpenSslCertificateDirectoryVariableName); | ||
| hasValidSslCertDir = false; | ||
| } | ||
|
|
||
| sawTrustFailure = !hasValidSslCertDir; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3. Trust flag overwritten • TrustCertificateCore now reassigns sawTrustFailure based only on SSL_CERT_DIR validity, overwriting earlier failures from dotnet store / NSS trust steps. • This can incorrectly return TrustLevel.Full (and avoid non-zero exit) even when earlier trust steps failed, misleading users about actual trust state. Agent prompt
|
||
| } | ||
|
|
||
| return sawTrustFailure | ||
|
|
@@ -948,9 +991,18 @@ private static bool TryRehashOpenSslCertificates(string certificateDirectory) | |
| return true; | ||
| } | ||
|
|
||
| private sealed class NssDb(string path, bool isFirefox) | ||
| private sealed class NssDb | ||
| { | ||
| public string Path => path; | ||
| public bool IsFirefox => isFirefox; | ||
| private readonly string _path; | ||
| private readonly bool _isFirefox; | ||
|
|
||
| public NssDb(string path, bool isFirefox) | ||
| { | ||
| _path = path; | ||
| _isFirefox = isFirefox; | ||
| } | ||
|
|
||
| public string Path => _path; | ||
| public bool IsFirefox => _isFirefox; | ||
|
Comment on lines
+994
to
+1006
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1. nssdb avoids primary constructor • NssDb was changed from a C# 12 primary constructor to a traditional constructor with repetitive parameter-to-field assignment. • This adds boilerplate and diverges from the required modern DI/boilerplate-reduction convention, making the code less concise and consistent. • Reverting to a primary constructor would satisfy the requirement and keep intent clear. Agent prompt
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,16 +124,20 @@ public static int Main(string[] args) | |
| { | ||
| var reporter = new ConsoleReporter(PhysicalConsole.Singleton, verbose.HasValue(), quiet.HasValue()); | ||
|
|
||
| var listener = new ReporterEventListener(reporter); | ||
| if (verbose.HasValue()) | ||
| { | ||
| var listener = new ReporterEventListener(reporter); | ||
| listener.EnableEvents(CertificateManager.Log, System.Diagnostics.Tracing.EventLevel.Verbose); | ||
| } | ||
| else | ||
| { | ||
| listener.EnableEvents(CertificateManager.Log, System.Diagnostics.Tracing.EventLevel.LogAlways); | ||
| } | ||
|
Comment on lines
+127
to
+135
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 5. Logalways output can crash • dotnet-dev-certs now enables CertificateManager.Log at EventLevel.LogAlways even when not
verbose.
• Event 111’s message uses a {2} placeholder but only writes two payload values;
ReporterEventListener formats messages with string.Format without handling FormatException,
which can crash the tool when that event is emitted.
Agent prompt
|
||
|
|
||
| if (checkJsonOutput.HasValue()) | ||
| { | ||
| if (exportPath.HasValue() || trust?.HasValue() == true || format.HasValue() || noPassword.HasValue() || check.HasValue() || clean.HasValue() || | ||
| (!import.HasValue() && password.HasValue()) || | ||
| (!import.HasValue() && password.HasValue()) || | ||
| (import.HasValue() && !password.HasValue())) | ||
| { | ||
| reporter.Error(InvalidUsageErrorMessage); | ||
|
|
||
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.
4. $home used for comparison
🐞 Bug✓ CorrectnessAgent prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools