Skip to content

Adding Additional Logging around NTLM Authentication - #254

Merged
mykeelium merged 6 commits into
v4from
mcuomo/BED-6657
Oct 22, 2025
Merged

mykeelium merged 6 commits into
v4from
mcuomo/BED-6657

Conversation

@mykeelium

@mykeelium mykeelium commented Oct 21, 2025 •

Copy link
Copy Markdown
Contributor

Description

This adds more logging around NTLM Authentication for endpoints to check potential ESC8 Vulnerability.

Motivation and Context

BED-6657

How Has This Been Tested?

This has been tested by creating a build with this change, and ensuring the log statement are available.

Screenshots (if appropriate):

Types of changes

  • Chore (a change that does not modify the application functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • Documentation updates are needed, and have been made accordingly.
  • I have added and/or updated tests to cover my changes.
  • All new and existing tests passed.
  • My changes include a database migration.

Summary by CodeRabbit

  • Improvements
    • Enhanced diagnostic logging across NTLM authentication and enrollment flows: structured, step‑by‑step traces of authentication stages, reported supported schemes, channel binding status, endpoint accessibility, and richer context for network and authorization errors to aid troubleshooting.

@mykeelium mykeelium self-assigned this Oct 21, 2025
@mykeelium mykeelium added the enhancement New feature or request label Oct 21, 2025
@coderabbitai

coderabbitai Bot commented Oct 21, 2025 •

Copy link
Copy Markdown

Walkthrough

Added structured, detailed logging across NTLM authentication components and certificate enrollment processing; no control-flow or behavioral changes.

Changes

Cohort / File(s) Summary
NTLM logging updates
src/CommonLib/Ntlm/HttpNtlmAuthenticationService.cs, src/CommonLib/Ntlm/NtlmAuthenticationHandler.cs
Replaced string-concatenation logs with structured placeholders in HttpNtlmAuthenticationService; added step-by-step structured trace logs in NtlmAuthenticationHandler.PerformNtlmAuthenticationAsync. No logic changes.
CA enrollment diagnostic logging
src/CommonLib/Processors/CAEnrollmentProcessor.cs
Inserted extensive structured logging at multiple decision points (port accessibility, DNS resolution, HTTP statuses 404/403/other, WebException/HttpRequestException, HttpUnauthorized/Forbidden/ServerError, MissingChallenge/ExtendedProtectionMisconfigured, and generic exceptions). Control flow preserved; logs emitted before returning success/failure.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I hopped through code with logs in paw,

Traced each step of NTLM's law,
Placeholders neat, the messages sing,
Debug carrots fit for spring,
A happy rabbit leaves a tiny log.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "Adding Additional Logging around NTLM Authentication" directly and clearly summarizes the main change in the changeset. The raw summary confirms that the PR adds logging statements across three NTLM-related files (HttpNtlmAuthenticationService.cs, NtlmAuthenticationHandler.cs, and CAEnrollmentProcessor.cs), which aligns precisely with the title. The title is concise, specific, and provides sufficient clarity for someone scanning the commit history to understand the primary change.
Description Check ✅ Passed The pull request description addresses all required sections of the repository template: Description (explaining the logging additions for ESC8 vulnerability checks), Motivation and Context (BED-6657 ticket reference), How Has This Been Tested (build testing with log verification), Types of changes (marked as Chore), and Checklist items (with relevant boxes checked). While the "Motivation and Context" section is minimal and "How Has This Been Tested?" could be more detailed, all major required sections are present and completed sufficiently to meet the template requirements. The description is mostly complete and on-topic.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mcuomo/BED-6657

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 209b965 and bb73c86.

📒 Files selected for processing (3)
  • src/CommonLib/Ntlm/HttpNtlmAuthenticationService.cs (1 hunks)
  • src/CommonLib/Ntlm/NtlmAuthenticationHandler.cs (1 hunks)
  • src/CommonLib/Processors/CAEnrollmentProcessor.cs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/CommonLib/Ntlm/HttpNtlmAuthenticationService.cs
  • src/CommonLib/Processors/CAEnrollmentProcessor.cs
  • src/CommonLib/Ntlm/NtlmAuthenticationHandler.cs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
src/CommonLib/Ntlm/NtlmAuthenticationHandler.cs (2)

43-59: Consider reducing verbosity around cancellation token checks.

The cancellation token check is logged twice with similar patterns (lines 43-45 and 57-59). Since ThrowIfCancellationRequested() is a lightweight operation, the before/after trace logging may be excessive for diagnostic purposes.

Consider keeping only the check itself without the surrounding trace statements, or consolidating to a single log level:

-        _logger.LogDebug("Check if cancellation token is requested.");
         cancellationToken.ThrowIfCancellationRequested();
-        _logger.LogTrace("After if cancellation token is requested.");

45-69: Improve clarity of log messages.

Several log messages have awkward phrasing:

  • "After if cancellation token is requested" (lines 45, 59)
  • "After negotiate step" (line 50)

Consider revising for better clarity:

-        _logger.LogTrace("After if cancellation token is requested.");
+        _logger.LogTrace("Cancellation token check passed.");
-        _logger.LogTrace("After negotiate step.");
+        _logger.LogTrace("Negotiate step completed.");

Similar improvements could be applied to lines 55, 64, and 69.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c62556c and 209b965.

📒 Files selected for processing (3)
  • src/CommonLib/Ntlm/HttpNtlmAuthenticationService.cs (1 hunks)
  • src/CommonLib/Ntlm/NtlmAuthenticationHandler.cs (1 hunks)
  • src/CommonLib/Processors/CAEnrollmentProcessor.cs (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/CommonLib/Ntlm/NtlmAuthenticationHandler.cs (1)
src/CommonLib/ThirdParty/PSOpenAD/Authentication.cs (3)
  • Step (101-101)
  • Step (115-123)
  • Step (189-246)
src/CommonLib/Processors/CAEnrollmentProcessor.cs (4)
src/CommonLib/OutputTypes/APIResult.cs (4)
  • APIResult (2-5)
  • APIResult (7-28)
  • APIResult (10-15)
  • APIResult (17-22)
src/CommonLib/OutputTypes/CAHttpEndpoint.cs (1)
  • CAEnrollmentEndpoint (63-70)
src/CommonLib/Ntlm/HttpNtlmAuthenticationService.cs (8)
  • HttpUnauthorizedException (179-180)
  • HttpUnauthorizedException (182-183)
  • HttpForbiddenException (197-198)
  • HttpForbiddenException (200-201)
  • HttpServerErrorException (206-207)
  • HttpServerErrorException (209-210)
  • ExtendedProtectionMisconfiguredException (188-189)
  • ExtendedProtectionMisconfiguredException (191-192)
src/CommonLib/Ntlm/HttpTransport.cs (2)
  • MissingChallengeException (60-63)
  • MissingChallengeException (61-62)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (1)
src/CommonLib/Processors/CAEnrollmentProcessor.cs (1)

136-224: Comprehensive logging additions look good.

The extensive structured logging across all exception paths and success scenarios provides excellent diagnostics for ESC8 vulnerability checks. The consistent use of structured logging placeholders and clear messages will help troubleshooting NTLM authentication issues.

Comment thread src/CommonLib/Ntlm/HttpNtlmAuthenticationService.cs Outdated
Comment thread src/CommonLib/Processors/CAEnrollmentProcessor.cs Outdated
Comment thread src/CommonLib/Processors/CAEnrollmentProcessor.cs Outdated
Comment thread src/CommonLib/Processors/CAEnrollmentProcessor.cs
@mykeelium
mykeelium merged commit 057a598 into v4 Oct 22, 2025
3 checks passed
@mykeelium
mykeelium deleted the mcuomo/BED-6657 branch October 22, 2025 12:54
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants