Emit warning if ConvertTo-Json exceeds -Depth value#13692
Merged
iSazonov merged 4 commits intoPowerShell:masterfrom Sep 28, 2020
Merged
Emit warning if ConvertTo-Json exceeds -Depth value#13692iSazonov merged 4 commits intoPowerShell:masterfrom
ConvertTo-Json exceeds -Depth value#13692iSazonov merged 4 commits intoPowerShell:masterfrom
Conversation
Collaborator
|
@SteveL-MSFT If we will move to new .Net JSON API in next milestone (7.2 LTS!) does it make sense to change anything today in JSON cmdlets? |
Member
Author
|
@iSazonov this change doesn't impact functionality and addresses the concern that users aren't aware they aren't getting a full fidelity serialization of their object. I think it's ok to take this for 7.1 even if we plan to move to .NET JSON API in 7.2. |
iSazonov
reviewed
Sep 25, 2020
test/powershell/Modules/Microsoft.PowerShell.Security/SecureString.Tests.ps1
Show resolved
Hide resolved
iSazonov
approved these changes
Sep 25, 2020
14 tasks
rjmholt
approved these changes
Sep 28, 2020
|
Thank you! |
|
🎉 Handy links: |
|
🎉 Handy links: |
Member
|
Not taking this to 7.0.x as it adds a new warning and is a change in behavior. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
When using
ConvertTo-Json, the default-Depthvalue is 2 to avoid recursion for objects like Services on Windows. Users who do not set a deep enough depth may be losing data they may not be aware of as they expected full fidelity of the object to be serialized to JSON. The change agreed by @PowerShell/powershell-committee is to emit a warning message once the depth is exceeded. The warning is only emitted once per object serialized, but note that arrays are treated as a single object and not unrolled.The SecureString tests were updated because it seems a credscan change identified a test "secret" in the script and caused CI to fail. After fixing that, I needed to have scriptanalyzer not fail on using plaintext "secret".
PR Context
Fix #8393
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.