Azure / Azure/autorest.powershell

Model cmdlet generated parameters don't export to hash table

Open
#1,225 1 comment 0 reactions 0 assignees View on GitHub
P1
Dominant language
C#
Stars
123
Forks
99
PR merge metrics
No merged PRs in 30d

Description

> model-cmdlet:
> model-name: **AnomalySecurityMlAnalyticsSettings**

generated cmdlets:
New-AzSentinelAnomalySecurityMlAnalyticsSettingsObject [-AnomalySettingsVersion ]
[-AnomalyVersion ]
[-CustomizableObservation <**IAnomalySecurityMlAnalyticsSettingsPropertiesCustomizableObservations**>]
[-Description ] [-DisplayName ] [-Enabled ] [-Etag ] [-Frequency ]
[-IsDefaultSetting ] [-RequiredDataConnector ]
[-SettingsDefinitionId ] [-SettingsStatus ] [-Tactic ] [-Technique ]
[]

Issue: the value of param customizableObservations should be hash table type.

readme.md
```` yaml
require:
- $(this-folder)/../readme.azure.noprofile.md
# lock the commit
branch: 5bf60a6746bc03fbff78cc68595eb11f2f212d19
tag: package-2023-02

input-file:
- $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/AlertRules.json
- $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/AutomationRules.json
- $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/Bookmarks.json
- $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/DataConnectors.json
- $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/Incidents.json
- $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/Metadata.json
- $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/OnboardingStates.json
- $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/SecurityMLAnalyticsSettings.json
- $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/ThreatIntelligence.json
# - $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/Watchlists.json
- $(repo)/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/stable/2023-02-01/operations.json

module-version: 1.2.0
title: SecurityInsights
subject-prefix: Sentinel

inlining-threshold: 50

use-extension:
"@autorest/powershell": "4.x"
disable-getput: true
support-json-input: false

directive:
# Customize
- no-inline:
- SecurityMlAnalyticsSetting
- model-cmdlet:
- model-name: AnomalySecurityMlAnalyticsSettings
- model-name: PropertyConditionProperties
- model-name: PropertyChangedConditionProperties
- model-name: PropertyArrayChangedConditionProperties
- model-name: AutomationRuleRunPlaybookAction
- model-name: AutomationRuleModifyPropertiesAction
- model-name: SecurityMlAnalyticsSettingsDataSource
#Hash Table
- from: SecurityMLAnalyticsSettings.json
where: $.definitions.AnomalySecurityMLAnalyticsSettingsProperties.properties.customizableObservations
transform: >-
return {
"description": "The customizable observations of the AnomalySecurityMLAnalyticsSettings.",
"additionalProperties": true,
"type": "object"
}
# Hide Operation API
- where:
subject: Operation
hide: true
# Fix Action to be AlertRuleAction
- where:
subject: Action
set:
subject: AlertRuleAction
# Change Sets to Updates to match current module
- where:
verb: Set
set:
verb: Update
- where:
subject: QueryThreatIntelligenceIndicator
set:
subject: ThreatIntelligenceIndicatorQuery
# Fix Update ThreatIntelligenceIndicator
- select: command
where:
verb: New
subject: ThreatIntelligenceIndicator
variant: CreateExpanded1
set:
verb: Update
variant: UpdateExpanded
- select: command
where:
verb: New
subject: ThreatIntelligenceIndicator
variant: CreateViaIdentity1
set:
verb: Update
variant: UpdateViaIdentity
- select: command
where:
verb: New
subject: ThreatIntelligenceIndicator
variant: CreateViaIdentityExpanded1
set:
verb: Update
variant: UpdateViaIdentityExpanded
- where:
subject: ThreatIntelligenceIndicatorQuery
variant: QueryViaIdentityExpanded
remove: true
- where:
subject: ^AlertRule$|^DataConnector$
variant: ^(Create|Update)(ViaIdentity)?(Workspace)?(Expanded)?$
hide: true
# Remove the unexpanded parameter set
- where:
variant: ^Query$|^QueryViaIdentity$
remove: true
- where:
variant: ^(Create|Update)(?!.*?Expanded)
subject: ^AlertRuleAction$|^AutomationRule$|^Bookmark$|^Incident$|^IncidentComment$|^IncidentRelation$|^OnboardingState$
remove: true
# Remove the expanded parameter set for SecurityMlAnalyticsSetting
- where:
subject: SecurityMlAnalyticsSetting
variant: ^(Create|Update)(.*Expanded)$
hide: true
# Hide Etag as it isnt used
- where:
parameter-name: Etag
hide: true
# TI API not useful until API changes
- where:
verb: ^Add$|^New$|^Update$|^Remove$
subject: ThreatIntelligenceIndicator
hide: true
- where:
verb: ^Add$|^New$|^Update$|^Remove$
subject: ThreatIntelligenceIndicatorTag
hide: true
# cmdlet review feedback
- where:
subject: Bookmark
parameter-name: Created|^Updated$
hide: true
- where:
verb: New
subject: AlertRuleAction
variant: Create
hide: true
- where:
verb: New
subject: ^AlertRuleAction$|^AutomationRule$|^Bookmark$|^Incident$|^IncidentComment$|
parameter-name: Id
set:
default:
script: '(New-Guid).Guid'
- where:
verb: New
subject: ^IncidentRelation$
parameter-name: RelationName
set:
default:
script: '(New-Guid).Guid'
- where:
verb: New
subject: ^AlertRule$
parameter-name: RuleId
set:
default:
script: '(New-Guid).Guid'
- where:
verb: ^New$|^Update$|^Remove$
subject: Metadata
hide: true
# Rename Id for user expierence
- where:
subject: AlertRuleAction
parameter-name: Id
set:
alias: ActionId
- where:
subject: AlertRuleTemplate
parameter-name: Id
set:
alias: TemplateId
- where:
subject: AutomationRule
parameter-name: Id
set:
alias: AutomationRuleId
- where:
subject: Bookmark
parameter-name: Id
set:
alias: BookmarkId
- where:
subject: DataConnector
parameter-name: Id
set:
alias: DataConnectorId
- where:
subject: Incident
parameter-name: Id
set:
alias: IncidentId
- where:
subject: IncidentComment
parameter-name: Id
set:
alias: IncidentCommentId
# fix Equals that conflicts with inhertied property
- where:
enum-name: AutomationRulePropertyConditionSupportedOperator
enum-value-name: Equals
set:
enum-value-name: Equal`

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the readme.md configuration and the SecurityMLAnalyticsSettings.json definition, focusing on the model-cmdlet directive and the transform for customizableObservations. Regenerate the SecurityInsights cmdlets and verify that New-AzSentinelAnomalySecurityMlAnalyticsSettingsObject exposes CustomizableObservation as a hash-table parameter rather than the generated interface type.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, yaml
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.