Component parameter passing step

This commit is contained in:
Ed Minnix
2025-03-05 00:01:08 -05:00
parent 795a2e1175
commit 48b90b28c7

View File

@@ -112,6 +112,16 @@ class MicrosoftAspNetCoreComponentsComponent extends Class {
}
}
/**
* The `Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::AddComponentParameter` method.
*/
private class MicrosoftAspNetCoreComponentsAddComponentParameterMethod extends Method {
MicrosoftAspNetCoreComponentsAddComponentParameterMethod() {
this.hasFullyQualifiedName("Microsoft.AspNetCore.Components.Rendering", "RenderTreeBuilder",
"AddComponentParameter")
}
}
private module Sources {
private import semmle.code.csharp.security.dataflow.flowsources.Remote
@@ -133,3 +143,42 @@ private module Sources {
override string getSourceType() { result = "ASP.NET Core component route parameter" }
}
}
private module JumpNodes {
/**
* A call to `Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::AddComponentParameter` which
* sets the value of a parameter.
*/
private class ParameterPassingCall extends Call {
ParameterPassingCall() {
this.getTarget() instanceof MicrosoftAspNetCoreComponentsAddComponentParameterMethod
}
/**
* Gets the property whose value is being set.
*/
Property getParameterProperty() {
result.getAnAttribute() instanceof MicrosoftAspNetCoreComponentsParameterAttribute and
exists(NameOfExpr ne | ne = this.getArgument(1) |
result.getAnAccess() = ne.getAccess().(MemberAccess)
)
}
/**
* Gets the value being set.
*/
Expr getParameterValue() { result = this.getArgument(2) }
}
private class ComponentParameterJump extends DataFlow::NonLocalJumpNode {
ParameterPassingCall call;
ComponentParameterJump() { this.asExpr() = call.getParameterValue() }
override DataFlow::Node getAJumpSuccessor(boolean preservesValue) {
preservesValue = false and
result.asExpr() = call.getParameterProperty().getAnAccess()
}
}
}