-
Couldn't load subscription status.
- Fork 1.8k
Add React missing useRef related constructs #20668
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
base: main
Are you sure you want to change the base?
Add React missing useRef related constructs #20668
Conversation
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.
Pull Request Overview
Adds support for React's useRef hook by introducing a PreCallGraphStep for data flow tracking and a DomValueSource for DOM value detection. This enhancement improves taint tracking through useRef patterns.
- Added
UseRefStepto model data flow from initial value throughuseRefto.currentproperty access - Added
UseRefDomValueSourceto identify DOM values accessed viauseRef().current
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| javascript/ql/lib/semmle/javascript/frameworks/React.qll | Implements UseRefStep for data flow tracking and UseRefDomValueSource for DOM value detection |
| javascript/ql/lib/change-notes/2025-10-21-react-precallgraph-step.md | Documents the new features in the change notes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| /** | ||
| * Step through a `useRef` call. | ||
| * | ||
| * It returns a pair of the initial state, and an object with a single property (current) potentially containing an input value. |
Copilot
AI
Oct 22, 2025
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.
The documentation incorrectly describes the return value as 'a pair of the initial state, and an object'. useRef returns only a single object with a current property, not a pair. Consider revising to: 'It returns an object with a single property (current) initialized to the initial value.'
| * It returns a pair of the initial state, and an object with a single property (current) potentially containing an input value. | |
| * It returns an object with a single property (`current`) initialized to the initial value. |
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.
@knewbury01 could you accept this suggestion? It seems correct to me
Co-authored-by: Asger F <asgerf@github.com>
|
Waiting for another DCA run |
adds the following:
PreCallGraphStepis similar to theuseStatehook related one, but for the hookuseRef.DomValueSourcethat uses thereffrom a dom. This may effect sources found for this query, and therefore the alerts found for that query.