Skip to content

Commit 36270b1

Browse files
Merge pull request #295578 from austinmccollum/austinmc-uploadapi-updates
update upload API based on user feedback
2 parents c35fc91 + 8773f91 commit 36270b1

File tree

1 file changed

+83
-10
lines changed

1 file changed

+83
-10
lines changed

articles/sentinel/stix-objects-api.md

Lines changed: 83 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,15 @@ Acquire a Microsoft Entra access token with [OAuth 2.0 authentication](../active
5757

5858
The version of the token (v1.0 or v2.0) received is determined by the `accessTokenAcceptedVersion` property in the [app manifest](/entra/identity-platform/reference-app-manifest#manifest-reference) of the API that your application is calling. If `accessTokenAcceptedVersion` is set to 1, then your application receives a v1.0 token.
5959

60-
Use Microsoft Authentication Library [(MSAL)](/entra/identity-platform/msal-overview) to acquire either a v1.0 or v2.0 access token. Or, send requests to the REST API in the following format:
60+
Use Microsoft Authentication Library [(MSAL)](/entra/identity-platform/msal-overview) to acquire either a v1.0 or v2.0 access token. Use the access token to create the authorization header which contains the bearer token.
61+
62+
For example, a request to the upload API uses the following elements to retrieve an access token and create the authorization header, which is used in each request:
6163
- POST `https://login.microsoftonline.com/{{tenantId}}/oauth2/v2.0/token`
62-
- Headers for using Microsoft Entra App:
64+
65+
Headers for using Microsoft Entra App:
6366
- grant_type: "client_credentials"
6467
- client_id: {Client ID of Microsoft Entra App}
65-
- client_secret: {secret of Microsoft Entra App}
68+
- client_secret or client_certificate: {secrets of the Microsoft Entra App}
6669
- scope: `"https://management.azure.com/.default"`
6770

6871
If `accessTokenAcceptedVersion` in the app manifest is set to 1, your application receives a v1.0 access token even though it's calling the v2 token endpoint.
@@ -88,22 +91,79 @@ Method: `POST`<br>
8891
#### Request body
8992
The JSON object for the body contains the following fields:
9093

91-
|Field name |Data Type |Description|
94+
|Field name |Data Type |Description|
9295
|---|---|---|
9396
| `sourcesystem` (required) | string | Identify your source system name. The value `Microsoft Sentinel` is restricted.|
9497
| `stixobjects` (required) | array | An array of STIX objects in [STIX 2.0 or 2.1 format](https://docs.oasis-open.org/cti/stix/v2.1/cs01/stix-v2.1-cs01.html#_muftrcpnf89v) |
9598

9699
Create the array of STIX objects using the STIX format specification. Some of the STIX property specifications are expanded here for your convenience with links to the relevant STIX document sections. Also note some properties, while valid for STIX, don't have corresponding object schema properties in Microsoft Sentinel.
97100

101+
>[!WARNING]
102+
>If you're using a Microsoft Sentinel Logic App to connect to the upload API, note there are three threat intelligence actions available. Only use the [**Threat Intelligence - Upload STIX Objects (Preview)**](/connectors/azuresentinel/#threat-intelligence---upload-stix-objects-(preview)). The other two will fail with this endpoint and JSON body fields.
103+
104+
#### Sample request message
105+
106+
Here's a sample PowerShell function that uses a self-signed certificate uploaded to an Entra app registration to generate the access token and authorization header:
107+
108+
```PowerShell
109+
function Test-UploadApi {
110+
<#
111+
.SYNOPSIS
112+
requires Powershell module MSAL.PS version 4.37 or higher
113+
https://www.powershellgallery.com/packages/MSAL.PS/
114+
.EXAMPLE
115+
Test-Api -API UploadApi -WorkspaceName "workspacename" -ResourceGroupName "rgname" -AppId "00001111-aaaa-2222-bbbb-3333cccc4444" -TenantName "contoso.onmicrosoft.com" -FilePath "C:\Users\user\Documents\stixobjects.json"
116+
#>
117+
[CmdletBinding()]
118+
param (
119+
[Parameter(Mandatory = $true)]
120+
[string]$TenantName,
121+
[Parameter(Mandatory = $true)]
122+
[string]$CertThumbprint,
123+
[Parameter(Mandatory = $true)]
124+
[string]$AppId,
125+
[Parameter(Mandatory = $true)]
126+
[string]$WorkspaceId,
127+
[Parameter(Mandatory = $true)]
128+
[string]$FilePath
129+
)
130+
$Scope = "https://management.azure.com/.default"
131+
# Connection details for getting initial token with self-signed certificate from local store
132+
$connectionDetails = @{
133+
'TenantId' = $TenantName
134+
'ClientId' = $AppId
135+
'ClientCertificate' = Get-Item -Path "Cert:\CurrentUser\My\$CertThumbprint"
136+
scope = $Scope
137+
}
138+
# Request the token
139+
# Using Powershell module MSAL.PS https://www.powershellgallery.com/packages/MSAL.PS/
140+
# Get-MsalToken is automatically using OAuth 2.0 token endpoint https://login.microsoftonline.com/$TenantName/oauth2/v2.0/token
141+
# and sets auth flow to grant_type = 'client_credentials'
142+
$token = Get-MsalToken @connectionDetails
143+
144+
# Create header
145+
# Again relying on MSAL.PS which has method CreateAuthorizationHeader() getting us the bearer token
146+
$Header = @{
147+
'Authorization' = $token.CreateAuthorizationHeader()
148+
}
149+
$Uri = "https://api.ti.sentinel.azure.com/workspaces/$workspaceId/threat-intelligence-stix-objects:upload?api-version=$apiVersion"
150+
$stixobjects = get-content -path $FilePath
151+
if(-not $stixobjects) { Write-Host "No file found at $FilePath"; break }
152+
$results = Invoke-RestMethod -Uri $Uri -Headers $Header -Body $stixobjects -Method POST -ContentType "application/json"
153+
154+
$results | ConvertTo-Json -Depth 4
155+
}
156+
```
157+
98158
#### Common properties
99159

100160
All the objects you import with the upload API share these common properties.
101161

102-
|Property Name |Type | Description |
162+
|Property Name |Type | Description |
103163
|----|----|----|
104164
|`id` (required)| string | An ID used to identify the STIX object. See section [2.9](https://docs.oasis-open.org/cti/stix/v2.1/cs01/stix-v2.1-cs01.html#_64yvzeku5a5c) for specifications on how to create an `id`. The format looks something like `indicator--<UUID>`|
105165
|`spec_version` (optional) | string | STIX object version. This value is required in the STIX specification, but since this API only supports STIX 2.0 and 2.1, when this field isn't set, the API defaults to `2.1`|
106-
|`type` (required)| string | The value of this property *must* be a supported STIX object.|
166+
|`type` (required)| string | The value of this property *must* be a supported STIX object.|
107167
|`created` (required) | timestamp | See section [3.2](https://docs.oasis-open.org/cti/stix/v2.1/cs01/stix-v2.1-cs01.html#_xzbicbtscatx) for specifications of this common property.|
108168
|`created_by_ref` (optional) | string | The created_by_ref property specifies the ID property of the entity that created this object.<br><br>If this attribute is omitted, the source of this information is undefined. For object creators who wish to remain anonymous, keep this value undefined.|
109169
|`modified` (required) | timestamp | See section [3.2](https://docs.oasis-open.org/cti/stix/v2.1/cs01/stix-v2.1-cs01.html#_xzbicbtscatx) for specifications of this common property.|
@@ -119,9 +179,9 @@ For more information, see [STIX common properties](https://docs.oasis-open.org/c
119179

120180
#### Indicator
121181

122-
|Property Name |Type | Description |
182+
|Property Name |Type | Description |
123183
|----|----|----|
124-
|`name` (optional)| string | A name used to identify the indicator.<br><br>Producers *should* provide this property to help products and analysts understand what this indicator actually does.|
184+
|`name` (optional)| string | A name used to identify the indicator.<br><br>Producers *should* provide this property to help products and analysts understand what this indicator actually does.|
125185
|`description` (optional) | string | A description that provides more details and context about the indicator, potentially including its purpose and its key characteristics.<br><br>Producers *should* provide this property to help products and analysts understand what this indicator actually does. |
126186
|`indicator_types` (optional) | list of strings | A set of categorizations for this indicator.<br><br>The values for this property *should* come from the [indicator-type-ov](https://docs.oasis-open.org/cti/stix/v2.1/cs01/stix-v2.1-cs01.html#_cvhfwe3t9vuo) |
127187
|`pattern` (required) | string | The detection pattern for this indicator *might* be expressed as a [STIX Patterning](https://docs.oasis-open.org/cti/stix/v2.1/cs01/stix-v2.1-cs01.html#_e8slinrhxcc9) or another appropriate language such as SNORT, YARA, etc. |
@@ -135,18 +195,26 @@ For more information, see [STIX indicator](https://docs.oasis-open.org/cti/stix/
135195

136196
#### Attack pattern
137197

198+
Follow the STIX specifications for creating an attack pattern STIX object. Use [this example](#sample-attack-pattern) as an extra reference.
199+
138200
For more information, see [STIX attack pattern](https://docs.oasis-open.org/cti/stix/v2.1/os/stix-v2.1-os.html#_axjijf603msy).
139201

140202
#### Identity
141203

204+
Follow the STIX specifications for creating an identity STIX object. Use [this example](#sample-relationship-with-threat-actor-and-identity) as an extra reference.
205+
142206
For more information, see [STIX identity](https://docs.oasis-open.org/cti/stix/v2.1/os/stix-v2.1-os.html#_wh296fiwpklp).
143207

144208
#### Threat actor
145209

210+
Follow the STIX specifications for creating a threat actor STIX object. Use [this example](#sample-relationship-with-threat-actor-and-identity) as an extra reference.
211+
146212
For more information, see [STIX threat actor](https://docs.oasis-open.org/cti/stix/v2.1/os/stix-v2.1-os.html#_k017w16zutw).
147213

148214
#### Relationship
149215

216+
Follow the STIX specifications for creating a relationship STIX object. Use [this example](#sample-relationship-with-threat-actor-and-identity) as an extra reference.
217+
150218
For more information, see [STIX relationship](https://docs.oasis-open.org/cti/stix/v2.1/os/stix-v2.1-os.html#_e2e1szrqfoan).
151219

152220
### Process the response message
@@ -166,7 +234,7 @@ The response body is an array of error messages in JSON format:
166234

167235
|Field name | Data Type | Description |
168236
|----|----|----|
169-
|errors | Array of error objects | List of validation errors |
237+
|errors | Array of error objects | List of validation errors |
170238

171239
**Error object**
172240

@@ -291,6 +359,9 @@ The objects are sent as an array, so the `recordIndex` begins at `0`.
291359

292360
In this example, the indicator is marked with the green TLP by using `marking-definition--089a6ecb-cc15-43cc-9494-767639779123` in the `object_marking_refs` common property. More extension attributes of `toxicity` and `rank` are also included. Although these properties aren't in the Microsoft Sentinel schema for indicators, ingesting an object with these properties doesn't trigger an error. The properties simply aren't referenced or indexed in the workspace.
293361

362+
> [!NOTE]
363+
> This indicator has the `revoked` property set to `$true` and its `valid_until` date is in the past. This indicator as-is doesn't work in analytics rules and isn't returned in queries unless an appropriate time range is specified.
364+
294365
```json
295366
{
296367
"sourcesystem": "TestStixObjects",
@@ -364,6 +435,8 @@ In this example, the indicator is marked with the green TLP by using `marking-de
364435

365436
#### Sample attack pattern
366437

438+
This attack pattern and any other non-indicator STIX objects are only viewable in the management interface unless you opt in to the new STIX tables. For more information about the tables required to view objects like this in KQL, see [View your threat intelligence](understand-threat-intelligence.md#view-your-threat-intelligence).
439+
367440
```json
368441
{
369442
"sourcesystem": "TestStixObjects",
@@ -601,4 +674,4 @@ To learn more about how to work with threat intelligence in Microsoft Sentinel,
601674
- [Understand threat intelligence](understand-threat-intelligence.md)
602675
- [Work with threat indicators](work-with-threat-indicators.md)
603676
- [Use matching analytics to detect threats](use-matching-analytics-to-detect-threats.md)
604-
- Utilize the intelligence feed from Microsoft and [enable MDTI data connector](connect-mdti-data-connector.md)
677+
- Utilize the intelligence feed from Microsoft and [enable the MDTI data connector](connect-mdti-data-connector.md)

0 commit comments

Comments
 (0)