Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IAST] Propagation tests reorg #6487

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading