Skip to content

Commit f24c042

Browse files
Rename Razor Page class to Razor View class
1 parent aa3fd6a commit f24c042

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ private class ViewCall extends MethodCall {
6464
boolean hasArea() { if exists(this.getAreaName()) then result = true else result = false }
6565
}
6666

67-
/** A compiler-generated Razor page. */
68-
class RazorPageClass extends Class {
67+
/** A compiler-generated Razor page from a `.cshtml` file. */
68+
class RazorViewClass extends Class {
6969
AssemblyAttribute attr;
7070

71-
RazorPageClass() {
71+
RazorViewClass() {
7272
exists(Class baseClass | baseClass = this.getBaseClass().getUnboundDeclaration() |
7373
baseClass.hasQualifiedName("Microsoft.AspNetCore.Mvc.Razor", "RazorPage<>")
7474
or
@@ -103,7 +103,7 @@ private string getARazorPathPrefix() {
103103
}
104104

105105
private class ViewCallJumpNode extends DataFlow::NonLocalJumpNode {
106-
RazorPageClass rp;
106+
RazorViewClass rp;
107107

108108
ViewCallJumpNode() {
109109
exists(ViewCall vc |
@@ -122,23 +122,23 @@ private class ViewCallJumpNode extends DataFlow::NonLocalJumpNode {
122122
}
123123
}
124124

125-
private predicate viewCallRefersToPage(ViewCall vc, RazorPageClass rp) {
125+
private predicate viewCallRefersToPage(ViewCall vc, RazorViewClass rp) {
126126
viewCallRefersToPageAbsolute(vc, rp) or
127127
viewCallRefersToPageRelative(vc, rp)
128128
}
129129

130130
bindingset[path]
131131
private string stripTilde(string path) { result = path.regexpReplaceAll("^~/", "/") }
132132

133-
private predicate viewCallRefersToPageAbsolute(ViewCall vc, RazorPageClass rp) {
133+
private predicate viewCallRefersToPageAbsolute(ViewCall vc, RazorViewClass rp) {
134134
getARazorPathPrefix() + ["/", ""] + stripTilde(vc.getNameArgument()) = rp.getSourceFilepath()
135135
}
136136

137-
private predicate viewCallRefersToPageRelative(ViewCall vc, RazorPageClass rp) {
138-
rp = min(int i, RazorPageClass rp2 | matchesViewCallWithIndex(vc, rp2, i) | rp2 order by i)
137+
private predicate viewCallRefersToPageRelative(ViewCall vc, RazorViewClass rp) {
138+
rp = min(int i, RazorViewClass rp2 | matchesViewCallWithIndex(vc, rp2, i) | rp2 order by i)
139139
}
140140

141-
private predicate matchesViewCallWithIndex(ViewCall vc, RazorPageClass rp, int i) {
141+
private predicate matchesViewCallWithIndex(ViewCall vc, RazorViewClass rp, int i) {
142142
exists(RelativeViewCallFilepath fp |
143143
fp.hasViewCallWithIndex(vc, i) and
144144
getARazorPathPrefix() + fp.getNormalizedPath() = rp.getSourceFilepath()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
category: minorAnalysis
33
---
4-
* Modelled additional flow steps to track flow from a `View` call in an MVC controller to the corresponding Razor page, which may result in additional results for queries such as `cs/web/xss`.
4+
* Modelled additional flow steps to track flow from a `View` call in an MVC controller to the corresponding Razor View (`.cshtml`) file, which may result in additional results for queries such as `cs/web/xss`.

0 commit comments

Comments
 (0)