Skip to content

Commit

Permalink
(GH-642) Ensure camelCase for items in dsc_lib
Browse files Browse the repository at this point in the history
Prior to this change, the structs and enums in `dsc_lib` didn't consistently
use camelCase - most property names and enum values use camelCase, but not
all - and this inconsistency isn't predictable for end users, who need to
consult the JSON Schemas to be sure.

This change updates the definitions to rename the fields and values when
serializing and deserializing, which also updates their JSON Schema.

A future change is required to update the canonical schemas in the
repository to match these updates.
  • Loading branch information
michaeltlombardi committed Feb 18, 2025
1 parent 3963389 commit 39f84b7
Show file tree
Hide file tree
Showing 34 changed files with 3,526 additions and 3,518 deletions.
124 changes: 62 additions & 62 deletions configurations/windows/windows_baseline.dsc.yaml
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
# This configuration validates a Windows system against a security baseline configuration
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
metadata:
Microsoft.DSC:
securityContext: Elevated
resources:
- name: Validate the OS is Windows
type: Microsoft.DSC/Assertion
properties:
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: os
type: Microsoft/OSInfo
properties:
family: Windows
- name: Registry checks
type: Microsoft.DSC/Group
dependsOn:
- "[resourceId('Microsoft.DSC/Assertion','Validate the OS is Windows')]"
properties:
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Default RDP port
type: Microsoft.Windows/Registry
metadata:
area: Network Access
severity: Critical
properties:
keyPath: HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
valueName: PortNumber
valueData:
DWord: 3389
- name: Disable SMBv1
type: Microsoft.Windows/Registry
metadata:
area: Network Access
severity: Critical
properties:
keyPath: HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters
valueName: SMB1
valueData:
DWord: 0 # Disabled
- name: Disable Windows Search service
type: Microsoft.Windows/Registry
metadata:
area: Services
severity: Critical
properties:
keyPath: HKLM\SYSTEM\CurrentControlSet\Services\WSearch
valueName: Start
valueData:
DWord: 4 # Disabled
- name: Scan Removeable Drives
type: Microsoft.Windows/Registry
metadata:
area: Services
severity: Critical
properties:
keyPath: HKLM\SOFTWARE\Policies\Microsoft\Windows Defender
valueName: DisableRemovableDriveScanning
valueData:
DWord: 0 # Disabled
# This configuration validates a Windows system against a security baseline configuration
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
metadata:
Microsoft.DSC:
securityContext: elevated
resources:
- name: Validate the OS is Windows
type: Microsoft.DSC/Assertion
properties:
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: os
type: Microsoft/OSInfo
properties:
family: Windows
- name: Registry checks
type: Microsoft.DSC/Group
dependsOn:
- "[resourceId('Microsoft.DSC/Assertion','Validate the OS is Windows')]"
properties:
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Default RDP port
type: Microsoft.Windows/Registry
metadata:
area: Network Access
severity: Critical
properties:
keyPath: HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
valueName: PortNumber
valueData:
DWord: 3389
- name: Disable SMBv1
type: Microsoft.Windows/Registry
metadata:
area: Network Access
severity: Critical
properties:
keyPath: HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters
valueName: SMB1
valueData:
DWord: 0 # Disabled
- name: Disable Windows Search service
type: Microsoft.Windows/Registry
metadata:
area: Services
severity: Critical
properties:
keyPath: HKLM\SYSTEM\CurrentControlSet\Services\WSearch
valueName: Start
valueData:
DWord: 4 # Disabled
- name: Scan Removeable Drives
type: Microsoft.Windows/Registry
metadata:
area: Services
severity: Critical
properties:
keyPath: HKLM\SOFTWARE\Policies\Microsoft\Windows Defender
valueName: DisableRemovableDriveScanning
valueData:
DWord: 0 # Disabled
154 changes: 77 additions & 77 deletions dsc/assertion.dsc.resource.json
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
{
"$schema": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/bundled/resource/manifest.json",
"type": "Microsoft.DSC/Assertion",
"version": "0.1.0",
"description": "`test` will be invoked for all resources in the supplied configuration.",
"kind": "Group",
"get": {
"executable": "dsc",
"args": [
"--trace-format",
"pass-through",
"config",
"--as-group",
"test",
"--as-get",
{
"jsonInputArg": "--input",
"mandatory": true
}
]
},
"set": {
"executable": "dsc",
"args": [
"--trace-format",
"pass-through",
"config",
"--as-group",
"test",
{
"jsonInputArg": "--input",
"mandatory": true
}
],
"implementsPretest": true,
"return": "state"
},
"test": {
"executable": "dsc",
"args": [
"--trace-format",
"pass-through",
"config",
"--as-group",
"test",
"--as-config",
{
"jsonInputArg": "--input",
"mandatory": true
}
],
"return": "state"
},
"exitCodes": {
"0": "Success",
"1": "Invalid argument",
"2": "Resource error",
"3": "JSON Serialization error",
"4": "Invalid input format",
"5": "Resource instance failed schema validation",
"6": "Command cancelled",
"7": "Resource not found"
},
"validate": {
"executable": "dsc",
"args": [
"--trace-format",
"pass-through",
"config",
"validate",
{
"jsonInputArg": "--input",
"mandatory": true
}
]
}
}
{
"$schema": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/bundled/resource/manifest.json",
"type": "Microsoft.DSC/Assertion",
"version": "0.1.0",
"description": "`test` will be invoked for all resources in the supplied configuration.",
"kind": "group",
"get": {
"executable": "dsc",
"args": [
"--trace-format",
"pass-through",
"config",
"--as-group",
"test",
"--as-get",
{
"jsonInputArg": "--input",
"mandatory": true
}
]
},
"set": {
"executable": "dsc",
"args": [
"--trace-format",
"pass-through",
"config",
"--as-group",
"test",
{
"jsonInputArg": "--input",
"mandatory": true
}
],
"implementsPretest": true,
"return": "state"
},
"test": {
"executable": "dsc",
"args": [
"--trace-format",
"pass-through",
"config",
"--as-group",
"test",
"--as-config",
{
"jsonInputArg": "--input",
"mandatory": true
}
],
"return": "state"
},
"exitCodes": {
"0": "Success",
"1": "Invalid argument",
"2": "Resource error",
"3": "JSON Serialization error",
"4": "Invalid input format",
"5": "Resource instance failed schema validation",
"6": "Command cancelled",
"7": "Resource not found"
},
"validate": {
"executable": "dsc",
"args": [
"--trace-format",
"pass-through",
"config",
"validate",
{
"jsonInputArg": "--input",
"mandatory": true
}
]
}
}
82 changes: 41 additions & 41 deletions dsc/examples/groups.dsc.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
# Example for grouping and groups in groups
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
metadata:
Microsoft.DSC:
requiredSecurityContext: Current # this is the default and just used as an example indicating this config works for admins and non-admins
resources:
- name: Last Group
type: Microsoft.DSC/Group
properties:
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Last
type: Microsoft.DSC.Debug/Echo
properties:
output: Last
dependsOn:
- "[resourceId('Microsoft.DSC/Group','First Group')]"
- name: First Group
type: Microsoft.DSC/Group
properties:
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: First
type: Microsoft.DSC.Debug/Echo
properties:
output: First
- name: Nested Group
type: Microsoft.DSC/Group
properties:
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Nested Second
type: Microsoft.DSC.Debug/Echo
properties:
output: Nested Second
dependsOn:
- "[resourceId('Microsoft.DSC.Debug/Echo','Nested First')]"
- name: Nested First
type: Microsoft.DSC.Debug/Echo
properties:
output: Nested First
# Example for grouping and groups in groups
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
metadata:
Microsoft.DSC:
requiredSecurityContext: current # this is the default and just used as an example indicating this config works for admins and non-admins
resources:
- name: Last Group
type: Microsoft.DSC/Group
properties:
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Last
type: Microsoft.DSC.Debug/Echo
properties:
output: Last
dependsOn:
- "[resourceId('Microsoft.DSC/Group','First Group')]"
- name: First Group
type: Microsoft.DSC/Group
properties:
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: First
type: Microsoft.DSC.Debug/Echo
properties:
output: First
- name: Nested Group
type: Microsoft.DSC/Group
properties:
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Nested Second
type: Microsoft.DSC.Debug/Echo
properties:
output: Nested Second
dependsOn:
- "[resourceId('Microsoft.DSC.Debug/Echo','Nested First')]"
- name: Nested First
type: Microsoft.DSC.Debug/Echo
properties:
output: Nested First
22 changes: 11 additions & 11 deletions dsc/examples/require_admin.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# example showing use of specific metadata to indicate this config requires admin to run
# note that the resource doesn't require admin, but this will fail to even try to run the
# config if the user is not root or elevated as administrator
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
metadata:
Microsoft.DSC:
securityContext: Elevated
resources:
- name: os
type: Microsoft/OSInfo
properties: {}
# example showing use of specific metadata to indicate this config requires admin to run
# note that the resource doesn't require admin, but this will fail to even try to run the
# config if the user is not root or elevated as administrator
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
metadata:
Microsoft.DSC:
securityContext: elevated
resources:
- name: os
type: Microsoft/OSInfo
properties: {}
Loading

0 comments on commit 39f84b7

Please sign in to comment.