Skip to content

Commit 194ca1c

Browse files
author
dicolanl
committed
Incident Comments
1 parent f6d49ac commit 194ca1c

20 files changed

+887
-38
lines changed

src/SecurityInsights/SecurityInsights/Az.SecurityInsights.psd1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ CmdletsToExport = 'Get-AzSentinelAlertRuleAction',
8787
'New-AzSentinelBookmarkIncidentInfo',
8888
'Remove-AzSentinelBookmark',
8989
'Set-AzSentinelBookmark',
90+
'Get-AzSentinelDataConnector',
91+
'New-AzSentinelDataConnector',
92+
'Remove-AzSentinelDataConnector',
93+
'Set-AzSentinelDataConnector',
9094
'Get-AzSentinelIncidentComment',
9195
'New-AzSentinelIncidentComment',
9296
'Get-AzSentinelIncident',

src/SecurityInsights/SecurityInsights/Cmdlets/Actions/NewAlertRuleActions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public override void ExecuteCmdlet()
6464
TriggerUri = TriggerUri
6565
};
6666

67-
if (ShouldProcess(name, VerbsCommon.Set))
67+
if (ShouldProcess(name, VerbsCommon.New))
6868
{
6969
var outputaction = SecurityInsightsClient.AlertRules.CreateOrUpdateActionWithHttpMessagesAsync(ResourceGroupName, WorkspaceName, AlertRuleId, name, action).GetAwaiter().GetResult().Body;
7070

src/SecurityInsights/SecurityInsights/Cmdlets/AlertRules/NewAlertRules.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public class NewAlertRules : SecurityInsightsCmdletBase
111111
public TimeSpan? QueryPeriod { get; set; }
112112

113113
[Parameter(ParameterSetName = ParameterSetNames.ScheduledAlertRule, Mandatory = false, HelpMessage = ParameterHelpMessages.Severity)]
114+
[ValidateSet("High", "Informational", "Low", "Medium")]
114115
[ValidateNotNullOrEmpty]
115116
public string Severity { get; set; }
116117

@@ -119,6 +120,7 @@ public class NewAlertRules : SecurityInsightsCmdletBase
119120
public IList<string> Tactics { get; set; }
120121

121122
[Parameter(ParameterSetName = ParameterSetNames.ScheduledAlertRule, Mandatory = false, HelpMessage = ParameterHelpMessages.TriggerOperator)]
123+
[ValidateSet("Equal", "GreaterThan", "LessThan", "NotEqual")]
122124
[ValidateNotNullOrEmpty]
123125
public TriggerOperator TriggerOperator { get; set; }
124126

@@ -136,7 +138,7 @@ public override void ExecuteCmdlet()
136138
}
137139

138140
var name = AlertRuleId;
139-
if (ShouldProcess(name, VerbsCommon.Set))
141+
if (ShouldProcess(name, VerbsCommon.New))
140142
{
141143

142144
switch(ParameterSetName)

src/SecurityInsights/SecurityInsights/Cmdlets/Bookmarks/NewBookmarks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public override void ExecuteCmdlet()
8686

8787
};
8888

