Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release version 0.6.6 #92

Merged
merged 28 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6ccb3ef
Release '0.6.2' (#31)
pkhabazi Jan 29, 2020
6f80f4d
Release Update Incident function (#37)
pkhabazi Feb 20, 2020
acc8b21
Release Feature playbook configuration (#33)
pkhabazi Feb 22, 2020
a9e559b
Fix/smallconflicts (#40)
pkhabazi Feb 24, 2020
2c138a5
fixing Subscribtion parameter for playbook (#43)
pkhabazi Feb 26, 2020
973b4c2
Merge branch 'master' of github.com:wortell/AZSentinel into development
pkhabazi Feb 26, 2020
bf07860
fixing Subscribtion parameter for playbook (#45)
pkhabazi Feb 26, 2020
19395a7
Fix- get-Azsentinalhuntingrule - Cannot validate argument on paramete…
pkhabazi Mar 15, 2020
6406bde
Fix - new-azsentinelalertrule playbook property (#49)
pkhabazi Mar 15, 2020
9007362
Feature - get all incidents (#51)
pkhabazi Mar 26, 2020
4d423a1
fixing logicapp sas token (#52)
pkhabazi Mar 26, 2020
8b1e50d
Merge branch 'master' of github.com:wortell/AZSentinel into development
pkhabazi Mar 27, 2020
10331af
Add support for day time periods (#61)
pemontto Apr 16, 2020
969cf29
Add missing dot to yml file extension (#59)
NVolcz Apr 16, 2020
4ecb7ea
Merge branch 'master' of github.com:wortell/AZSentinel into development
pkhabazi Apr 20, 2020
d79f8d5
adding support for resource provider in set-azsentinel (#69)
pkhabazi May 7, 2020
1f38c8c
New function for enabling and disabling Alert rules (#71)
pkhabazi May 7, 2020
19a63bd
New feature change the displayName of an alert (#68)
pkhabazi Jun 10, 2020
472e064
Handle nextLink for Playbooks (#78)
stehod Jun 26, 2020
3272c3c
adding support for alert aggregation (#65)
pkhabazi Jun 26, 2020
c4b3a00
Merge branch 'master' into development
pkhabazi Jun 26, 2020
2bd5ff5
Merge branch 'master' of github.com:wortell/AZSentinel into development
pkhabazi Jun 29, 2020
eb36838
Update groupingConfiguration.ps1 (#87)
ThijsLecomte Aug 27, 2020
4d9376a
Fix bug that causes loss of certain incident properties, add option t…
jholtmann Sep 7, 2020
f86f8d3
Feature - Adding support for all alert rule types (#90)
pkhabazi Sep 15, 2020
88b234b
New Functionality to get alert rule templates provided by Microsoft (…
ramirezversion Sep 16, 2020
ddc9c0a
Update/get az sentinel alert rule templates (#95)
pkhabazi Sep 18, 2020
ec36613
Feature/add az sentinel incident comment (#96)
pkhabazi Sep 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion AzSentinel/AzSentinel.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@
'Update-AzSentinelIncident',
'Get-AzSentinelAlertRuleAction',
'New-AzSentinelAlertRuleAction',
'Remove-AzSentinelAlertRuleAction'
'Remove-AzSentinelAlertRuleAction',
'Get-AzSentinelAlertRuleTemplates',
'Add-AzSentinelIncidentComment'
)

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
Expand Down
6 changes: 3 additions & 3 deletions AzSentinel/Classes/AlertRule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ class AlertRule {

[string]$type

[string]$kind
[Kind]$kind = 'Scheduled'

[pscustomobject]$Properties

[string]$Id

AlertRule ($Name, $Etag, $Properties, $Id) {
AlertRule ($Name, $Etag, $Properties, $Id, $kind) {

$this.id = $Id
$this.type = 'Microsoft.SecurityInsights/alertRules'
$this.kind = 'Scheduled'
$this.kind = $kind
$this.Name = $Name
$this.Etag = $Etag
$this.Properties = $Properties
Expand Down
9 changes: 9 additions & 0 deletions AzSentinel/Classes/Fusion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Fusion {
[bool]$Enabled
[string]$AlertRuleTemplateName

Fusion ($Enabled, $AlertRuleTemplateName) {
$this.enabled = $Enabled
$this.AlertRuleTemplateName = $AlertRuleTemplateName
}
}
9 changes: 9 additions & 0 deletions AzSentinel/Classes/MLBehaviorAnalytics.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class MLBehaviorAnalytics {
[bool]$Enabled
[string]$AlertRuleTemplateName

MLBehaviorAnalytics ($Enabled, $AlertRuleTemplateName) {
$this.enabled = $Enabled
$this.AlertRuleTemplateName = $AlertRuleTemplateName
}
}
17 changes: 17 additions & 0 deletions AzSentinel/Classes/MicrosoftSecurityIncidentCreation.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class MicrosoftSecurityIncidentCreation {
[string] $DisplayName
[string]$Description
[bool]$Enabled
[string]$ProductFilter
[Severity[]]$SeveritiesFilter
[string]$DisplayNamesFilter

MicrosoftSecurityIncidentCreation ($DisplayName, $Description, $Enabled, $ProductFilter, $SeveritiesFilter, $DisplayNamesFilter) {
$this.displayName = $DisplayName
$this.description = $Description
$this.enabled = $Enabled
$this.productFilter = $ProductFilter
$this.severitiesFilter = $SeveritiesFilter
$this.displayNamesFilter = $DisplayNamesFilter
}
}
3 changes: 3 additions & 0 deletions AzSentinel/Classes/classes.psd1
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
@{
order = @(
,'MicrosoftSecurityIncidentCreation'
,'Fusion'
,'MLBehaviorAnalytics'
,'groupingConfiguration'
,'IncidentConfiguration'
,'ScheduledAlertProp'
Expand Down
2 changes: 1 addition & 1 deletion AzSentinel/Classes/groupingConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GroupingConfiguration {
}

groupingConfiguration ($Enabled, $reopenClosedIncident, $lookbackDuration, $entitiesMatchingMethod, $groupByEntities) {
$this.enabled = if ($Enabled) { $null -ne $Enabled } else { $true }
$this.enabled = if ($null -ne $Enabled ) { $Enabled } else { $true }
$this.reopenClosedIncident = if ($null -ne $reopenClosedIncident) { $reopenClosedIncident } else { $false }
$this.lookbackDuration = if ($lookbackDuration) { [groupingConfiguration]::TimeString($lookbackDuration) } else { "PT5H" }
$this.entitiesMatchingMethod = if ($entitiesMatchingMethod) { $entitiesMatchingMethod } else { "All" }
Expand Down
104 changes: 104 additions & 0 deletions AzSentinel/Public/Add-AzSentinelIncidentComment.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#requires -module @{ModuleName = 'Az.Accounts'; ModuleVersion = '1.5.2'}
#requires -version 6.2

function Add-AzSentinelIncidentComment {
<#
.SYNOPSIS
Add Azure Sentinel Incident comment
.DESCRIPTION
With this function you can add comment to existing Azure Sentinel Incident.
.PARAMETER SubscriptionId
Enter the subscription ID, if no subscription ID is provided then current AZContext subscription will be used
.PARAMETER WorkspaceName
Enter the Workspace name
.PARAMETER Name
Enter the name of the incidnet in GUID format
.PARAMETER CaseNumber
Enter the case number to get specfiek details of a open case
.PARAMETER Comment
Enter Comment tekst to add comment to the incident
.EXAMPLE
Add-AzSentinelIncidentComment -WorkspaceName "" CaseNumber "" -Comment
Add a comment to existing incidnet
#>

[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param (
[Parameter(Mandatory = $false,
ParameterSetName = "Sub")]
[ValidateNotNullOrEmpty()]
[string] $SubscriptionId,

[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$WorkspaceName,

[Parameter(Mandatory = $false,
ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[guid]$Name,

[Parameter(Mandatory = $false,
ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[int]$CaseNumber,

[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string]$Comment
)

begin {
precheck
}

process {
switch ($PsCmdlet.ParameterSetName) {
Sub {
$arguments = @{
WorkspaceName = $WorkspaceName
SubscriptionId = $SubscriptionId
}
}
default {
$arguments = @{
WorkspaceName = $WorkspaceName
}
}
}

Write-Verbose -Message "Using URI: $($uri)"

if ($CaseNumber) {
$incident = Get-AzSentinelIncident @arguments -CaseNumber $CaseNumber -All
}
elseif ($Name) {
$incident = Get-AzSentinelIncident @arguments -Name $Name
}
else {
Write-Error "Both CaseNumber and Name are empty" -ErrorAction Stop
}

if ($incident) {
$uri = "$script:baseUri/providers/Microsoft.SecurityInsights/Cases/$($incident.name)/comments/$(New-Guid)?api-version=2019-01-01-preview"
$body = @{
"properties" = @{
"message" = $Comment
}
}

Write-Verbose "Found incident with case number: $($incident.caseNumber)"

try {
$return = Invoke-WebRequest -Uri $uri -Method Put -Body ($body | ConvertTo-Json -Depth 99 -EnumsAsStrings) -Headers $script:authHeader
return ($return.Content | ConvertFrom-Json).properties
}
catch {
$return = $_.Exception.Message
Write-Verbose $_
Write-Error "Unable to update Incident $($incident.caseNumber) with error message $return"
return $return
}
}
}
}
60 changes: 52 additions & 8 deletions AzSentinel/Public/Get-AzSentinelAlertRule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function Get-AzSentinelAlertRule {
Enter the Workspace name
.PARAMETER RuleName
Enter the name of the Alert rule
.PARAMETER Kind
The alert rule kind
.EXAMPLE
Get-AzSentinelAlertRule -WorkspaceName "" -RuleName "",""
In this example you can get configuration of multiple alert rules in once
Expand All @@ -32,7 +34,12 @@ function Get-AzSentinelAlertRule {
[Parameter(Mandatory = $false,
ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[string[]]$RuleName
[string[]]$RuleName,

[Parameter(Mandatory = $false,
ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
[Kind[]]$Kind
)

begin {
Expand Down Expand Up @@ -67,7 +74,6 @@ function Get-AzSentinelAlertRule {
}

$return = @()

if ($alertRules.value) {
Write-Verbose "Found $($alertRules.value.count) Alert rules"

Expand All @@ -76,7 +82,38 @@ function Get-AzSentinelAlertRule {
[PSCustomObject]$temp = $alertRules.value | Where-Object { $_.properties.displayName -eq $rule }
if ($null -ne $temp) {

$playbook = Get-AzSentinelAlertRuleAction @arguments -RuleId ($temp.name)
$playbook = Get-AzSentinelAlertRuleAction @arguments -RuleId ($temp.name)[0]

if ($playbook) {
$playbookName = ($playbook.properties.logicAppResourceId).Split('/')[-1]
}
else {
$playbookName = ""
}

$temp.properties | Add-Member -NotePropertyName name -NotePropertyValue $temp.name -Force
$temp.properties | Add-Member -NotePropertyName etag -NotePropertyValue $temp.etag -Force
$temp.properties | Add-Member -NotePropertyName id -NotePropertyValue $temp.id -Force
$temp.properties | Add-Member -NotePropertyName kind -NotePropertyValue $temp.kind -Force

if ($temp.kind -eq "Scheduled") {
$temp.properties | Add-Member -NotePropertyName playbookName -NotePropertyValue $playbookName -Force
}

$return += $temp.properties
}
else {
Write-Verbose "Unable to find Rule: $rule"
}
}
return $return
}
elseif ($Kind.Count -ge 1) {
foreach ($rule in $Kind) {
[PSCustomObject]$temp = $alertRules.value | Where-Object { $_.Kind -eq $rule }
if ($null -ne $temp) {

$playbook = Get-AzSentinelAlertRuleAction @arguments -RuleId ($temp.name)[0]

if ($playbook) {
$playbookName = ($playbook.properties.logicAppResourceId).Split('/')[-1]
Expand All @@ -88,19 +125,22 @@ function Get-AzSentinelAlertRule {
$temp.properties | Add-Member -NotePropertyName name -NotePropertyValue $temp.name -Force
$temp.properties | Add-Member -NotePropertyName etag -NotePropertyValue $temp.etag -Force
$temp.properties | Add-Member -NotePropertyName id -NotePropertyValue $temp.id -Force
$temp.properties | Add-Member -NotePropertyName playbookName -NotePropertyValue $playbookName -Force
$temp.properties | Add-Member -NotePropertyName kind -NotePropertyValue $temp.kind -Force
if ($temp.kind -eq "Scheduled") {
$temp.properties | Add-Member -NotePropertyName playbookName -NotePropertyValue $playbookName -Force
}

$return += $temp.properties
}
else {
Write-Error "Unable to find Rule: $rule"
Write-Verbose "Unable to find Rule: $rule"
}
}
return $return
}
else {
$alertRules.value | ForEach-Object {
$playbook = Get-AzSentinelAlertRuleAction @arguments -RuleId ($_.name)
$playbook = Get-AzSentinelAlertRuleAction @arguments -RuleId ($temp.name)[0]

if ($playbook) {
$playbookName = ($playbook.properties.logicAppResourceId).Split('/')[-1]
Expand All @@ -109,14 +149,18 @@ function Get-AzSentinelAlertRule {
$playbookName = ""
}
$_.properties | Add-Member -NotePropertyName name -NotePropertyValue $_.name -Force
$_.properties | Add-Member -NotePropertyName playbookName -NotePropertyValue $playbookName -Force
$_.properties | Add-Member -NotePropertyName id -NotePropertyValue $_.id -Force
$_.properties | Add-Member -NotePropertyName kind -NotePropertyValue $_.kind -Force
if ($_.kind -eq "Scheduled") {
$_.properties | Add-Member -NotePropertyName playbookName -NotePropertyValue $playbookName -Force
}

return $_.properties
}
}
}
else {
Write-Warning "No rules found on $($WorkspaceName)"
Write-Verbose "No rules found on $($WorkspaceName)"
}
}
}
Loading