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

groupingConfiguration error #132

Closed
rleal124 opened this issue Nov 4, 2020 · 12 comments · Fixed by #137 or #159
Closed

groupingConfiguration error #132

rleal124 opened this issue Nov 4, 2020 · 12 comments · Fixed by #137 or #159
Assignees
Labels
bug Something isn't working inprogress

Comments

@rleal124
Copy link

rleal124 commented Nov 4, 2020

When I upload a analytic rule to sentinel I want to disable the grouping configuration.

the following stanza following the documentation should be work and disable the grouping configuration, But the not have effect and the grouping configuration still happened enable. Can please help me?
groupingConfiguration:
GroupingConfigurationEnabled: false
reopenClosedIncident: false
lookbackDuration: PT5H
entitiesMatchingMethod: All
groupByEntities:
- Account
- Ip
- Host
- Url

@rleal124 rleal124 changed the title groupingConfiguration erro groupingConfiguration error Nov 4, 2020
@rleal124
Copy link
Author

rleal124 commented Nov 4, 2020

I find the issue: On file AzSentinel.psm1 on function Import-AzSentinelAlertRule, the line
$this.enabled = if ($null -ne $Enabled ) { $Enabled } else { $true }, is not correct.

Because, will enable, or set to true the groupingConfiguration.
I change the line to
$this.enabled = if ($null -ne $Enabled ) { $Enabled } else { $false }

And now I can set to true or false groupingConfiguration

@pemontto
Copy link
Contributor

pemontto commented Nov 5, 2020

Confirmed, seeing the same issue here

@pkhabazi
Copy link
Contributor

pkhabazi commented Nov 5, 2020

hi @rleal124, thanks for the feedback! So you want to create a scheduled analytic rule where the group configuration is disabled. I think there are two issues here. The first issue is indeed in the If statement. Because now if the value/property is not set then Group configuration will be enabled by default (which should not be the default).
Second issue is, I think, in your template file. Because if the property is configured correct then that will be used in the deployment.
See below JSON template that I have used for testing:

{
  "Scheduled": [
    {
      "displayName": "AlertRule01",
      "description": "",
      "severity": "Medium",
      "enabled": true,
      "query": "SecurityEvent | where EventID == \"4688\" | where CommandLine contains \"-noni -ep bypass $\"",
      "queryFrequency": "5H",
      "queryPeriod": "6H",
      "triggerOperator": "GreaterThan",
      "triggerThreshold": 5,
      "suppressionDuration": "6H",
      "suppressionEnabled": false,
      "tactics": [
        "Persistence",
        "LateralMovement",
        "Collection"
      ],
      "playbookName": "",
      "aggregationKind": "SingleAlert",
      "createIncident": true,
      "groupingConfiguration": {
        "enabled": false,
        "reopenClosedIncident": false,
        "lookbackDuration": "PT5H",
        "entitiesMatchingMethod": "All",
        "groupByEntities": [
          "Account",
          "Ip",
          "Host",
          "Url"
        ]
      }
    }
  ],
  "Fusion": [

  ],
  "MLBehaviorAnalytics": [

  ],
  "MicrosoftSecurityIncidentCreation": [

  ]
}

If you run the above you will get the following result:
image

@pkhabazi pkhabazi added bug Something isn't working inprogress labels Nov 5, 2020
@pemontto
Copy link
Contributor

pemontto commented Nov 5, 2020

@pkhabazi ahh that did get me, I was trying to use a rule I'd downloaded with Get-AzSentinelAlertRule and realised now that the schemas are completely different. It puts the groupingConfiguration under incidentConfiguration.

incidentConfiguration:
  createIncident: true
  groupingConfiguration:
    enabled: false
    reopenClosedIncident: false
    lookbackDuration: PT5H
    entitiesMatchingMethod: All
    groupByEntities: []

@rleal124
Copy link
Author

rleal124 commented Nov 5, 2020

@pkhabazi Hi, Thanks for your feedback. I used the same template for tests, Also I using one in JSON format and other for YAML format.

In below my format in json:
{
"Scheduled": [
{
"displayName": "AlertRule01",
"description": "AlertRule01description",
"severity": "Medium",
"enabled": true,
"query": "SecurityEvent | where EventID == "4688" | where CommandLine contains "-noni -ep bypass $"",
"queryFrequency": "PT5M",
"queryPeriod": "PT5M",
"triggerOperator": "GreaterThan",
"triggerThreshold": 0,
"suppressionDuration": "PT1H",
"suppressionEnabled": false,
"tactics": [
"Impact"
],
"playbookName": "",
"aggregationKind": "SingleAlert",
"createIncident": true,
"groupingConfiguration": {
"enabled": false,
"reopenClosedIncident": false,
"lookbackDuration": "PT5H",
"entitiesMatchingMethod": "All",
"groupByEntities": [
"Account",
"Ip",
"Host",
"Url"
]
}
}
]
}

