@@ -691,15 +691,22 @@ private DataFlow::SourceNode reactRouterDom() {
691691 result = DataFlow:: moduleImport ( "react-router-dom" )
692692}
693693
694+ private DataFlow:: SourceNode reactRouterMatchObject ( ) {
695+ result = reactRouterDom ( ) .getAMemberCall ( [ "useRouteMatch" , "matchPath" ] )
696+ or
697+ exists ( ReactComponent c |
698+ dependedOnByReactRouterClient ( c .getTopLevel ( ) ) and
699+ result = c .getAPropRead ( "match" )
700+ )
701+ }
702+
694703private class ReactRouterSource extends ClientSideRemoteFlowSource {
695704 ClientSideRemoteFlowKind kind ;
696705
697706 ReactRouterSource ( ) {
698707 this = reactRouterDom ( ) .getAMemberCall ( "useParams" ) and kind .isPath ( )
699708 or
700- exists ( string prop |
701- this = reactRouterDom ( ) .getAMemberCall ( "useRouteMatch" ) .getAPropertyRead ( prop )
702- |
709+ exists ( string prop | this = reactRouterMatchObject ( ) .getAPropertyRead ( prop ) |
703710 prop = "params" and kind .isPath ( )
704711 or
705712 prop = "url" and kind .isUrl ( )
@@ -713,16 +720,25 @@ private class ReactRouterSource extends ClientSideRemoteFlowSource {
713720
714721/**
715722 * Holds if `mod` transitively depends on `react-router-dom`.
716- *
717- * We assume any React component in such a file may be used in a context where react-router
718- * injects the `location` property in its `props` object.
719723 */
720724private predicate dependsOnReactRouter ( Module mod ) {
721725 mod .getAnImport ( ) .getImportedPath ( ) .getValue ( ) = "react-router-dom"
722726 or
723727 dependsOnReactRouter ( mod .getAnImportedModule ( ) )
724728}
725729
730+ /**
731+ * Holds if `mod` is imported from a module that transitively depends on `react-router-dom`.
732+ *
733+ * We assume any React component in such a file may be used in a context where react-router
734+ * injects the `location` and `match` properties in its `props` object.
735+ */
736+ private predicate dependedOnByReactRouterClient ( Module mod ) {
737+ dependsOnReactRouter ( mod )
738+ or
739+ dependedOnByReactRouterClient ( any ( Module m | m .getAnImportedModule ( ) = mod ) )
740+ }
741+
726742/**
727743 * A reference to the DOM location obtained through `react-router-dom`
728744 *
@@ -740,7 +756,7 @@ private class ReactRouterLocationSource extends DOM::LocationSource::Range {
740756 this = reactRouterDom ( ) .getAMemberCall ( "useLocation" )
741757 or
742758 exists ( ReactComponent component |
743- dependsOnReactRouter ( component .getTopLevel ( ) ) and
759+ dependedOnByReactRouterClient ( component .getTopLevel ( ) ) and
744760 this = component .getAPropRead ( "location" )
745761 )
746762 }
@@ -759,6 +775,8 @@ private DataFlow::SourceNode higherOrderComponentBuilder() {
759775 or
760776 result = DataFlow:: moduleMember ( [ "react-hot-loader" , "react-hot-loader/root" ] , "hot" ) .getACall ( )
761777 or
778+ result = DataFlow:: moduleMember ( "redux-form" , "reduxForm" ) .getACall ( )
779+ or
762780 result = reactRouterDom ( ) .getAPropertyRead ( "withRouter" )
763781 or
764782 exists ( FunctionCompositionCall compose |
0 commit comments