-
Notifications
You must be signed in to change notification settings - Fork 1.9k
C#: Blazor: Add non-local jump node for parameter passing #18930
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
Closed
egregius313
wants to merge
11
commits into
github:main
from
egregius313:egregius313/csharp/blazor/parameter-passing-jumpnode
Closed
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
48b90b2
Component parameter passing step
egregius313 0463f48
Add Name and NameList test classes
egregius313 17da291
fixup! Component parameter passing step
egregius313 824b182
fixup! Add Name and NameList test classes
egregius313 97e00ae
Fix formatting
egregius313 8ea6974
XSS qlref
egregius313 22e958b
Fix jump node by using associated property
egregius313 133c6fa
Fix test expectations
egregius313 a0fe7d6
Remove unused line
egregius313 e2f0a61
Add XSS test to integration tests
egregius313 ca14c57
Add likely XSS case to integration tests
egregius313 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
csharp/ql/test/library-tests/frameworks/microsoft/aspnetcore/blazor/Name.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| namespace VulnerableBlazorApp.Components | ||
| { | ||
| using Microsoft.AspNetCore.Components; | ||
|
|
||
| public partial class Name : Microsoft.AspNetCore.Components.ComponentBase | ||
| { | ||
| protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder) | ||
| { | ||
| if (TheName is not null) | ||
| { | ||
| builder.OpenElement(0, "div"); | ||
| builder.OpenElement(1, "p"); | ||
| builder.AddContent(2, (MarkupString)TheName); | ||
| builder.CloseElement(); | ||
| builder.CloseElement(); | ||
| } | ||
| } | ||
|
|
||
| [Parameter] | ||
| public string TheName { get; set; } | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
csharp/ql/test/library-tests/frameworks/microsoft/aspnetcore/blazor/NameList.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| namespace VulnerableBlazorApp.Components | ||
| { | ||
| using System.Collections.Generic; | ||
| using Microsoft.AspNetCore.Components; | ||
|
|
||
| [RouteAttribute("/names/{name?}")] | ||
| public partial class NameList : Microsoft.AspNetCore.Components.ComponentBase | ||
| { | ||
| protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder builder) | ||
| { | ||
| if (Names is not null) | ||
| { | ||
| builder.OpenElement(0, "div"); | ||
| builder.OpenElement(1, "ul"); | ||
| foreach (var name in Names) | ||
| { | ||
| builder.OpenElement(2, "li"); | ||
| builder.OpenComponent<VulnerableBlazorApp.Components.Name>(3); | ||
| builder.AddComponentParameter(4, nameof(VulnerableBlazorApp.Components.Name.TheName), name); | ||
| builder.CloseComponent(); | ||
| builder.CloseElement(); | ||
| } | ||
| builder.CloseElement(); | ||
| builder.CloseElement(); | ||
| } | ||
|
|
||
| builder.OpenElement(5, "div"); | ||
| builder.OpenElement(6, "p"); | ||
| builder.AddContent(7, "Name: "); | ||
| builder.OpenComponent<VulnerableBlazorApp.Components.Name>(8); | ||
| builder.AddComponentParameter(9, nameof(VulnerableBlazorApp.Components.Name.TheName), Name); | ||
| builder.CloseComponent(); | ||
| builder.CloseElement(); | ||
| } | ||
|
|
||
| [Parameter] | ||
| public string Name { get; set; } | ||
|
|
||
| protected override void OnParametersSet() | ||
| { | ||
| if (Name is not null) | ||
| { | ||
| Names.Add(Name); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| public List<string> Names { get; set; } = new List<string>(); | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
csharp/ql/test/library-tests/frameworks/microsoft/aspnetcore/blazor/Xss.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| edges | ||
| | NameList.cs:31:99:31:102 | access to property Name : String | Name.cs:13:53:13:59 | access to property TheName | provenance | Sink:MaD:149 | | ||
| nodes | ||
| | Components_Pages_TestPage_razor.g.cs:138:15:138:22 | access to property UrlParam | semmle.label | access to property UrlParam | | ||
| | Components_Pages_TestPage_razor.g.cs:188:18:188:27 | access to property QueryParam | semmle.label | access to property QueryParam | | ||
| | Name.cs:13:53:13:59 | access to property TheName | semmle.label | access to property TheName | | ||
| | NameList.cs:31:99:31:102 | access to property Name : String | semmle.label | access to property Name : String | | ||
| subpaths | ||
| #select | ||
| | Components_Pages_TestPage_razor.g.cs:138:15:138:22 | access to property UrlParam | Components_Pages_TestPage_razor.g.cs:138:15:138:22 | access to property UrlParam | Components_Pages_TestPage_razor.g.cs:138:15:138:22 | access to property UrlParam | $@ flows to here and is written to HTML or JavaScript. | Components_Pages_TestPage_razor.g.cs:138:15:138:22 | access to property UrlParam | User-provided value | | ||
| | Components_Pages_TestPage_razor.g.cs:188:18:188:27 | access to property QueryParam | Components_Pages_TestPage_razor.g.cs:188:18:188:27 | access to property QueryParam | Components_Pages_TestPage_razor.g.cs:188:18:188:27 | access to property QueryParam | $@ flows to here and is written to HTML or JavaScript. | Components_Pages_TestPage_razor.g.cs:188:18:188:27 | access to property QueryParam | User-provided value | | ||
| | Name.cs:13:53:13:59 | access to property TheName | NameList.cs:31:99:31:102 | access to property Name : String | Name.cs:13:53:13:59 | access to property TheName | $@ flows to here and is written to HTML or JavaScript. | NameList.cs:31:99:31:102 | access to property Name : String | User-provided value | |
1 change: 1 addition & 0 deletions
1
csharp/ql/test/library-tests/frameworks/microsoft/aspnetcore/blazor/Xss.qlref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Security Features/CWE-079/XSS.ql | ||
Check warningCode scanning / CodeQL Query test without inline test expectations Warning test
Query test does not use inline test expectations.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also work if instead of a
nameof, the name of the property is directly referenced as a string literal?