And in YAML format
Scheduled:

  • displayName: AlertRule01
    description: AlertRule01description
    severity: Medium
    enabled: true
    query: |
    SecurityEvent
    | where EventID == "4688"
    | where CommandLine contains "-noni -ep bypass $"
    queryFrequency: PT5M
    queryPeriod: PT5M
    triggerOperator: GreaterThan
    triggerThreshold: 0
    suppressionDuration: PT1H
    suppressionEnabled: false
    tactics:
    • Impact
      playbookName: ""
      aggregationKind: SingleAlert
      createIncident: true
      groupingConfiguration:
      enabled: false
      reopenClosedIncident: false
      lookbackDuration: PT5H
      entitiesMatchingMethod: All
      groupByEntities:
      • Account
      • Ip
      • Host
      • Url

@pemontto
Copy link
Contributor

pemontto commented Nov 5, 2020

Working for me now, also had to move aggregationKind out from eventGroupingSettings into the root. Any reason why the schema would be different between the YAML exported and JSON for importing?

@pkhabazi
Copy link
Contributor

pkhabazi commented Nov 6, 2020

@pkhabazi ahh that did get me, I was trying to use a rule I'd downloaded with Get-AzSentinelAlertRule and realised now that the schemas are completely different. It puts the groupingConfiguration under incidentConfiguration.

incidentConfiguration:
  createIncident: true
  groupingConfiguration:
    enabled: false
    reopenClosedIncident: false
    lookbackDuration: PT5H
    entitiesMatchingMethod: All
    groupByEntities: []

That's a good one! I tried to simplify the JSON input format, so I changed the format a little. Maybe a good point to update the output in the same format as input format or the way around.

@pkhabazi
Copy link
Contributor

pkhabazi commented Nov 6, 2020

@rleal124 so thus the template that you shared work or not? And which version of AzSentinel are you using?

@rleal124
Copy link
Author

rleal124 commented Nov 6, 2020

Hi,
@pkhabazi yes is working and current I have the last version of AzSentinel installed (0.6.13)

YAML FILE

`
Scheduled:

  • displayName: AlertRule01
    description: AlertRule01description
    severity: Medium
    enabled: true
    query: |
    SecurityEvent
    | where EventID == "4688"
    | where CommandLine contains "-noni -ep bypass $"
    queryFrequency: PT5M
    queryPeriod: PT5M
    triggerOperator: GreaterThan
    triggerThreshold: 0
    suppressionDuration: PT1H
    suppressionEnabled: false
    tactics:
    -Impact
    playbookName: ""
    aggregationKind: SingleAlert
    createIncident: true
    groupingConfiguration:
    enabled: false
    reopenClosedIncident: false
    lookbackDuration: PT5H
    entitiesMatchingMethod: All
    groupByEntities:
    -Account
    -Ip
    -Host
    -Url
    `

And For JSON

{ "Scheduled": [ { "displayName": "AlertRule01", "description": "AlertRule01description", "severity": "Medium", "enabled": true, "query": "SecurityEvent | where EventID == "4688" | where CommandLine contains "-noni -ep bypass $"", "queryFrequency": "PT5M", "queryPeriod": "PT5M", "triggerOperator": "GreaterThan", "triggerThreshold": 0, "suppressionDuration": "PT1H", "suppressionEnabled": false, "tactics": [ "Impact" ], "playbookName": "", "aggregationKind": "SingleAlert", "createIncident": true, "groupingConfiguration": { "enabled": false, "reopenClosedIncident": false, "lookbackDuration": "PT5H", "entitiesMatchingMethod": "All", "groupByEntities": [ "Account", "Ip", "Host", "Url" ] } } ] }

@pemontto
Copy link
Contributor

pemontto commented Nov 6, 2020

I guess the pulled structure is truer to the API, and may be future proofed if for some reason the names of nested keys overlap, though that seems quite unlikely. I'm happy with either as long as there is consensus.

I've referenced the output schema in the Azure/Azure-Sentinel#585 in the hopes that all rule definitions will be more easily compatible.

@pkhabazi pkhabazi self-assigned this Nov 10, 2020
This was referenced Nov 10, 2020
@pkhabazi pkhabazi linked a pull request Nov 10, 2020 that will close this issue
8 tasks
@pkhabazi pkhabazi reopened this Nov 10, 2020
@pkhabazi
Copy link
Contributor

Reopening issue because we need to find a solution for the correct schema

@pkhabazi
Copy link
Contributor

pkhabazi commented Dec 9, 2020

I have updated the get-azsentinelalertrule function output to match the JSON template format. This will solve the issue with exported rules.

@pkhabazi pkhabazi linked a pull request Dec 14, 2020 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working inprogress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants