Skip to content

Conversation

cd1zz
Copy link
Contributor

@cd1zz cd1zz commented Jun 16, 2025

Updates to KQL and the function app powering the user submitted phishing email logicapp

@KwachSean KwachSean requested a review from Copilot July 22, 2025 09:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates KQL queries and function app configurations for Microsoft Defender XDR enrichment plugins, specifically enhancing user-related security analysis capabilities. The changes improve query accuracy, add new functionality, and enhance documentation.

  • Standardized case-insensitive user principal name matching across all queries
  • Enhanced failed sign-in analysis with date-specific filtering and improved structure
  • Added comprehensive 48-hour user sign-in activity monitoring capability
Comments suppressed due to low confidence (1)

Plugins/Community Based Plugins/Microsoft Defender XDR Custom Plugin Scenarios/EnrichmentPlugins/UserEnrichment.yaml:698

  • [nitpick] Variable naming inconsistency: 'UPN' is used here while other queries use lowercase 'upn'. Consider using consistent naming convention across all queries.
            let UPN = "{{upn}}";

Description: User principal name. i.e., [email protected]
Description: User principal name (e.g., [email protected])
Required: true
- Name: date
Copy link
Preview

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

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

The 'date' parameter lacks input validation in the KQL template. Consider adding validation to ensure the date format matches YYYY-MM-DD and handle invalid date inputs gracefully to prevent query errors.

Copilot uses AI. Check for mistakes.

Template: |-
// Query failed sign-in attempts for a specific user on a specific UTC date.
// user_context: {{user_context}}
let startDate = datetime("{{date}}"); // Parse the input date (YYYY-MM-DD, UTC)
Copy link
Preview

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

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

Direct string interpolation of user input into datetime() function without validation could lead to injection issues or query failures. Consider validating the date format before using it in the KQL query.

Suggested change
let startDate = datetime("{{date}}"); // Parse the input date (YYYY-MM-DD, UTC)
let isValidDate = tostring("{{date}}") matches regex @"^\d{4}-\d{2}-\d{2}$"; // Validate date format (YYYY-MM-DD)
let startDate = isValidDate ? datetime("{{date}}") : datetime(null); // Parse the input date or set to null if invalid
let endDate = startDate + 1d; // Compute the end of the day window (exclusive)

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant