Skip to content

Azure defender & sentinel#130

Open
mjsprengers wants to merge 42 commits intoBlazebit:mainfrom
mjsprengers:azure_defender_sentinel
Open

Azure defender & sentinel#130
mjsprengers wants to merge 42 commits intoBlazebit:mainfrom
mjsprengers:azure_defender_sentinel

Conversation

@mjsprengers
Copy link
Copy Markdown
Contributor

This PR adds/extends data fetchers for:

  1. Sentinel
  2. Defender
  3. ARM Graph
    It also fixes some issues with existing (paginated) queries

mjsprengers and others added 30 commits October 30, 2024 09:21
…tDataFetcher

Both fetchers were only returning the first page of results. Added pagination
loop using getOdataNextLink()/withUrl(). Also added Serializable and license
header to IncidentDataFetcher to match AlertDataFetcher.
…ctor

Adds SecureScoreDataFetcher and SecureScoreControlProfileDataFetcher using
the Graph beta security().secureScores() and security().secureScoreControlProfiles()
endpoints, both with pagination support.
New module for Microsoft Defender for Endpoint with four DataFetchers:
DefenderMachineDataFetcher, DefenderAlertDataFetcher,
DefenderVulnerabilityDataFetcher, DefenderRecommendationDataFetcher.

Uses Java's built-in HttpClient with bearer token auth against the
Defender for Endpoint API (api.securitycenter.microsoft.com). Supports
OData nextLink pagination.
New module for Microsoft Sentinel (Security Insights) with three DataFetchers:
SentinelIncidentDataFetcher, SentinelAlertRuleDataFetcher,
SentinelDataConnectorDataFetcher.

Uses azure-resourcemanager-securityinsights SDK (1.0.0). The SentinelClientAccessor
interface requires tenantId, subscriptionId, resourceGroupName, workspaceName,
and a SecurityInsightsManager. PagedIterable handles pagination automatically.
…tDataFetcher

Covers the pagination fix (verifies all items are returned) and the
Serializable addition to IncidentDataFetcher.
…aFetcher

Includes JSON fixtures for two secure scores and two control profiles,
factory methods in AzureTestObjects, and tests covering all-items return,
tenant filtering, and Serializable verification.
DefenderQueryTest covers all four fetchers (machines, alerts, vulnerabilities,
recommendations) with inline JSON test data. Tests verify full-collection
return and field-based filtering.
Switched all three Sentinel fetchers from beansConvention to
componentMethodConvention so ARM-style fluent methods (id(), name(),
properties()) are correctly exposed as queryable columns.

SentinelQueryTest covers incidents, alert rules, data connectors, and
Serializable verification. SentinelTestObjects uses DefaultJsonReader to
load IncidentInner/AlertRuleInner/DataConnectorInner from JSON fixtures.
Queries VM patch assessment results from the patchassessmentresources
table using KQL, returning the latest assessment per VM with patch counts
by classification (critical, security, other).
…, RoleAssignmentDataFetcher, RiskyUserDataFetcher

- SecurityAssessmentDataFetcher: queries Defender for Cloud assessments via Azure
  Resource Graph (securityresources table), exposes statusCode and severity
- RoleAssignmentDataFetcher: lists ARM role assignments at subscription scope via
  the authorization API, exposes principalId, principalType, roleDefinitionId
- RiskyUserDataFetcher: fetches Identity Protection risky users via Graph beta API
  with OData pagination
- ConditionalAccessPolicyDataFetcher: fixes pagination (was fetching only first page)
  and adds Serializable; convention context updated to break RiskyUser.getHistory() cycle
- Fixes azure-resourcemanager-resourcegraph groupId/version (com.azure.resourcemanager:1.0.0)
  and updates API calls to match the 1.0.0 fluent style (withQuery/withSubscriptions/withSkipToken)
…attern

Replaces flat record with AzureResourceWrapper<RoleAssignmentInner> so callers
can query all SDK fields via payload.*, consistent with other ARM fetchers.
ResourceGroupName is parsed from the role assignment resource ID.
AzureResourceSecurityAssessment remains a record (no SDK model, Resource Graph JSON).
Clarifies that in multi-tenant setups one ResourceGraphClientAccessor must be
configured per tenant, separate from AZURE_RESOURCE_MANAGER, because
AzureResourceManager does not expose credentials for building a ResourceGraphManager.
…etworkSecurityGroupDataFetcher, fix ServicePlanDataFetcher to read CSV via getResourceAsStream

- PostgreSqlFlexibleServer*DataFetchers: switch getAll() to findAll() so they
  return empty results instead of throwing PropertyNotFoundException when
  POSTGRESQL_MANAGER is not configured; add early return in
  PostgreSqlFlexibleServerWithParametersDataFetcher to skip PARAMETERS_TO_FETCH
  lookup when no managers are present
- AzureResourceManagerSchemaProvider: register NetworkSecurityGroupDataFetcher
- ServicePlanDataFetcher: replace Path.of(resource.toURI()) with
  getResourceAsStream() so the CSV can be read from inside a JAR
…/Graph data fetchers

- Wire up AZURE_RESOURCE_MANAGER, RESOURCE_GRAPH_CLIENT, GRAPH_SERVICE_CLIENT,
  and POSTGRESQL_MANAGER configs; derive subscription ID dynamically from ARM
- Register aliases and add test queries for all previously untested types:
  AzureDisk, AzureNetworkSecurityGroup, AzureResourceGroup, AzureSubscription,
  AzureTenant, AzureUserLastSignInActivity, AzureServicePlan,
  AzureSecureScore, AzureSecureScoreControlProfile
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