-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ASM][IAST] Add source tainting for Grpc (#5473)
* Initial commit with the CallTargetRefStruct.cs readonly struct * Managed test * Native code implementation * fixes * Fixes and test suite * revert * Add instrumentation on grpc request object + Visitor to track strings and taint them * Add new sample + integration test * Add grpc Source Type * Update Sample to add more tests * Add problematic instrumentation * Implement new instrumentation for reading grpc messages strings * Move Sample + Working integration tests * Add the missing telemetry * Revert debug on triming file * Remove Security Sample * Update integration tests on existing APM sample * Lower the minimum version of Google.Protobuf to support older versions * Missing integration in the group * Exclude net fx * Skip build on unsupported * Update snapshot with deduplication enabled * Scrub location * Applied comments --------- Co-authored-by: Tony Redondo <tony.redondo@datadoghq.com>
- Loading branch information
1 parent
e24746d
commit 7aad726
Showing
26 changed files
with
501 additions
and
49 deletions.
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
44 changes: 44 additions & 0 deletions
44
...on/Grpc/GrpcDotNet/GrpcAspNetCoreServer/IAST/ParsingPrimitivesReadRawStringIntegration.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,44 @@ | ||
// <copyright file="ParsingPrimitivesReadRawStringIntegration.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; | ||
using System.ComponentModel; | ||
using System.IO; | ||
using System.Threading; | ||
using Datadog.Trace.ClrProfiler.CallTarget; | ||
using Datadog.Trace.Configuration; | ||
using Datadog.Trace.Iast; | ||
|
||
namespace Datadog.Trace.ClrProfiler.AutoInstrumentation.Grpc.GrpcDotNet.GrpcAspNetCoreServer.IAST; | ||
|
||
/// <summary> | ||
/// System.String Google.Protobuf.ParsingPrimitives::ReadRawString calltarget instrumentation | ||
/// </summary> | ||
[InstrumentMethod( | ||
AssemblyName = "Google.Protobuf", | ||
TypeName = "Google.Protobuf.ParsingPrimitives", | ||
MethodName = "ReadRawString", | ||
ReturnTypeName = ClrNames.String, | ||
ParameterTypeNames = ["System.ReadOnlySpan`1[System.Byte]&", "Google.Protobuf.ParserInternalState&", ClrNames.Int32], | ||
MinimumVersion = "3.0.0", | ||
MaximumVersion = "3.*.*", | ||
IntegrationName = nameof(Grpc), | ||
InstrumentationCategory = InstrumentationCategory.Iast)] | ||
[Browsable(false)] | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public class ParsingPrimitivesReadRawStringIntegration | ||
{ | ||
internal static CallTargetReturn<string?> OnMethodEnd<TTarget>(string? returnValue, Exception? exception, in CallTargetState state) | ||
{ | ||
if (returnValue is not null) | ||
{ | ||
var taintedObjects = IastModule.GetIastContext()?.GetTaintedObjects(); | ||
taintedObjects?.TaintInputString(returnValue, new Source(SourceType.GrpcRequestBody, null, returnValue)); | ||
} | ||
|
||
return new CallTargetReturn<string?>(returnValue); | ||
} | ||
} |
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
Oops, something went wrong.