Visitar URL original
Data flow: Refactor configuration by aschackmull · Pull Request #12186 · github/codeql · GitHub
The Wayback Machine - https://web.archive.org/web/20260605044413/https://github.com/github/codeql/pull/12186
Skip to content

Data flow: Refactor configuration#12186

Merged
aschackmull merged 16 commits into
github:mainfrom
aschackmull:dataflow/refactor-configuration
Mar 6, 2023
Merged

Data flow: Refactor configuration#12186
aschackmull merged 16 commits into
github:mainfrom
aschackmull:dataflow/refactor-configuration

Conversation

@aschackmull
Copy link
Copy Markdown
Contributor

@aschackmull aschackmull commented Feb 14, 2023 •

The main data flow and taint tracking APIs have been changed. The old APIs remain in place for now and translate to the new through a backwards-compatible wrapper. If multiple configurations are in scope simultaneously, then this may affect results slightly. The new API is quite similar to the old, but makes use of a configuration module instead of a configuration class.

}

private class BarrierGuardGuardedNode extends BarrierGuardGuardedNodeBridge {
deprecated override predicate guardedNode(Node n, Configuration config) {

Check warning

Code scanning / CodeQL

Inconsistent deprecation

This deprecated predicate overrides [a non-deprecated predicate](1). Consider deprecating both.
)
}

deprecated override predicate guardedNode(Node n, FlowState state, Configuration config) {

Check warning

Code scanning / CodeQL

Inconsistent deprecation

This deprecated predicate overrides [a non-deprecated predicate](1). Consider deprecating both.
@aschackmull aschackmull force-pushed the dataflow/refactor-configuration branch from d9d3390 to 93a38d5 Compare February 16, 2023 08:22
Copy link
Copy Markdown
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

Looks really great. A few comments, mainly about hiding implementation details inside an Internal module.

Comment thread java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImpl.qll Outdated
Comment thread java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImpl.qll
Comment thread java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImpl.qll Outdated
Comment thread java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImpl.qll
Comment thread java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImpl.qll
Comment thread java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImpl.qll Outdated
Comment thread java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImpl.qll Outdated
Comment thread java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImpl.qll Outdated
Comment thread config/identical-files.json Outdated
Comment thread java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImpl1.qll
Comment thread java/ql/lib/semmle/code/java/dataflow/DataFlow.qll Outdated
* should instead depend on a `DataFlow2::Configuration`, a
* `DataFlow3::Configuration`, or a `DataFlow4::Configuration`.
*/
abstract class Configuration extends string {

Check failure

Code scanning / CodeQL

Bidirectional imports for abstract classes

This abstract class imports its subclass [DefaultValueFlowConf](1) but doesn't import 139 other subclasses, such as [UntrustedUrlConfig](2). This abstract class imports its subclass [DefaultTaintFlowConf](3) but doesn't import 139 other subclasses, such as [UntrustedUrlConfig](2).
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This looks like a FP.

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.

Yes, that seems like an FP.
The reported subclass is in the test-pack, and there is not pack dependency from this lib/-pack to the test-pack.

Parameterized modules make it difficult to avoid spurious type/import edges.
There is already a filter for type-expressions that fixes some spurious edges.
(They are hard to filter away anywhere else, as each individual edge in the qualifier and defines are good, but the combination is not, due to parameterized modules being collapsed).

Maybe the solution is a similar filter for imports?
(But that is just me thinking out loud, I haven't tested anything).

@aschackmull aschackmull force-pushed the dataflow/refactor-configuration branch from 6f31a38 to 8347adf Compare February 21, 2023 09:16
@aschackmull aschackmull force-pushed the dataflow/refactor-configuration branch 2 times, most recently from e959eb6 to 63fa4ff Compare February 21, 2023 10:11
Copy link
Copy Markdown

@github-advanced-security github-advanced-security AI left a comment

Choose a reason for hiding this comment

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

CodeQL found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

@aschackmull aschackmull marked this pull request as ready for review February 27, 2023 13:21
@aschackmull aschackmull requested review from a team as code owners February 27, 2023 13:21
@aschackmull aschackmull removed the request for review from a team February 27, 2023 13:21
@aschackmull aschackmull force-pushed the dataflow/refactor-configuration branch from bc3c187 to 5469a82 Compare February 28, 2023 13:31
@aschackmull aschackmull marked this pull request as ready for review March 2, 2023 14:47
MathiasVP
MathiasVP previously approved these changes Mar 2, 2023
Copy link
Copy Markdown
Contributor

@MathiasVP MathiasVP left a comment

Choose a reason for hiding this comment

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

The changes to C/C++ in 7e3e10c LGTM! (I've yet to look at any of the actual dataflow stuff)

Comment on lines -35 to -37
| tst.go:35:2:35:2 | definition of u [pointer] | semmle.label | definition of u [pointer] |
| tst.go:36:2:36:2 | implicit dereference | semmle.label | implicit dereference |
| tst.go:36:2:36:2 | u [pointer] | semmle.label | u [pointer] |
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.

Why do these three nodes not appear in the test output any more?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's a good question. It was the only such change across all our tests. But all the actual results are preserved, so I'm not sure it's worth it to investigate too much.

@hvitved
Copy link
Copy Markdown
Contributor

hvitved commented Mar 2, 2023 •

The C# mono/mono project appears to have a performance regression.

Also a lot of performance regressions for Ruby.

@aschackmull
Copy link
Copy Markdown
Contributor Author

DCA just came back for Ruby - looking good so far!

@MathiasVP
Copy link
Copy Markdown
Contributor

I opened aschackmull#3 to fix the C++ performance. There might be a join-on-state to be looked at as well.

aschackmull and others added 2 commits March 6, 2023 09:32
Copy link
Copy Markdown
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

So happy to see that we are finally able to make this rewrite. Looks great to me, and it looks like we even get performance improvements as well 💪

@aschackmull aschackmull merged commit 5c7f2ac into github:main Mar 6, 2023
@aschackmull aschackmull deleted the dataflow/refactor-configuration branch March 6, 2023 12:39
smowton added a commit to smowton/codeql that referenced this pull request Mar 8, 2023
This was amended as part of github#12186, but the conversion was inadequate because the new implementation didn't work when a sink (type conversion) led directly to a non-`localTaintStep` step, such as a store step or an interprocedural step. Here I move the sink back one step to the argument of the type
conversion and sanitize the result of the conversion instead, to ensure there is always a unique local successor to a sink.

This should eliminate unexpected extra results that resulted from github#12186. Independently there are also *lost* results that stem from needing a higher `fieldFlowBranchLimit` that are not addressed in this PR, but raising that limit is a performance risk and so I will address this separately.
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.

6 participants