首页 > 解决方案 > Azure 身份保护 - 风险检测 API - 按日期筛选

问题描述

我正在尝试按日期过滤从 Azure Identity Protection 检索到的 RiskDetection 数据,但到目前为止没有成功。

对于以下按activityDateTime(或示例数据中的任何日期字段)过滤的示例数据,在响应中显示内部错误:

https://graph.microsoft.com/beta/riskDetections ?$filter=activityDateTime ge 2020-02-05

{'error': {'code': 'Internal Server Error', 'message': 'There was an internal 
server error while processing the request. 
Error ID: 0c2de841-9d83-479a-b7f2-ed2c102908f6', 
'innerError': 
{'request-id': '0c2de841-9d83-479a-b7f2-ed2c102908f6', 
'date': '2020-02-07T01:28:17'}}}

来自https://docs.microsoft.com/en-us/graph/query-parameters

注意:Azure AD 资源不支持以下 $filter 运算符:ne、gt、ge、lt、le 和 not。任何 Microsoft Graph 资源当前不支持包含字符串运算符。

有没有办法按日期过滤 RiskDetections?将不胜感激任何帮助。

以下带有 riskType 和 riskLevel 的过滤器显示数据:

risk_detections_api_url = " https://graph.microsoft.com/beta/riskDetections ?$filter=riskType eq 'anonymizedIPAddress' 或 riskLevel eq 'medium'"

下面带有 userPrincipalName 的过滤器显示数据:

risk_detections_api_url = " https://graph.microsoft.com/beta/riskDetections ?$filter=userPrincipalName eq 'john.doe@example.com'"

下面带有 ipAddress 的过滤器显示数据:

risk_detections_api_url = " https://graph.microsoft.com/beta/riskDetections ?$filter=ipAddress eq '195.228.45.176'"

样本数据

{
        "id": "8901d1fee9bqwqweqwe683a221af3d2ae691736f2e369e0dd530625398",
        "requestId": "cc755f41-0313-4cb2-96ce-3a6283fef200",
        "correlationId": "c422083d-0e32-4afb-af4e-6ca46e4235b4",
        "riskType": "anonymizedIPAddress",
        "riskState": "atRisk",
        "riskLevel": "medium",
        "riskDetail": "none",
        "source": "IdentityProtection",
        "detectionTimingType": "realtime",
        "activity": "signin",
        "tokenIssuerType": "AzureAD",
        "ipAddress": "195.228.45.176",
        "activityDateTime": "2019-12-26T17:40:02.1402381Z",
        "detectedDateTime": "2019-12-26T17:40:02.1402381Z",
        "lastUpdatedDateTime": "2019-12-26T17:43:21.8931807Z",
        "userId": "e3835755-80b0-4b61-a1c0-5ea9ead75300",
        "userDisplayName": "John Doe",
        "userPrincipalName": "john.doe@example.com",
        "additionalInfo": "[{\"Key\":\"userAgent\",\"Value\":\"Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0\"}]",
        "location": {
            "city": "Budapest",
            "state": "Budapest",
            "countryOrRegion": "HU",
            "geoCoordinates": {
                "latitude": 47.45996,
                "longitude": 19.14968
            }
        }
}

标签: azureazure-active-directoryazure-ad-graph-api

解决方案


基于PropertiesactivityDateTimedatetimeoffset类型。

所以你应该使用GET https://graph.microsoft.com/beta/riskDetections?$filter=activityDateTime gt 2019-12-25而不是GET https://graph.microsoft.com/beta/riskDetections?$filter=activityDateTime gt '2019-12-25'.

这里有一个类似的 API 文档:List directoryAudits

但是当我测试它时,它给出了 500 错误:

{
    "error": {
        "code": "Internal Server Error",
        "message": "There was an internal server error while processing the request. Error ID: d52436f6-073b-4fc8-b3bc-c6a6336d6886",
        "innerError": {
            "request-id": "d52436f6-073b-4fc8-b3bc-c6a6336d6886",
            "date": "2020-02-05T04:10:45"
        }
    }
}

我相信这个 API 的 beta 版本仍然在变化。您可以使用您的请求 ID 联系 Microsoft 支持以进行进一步调查。


推荐阅读