Azure Identity Protection - API обнаружения рисков - Фильтр по дате - PullRequest
0 голосов
/ 04 февраля 2020

Я пытаюсь отфильтровать данные RiskDetection, полученные из Azure Identity Protection по дате, и пока безуспешно.

Для приведенных ниже примеров данных ниже фильтр по 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

Примечание. Следующие операторы $ filter не поддерживаются для Azure ресурсов AD: 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
            }
        }
}

Ответы [ 2 ]

1 голос
/ 05 февраля 2020

На основе Свойства , activityDateTime имеет тип datetimeoffset.

Поэтому вы должны использовать 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 документ здесь: Список 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 все еще изменяется. Вы можете обратиться в службу поддержки Microsoft с вашим идентификатором запроса для дальнейшего расследования.

0 голосов
/ 07 февраля 2020

Вам нужно будет указать дату в формате UT C.

Пример: https://graph.microsoft.com/beta/riskDetections? $ Filter = activityDateTime ge 2020-01-01T22: 13: 50.843847Z

В python вы бы сделали что-то вроде ниже, чтобы создать URL с фильтром:

from datetime import datetime
date_filter = datetime.utcnow().isoformat()+"Z"
request_url = "https://graph.microsoft.com/beta/riskDetections?$filter=activityDateTime ge " + date_filter

Ответ теперь отфильтрован:

[
    {
        "id": "68f0402c7063a2fbbae5895f2c63598ca3c2b81c44be60145be1a9cd7e20af4b",
        "requestId": "181d3817-b4fb-4d2b-a87c-065776f05800",
        "correlationId": "6d02786c-0bc7-441f-b303-51430016f955",
        "riskType": "unfamiliarFeatures",
        "riskState": "atRisk",
        "riskLevel": "low",
        "riskDetail": "none",
        "source": "IdentityProtection",
        "detectionTimingType": "realtime",
        "activity": "signin",
        "tokenIssuerType": "AzureAD",
        "ipAddress": "52.185.138.50",
        "activityDateTime": "2020-02-07T05:48:07.6322964Z",
        "detectedDateTime": "2020-02-07T05:48:07.6322964Z",
        "lastUpdatedDateTime": "2020-02-07T05:49:33.3003616Z",
        "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; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36\"}]",
        "location": {
            "city": "tokyo",
            "state": "tokyo",
            "countryOrRegion": "jp",
            "geoCoordinates": {
                "latitude": 35.69628,
                "longitude": 139.7386
            }
        }
    }
]
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...