Skip to content

Commit 89df162

Browse files
Fix standalone tests
1 parent 644010f commit 89df162

File tree

7 files changed

+41
-7
lines changed

7 files changed

+41
-7
lines changed

csharp/ql/integration-tests/all-platforms/cshtml_standalone_flowsteps/Views/Test/Test.cshtml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
@namespace test
1+
@page
2+
23
@model UserData
3-
@{
4-
}
54

65
@if (Model != null)
76
{
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@using test
2+
3+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| Views/Test/Test.cshtml:7:27:7:36 | access to property Name | Controllers/TestController.cs:13:40:13:47 | tainted1 : UserData | Views/Test/Test.cshtml:7:27:7:36 | access to property Name | $@ flows to here and is written to HTML or JavaScript: Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.Raw() method. | Controllers/TestController.cs:13:40:13:47 | tainted1 : UserData | User-provided value |
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @name Cross-site scripting
3+
* @description Writing user input directly to a web page
4+
* allows for a cross-site scripting vulnerability.
5+
* @kind path-problem
6+
* @problem.severity error
7+
* @security-severity 6.1
8+
* @precision high
9+
* @id cs/web/xss
10+
* @tags security
11+
* external/cwe/cwe-079
12+
* external/cwe/cwe-116
13+
*/
14+
15+
import csharp
16+
import semmle.code.csharp.security.dataflow.XSSQuery
17+
18+
// import PathGraph // exclude query predicates with output dependant on the absolute filepath the tests are run in
19+
from XssNode source, XssNode sink, string message
20+
where xssFlow(source, sink, message)
21+
select sink, source, sink, "$@ flows to here and " + message, source, "User-provided value"

csharp/ql/integration-tests/all-platforms/cshtml_standalone_flowsteps/XSS.qlref

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
</Project>

csharp/ql/lib/semmle/code/csharp/frameworks/Razor.qll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ class RazorPageClass extends Class {
6969
AssemblyAttribute attr;
7070

7171
RazorPageClass() {
72-
this.getBaseClass()
73-
.getUnboundDeclaration()
74-
.hasQualifiedName("Microsoft.AspNetCore.Mvc.Razor", "RazorPage<>") and
72+
exists(Class baseClass | baseClass = this.getBaseClass().getUnboundDeclaration() |
73+
baseClass.hasQualifiedName("Microsoft.AspNetCore.Mvc.Razor", "RazorPage<>")
74+
or
75+
baseClass.hasQualifiedName("Microsoft.AspNetCore.Mvc.RazorPages", "Page")
76+
) and
7577
attr.getFile() = this.getFile() and
7678
attr.getType()
7779
.hasQualifiedName("Microsoft.AspNetCore.Razor.Hosting", "RazorCompiledItemAttribute")

0 commit comments

Comments
 (0)