X Tutup
The Wayback Machine - https://web.archive.org/web/20260116000528/https://github.com/github/codeql/pull/15734
Skip to content

Conversation

@hvitved
Copy link
Contributor

@hvitved hvitved commented Feb 27, 2024

Previously, we would not get subpaths computed for hidden wrappers, such as when flow passes through a callback passed into a library method with a flow summary:

a = [taint]
b = a.each do |x| # missing subpath: `a` (line 2) to `x` (line 2), `x` (line 2) to `x` (line 3), and `x` (line 3) to `b`
  x
end
sink x

This PR changes that to allow for an arbitrary number of hidden intermediate wrappers, and also takes into account that argument/out/parameter nodes may be hidden (we previously only took into account that return nodes could be hidden).

}

private module CaptureInput implements Shared::InputSig<Location> {
private import csharp as Cs

Check warning

Code scanning / CodeQL

Names only differing by case

Cs is only different by casing from CS that is used elsewhere for modules.
@hvitved hvitved force-pushed the dataflow/hidden-subpath branch from 543cbfc to f533ae9 Compare February 29, 2024 10:25
@hvitved hvitved marked this pull request as ready for review February 29, 2024 19:12
@hvitved hvitved requested review from a team as code owners February 29, 2024 19:12
@hvitved hvitved requested a review from a team as a code owner February 29, 2024 19:12
@hvitved hvitved requested a review from aschackmull March 1, 2024 12:38
@hvitved hvitved force-pushed the dataflow/hidden-subpath branch from f533ae9 to 2aa0cda Compare March 7, 2024 08:01
@hvitved hvitved removed request for a team March 7, 2024 08:02
---
category: minorAnalysis
---
* Path explanations now include flow that goes through callbacks passed into library functions. For example, if `map` is library function, then in `result = map(xs, x => x + 1)` we will now include the step from `x` to `x + 1` in the path explanation, instead og going directly from `xs` to `result`. Note that this change does not affect actual query results, but only how path explanations are computed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Path explanations now include flow that goes through callbacks passed into library functions. For example, if `map` is library function, then in `result = map(xs, x => x + 1)` we will now include the step from `x` to `x + 1` in the path explanation, instead og going directly from `xs` to `result`. Note that this change does not affect actual query results, but only how path explanations are computed.
* Path explanations now include flow that goes through callbacks passed into library functions. For example, if `map` is a library function, then in `result = map(xs, x => x + 1)` we will now include the step from `x` to `x + 1` in the path explanation, instead of going directly from `xs` to `result`. Note that this change does not affect actual query results, but only how path explanations are computed.

Comment on lines 4243 to 4245
private PathNodeImpl localStepFromHidden(PathNodeImpl n) {
n = localStep(result) and
result.isHidden()
Copy link
Contributor

Choose a reason for hiding this comment

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

From the name I'd expect that n was hidden, not that the order was swapped.

Suggested change
private PathNodeImpl localStepFromHidden(PathNodeImpl n) {
n = localStep(result) and
result.isHidden()
private PathNodeImpl localStepFromHidden(PathNodeImpl n) {
result = localStep(n) and
n.isHidden()

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe just change the predicate name:

Suggested change
private PathNodeImpl localStepFromHidden(PathNodeImpl n) {
n = localStep(result) and
result.isHidden()
private PathNodeImpl revLocalStepToHidden(PathNodeImpl n) {
n = localStep(result) and
result.isHidden()

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe that should be revLocalStepFromHidden. I guess that depends on whether you read it as rev applying to all of the rest or just to localStep.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the code would be clearer if both of these relations were using named columns instead of the result column and were both in the forward direction, i.e. localStepFromHidden(n1, n2) and localStepToHidden(n1, n2)`. This would add a few lines and name a few more intermediate nodes in the usages below, but I think that's a readability win.

Copy link
Contributor

@aschackmull aschackmull left a comment

Choose a reason for hiding this comment

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

I think readability can be improved a bit, but otherwise LGTM.

@hvitved hvitved force-pushed the dataflow/hidden-subpath branch from c8d3e64 to 7a3b8eb Compare March 18, 2024 13:49
Co-authored-by: Anders Schack-Mulligen <aschackmull@users.noreply.github.com>
Copy link
Contributor

@aschackmull aschackmull left a comment

Choose a reason for hiding this comment

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

LGTM

@hvitved hvitved merged commit 8899d66 into github:main Mar 18, 2024
@hvitved hvitved deleted the dataflow/hidden-subpath branch March 18, 2024 19:17
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

X Tutup