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

Model cmdlet generated parameters don't export to hash table #1225

Open
JoyerJin opened this issue Sep 1, 2023 · 1 comment
Open

Model cmdlet generated parameters don't export to hash table #1225

JoyerJin opened this issue Sep 1, 2023 · 1 comment
Labels

Comments

@JoyerJin
Copy link

JoyerJin commented Sep 1, 2023

model-cmdlet:
model-name: AnomalySecurityMlAnalyticsSettings

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

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

readme.md

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`
@dolauli dolauli added the P1 label Sep 7, 2023
@JoyerJin
Copy link
Author

JoyerJin commented Oct 17, 2023

New model in DataCollectionRule:

function New-AzPrometheusForwarderDataSourceObject {
    [OutputType('Microsoft.Azure.PowerShell.Cmdlets.Monitor.DataCollection.Models.PrometheusForwarderDataSource')]
    [CmdletBinding(PositionalBinding=$false)]
    Param(

        [Parameter(HelpMessage="The list of label inclusion filters in the form of label `"name-value`" pairs.
        Currently only one label is supported: 'microsoft_metrics_include_label'.
        Label values are matched case-insensitively.")]
        [System.Collections.HashTable]
        $LabelIncludeFilter,
        [Parameter(HelpMessage="A friendly name for the data source.
        This name should be unique across all data sources (regardless of type) within the data collection rule.")]
        [string]
        $Name,
        [Parameter(HelpMessage="List of streams that this data source will be sent to.")]
        [Microsoft.Azure.PowerShell.Cmdlets.Monitor.DataCollection.PSArgumentCompleterAttribute("Microsoft-PrometheusMetrics")]
        [string[]]
        $Stream
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants