1414 The relative scale for the Font Awesome icon within the circle. Default is 0.55.
1515
1616. PARAMETER InputFile
17- The path to the JSON schema file. Default is the repo root bh-scim- extension.json .
17+ The path to the JSON schema file. Default is the hardcoded main extension file .
1818
1919. PARAMETER OutputDir
2020 The directory where PNG icons are written. Default is the Icons directory.
2121
2222. PARAMETER PackageCachePath
2323 The directory where NuGet packages are cached. Default is the BloodHound-IconRender
2424 subdirectory under the temp directory.
25+ . NOTES
26+ Author: Michael Grafnetter
27+ Version: 3.1
2528#>
2629
2730# requires -Version 7
2831
2932[CmdletBinding ()]
33+ [OutputType ([void ])]
3034param (
3135 [Parameter (Mandatory = $false )]
3236 [ValidateNotNullOrEmpty ()]
@@ -51,6 +55,20 @@ param(
5155
5256Set-StrictMode - Version Latest
5357
58+ class NodeDefinition {
59+ [string ] $NodeName
60+ [string ] $IconName
61+ [string ] $IconColor
62+ [string ] $IconType
63+
64+ NodeDefinition([string ] $nodeName , [string ] $iconName , [string ] $iconColor , [string ] $iconType ) {
65+ $this.NodeName = $nodeName
66+ $this.IconName = $iconName
67+ $this.IconColor = $iconColor
68+ $this.IconType = $iconType
69+ }
70+ }
71+
5472<#
5573. SYNOPSIS
5674 Main entry point for the script.
@@ -74,26 +92,23 @@ function Main {
7492
7593 # Parse the JSON file
7694 [psobject ] $json = Get-Content - Path $InputFile | ConvertFrom-Json
77- [psobject []] $nodeDefinitions = @ ( $json .node_kinds | Sort-Object - Property name)
95+ [NodeDefinition []] $nodeDefinitions = Get-NodeDefinitions - Json $json
7896
7997 # Generate PNG icons for each node kind
8098 foreach ($nodeDefinition in $nodeDefinitions ) {
81- [string ] $nodeName = $nodeDefinition.name
82-
83- [string ] $iconName = $null
84- [string ] $iconColor = $null
85- [string ] $iconType = ' font-awesome'
86-
87- if ($nodeDefinition.icon -is [string ]) {
88- $iconName = $nodeDefinition.icon
89- $iconColor = $nodeDefinition.color
99+ [string ] $nodeName = $nodeDefinition.NodeName
100+ [string ] $iconName = $nodeDefinition.IconName
101+ [string ] $iconColor = $nodeDefinition.IconColor
102+ [string ] $iconType = $nodeDefinition.IconType
103+
104+ if ([string ]::IsNullOrWhiteSpace($iconName )) {
105+ Write-Warning " Skipping ${nodeName} `: icon name is missing."
106+ continue
90107 }
91- else {
92- $iconName = $nodeDefinition.icon.name
93- $iconColor = $nodeDefinition.icon.color
94- if ($nodeDefinition.icon.type ) {
95- $iconType = $nodeDefinition.icon.type
96- }
108+
109+ if ([string ]::IsNullOrWhiteSpace($iconColor )) {
110+ Write-Warning " Skipping ${nodeName} `: icon color is missing."
111+ continue
97112 }
98113
99114 if (-not [string ]::IsNullOrWhiteSpace($iconColor )) {
@@ -104,6 +119,69 @@ function Main {
104119 }
105120}
106121
122+ <#
123+ . SYNOPSIS
124+ Normalizes node definitions from supported extension formats.
125+
126+ . PARAMETER Json
127+ The parsed JSON object.
128+
129+ . OUTPUTS
130+ Array of objects with Name, IconName, IconColor, and IconType properties.
131+ #>
132+ function Get-NodeDefinitions {
133+ [OutputType ([NodeDefinition ])]
134+ param (
135+ [Parameter (Mandatory = $true )]
136+ [psobject ] $Json
137+ )
138+ <#
139+ New extension format:
140+ {
141+ "node_kinds": [
142+ {
143+ "name": "AZ_Tenant",
144+ "display_name": "Azure Tenant",
145+ "description": "An Azure tenant environment",
146+ "is_display_kind": "true",
147+ "icon": "cloud",
148+ "color": "0xFF00FF"
149+ }
150+ ]
151+ }
152+ #>
153+ if ($null -ne $Json.PSObject.Properties [' node_kinds' ]) {
154+ foreach ($node in $Json.node_kinds ) {
155+ [NodeDefinition ]::new($node.name , $node.icon , $node.color , ' font-awesome' )
156+ }
157+ return
158+ }
159+ <#
160+ Old custom types format:
161+ {
162+ "custom_types": {
163+ "OktaOrganization": {
164+ "icon": {
165+ "color": "#16a5a5",
166+ "name": "globe",
167+ "type": "font-awesome"
168+ }
169+ }
170+ }
171+ }
172+ #>
173+ if ($null -ne $Json.PSObject.Properties [' custom_types' ]) {
174+ [string []] $nodeNames = $Json.custom_types | Get-Member - MemberType NoteProperty | Select-Object - ExpandProperty Name
175+ foreach ($nodeName in $nodeNames ) {
176+ [psobject ] $nodeDefinition = $Json.custom_types .$nodeName
177+ [NodeDefinition ]::new($nodeName , $nodeDefinition.icon.name , $nodeDefinition.icon.color , $nodeDefinition.icon.type )
178+ }
179+ return
180+ }
181+
182+ throw ' Unsupported schema format: expected node_kinds or custom_types.'
183+ }
184+
107185<#
108186. SYNOPSIS
109187 Sanitizes a string to be safe for use as a filename by replacing invalid characters with underscores.
@@ -290,6 +368,7 @@ function Import-NuGetLibrary {
290368 This ensures that the required types for rendering icons are available in the script.
291369#>
292370function Import-SkiaDependencies {
371+ [OutputType ([void ])]
293372 param (
294373 [Parameter (Mandatory = $true )]
295374 [string ] $CacheRoot
@@ -533,4 +612,3 @@ function New-NodeIcon {
533612}
534613
535614Main
536-
0 commit comments