Skip to content

Commit

Permalink
[IAST] Propagation tests reorg (#6487)
Browse files Browse the repository at this point in the history
## Summary of changes
Moved propagation tests to their right folder and namespace in
instrumented tests

## Reason for change
Namespaces were not standard and tests location made them difficult to
locate

## Implementation details
Moved propagation tests from Vulnerabilities to Propagation folder and
namespace

## Test coverage

## Other details
<!-- Fixes #{issue} -->

<!-- ⚠️ Note: where possible, please obtain 2 approvals prior to
merging. Unless CODEOWNERS specifies otherwise, for external teams it is
typically best to have one review from a team member, and one review
from apm-dotnet. Trivial changes do not require 2 reviews. -->
  • Loading branch information
daniel-romano-DD authored Dec 30, 2024
1 parent ebc42dd commit 6486306
Show file tree
Hide file tree
Showing 30 changed files with 759 additions and 760 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Samples.InstrumentedTests.Iast.Bugs;

public class GetCustomAttributesCrashTests : Samples.InstrumentedTests.Iast.Vulnerabilities.InstrumentationTestsBase
public class GetCustomAttributesCrashTests : Samples.InstrumentedTests.Iast.InstrumentationTestsBase
{
public GetCustomAttributesCrashTests()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using Castle.Core.Internal;
using FluentAssertions;

namespace Samples.InstrumentedTests.Iast.Vulnerabilities;
namespace Samples.InstrumentedTests.Iast;

public class InstrumentationTestsBase : IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace Samples.InstrumentedTests.Iast.Vulnerabilities;
namespace Samples.InstrumentedTests.Iast;
struct StructForStringTest
{
readonly string str;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Runtime.CompilerServices;
using FluentAssertions;

namespace Samples.InstrumentedTests.Iast.Vulnerabilities.StringPropagation;
namespace Samples.InstrumentedTests.Iast.Propagation.String;

public class DefaultInterpolatedStringHandlerTests : InstrumentationTestsBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using FluentAssertions;
using Xunit;

namespace Samples.InstrumentedTests.Iast.Vulnerabilities.StringPropagation;
namespace Samples.InstrumentedTests.Iast.Propagation.String;

public class StringCaseChangeTests : InstrumentationTestsBase
{
Expand Down Expand Up @@ -33,8 +33,8 @@ public void GivenATaintedObject_WhenCallingToUpper_ResultIsOk()
string str1 = AddTaintedString("0a2");
string str2 = AddTaintedString("0b2");
AssertTaintedFormatWithOriginalCallCheck(" :+-0A2-+: :+-0B2-+:",
String.Concat(" ", str1, " ", str2).ToUpper(),
() => String.Concat(" ", str1, " ", str2).ToUpper());
System.String.Concat(" ", str1, " ", str2).ToUpper(),
() => System.String.Concat(" ", str1, " ", str2).ToUpper());
}

[Fact]
Expand All @@ -49,8 +49,8 @@ public void GivenATaintedObject_WhenCallingToLower_ResultIsOk()
string str1 = AddTaintedString("0A2");
string str2 = AddTaintedString("0B2");
AssertTaintedFormatWithOriginalCallCheck(" :+-0a2-+: :+-0b2-+:",
String.Concat(" ", str1, " ", str2).ToLower(),
() => String.Concat(" ", str1, " ", str2).ToLower());
System.String.Concat(" ", str1, " ", str2).ToLower(),
() => System.String.Concat(" ", str1, " ", str2).ToLower());
}

[Fact]
Expand All @@ -65,8 +65,8 @@ public void GivenATaintedObject_WhenCallingToUpperInvariant_ResultIsOk()
string str1 = AddTaintedString("0a2");
string str2 = AddTaintedString("0b2");
AssertTaintedFormatWithOriginalCallCheck(" :+-0A2-+: :+-0B2-+:",
String.Concat(" ", str1, " ", str2).ToUpperInvariant(),
() => String.Concat(" ", str1, " ", str2).ToUpperInvariant());
System.String.Concat(" ", str1, " ", str2).ToUpperInvariant(),
() => System.String.Concat(" ", str1, " ", str2).ToUpperInvariant());
}

[Fact]
Expand All @@ -81,8 +81,8 @@ public void GivenATaintedObject_WhenCallingToLowerInvariant_ResultIsOk()
string str1 = AddTaintedString("0A2");
string str2 = AddTaintedString("0B2");
AssertTaintedFormatWithOriginalCallCheck(" :+-0a2-+: :+-0b2-+:",
String.Concat(" ", str1, " ", str2).ToLowerInvariant(),
() => String.Concat(" ", str1, " ", str2).ToLowerInvariant());
System.String.Concat(" ", str1, " ", str2).ToLowerInvariant(),
() => System.String.Concat(" ", str1, " ", str2).ToLowerInvariant());
}

[Fact]
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Xunit;

namespace Samples.InstrumentedTests.Iast.Vulnerabilities.StringPropagation;
namespace Samples.InstrumentedTests.Iast.Propagation.String;
#pragma warning disable CS0618 // Obsolete

public class StringCopyTests : InstrumentationTestsBase
Expand All @@ -17,19 +17,19 @@ public StringCopyTests()
[Fact]
public void GivenATaintedObject_WhenCallingCopy_ResultIsTainted()
{
AssertTaintedFormatWithOriginalCallCheck(":+-tainted-+:", String.Copy(taintedValue), () => String.Copy(taintedValue));
AssertTaintedFormatWithOriginalCallCheck(":+-tainted-+:", System.String.Copy(taintedValue), () => System.String.Copy(taintedValue));
}

[Fact]
public void GivenAUntaintedObject_WhenCallingCopy_ResultIsNotTainted()
{
AssertUntaintedWithOriginalCallCheck(() => String.Copy(UntaintedString), () => String.Copy(UntaintedString));
AssertUntaintedWithOriginalCallCheck(() => System.String.Copy(UntaintedString), () => System.String.Copy(UntaintedString));
}

[Fact]
public void GivenATaintedObject_WhenCallingCopyWithNull_ArgumentNullException()
{
AssertUntaintedWithOriginalCallCheck(() => String.Copy(null), () => String.Copy(null));
AssertUntaintedWithOriginalCallCheck(() => System.String.Copy(null), () => System.String.Copy(null));
}
}
#pragma warning restore CS0618 // Obsolete
Loading

0 comments on commit 6486306

Please sign in to comment.