Skip to content

Docs: document the access path limit in the Java data flow guide - #23047

Open
yuan2li wants to merge 2 commits into
github:mainfrom
yuan2li:docs-java-access-path-limit
Open

yuan2li wants to merge 2 commits into
github:mainfrom
yuan2li:docs-java-access-path-limit

Conversation

@yuan2li

@yuan2li yuan2li commented Nov 8, 2026

Copy link
Copy Markdown

Fixes #23042.

The access path limit (accessPathLimit(), default 5 in the shared data flow library) decides which flows through fields, collections and maps can be found, but the data flow guides do not mention it. A flow that needs a longer path is dropped without a warning.

This PR changes analyzing-data-flow-in-java.rst in two places:

  • It adds accessPathLimit to the list of optional configuration predicates.
  • It adds a short "Access path limit" section. The section explains what an access path is, states the default and its effect, and shows how to raise the limit in a DataFlow::ConfigSig.

Checking the text. I used CodeQL 2.27.4 (codeql/java-all 9.3.4, codeql/dataflow 2.1.17) on two programs that pass a tainted value through five and six nested lists. With the default limit, only the five-list flow is found. With int accessPathLimit() { result = 8 } in the configuration, the six-list flow should be found, as it is on 2.26.2, but on 2.27.4 it is not, because raising the limit currently has no effect (#23041). The text documents the intended behaviour. If capping the limit at the language default turns out to be intended, I will change the section to say that a configuration can only lower it.

The limit lives in the shared library, so the same section could be added to the other languages' data flow guides. I kept this PR to Java and can extend it if that is wanted.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A moderate documentation issue remains because the example claims a configurable access-path limit of 8, while the implementation still caps paths at the language default of 5, so the example must be corrected or qualified.

1 open issue
What changed in this PR

Updates the Java/Kotlin data-flow guide to document the access path limit, its default behavior, and configuration options.

Changes:

  • Adds accessPathLimit to the optional DataFlow::ConfigSig predicates.
  • Documents the default limit of 5 and its effect on flow discovery.
  • Provides an example for configuring a higher limit and notes the performance trade-off.
File Description
docs/​codeql/​codeql-language-guides/​analyzing-data-flow-in-java.rst Documents access path limits and configuration in the Java/Kotlin data-flow guide.

Review effort: Lite (auto)

Comment on lines +232 to +235
int accessPathLimit() { result = 8 }
}

A higher limit can find more flows, but the analysis takes more time and memory.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#23049 is now merged, so a configured limit above the default takes effect again. fba3022 adds that it does so up to 10 for Java and Kotlin, and that a larger value behaves like 10.

@aschackmull aschackmull added the ready-for-doc-review This PR requires and is ready for review from the GitHub docs team. label Nov 10, 2026
@aschackmull

Copy link
Copy Markdown
Contributor

Looks fine to me, but I think we'll want a docs review as well.

This branch has not been deployed

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

Labels

documentation external-contribution ready-for-doc-review This PR requires and is ready for review from the GitHub docs team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java data flow: access paths longer than five contents are silently dropped; the default accessPathLimit is not stated in the data-flow guides

3 participants