Skip to content

Dataflow: Strengthen tracked types.#13083

Merged
aschackmull merged 16 commits intogithub:mainfrom
aschackmull:dataflow/typestrengthen
Jun 9, 2023
Merged

Dataflow: Strengthen tracked types.#13083
aschackmull merged 16 commits intogithub:mainfrom
aschackmull:dataflow/typestrengthen

Conversation

@aschackmull
Copy link
Copy Markdown
Contributor

This adds support for type strengthening in the data flow library. Resolves https://github.com/github/codeql-team/issues/1773.

Initial tests indicated that strengthening types already from stage 3 when type pruning is introduced came at a potentially steep performance cost, thus stage 3 is kept as-is and strengthening is introduced in stage 4, which appeared to perform much better. Note that we cannot delay further than stage 4, since stage 5 constructs a depth 2 access path approximation that makes use of the types that are traced to store steps in stage 4, so from that point and onwards the traced types must be consistent between stages.

*/
predicate expectsContent(Node n, ContentSet c) { none() }

predicate typeStrongerThan(DataFlowType t1, DataFlowType t2) { none() }
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.

It would be super helpful to have some QLDoc to explain what "strong" means in this context. Is it (roughly) equivalent to saying that t1 is a strict subtype of t2?

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.

Yes. I postponed qldoc a bit, since I'll hopefully soon rewrite the language-to-library api to go through a signature, such that the entire library can be a parameterised module in a qlpack - at that point all these predicates will get language-agnostic qldoc in the signature.

@aschackmull aschackmull force-pushed the dataflow/typestrengthen branch from c069df3 to 7497b5b Compare May 11, 2023 08:27
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

java

Generated file changes for java

  • Changes to framework-coverage-java.csv:
- java.sql,13,,3,,,,,,,,4,,,,,,,,,,,,,,,,,,9,,,,,,,,,,,2,1
+ java.sql,13,,3,,,,,,,,4,,,,,,,,,,,,,,,,,,9,,,,,,,,,,,3,

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

java

Generated file changes for java

  • Changes to framework-coverage-java.csv:
- java.sql,13,,3,,,,,,,,4,,,,,,,,,,,,,,,,,,9,,,,,,,,,,,2,1
+ java.sql,13,,3,,,,,,,,4,,,,,,,,,,,,,,,,,,9,,,,,,,,,,,3,

Comment thread java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImpl.qll Fixed
Comment thread cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll Fixed
Comment thread cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll Fixed
Comment thread csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImpl.qll Fixed
Comment thread go/ql/lib/semmle/go/dataflow/internal/DataFlowImpl.qll Fixed
Comment thread python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl.qll Fixed
Comment thread ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImpl.qll Fixed
Comment thread swift/ql/lib/codeql/swift/dataflow/internal/DataFlowImpl.qll Fixed
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

java

Generated file changes for java

  • Changes to framework-coverage-java.csv:
- java.sql,13,,3,,,,,,,,4,,,,,,,,,,,,,,,,,,9,,,,,,,,,,,2,1
+ java.sql,13,,3,,,,,,,,4,,,,,,,,,,,,,,,,,,9,,,,,,,,,,,3,

@aschackmull aschackmull force-pushed the dataflow/typestrengthen branch from b218ac6 to 6351b68 Compare May 12, 2023 09:30
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

java

Generated file changes for java

  • Changes to framework-coverage-java.rst:
-    Java Standard Library,``java.*``,3,679,168,39,,9,,,13
+    Java Standard Library,``java.*``,3,678,168,39,,9,,,13
-    Totals,,246,9119,1957,174,10,113,33,1,361
+    Totals,,246,9118,1957,174,10,113,33,1,361
  • Changes to framework-coverage-java.csv:
- java.sql,13,,3,,,,,,,,4,,,,,,,,,,,,,,,,,,9,,,,,,,,,,,2,1
+ java.sql,13,,2,,,,,,,,4,,,,,,,,,,,,,,,,,,9,,,,,,,,,,,2,

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.

LGTM. Two minor comments.

Comment thread cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll
Comment on lines +2636 to +2641
if castingNodeEx(node)
then
exists(Typ nt | nt = node.getDataFlowType() |
if typeStrongerThan(nt, t0) then t = nt else (compatibleTypes(nt, t0) and t = t0)
)
else t = t0
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.

