Skip to content

Conversation

@knewbury01
Copy link
Contributor

@knewbury01 knewbury01 commented Oct 21, 2025

adds the following:

  • Add React Precallgraphstep useRef - this PreCallGraphStep is similar to the useState hook related one, but for the hook useRef.
  • Add React DomValueSource that uses the ref from a dom. This may effect sources found for this query, and therefore the alerts found for that query.

@knewbury01 knewbury01 changed the title Add React Precallgraphstep useRef Add React missing useRef related constructs Oct 22, 2025
@knewbury01 knewbury01 marked this pull request as ready for review October 22, 2025 20:56
@knewbury01 knewbury01 requested a review from a team as a code owner October 22, 2025 20:56
Copilot AI review requested due to automatic review settings October 22, 2025 20:56
Copy link
Contributor

Copilot AI left a 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 UseRefStep to model data flow from initial value through useRef to .current property access
  • Added UseRefDomValueSource to identify DOM values accessed via useRef().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.
Copy link

Copilot AI Oct 22, 2025

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.'

Suggested change
* 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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

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>
@asgerf
Copy link
Contributor

asgerf commented Oct 28, 2025

Waiting for another DCA run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants