microsoftgraph / microsoftgraph/msgraph-sdk-powershell

Switch From Using Unmaintained Newtonsoft.Json to Using System.Text.Json in Powershell Authentication Module

Open
#2,774 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement type:security
Dominant language
C#
Stars
898
Forks
230
Avg merge
2d 5h
Merged PRs (30d)
31

Description

Describe the bug

The Newtonsoft.Json dependency of the SDK's authentication module, is no longer actively maintained. In the past we have also encountered trust issues with the signed Newtonsoft.Json package throwing verificationError 18 which interprets to
"Your file is signed but we don't trust it"
and PS SDK users, have raised this too as an issue for them. See https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/2741 and https://github.com/JamesNK/Newtonsoft.Json/issues/2755

Expected behavior

Avoid Newtonsoft.Json related issues mentioned above by switching to System.Text.Json

How to reproduce

The task will include writing tests to cover the affected code segments and mitigate against any regressions before switching to system.text.json.

The current tricky work is the Json DOM handling in the 3 files below

It should be easier to replace JsonConvert.SerializeObject with JsonSerializer.Seralize in other files like https://github.com/microsoftgraph/msgraph-sdk-powershell/blob/f06dcb11f2064bcd73ba3393dc9523c9bd45235f/src/Authentication/Authentication/Cmdlets/InvokeMgGraphRequest.cs#L579

Acceptance Criteria
  • 100% test coverage on affected files/files originally using Newtonsoft.Json package
  • Working authentication module with the tests passing and using System.Text.Json instead of Newtonsoft.Json

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 reading GraphSettings.cs, GraphSettingsConverter.cs, and StringUtil.cs, then inspect the other authentication files using Newtonsoft.Json, including InvokeMgGraphRequest.cs. Add tests for the affected code and verify the authentication module passes all tests while using System.Text.Json and no longer relying on Newtonsoft.Json.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, json, powershell
Domain
authentication
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.