Perhaps factor this duplicated pattern out into a helper predicate?

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

java

Generated file changes for java

  • Changes to framework-coverage-java.rst:
-    Java Standard Library,``java.*``,3,679,168,39,,9,,,13
+    Java Standard Library,``java.*``,3,678,168,39,,9,,,13
-    Totals,,246,9119,1957,174,10,113,33,1,361
+    Totals,,246,9118,1957,174,10,113,33,1,361
  • Changes to framework-coverage-java.csv:
- java.sql,13,,3,,,,,,,,4,,,,,,,,,,,,,,,,,,9,,,,,,,,,,,2,1
+ java.sql,13,,2,,,,,,,,4,,,,,,,,,,,,,,,,,,9,,,,,,,,,,,2,

hvitved
hvitved previously approved these changes May 15, 2023
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.

🎉 Let's wait for a final QA run before merging.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 7, 2023

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

java

Generated file changes for java

  • Changes to framework-coverage-java.rst:
-    Java Standard Library,``java.*``,3,683,172,64,,9,,,17
+    Java Standard Library,``java.*``,3,682,172,64,,9,,,17
-    Totals,,255,9190,1975,244,10,122,33,1,382
+    Totals,,255,9189,1975,244,10,122,33,1,382
  • Changes to framework-coverage-java.csv:
- java.sql,13,,3,,,,,,,,,,,,,,,,,,,,,,,,,4,,9,,,,,,,,2,1
+ java.sql,13,,2,,,,,,,,,,,,,,,,,,,,,,,,,4,,9,,,,,,,,2,

@aschackmull aschackmull force-pushed the dataflow/typestrengthen branch from 78b5020 to 92b07dc Compare June 7, 2023 11:52
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 7, 2023

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

java

Generated file changes for java

  • Changes to framework-coverage-java.rst:
-    Java Standard Library,``java.*``,3,683,172,64,,9,,,17
+    Java Standard Library,``java.*``,3,682,172,64,,9,,,17
-    Totals,,255,9194,1985,251,10,122,33,1,385
+    Totals,,255,9193,1985,251,10,122,33,1,385
  • Changes to framework-coverage-java.csv:
- java.sql,13,,3,,,,,,,,,,,,,,,,,,,,,,,,,4,,9,,,,,,,,2,1
+ java.sql,13,,2,,,,,,,,,,,,,,,,,,,,,,,,,4,,9,,,,,,,,2,

hvitved
hvitved previously approved these changes Jun 8, 2023
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 8, 2023

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

java

Generated file changes for java

  • Changes to framework-coverage-java.rst:
-    Java Standard Library,``java.*``,3,683,184,76,,9,,,17
+    Java Standard Library,``java.*``,3,682,184,76,,9,,,17
-    Totals,,255,9199,1997,263,10,122,33,1,385
+    Totals,,255,9198,1997,263,10,122,33,1,385
  • Changes to framework-coverage-java.csv:
- java.sql,13,,3,,,,,,,,,,,,,,,,,,,,,,,,,4,,9,,,,,,,,2,1
+ java.sql,13,,2,,,,,,,,,,,,,,,,,,,,,,,,,4,,9,,,,,,,,2,

@aschackmull aschackmull force-pushed the dataflow/typestrengthen branch from f2b9e01 to 68f1e40 Compare June 9, 2023 06:39
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 9, 2023

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

java

Generated file changes for java

  • Changes to framework-coverage-java.rst:
-    Java Standard Library,``java.*``,3,683,184,76,,9,,,17
+    Java Standard Library,``java.*``,3,682,184,76,,9,,,17
-    Totals,,255,9199,1997,263,10,122,33,1,385
+    Totals,,255,9198,1997,263,10,122,33,1,385
  • Changes to framework-coverage-java.csv:
- java.sql,13,,3,,,,,,,,,,,,,,,,,,,,,,,,,4,,9,,,,,,,,2,1
+ java.sql,13,,2,,,,,,,,,,,,,,,,,,,,,,,,,4,,9,,,,,,,,2,

Copy link
Copy Markdown
Contributor

@yoff yoff left a comment

Choose a reason for hiding this comment

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

Proxy approval after rebase

@aschackmull aschackmull merged commit 1b7bbf6 into github:main Jun 9, 2023
@aschackmull aschackmull deleted the dataflow/typestrengthen branch June 9, 2023 11:23
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.

5 participants