Compare commits

...

5 Commits

Author SHA1 Message Date
DoLearnWhileAlive 8f5c724737 ConvertTo-MOFInstance: Include resource properties with empty array value (#127)
* ConvertTo-MOFInstance: Include resource properties with empty array value

* Add test for checking mof compilation with empty array value
2025-12-04 12:48:57 -08:00
Raimund Andrée e32eb0fe51 Fixed an issue with array parameters is key-value pairs (#128) (#129)
* Fixed an issue with array parameters is key-value pairs (#128)

* Add hashtable property to xTestClassResource

* Add support for Hashtable property in DSC resource tests
2025-12-04 12:47:16 -08:00
Andy Jordan c26e6b79d0 Update Code of Conduct and Security Policy (#124)
Updates the readme, code of conduct and security policy per OSPO request.
2024-07-03 15:29:29 -07:00
Michael Greene b711f75b46 Update ReadMe (#114)
* Update README.md

* Update README.md

* Update README.md

Co-authored-by: Mikey Lombardi (He/Him) <michael.t.lombardi@gmail.com>

---------

Co-authored-by: Mikey Lombardi (He/Him) <michael.t.lombardi@gmail.com>
2023-08-04 09:34:33 -07:00
Andrew d6e028d39c Updated changelog for v2.0.7 2023-05-13 12:11:56 -07:00
7 changed files with 113 additions and 6 deletions
+10
View File
@@ -0,0 +1,10 @@
# Microsoft Open Source Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
Resources:
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
- Employees can reach out at [aka.ms/opensource/moderation-support](https://aka.ms/opensource/moderation-support)
+41
View File
@@ -0,0 +1,41 @@
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.9 BLOCK -->
## Security
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin) and [PowerShell](https://github.com/PowerShell).
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below.
## Reporting Security Issues
**Please do not report security vulnerabilities through public GitHub issues.**
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report).
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp).
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue
This information will help us triage your report more quickly.
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs.
## Preferred Languages
We prefer all communications to be in English.
## Policy
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd).
<!-- END MICROSOFT SECURITY.MD BLOCK -->
+9
View File
@@ -1,5 +1,14 @@
# v2 Changelog # v2 Changelog
## [v2.0.7]
### Main changes
- Fixed Invoke-DscResource error when a class-based resource module path contains a space.
- Fixed an issue with array parameters is key-value pairs (#128).
[v2.0.7]: https://www.powershellgallery.com/packages/PSDesiredStateConfiguration/2.0.7
## [v2.0.6] ## [v2.0.6]
### Main changes ### Main changes
+10 -1
View File
@@ -1,6 +1,7 @@
# PSDesiredStateConfiguration module # PSDesiredStateConfiguration module
**NOTE: We are currently NOT accepting PRs for this project** > [!NOTE]
> The next generation of this platform is in development. Please submit your feedback on [DSC v3](https://github.com/powershell/dsc).
**PSDesiredStateConfiguration** (DSC) is the PowerShell module that enables writing configuration as code. **PSDesiredStateConfiguration** (DSC) is the PowerShell module that enables writing configuration as code.
@@ -58,3 +59,11 @@ CI pipeline definition is in `.vsts-ci\azure-pipelines-ci.yml` and running Compl
## Publishing Releases ## Publishing Releases
[The module is released on Powershell Gallery](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration). [The module is released on Powershell Gallery](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration).
For a release the code of this repo is mirrored into an internal repo and `.vsts-ci\azure-pipelines-release.yml` pipeline is run. Release builds are signed. For a release the code of this repo is mirrored into an internal repo and `.vsts-ci\azure-pipelines-release.yml` pipeline is run. Release builds are signed.
## Code of Conduct
Please see our [Code of Conduct](.github/CODE_OF_CONDUCT.md) before participating in this project.
## Security Policy
For any security issues, please see our [Security Policy](.github/SECURITY.md).
@@ -509,7 +509,7 @@ function ConvertTo-MOFInstance
$targetTypeName = $PropertyTypes[$p.Name].TypeConstraint $targetTypeName = $PropertyTypes[$p.Name].TypeConstraint
# see if the target type is an array # see if the target type is an array
$asArray = $p.Name -eq 'DependsOn' -or $targetTypeName -match 'Array' $asArray = $p.Name -eq 'DependsOn' -or $targetTypeName -match 'Array' -or ((-not [string]::IsNullOrEmpty($targetTypeName)) -and $targetTypeName.EndsWith('[]'))
# Convert the CIM typename to the appropriate .NET type to use # Convert the CIM typename to the appropriate .NET type to use
# to convert the input object into an appropriately encoded string # to convert the input object into an appropriately encoded string
@@ -671,10 +671,7 @@ function ConvertTo-MOFInstance
} }
else else
{ {
if ($targetTypeName -notmatch 'Array' -or $p.Value.Count) $p.Name + ' = ' + (stringify -value $p.Value -asArray $asArray -targetType $targetType ) + ";`n"
{
$p.Name + ' = ' + (stringify -value $p.Value -asArray $asArray -targetType $targetType ) + ";`n"
}
} }
} }
} }
@@ -302,6 +302,8 @@ Describe "All types DSC resource tests" {
"uInt32ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt32[]]'} "uInt32ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt32[]]'}
"uInt64Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt64]'} "uInt64Value" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt64]'}
"uInt64ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt64[]]'} "uInt64ValueArray" {$dscResourcePropertyInfo.PropertyType | Should -Be '[UInt64[]]'}
"HashTableValue" {$dscResourcePropertyInfo.PropertyType | Should -Be '[Hashtable]'}
} }
} }
} }
@@ -350,6 +352,8 @@ Describe "All types DSC resource tests" {
$resource.uInt64Value.GetType().Name | Should -Be "UInt64" $resource.uInt64Value.GetType().Name | Should -Be "UInt64"
$resource.uInt64ValueArray.GetType().Name | Should -Be "UInt64[]" $resource.uInt64ValueArray.GetType().Name | Should -Be "UInt64[]"
$resource.HashTableValue.GetType().Name | Should -Be "Hashtable"
# extra check for embedded objects # extra check for embedded objects
$resource.EmbClassObj.EmbClassStr1 | Should -Be "TestEmbObjValue" $resource.EmbClassObj.EmbClassStr1 | Should -Be "TestEmbObjValue"
$resource.EmbClassObjArray[0].EmbClassStr1 | Should -Be "TestEmbClassStr1Value" $resource.EmbClassObjArray[0].EmbClassStr1 | Should -Be "TestEmbClassStr1Value"
@@ -400,6 +404,11 @@ configuration DSCAllTypesConfig
sInt32ValueArray = @(-2147483648) sInt32ValueArray = @(-2147483648)
uInt64ValueArray = @(18446744073709551615) uInt64ValueArray = @(18446744073709551615)
sInt64ValueArray = @(-9223372036854775808) sInt64ValueArray = @(-9223372036854775808)
HashTableValue = @{
Key1 = 'Value1'
Key2 = 'Value2'
}
} }
} }
} }
@@ -439,4 +448,31 @@ MultiResourceConfig -OutputPath TestDrive:\MultiResourceConfig
"TestDrive:\MultiResourceConfig\localhost.mof" | Should -Exist "TestDrive:\MultiResourceConfig\localhost.mof" | Should -Exist
Get-Content -Raw -Path "TestDrive:\MultiResourceConfig\localhost.mof" | Write-Verbose -Verbose Get-Content -Raw -Path "TestDrive:\MultiResourceConfig\localhost.mof" | Write-Verbose -Verbose
} }
It "Check empty array compilation" {
[Scriptblock]::Create(@"
configuration DSCEmptyArrayConfig
{
Import-DscResource -ModuleName xTestClassResource
Node "localhost" {
xTestClassResource f2
{
Name = 'TestName'
Value = 'TestValue'
sArray = @()
}
}
}
DSCEmptyArrayConfig -OutputPath TestDrive:\DSCEmptyArrayConfig
"@) | Should -Not -Throw
"TestDrive:\DSCEmptyArrayConfig\localhost.mof" | Should -Exist
$mofContent = Get-Content -Raw -Path "TestDrive:\DSCEmptyArrayConfig\localhost.mof"
$mofContent | Write-Verbose -Verbose
$mofContent -match '\ssArray\s=\s{\r\n};' | Should -BeTrue
}
} }
@@ -109,6 +109,9 @@ class xTestClassResource
[DscProperty()] [DscProperty()]
[Char[]] $char16ValueArray; [Char[]] $char16ValueArray;
[DscProperty()]
[hashtable] $HashTableValue;
[void] Set() [void] Set()
{ {
@@ -257,6 +260,8 @@ class xTestClassResource
$this.Real32ValueArray = [single[]]::new(0) $this.Real32ValueArray = [single[]]::new(0)
$this.Real64ValueArray = [double[]]::new(0) $this.Real64ValueArray = [double[]]::new(0)
$this.HashTableValue = @{}
return $this return $this
} }
} }