Skip to content

Commit 70408f4

Browse files
SecurityJedidicolanlVeryEarly
authored
SecurityInsights-1.1.0 (#15703)
* SecurityInsights-1.1.0 Update to Get-AzSentinelIncident * Update ChangeLog.md Co-authored-by: dicolanl <[email protected]> Co-authored-by: Yabo Hu <[email protected]>
1 parent 9bf2db0 commit 70408f4

File tree

5 files changed

+75
-17
lines changed

5 files changed

+75
-17
lines changed

src/SecurityInsights/SecurityInsights/ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
-->
2020

2121
## Upcoming Release
22+
* Updated to Get-AzSentinelIncident parameters
23+
- Added -Filter to support OData filter
24+
- Added -OrderBy to suppoert OData ordering
25+
- Added -Max to support retrieving more than the default of 1000 incidents.
2226

2327
## Version 1.0.0
2428
* GA release for `Az.SecurityInsights`.

src/SecurityInsights/SecurityInsights/Cmdlets/Incidents/GetIncidents.cs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
using System;
1616
using System.Management.Automation;
17-
using Microsoft.Azure.Commands.SecurityInsights;
1817
using Microsoft.Azure.Commands.SecurityInsights.Common;
1918
using Microsoft.Azure.Commands.SecurityInsights.Models.Incidents;
2019
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
@@ -26,8 +25,6 @@ namespace Microsoft.Azure.Commands.SecurityInsights.Cmdlets.Incidents
2625
[Cmdlet(VerbsCommon.Get, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "SentinelIncident", DefaultParameterSetName = ParameterSetNames.WorkspaceScope), OutputType(typeof(PSSentinelIncident))]
2726
public class GetIncidents : SecurityInsightsCmdletBase
2827
{
29-
private const int MaxIncidentsToFetch = 1500;
30-
3128
[Parameter(ParameterSetName = ParameterSetNames.WorkspaceScope, Mandatory = true, HelpMessage = ParameterHelpMessages.ResourceGroupName)]
3229
[Parameter(ParameterSetName = ParameterSetNames.IncidentId, Mandatory = true, HelpMessage = ParameterHelpMessages.ResourceGroupName)]
3330
[ResourceGroupCompleter]
@@ -43,28 +40,38 @@ public class GetIncidents : SecurityInsightsCmdletBase
4340
[ValidateNotNullOrEmpty]
4441
public string IncidentId { get; set; }
4542

43+
[Parameter(ParameterSetName = ParameterSetNames.WorkspaceScope, Mandatory = false, ValueFromPipeline = false, HelpMessage = ParameterHelpMessages.Filter)]
44+
public string Filter { get; set; }
45+
46+
[Parameter(ParameterSetName = ParameterSetNames.WorkspaceScope, Mandatory = false, ValueFromPipeline = false, HelpMessage = ParameterHelpMessages.OrderBy)]
47+
public string OrderBy { get; set; }
48+
49+
[Parameter(ParameterSetName = ParameterSetNames.WorkspaceScope, Mandatory = false, ValueFromPipeline = false, HelpMessage = ParameterHelpMessages.Max)]
50+
[ValidateRange(1, int.MaxValue)]
51+
public int Max { get; set; }
52+
4653
[Parameter(ParameterSetName = ParameterSetNames.ResourceId, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = ParameterHelpMessages.ResourceId)]
4754
[ValidateNotNullOrEmpty]
4855
public string ResourceId { get; set; }
4956

5057
public override void ExecuteCmdlet()
5158
{
52-
int numberOfFetchedIncidents = 0;
5359
string nextLink = null;
5460
switch (ParameterSetName)
5561
{
5662
case ParameterSetNames.WorkspaceScope:
57-
var incidents = SecurityInsightsClient.Incidents.List(ResourceGroupName, WorkspaceName);
63+
string filter = (Filter == default(string)) ? null : Filter;
64+
string orderby = (OrderBy == default(string)) ? null : OrderBy;
65+
int max = (Max == default(int)) ? 1000 : Max;
66+
var incidents = SecurityInsightsClient.Incidents.List(ResourceGroupName, WorkspaceName, filter: filter, orderby: orderby);
5867
var incidentscount = incidents.Count();
5968
WriteObject(incidents.ConvertToPSType(), enumerateCollection: true);
60-
numberOfFetchedIncidents += incidentscount;
6169
nextLink = incidents?.NextPageLink;
62-
while (!string.IsNullOrWhiteSpace(nextLink) && numberOfFetchedIncidents < MaxIncidentsToFetch)
70+
while (!string.IsNullOrWhiteSpace(nextLink) && incidentscount < max)
6371
{
6472
incidents = SecurityInsightsClient.Incidents.ListNext(incidents.NextPageLink);
65-
incidentscount = incidents.Count();
6673
WriteObject(incidents.ConvertToPSType(), enumerateCollection: true);
67-
numberOfFetchedIncidents += incidentscount;
74+
incidentscount += incidents.Count();
6875
nextLink = incidents?.NextPageLink;
6976
}
7077
break;

src/SecurityInsights/SecurityInsights/Common/ParameterHelpMessages.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ public static class ParameterHelpMessages
104104

105105
#region Incidents
106106
public const string IncidentId = "Incident Id.";
107+
public const string Filter = "Filters the results, based on a Boolean condition.";
108+
public const string OrderBy = "Sorts the results";
109+
public const string Max = "Maximum number of records to return";
107110
public const string Classificaton = "Incident Classificaiton.";
108111
public const string ClassificationComment = "Incident Classificaiton Comment.";
109112
public const string ClassificationReason = "Incident Classificaiton Reason.";

src/SecurityInsights/SecurityInsights/help/Az.SecurityInsights.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
Module Name: Az.SecurityInsights
33
Module Guid: 453d4fb9-65ec-4cf1-8358-6a0fbd995d19
44
Download Help Link: https://docs.microsoft.com/powershell/module/az.securityinsights
5-
Help Version: 0.1.0
5+
Help Version: 1.1.0
66
Locale: en-US
77
---
88

99
# Az.SecurityInsights Module
1010
## Description
11-
Microsoft Azure Sentinel is a scalable, cloud-native, security information event management (SIEM) and security orchestration automated response (SOAR) solution. Azure Sentinel delivers intelligent security analytics and threat intelligence across the enterprise, providing a single solution for alert detection, threat visibility, proactive hunting, and threat response.<br/>
12-
The Azure Sentinel PowerShell module (Az.SecurityInsights) allows you to interact with the following components: * Incidents
13-
* Analytics Rules (Alert Rules)
11+
Microsoft Azure Sentinel is a scalable, cloud-native, security information event management (SIEM) and security orchestration automated response (SOAR) solution. Azure Sentinel delivers intelligent security analytics and threat intelligence across the enterprise, providing a single solution for alert detection, threat visibility, proactive hunting, and threat response.<br/> The Azure Sentinel PowerShell module (Az.SecurityInsights) allows you to interact with the following components: * Incidents * Analytics Rules (Alert Rules)
1412
* Analytics Rules Templates
1513
* Analytics Rules Actions (like attaching an Azure Logic Apps Playbooks to your rule)
1614
* Bookmarks

src/SecurityInsights/SecurityInsights/help/Get-AzSentinelIncident.md

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ schema: 2.0.0
88
# Get-AzSentinelIncident
99

1010
## SYNOPSIS
11-
Get one or more Azure Sentinel Incidents.
11+
Gets one or more Azure Sentinel Incidents.
1212

1313
## SYNTAX
1414

1515
### WorkspaceScope (Default)
1616
```
17-
Get-AzSentinelIncident -ResourceGroupName <String> -WorkspaceName <String>
18-
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
17+
Get-AzSentinelIncident -ResourceGroupName <String> -WorkspaceName <String> [-Filter <String>]
18+
[-OrderBy <String>] [-Max <Int32>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
1919
```
2020

2121
### IncidentId
@@ -32,7 +32,8 @@ Get-AzSentinelIncident -ResourceId <String> [-DefaultProfile <IAzureContextConta
3232
## DESCRIPTION
3333
The **Get-AzSentinelIncident** cmdlet gets a specific or multiple Incidents from the specified workspace.
3434
If you specify the *IncidentId* parameter, a single **Incident** object is returned.
35-
If you do not specify the *IncidentId* parameter, an array containing all of the Incidents in the specified workspace is returned.
35+
If you do not specify the *IncidentId* parameter, an array containing Incidents in the specified workspace is returned.
36+
Default, the module returns 1000 incidents. To fetch more than 1000, use the -Max parameter.
3637
You can use the **Incident** object to update the Incident. For example you can add comments, change the severity, assign an owner, etc. to the **Incident**.
3738

3839
*Note: An IncidentId is in the following format: c464bcd7-daee-47ff-ac58-1fbb73cf1d6b and is not the same as the Incident ID (number) as in the Azure Sentinel Incident view. The IncidentId can be found in the incident details view, in the "Incident link" field, represented in the last part of the https link.*
@@ -93,6 +94,21 @@ Accept pipeline input: False
9394
Accept wildcard characters: False
9495
```
9596
97+
### -Filter
98+
Filters the results, based on a Boolean condition.
99+
100+
```yaml
101+
Type: System.String
102+
Parameter Sets: WorkspaceScope
103+
Aliases:
104+
105+
Required: False
106+
Position: Named
107+
Default value: None
108+
Accept pipeline input: False
109+
Accept wildcard characters: False
110+
```
111+
96112
### -IncidentId
97113
Incident Id.
98114
@@ -108,6 +124,36 @@ Accept pipeline input: True (ByPropertyName)
108124
Accept wildcard characters: False
109125
```
110126
127+
### -Max
128+
Maximum number of records to return
129+
130+
```yaml
131+
Type: System.Int32
132+
Parameter Sets: WorkspaceScope
133+
Aliases:
134+
135+
Required: False
136+
Position: Named
137+
Default value: None
138+
Accept pipeline input: False
139+
Accept wildcard characters: False
140+
```
141+
142+
### -OrderBy
143+
Sorts the results
144+
145+
```yaml
146+
Type: System.String
147+
Parameter Sets: WorkspaceScope
148+
Aliases:
149+
150+
Required: False
151+
Position: Named
152+
Default value: None
153+
Accept pipeline input: False
154+
Accept wildcard characters: False
155+
```
156+
111157
### -ResourceGroupName
112158
Resource group name.
113159

0 commit comments

Comments
 (0)