Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c926a47

Browse files
committed
JS: QLDoc and test for HeuristicConnectEntryPoint
1 parent cca38a6 commit c926a47

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

javascript/ql/src/semmle/javascript/frameworks/Redux.qll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,9 +1134,11 @@ module Redux {
11341134
}
11351135

11361136
/**
1137-
* An entry point in the API graphs corresponding to functions named `mapDispatchToProps`,
1138-
* used to catch cases where the call to `connect` was not found (usually because of it being
1139-
* wrapped in another function, which API graphs won't look through).
1137+
* An API entry point corresponding to a `connect` function which we couldn't recognize exactly.
1138+
*
1139+
* The `connect` call is recognized based on an argument being named either `mapStateToProps` or `mapDispatchToProps`.
1140+
* Used to catch cases where the `connect` function was not recognized by API graphs (usually because of it being
1141+
* wrapped in another function, which API graphs won't look through).
11401142
*/
11411143
private class HeuristicConnectEntryPoint extends API::EntryPoint {
11421144
HeuristicConnectEntryPoint() { this = "react-redux-connect" }

javascript/ql/test/library-tests/frameworks/Redux/react-redux.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,8 @@ function mapStateToProps(state) {
9292
const mapDispatchToProps = { toolkitAction, manualAction };
9393

9494
const ConnectedComponent = connect(mapStateToProps, mapDispatchToProps)(MyComponent);
95+
96+
function connectLike(f, g) {
97+
return c => somethingWeirdAndComplicated(f, g)(c);
98+
}
99+
const ConnectedComponent2 = connectLike(mapStateToProps, mapDispatchToProps)(MyComponent);

javascript/ql/test/library-tests/frameworks/Redux/test.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ taintFlow
112112
| react-redux.jsx:69:31:69:38 | source() | react-redux.jsx:75:10:75:36 | props.p ... Action2 |
113113
| react-redux.jsx:69:31:69:38 | source() | react-redux.jsx:76:10:76:36 | props.p ... Action3 |
114114
| react-redux.jsx:70:30:70:37 | source() | react-redux.jsx:77:10:77:28 | props.propFromAsync |
115+
reactComponentRef
116+
| react-redux.jsx:64:1:80:1 | functio ... r}}/>\\n} | react-redux.jsx:64:1:80:1 | functio ... r}}/>\\n} |
117+
| react-redux.jsx:64:1:80:1 | functio ... r}}/>\\n} | react-redux.jsx:94:28:94:84 | connect ... ponent) |
118+
| react-redux.jsx:64:1:80:1 | functio ... r}}/>\\n} | react-redux.jsx:97:12:97:12 | c |
115119
getAffectedStateAccessPath
116120
| react-redux.jsx:12:33:17:9 | (state, ... } | toolkit |
117121
| react-redux.jsx:18:41:23:9 | (state, ... } | toolkit |

javascript/ql/test/library-tests/frameworks/Redux/test.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,5 @@ class BasicTaint extends TaintTracking::Configuration {
5959
query predicate taintFlow(DataFlow::Node source, DataFlow::Node sink) {
6060
any(BasicTaint cfg).hasFlow(source, sink)
6161
}
62+
63+
query DataFlow::SourceNode reactComponentRef(ReactComponent component) { result = component.getAComponentCreatorReference() }

0 commit comments

Comments
 (0)