mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
JS: Add parameters of server functions as remote flow sources
This commit is contained in:
@@ -875,3 +875,22 @@ private class ReactPropAsViewComponentInput extends ViewComponentInput {
|
||||
|
||||
override string getSourceType() { result = "React props" }
|
||||
}
|
||||
|
||||
private predicate isServerFunction(DataFlow::FunctionNode func) {
|
||||
exists(Directive::UseServerDirective useServer |
|
||||
useServer.getContainer() = func.getFunction()
|
||||
or
|
||||
useServer.getContainer().(Module).getAnExportedValue(_).getAFunctionValue() = func
|
||||
)
|
||||
}
|
||||
|
||||
private class ServerFunctionRemoteFlowSource extends RemoteFlowSource {
|
||||
ServerFunctionRemoteFlowSource() {
|
||||
exists(DataFlow::FunctionNode func |
|
||||
isServerFunction(func) and
|
||||
this = func.getAParameter()
|
||||
)
|
||||
}
|
||||
|
||||
override string getSourceType() { result = "React server function parameter" }
|
||||
}
|
||||
|
||||
@@ -305,3 +305,7 @@ threatModelSource
|
||||
| statePropertyWrites.js:38:24:38:33 | this.props | view-component-input |
|
||||
| thisAccesses.js:31:12:31:16 | props | view-component-input |
|
||||
| thisAccesses.js:48:18:48:18 | y | view-component-input |
|
||||
| use-server1.js:2:5:2:5 | x | remote |
|
||||
| use-server1.js:3:5:3:5 | y | remote |
|
||||
| use-server2.js:4:5:4:5 | x | remote |
|
||||
| use-server2.js:5:5:5:5 | y | remote |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
async function getData(
|
||||
x, // $ MISSING: threatModelSource=remote
|
||||
y) { // $ MISSING: threatModelSource=remote
|
||||
x, // $ threatModelSource=remote
|
||||
y) { // $ threatModelSource=remote
|
||||
"use server";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"use server";
|
||||
|
||||
export async function getData(
|
||||
x, // $ MISSING: threatModelSource=remote
|
||||
y) { // $ MISSING: threatModelSource=remote
|
||||
x, // $ threatModelSource=remote
|
||||
y) { // $ threatModelSource=remote
|
||||
}
|
||||
|
||||
async function getData2(
|
||||
|
||||
Reference in New Issue
Block a user