PowerShell / PowerShell/DSC

Parameter `secureString` transforms input incorrectly on adapter

Open
#1,209 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Bug Need-Review
Dominant language
Rust
Stars
523
Forks
75
Avg merge
3d 16h
Merged PRs (30d)
24

Description

Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.
Summary

Whilst working on #1208, another issue popped up. I have the following configuration document:

$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
parameters:
  myString:
    type: secureString
    defaultValue: "MySecret"
resources:
- name: Class-resource Info
  type: TestClassResource/TestClassResource
  properties:
    Name: 'TestClassResource'
    SecureStringProp: "[parameters('myString')]"

Instead of parsing the input through the adapter as such (seen in the logging):

{"resources":[{"name":"TestClassResource/TestClassResource","type":"TestClassResource/TestClassResource","properties":{"Name":"TestClassResource","SecureStringProp":"MySecret"}}],"metadata":{"Microsoft.DSC":{"context":"configuration"}}}

It does it like:

jsonInput={"resources":[{"name":"TestClassResource/TestClassResource","type":"TestClassResource/TestClassResource","properties":{"Name":"TestClassResource","SecureStringProp":{"secureString":"MySecret"}}}],"metadata":{"Microsoft.DSC":{"context":"configuration"}}}

Which results in the following error: Exception setting "SecureStringProp": "Cannot create object of type "System.Security.SecureString". The property 'secureString' was not found for the 'System.Security.SecureString' object. There is no settable property available."

Steps to reproduce

See steps above.

Expected behavior
The secure string is parsed as string
Actual behavior
The secure string is parsed as object
Error details

Environment data
Name                           Value
----                           -----
PSVersion                      7.5.3
PSEdition                      Core
GitCommitId                    7.5.3
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Version

dsc 3.2.0-preview.6

Visuals

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the YAML configuration document and inspect the adapter logging to trace where the secureString value becomes an object. Confirm the adapter emits SecureStringProp as "MySecret" rather than {"secureString":"MySecret"}, and verify the configuration applies successfully to the TestClassResource resource.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, rust
Domain
devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.