Skip to content

Commit

Permalink
[ASM] Refactor AspNetCore5DatabaseTests (#6482)
Browse files Browse the repository at this point in the history
## Summary of changes

This PR removes the Samples.Security.AspNetCore5.DatabaseIntegration
project and moves the test code to Samples.Security.AspNetCore5

It also adds a new DockerDependencyType value that can be used for
projects that contain both tests that required docker and others that
don't require them.

## Reason for change

## Implementation details

## 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. -->

---------

Co-authored-by: Andrew Lock <andrew.lock@datadoghq.com>
  • Loading branch information
NachoEchevarria and andrewlock authored Jan 7, 2025
1 parent cd4a686 commit e4e2a1d
Show file tree
Hide file tree
Showing 34 changed files with 304 additions and 1,699 deletions.
7 changes: 0 additions & 7 deletions Datadog.Trace.sln
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssemblyLoadContextResolve"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.AspNet.MultipleAppsInDomain", "tracer\test\test-applications\aspnet\Samples.AspNet.MultipleAppsInDomain\Samples.AspNet.MultipleAppsInDomain.csproj", "{A82EB6F8-D8D0-4763-B252-08CA3F39D153}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.Security.AspNetCore5.DatabaseIntegration", "tracer\test\test-applications\security\Samples.Security.AspNetCore5.DatabaseIntegration\Samples.Security.AspNetCore5.DatabaseIntegration.csproj", "{067CE939-C803-4959-890A-B6B34C83F87A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1430,10 +1428,6 @@ Global
{A82EB6F8-D8D0-4763-B252-08CA3F39D153}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A82EB6F8-D8D0-4763-B252-08CA3F39D153}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A82EB6F8-D8D0-4763-B252-08CA3F39D153}.Release|Any CPU.Build.0 = Release|Any CPU
{067CE939-C803-4959-890A-B6B34C83F87A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{067CE939-C803-4959-890A-B6B34C83F87A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{067CE939-C803-4959-890A-B6B34C83F87A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{067CE939-C803-4959-890A-B6B34C83F87A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1666,7 +1660,6 @@ Global
{D6155F26-8245-4B66-8944-79C3DF9F9DA3} = {BAF8F246-3645-42AD-B1D0-0F7EAFBAB34A}
{8B1AF6A7-DD41-4347-B637-90C23D69B50E} = {498A300E-D036-49B7-A43D-821D1CAF11A5}
{A82EB6F8-D8D0-4763-B252-08CA3F39D153} = {AFA0AB23-64F0-4AC1-9050-6CE8FE06F580}
{067CE939-C803-4959-890A-B6B34C83F87A} = {0972AD57-B16B-494F-AE0A-091DD6F3B42B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F}
Expand Down
4 changes: 2 additions & 2 deletions tracer/build/_build/Build.Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,7 @@ void RunWindowsIisIntegrationTests(Project project)
(null, _) => true,
(_, null) => true,
(_, { } p) when !string.IsNullOrWhiteSpace(SampleName) => p.Name.Contains(SampleName, StringComparison.OrdinalIgnoreCase),
(false, { } p) => p.RequiresDockerDependency() == DockerDependencyType.None,
(false, { } p) => p.RequiresDockerDependency() is DockerDependencyType.None or DockerDependencyType.Mixed,
(true, { } p) => p.RequiresDockerDependency() != DockerDependencyType.None,
})
.Where(x =>
Expand Down Expand Up @@ -1938,7 +1938,7 @@ var name when multiPackageProjects.Contains(name) => false,
(null, _) => true,
(_, { project: null}) => true,
(_, { } p) when !string.IsNullOrWhiteSpace(SampleName) => p.project.Name.Contains(SampleName, StringComparison.OrdinalIgnoreCase),
(false, { } p) => p.project.RequiresDockerDependency() == DockerDependencyType.None,
(false, { } p) => p.project.RequiresDockerDependency() == DockerDependencyType.None || p.project.RequiresDockerDependency() == DockerDependencyType.Mixed,
(true, { } p) => p.project.RequiresDockerDependency() != DockerDependencyType.None,
});

Expand Down
7 changes: 6 additions & 1 deletion tracer/build/_build/NukeExtensions/DockerDependencyType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public enum DockerDependencyType
public enum DockerDependencyType
{
/// <summary>
/// Does not require Docker to run sample
Expand All @@ -14,4 +14,9 @@
/// Requires Docker on all platforms except Windows to run samples.
/// </summary>
LinuxAndMac,

/// <summary>
/// Contains both tests that require Docker and tests that do not.
/// </summary>
Mixed,
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="AspNetCore5IastDbTests.cs" company="Datadog">
// <copyright file="AspNetCore5IastDbTests.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>
Expand All @@ -18,7 +18,7 @@ namespace Datadog.Trace.Security.IntegrationTests.IAST;
public class AspNetCore5IastDbTests : AspNetCore5IastTests
{
public AspNetCore5IastDbTests(AspNetCoreTestFixture fixture, ITestOutputHelper outputHelper)
: base(fixture, outputHelper, enableIast: true, testName: "AspNetCore5IastDbTestsIastEnabled", samplingRate: 100, vulnerabilitiesPerRequest: 200, isIastDeduplicationEnabled: false, sampleName: "AspNetCore5.DatabaseIntegration")
: base(fixture, outputHelper, enableIast: true, testName: "AspNetCore5IastDbTestsIastEnabled", samplingRate: 100, vulnerabilitiesPerRequest: 200, isIastDeduplicationEnabled: false, sampleName: "AspNetCore5")
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
SpanId: Id_2,
Name: aspnet_core.request,
Resource: GET /iast/storedsqli,
Service: Samples.Security.AspNetCore5.DatabaseIntegration,
Service: Samples.Security.AspNetCore5,
Type: web,
Tags: {
aspnet_core.endpoint: Samples.Security.AspNetCore5.Controllers.DatabaseIntegration.IastController.StoredSqli (Samples.Security.AspNetCore5.DatabaseIntegration),
aspnet_core.endpoint: Samples.Security.AspNetCore5.Controllers.IastController.StoredSqli (Samples.Security.AspNetCore5),
aspnet_core.route: iast/storedsqli,
component: aspnet_core,
env: integration_tests,
Expand All @@ -29,7 +29,7 @@
"hash": XXX,
"location": {
"spanId": XXX,
"path": "Samples.Security.AspNetCore5.Controllers.DatabaseIntegration.IastController",
"path": "Samples.Security.AspNetCore5.Controllers.IastController",
"method": "StoredSqli"
},
"evidence": {
Expand Down Expand Up @@ -72,7 +72,7 @@
SpanId: Id_3,
Name: aspnet_core_mvc.request,
Resource: GET /iast/storedsqli,
Service: Samples.Security.AspNetCore5.DatabaseIntegration,
Service: Samples.Security.AspNetCore5,
Type: web,
ParentId: Id_2,
Tags: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
SpanId: Id_2,
Name: aspnet_core.request,
Resource: GET /iast/storedxss,
Service: Samples.Security.AspNetCore5.DatabaseIntegration,
Service: Samples.Security.AspNetCore5,
Type: web,
Tags: {
aspnet_core.endpoint: Samples.Security.AspNetCore5.Controllers.DatabaseIntegration.IastController.StoredXss (Samples.Security.AspNetCore5.DatabaseIntegration),
aspnet_core.endpoint: Samples.Security.AspNetCore5.Controllers.IastController.StoredXss (Samples.Security.AspNetCore5),
aspnet_core.route: iast/storedxss,
component: aspnet_core,
env: integration_tests,
Expand Down Expand Up @@ -69,7 +69,7 @@
SpanId: Id_3,
Name: aspnet_core_mvc.request,
Resource: GET /iast/storedxss,
Service: Samples.Security.AspNetCore5.DatabaseIntegration,
Service: Samples.Security.AspNetCore5,
Type: web,
ParentId: Id_2,
Tags: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
SpanId: Id_2,
Name: aspnet_core.request,
Resource: GET /iast/storedxssescaped,
Service: Samples.Security.AspNetCore5.DatabaseIntegration,
Service: Samples.Security.AspNetCore5,
Type: web,
Tags: {
aspnet_core.endpoint: Samples.Security.AspNetCore5.Controllers.DatabaseIntegration.IastController.StoredXssEscaped (Samples.Security.AspNetCore5.DatabaseIntegration),
aspnet_core.endpoint: Samples.Security.AspNetCore5.Controllers.IastController.StoredXssEscaped (Samples.Security.AspNetCore5),
aspnet_core.route: iast/storedxssescaped,
component: aspnet_core,
env: integration_tests,
Expand All @@ -34,7 +34,7 @@
SpanId: Id_3,
Name: aspnet_core_mvc.request,
Resource: GET /iast/storedxssescaped,
Service: Samples.Security.AspNetCore5.DatabaseIntegration,
Service: Samples.Security.AspNetCore5,
Type: web,
ParentId: Id_2,
Tags: {
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit e4e2a1d

Please sign in to comment.