C#: Add integration test for cshtml extraction in standalone mode

This commit is contained in:
Tamas Vajk
2023-08-14 16:00:16 +02:00
parent af1a0b9a6c
commit ba0f07b66c
6 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
| Program.cs |
| Views/Home/Index.cshtml |
| _semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_Views_Home_Index_cshtml.g.cs |

View File

@@ -0,0 +1,17 @@
import csharp
private string getPath(File f) {
result = f.getRelativePath()
or
not exists(f.getRelativePath()) and
exists(int index |
index =
f.getBaseName()
.indexOf("_semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_") and
result = f.getBaseName().substring(index, f.getBaseName().length())
)
}
from File f
where f.fromSource() or f.getExtension() = "cshtml"
select getPath(f)

View File

@@ -0,0 +1 @@
var dummy = "dummy";

View File

@@ -0,0 +1,8 @@
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<Target Name="DeleteBinObjFolders" BeforeTargets="Clean">
<RemoveDir Directories=".\bin" />
<RemoveDir Directories=".\obj" />
</Target>
</Project>

View File

@@ -0,0 +1,3 @@
from create_database_utils import *
run_codeql_database_create(lang="csharp", extra_args=["--extractor-option=buildless=true", "--extractor-option=cil=false"])