-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ASM][IAST] Support manual JSON deserialisation (Newtonsoft.Json) (#5238
) * Add Newtonsoft.Json (non -working yet) * Refactor the tainting proces + add tests * Add the JToken Parse aspect + test * Rename Aspects class + Duck orignal method call * Add integration test * Fix nullability * Fix compilation issue for netfx * Change JSON formatting in ParseTests * Fix a test json format * Refactor NewtonsoftJsonAspects to static constructor
- Loading branch information
Showing
17 changed files
with
642 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
13 changes: 13 additions & 0 deletions
13
tracer/src/Datadog.Trace/Iast/Aspects/Newtonsoft.Json/ICanParse.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// <copyright file="ICanParse.cs" company="Datadog"> | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
// </copyright> | ||
|
||
#nullable enable | ||
|
||
namespace Datadog.Trace.Iast.Aspects.Newtonsoft.Json; | ||
|
||
internal interface ICanParse | ||
{ | ||
object Parse(string json); | ||
} |
15 changes: 15 additions & 0 deletions
15
tracer/src/Datadog.Trace/Iast/Aspects/Newtonsoft.Json/IJObject.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// <copyright file="IJObject.cs" company="Datadog"> | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
// </copyright> | ||
|
||
#nullable enable | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace Datadog.Trace.Iast.Aspects.Newtonsoft.Json; | ||
|
||
internal interface IJObject | ||
{ | ||
public IEnumerable<object> Properties(); | ||
} |
13 changes: 13 additions & 0 deletions
13
tracer/src/Datadog.Trace/Iast/Aspects/Newtonsoft.Json/IJToken.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// <copyright file="IJToken.cs" company="Datadog"> | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
// </copyright> | ||
|
||
#nullable enable | ||
|
||
namespace Datadog.Trace.Iast.Aspects.Newtonsoft.Json; | ||
|
||
internal interface IJToken | ||
{ | ||
public JTokenTypeProxy Type { get; } | ||
} |
15 changes: 15 additions & 0 deletions
15
tracer/src/Datadog.Trace/Iast/Aspects/Newtonsoft.Json/IJValue.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// <copyright file="IJValue.cs" company="Datadog"> | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
// </copyright> | ||
|
||
#nullable enable | ||
|
||
namespace Datadog.Trace.Iast.Aspects.Newtonsoft.Json; | ||
|
||
internal interface IJValue | ||
{ | ||
object Value { get; } // as an interface because in a struct it would fail with an AmbiguousMatchException | ||
|
||
JTokenTypeProxy Type { get; } | ||
} |
16 changes: 16 additions & 0 deletions
16
tracer/src/Datadog.Trace/Iast/Aspects/Newtonsoft.Json/JPropertyStruct.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// <copyright file="JPropertyStruct.cs" company="Datadog"> | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
// </copyright> | ||
|
||
#nullable enable | ||
|
||
using Datadog.Trace.DuckTyping; | ||
|
||
namespace Datadog.Trace.Iast.Aspects.Newtonsoft.Json; | ||
|
||
[DuckCopy] | ||
internal struct JPropertyStruct | ||
{ | ||
public object Value; | ||
} |
101 changes: 101 additions & 0 deletions
101
tracer/src/Datadog.Trace/Iast/Aspects/Newtonsoft.Json/JTokenTypeProxy.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// <copyright file="JTokenTypeProxy.cs" company="Datadog"> | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
// </copyright> | ||
|
||
#nullable enable | ||
|
||
namespace Datadog.Trace.Iast.Aspects.Newtonsoft.Json; | ||
|
||
internal enum JTokenTypeProxy | ||
{ | ||
/// <summary> | ||
/// No token type has been set. | ||
/// </summary> | ||
None = 0, | ||
|
||
/// <summary> | ||
/// A JSON object. | ||
/// </summary> | ||
Object = 1, | ||
|
||
/// <summary> | ||
/// A JSON array. | ||
/// </summary> | ||
Array = 2, | ||
|
||
/// <summary> | ||
/// A JSON constructor. | ||
/// </summary> | ||
Constructor = 3, | ||
|
||
/// <summary> | ||
/// A JSON object property. | ||
/// </summary> | ||
Property = 4, | ||
|
||
/// <summary> | ||
/// A comment. | ||
/// </summary> | ||
Comment = 5, | ||
|
||
/// <summary> | ||
/// An integer value. | ||
/// </summary> | ||
Integer = 6, | ||
|
||
/// <summary> | ||
/// A float value. | ||
/// </summary> | ||
Float = 7, | ||
|
||
/// <summary> | ||
/// A string value. | ||
/// </summary> | ||
String = 8, | ||
|
||
/// <summary> | ||
/// A boolean value. | ||
/// </summary> | ||
Boolean = 9, | ||
|
||
/// <summary> | ||
/// A null value. | ||
/// </summary> | ||
Null = 10, | ||
|
||
/// <summary> | ||
/// An undefined value. | ||
/// </summary> | ||
Undefined = 11, | ||
|
||
/// <summary> | ||
/// A date value. | ||
/// </summary> | ||
Date = 12, | ||
|
||
/// <summary> | ||
/// A raw JSON value. | ||
/// </summary> | ||
Raw = 13, | ||
|
||
/// <summary> | ||
/// A collection of bytes value. | ||
/// </summary> | ||
Bytes = 14, | ||
|
||
/// <summary> | ||
/// A Guid value. | ||
/// </summary> | ||
Guid = 15, | ||
|
||
/// <summary> | ||
/// A Uri value. | ||
/// </summary> | ||
Uri = 16, | ||
|
||
/// <summary> | ||
/// A TimeSpan value. | ||
/// </summary> | ||
TimeSpan = 17 | ||
} |
Oops, something went wrong.