89-
if (ShouldProcess(name, VerbsCommon.Set))
89+
if (ShouldProcess(name, VerbsCommon.New))
9090
{
9191
var outputBookmark = SecurityInsightsClient.Bookmarks.CreateOrUpdateWithHttpMessagesAsync(ResourceGroupName, WorkspaceName, name, bookmark).GetAwaiter().GetResult().Body;
9292

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ------------------------------------
14+
15+
using System;
16+
using System.Management.Automation;
17+
using Microsoft.Azure.Commands.SecurityInsights;
18+
using Microsoft.Azure.Commands.SecurityInsights.Common;
19+
using Microsoft.Azure.Commands.SecurityInsights.Models.DataConnectors;
20+
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
21+
using System.Linq;
22+
23+
namespace Microsoft.Azure.Commands.SecurityInsights.Cmdlets.DataConnectors
24+
{
25+
[Cmdlet(VerbsCommon.Get, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "SentinelDataConnector", DefaultParameterSetName = ParameterSetNames.WorkspaceScope), OutputType(typeof(PSSentinelDataConnector))]
26+
public class GetDataConnectors : SecurityInsightsCmdletBase
27+
{
28+
private const int MaxDataConnectorsToFetch = 1500;
29+
30+
[Parameter(ParameterSetName = ParameterSetNames.WorkspaceScope, Mandatory = true, HelpMessage = ParameterHelpMessages.ResourceGroupName)]
31+
[Parameter(ParameterSetName = ParameterSetNames.DataConnectorId, Mandatory = true, HelpMessage = ParameterHelpMessages.ResourceGroupName)]
32+
[ResourceGroupCompleter]
33+
[ValidateNotNullOrEmpty]
34+
public string ResourceGroupName { get; set; }
35+
36+
[Parameter(ParameterSetName = ParameterSetNames.WorkspaceScope, Mandatory = true, HelpMessage = ParameterHelpMessages.WorkspaceName)]
37+
[Parameter(ParameterSetName = ParameterSetNames.DataConnectorId, Mandatory = true, HelpMessage = ParameterHelpMessages.WorkspaceName)]
38+
[ValidateNotNullOrEmpty]
39+
public string WorkspaceName { get; set; }
40+
41+
[Parameter(ParameterSetName = ParameterSetNames.DataConnectorId, Mandatory = true, HelpMessage = ParameterHelpMessages.DataConnectorId)]
42+
[ValidateNotNullOrEmpty]
43+
public string DataConnectorId { get; set; }
44+
45+
[Parameter(ParameterSetName = ParameterSetNames.ResourceId, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = ParameterHelpMessages.ResourceId)]
46+
[ValidateNotNullOrEmpty]
47+
public string ResourceId { get; set; }
48+
49+
public override void ExecuteCmdlet()
50+
{
51+
int numberOfFetchedDataConnectors = 0;
52+
string nextLink = null;
53+
switch (ParameterSetName)
54+
{
55+
case ParameterSetNames.WorkspaceScope:
56+
var dataconnectors = SecurityInsightsClient.DataConnectors.ListWithHttpMessagesAsync(ResourceGroupName, WorkspaceName).GetAwaiter().GetResult().Body;
57+
int dataconnectorscount = dataconnectors.Count();
58+
WriteObject(dataconnectors, enumerateCollection: true);
59+
numberOfFetchedDataConnectors += dataconnectorscount;
60+
nextLink = dataconnectors?.NextPageLink;
61+
while (!string.IsNullOrWhiteSpace(nextLink) && numberOfFetchedDataConnectors < MaxDataConnectorsToFetch)
62+
{
63+
dataconnectors = SecurityInsightsClient.DataConnectors.ListNextWithHttpMessagesAsync(dataconnectors.NextPageLink).GetAwaiter().GetResult().Body;
64+
dataconnectorscount = dataconnectors.Count();
65+
WriteObject(dataconnectors, enumerateCollection: true);
66+
numberOfFetchedDataConnectors += dataconnectorscount;
67+
nextLink = dataconnectors?.NextPageLink;
68+
}
69+
break;
70+
case ParameterSetNames.DataConnectorId:
71+
var dataconnector = SecurityInsightsClient.DataConnectors.GetWithHttpMessagesAsync(ResourceGroupName, WorkspaceName, DataConnectorId).GetAwaiter().GetResult().Body;
72+
WriteObject(dataconnector, enumerateCollection: false);
73+
break;
74+
case ParameterSetNames.ResourceId:
75+
dataconnector = SecurityInsightsClient.DataConnectors.GetWithHttpMessagesAsync(ResourceGroupName, WorkspaceName, AzureIdUtilities.GetResourceName(ResourceId)).GetAwaiter().GetResult().Body;
76+
WriteObject(dataconnector, enumerateCollection: false);
77+
break;
78+
default:
79+
throw new PSInvalidOperationException();
80+
}
81+
}
82+
}
83+
}

0 commit comments

Comments
 (0)