Compare commits

...

474 Commits

Author SHA1 Message Date
Michael B. Gale
2584c99954 Ensure SetFormatterAssignment lhs/rhs match up 2023-02-08 13:05:58 +00:00
Michael B. Gale
24b7d8bb48 Fix isFormatter comment 2023-02-08 13:05:20 +00:00
Michael B. Gale
03079ffd76 Use instanceof 2023-02-08 10:58:52 +00:00
Michael B. Gale
02710a7e11 Check that formatter assignment isn't conditional 2023-02-08 10:52:53 +00:00
Michael B. Gale
7802f57628 Make it clearer that formatters may be santizing 2023-01-18 18:07:58 +00:00
Michael B. Gale
c93e7db831 Rename isSanitizerNode to isFormatter 2023-01-18 18:07:57 +00:00
Michael B. Gale
65beb08d5f Move go generate comments above imports 2023-01-18 18:07:57 +00:00
Michael B. Gale
af6ba6e9c7 Inline LoggerFormatter class 2023-01-18 18:07:57 +00:00
Michael B. Gale
425a4eb7df Make it easier to add new sanitizing formatters
Introduce abstract `SanitizingFormatter` class as a base for all
sanitizing formatters
2023-01-18 18:07:57 +00:00
Michael B. Gale
b2c07a4d4e Use uses instead of refersTo 2023-01-18 18:07:56 +00:00
Michael B. Gale
a7abebf76f Add change note 2023-01-18 18:07:56 +00:00
Michael B. Gale
7671c4a539 Fix style issues 2023-01-18 18:07:56 +00:00
Michael B. Gale
ec41ea8382 Reduce number of alerts for logrus
If a call to `SetFormatter` is present for a sanitizing formatter
such as `JSONFormatter`, then we discard alerts for CWE-117
(`go/log-injection`)
2023-01-18 18:07:55 +00:00
Michael Nebel
3a4623b437 Merge pull request #11907 from michaelnebel/csharp/cil/attributes
C#: CIL attributes
2023-01-18 10:46:34 +01:00
Rasmus Wriedt Larsen
e0ccb9306a Merge pull request #11908 from RasmusWL/dataflow-consistency-more-excludes
DataFlow: Add `uniqueParameterNodePositionExclude`
2023-01-18 10:44:51 +01:00
AlexDenisov
8910ba4f32 Merge pull request #11919 from github/redsun82/swift-obsolete-conf
Swift: remove obsolete configuration fields
2023-01-18 10:34:24 +01:00
Tony Torralba
c8e894b854 Merge pull request #11917 from github/workflow/coverage/update
Update CSV framework coverage reports
2023-01-18 10:02:22 +01:00
Erik Krogh Kristensen
1a64393c4c Merge pull request #11893 from erik-krogh/csharpIndexFiles
C#: add --working-dir=. to pre-finalize
2023-01-18 09:05:29 +01:00
Paolo Tranquilli
2c4c2dfeb3 Swift: remove obsolete configuration fields 2023-01-18 08:55:59 +01:00
Michael Nebel
8e3e6505ad C#: Add change note. 2023-01-18 07:56:24 +01:00
github-actions[bot]
571942fb21 Add changed framework coverage reports 2023-01-18 00:17:19 +00:00
Jeroen Ketema
6cd52237c3 Merge pull request #11913 from jketema/test-fixes
C++: Some minor test fixes
2023-01-17 21:52:57 +01:00
yoff
5a82012d03 Merge pull request #11854 from yoff/python/fix-tarslip-improv-bug
Python: fix bug  in `py/tarslip-extended`
2023-01-17 20:44:06 +01:00
Jeroen Ketema
ee19c3d80f C++: Rename identically named classes in syntax-zoo
Conceptually the test that comprises the whole of `syntax-zoo` forms one
single binary. To this binary ODR applies. There were two class definitions
`Foo` in `syntax-zoo`, violating ODR. Rename those classes to have different
names.
2023-01-17 19:02:40 +01:00
Jeroen Ketema
06767c6760 C++: Split bad_asts.cpp IR test into two files
The statements from `errorExpr` - which does not parse correctly - affected the
tuples that were being generated for the other code in `bad_asts.cpp` due to
the way the front-end handles parse errors. This did not affect the test
results, but was also not the intention of the test. Split off `errorExpr` into
a separate file.
2023-01-17 18:57:29 +01:00
Geoffrey White
ea06ad1933 Merge pull request #11529 from geoffw0/format
Swift: Uncontrolled format string query
2023-01-17 16:16:10 +00:00
Edward Minnix III
4c018759c8 Merge pull request #11283 from egregius313/egregius313/webview-setAllowContentAccess
Java: Android WebView Content Access Query
2023-01-17 11:02:47 -05:00
Michael Nebel
62533501fe C#: Update CIL attributes test case and the expected output. 2023-01-17 17:00:01 +01:00
Geoffrey White
54b3262d9c Merge pull request #11891 from geoffw0/authbypass
C++: Fix issue with cpp/user-controlled-bypass
2023-01-17 15:43:08 +00:00
Jami
babdee36aa Merge pull request #11779 from jcogs33/jcogs33/model-more-top-jdk-apis
Java: model top JDK APIs
2023-01-17 10:20:32 -05:00
Geoffrey White
d628cc5ab8 Update cpp/ql/src/Security/CWE/CWE-290/AuthenticationBypass.ql
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2023-01-17 14:37:19 +00:00
Paolo Tranquilli
6b43ff45a4 Merge pull request #11904 from github/redsun82/swift-extension-protocols
Swift: extract `ExtensionDecl` protocols
2023-01-17 15:16:20 +01:00
Paolo Tranquilli
d9bd41b8b1 Merge pull request #11571 from github/redsun82/swift-open-redirection
Swift: generalize open redirection on both platforms and rework output rewriting
2023-01-17 15:15:56 +01:00
Jami Cogswell
10f0975812 Java: remove models for System.[get|set]Property 2023-01-17 08:51:48 -05:00
Paolo Tranquilli
9e5db7c6ec Merge branch 'main' into redsun82/swift-extension-protocols 2023-01-17 14:39:09 +01:00
Michael Nebel
5f57a097ab C#: CIL method attribute extraction. 2023-01-17 14:17:35 +01:00
Michael Nebel
951f6362aa Merge pull request #11825 from michaelnebel/csharp/genericmathsupport
C# 11: Support for static virtual and static abstract interface members.
2023-01-17 14:14:02 +01:00
Rasmus Wriedt Larsen
a0b1c2ea79 DataFlow: Add uniqueParameterNodePositionExclude 2023-01-17 14:05:22 +01:00
Rasmus Wriedt Larsen
2b0a5fd5d1 DataFlow: Add uniqueParameterNodeAtPositionExclude 2023-01-17 14:05:17 +01:00
Erik Krogh Kristensen
2e4f4c64fe Merge pull request #11903 from erik-krogh/revertClap
QL: Revert "update clap to 3.0 in QL-for-QL"
2023-01-17 13:29:04 +01:00
Paolo Tranquilli
0a792f2f61 Swift: add upgrade and downgrade scripts for ExtensionDecl new protocols property 2023-01-17 13:07:02 +01:00
Paolo Tranquilli
0d32f00020 Swift: update ExtensionDecl test results 2023-01-17 12:58:02 +01:00
Paolo Tranquilli
d6e0ef9ff9 Swift: extract ExtensionDecl protocols 2023-01-17 12:56:09 +01:00
Paolo Tranquilli
f6e26211f9 Swift: add protocols to ExtensionDecl schema 2023-01-17 12:54:50 +01:00
Paolo Tranquilli
8906e101cb Swift: add ExtensionDecl QL test 2023-01-17 12:49:53 +01:00
erik-krogh
5a4fe71529 Revert "update clap to 3.0 in QL-for-QL"
This reverts commit d072ed969e.
2023-01-17 12:38:30 +01:00
Erik Krogh Kristensen
50b9f5bba0 Merge pull request #11892 from erik-krogh/clap
QL: update clap to 3.0 in QL-for-QL
2023-01-17 12:33:18 +01:00
Mathias Vorreiter Pedersen
77a9cea737 Merge pull request #11901 from github/redsun82/swift-ql-internal
Swift: introduce `@ql.internal` pragma for classes
2023-01-17 10:46:56 +00:00
Paolo Tranquilli
67bd8cba32 Merge pull request #11900 from github/alexdenisov/swift-ignore-lsregister
Swift: do not trace lsregister
2023-01-17 11:26:22 +01:00
Chris Smowton
29425982a5 Merge pull request #11899 from ataillefer/patch-1
Fix partial path traversal Java example
2023-01-17 09:39:36 +00:00
Paolo Tranquilli
6106edd5e2 Swift: add INTERNAL doc marker to ql.internal classes 2023-01-17 10:30:59 +01:00
Paolo Tranquilli
b22da25e05 Swift: remove ql.internal classes from global import 2023-01-17 10:18:03 +01:00
Paolo Tranquilli
48825442c3 Swift: add ql.internal pragma in schema definitions 2023-01-17 10:10:35 +01:00
Paolo Tranquilli
cdc99b5240 Swift: simplify pragma definition 2023-01-17 10:10:02 +01:00
Paolo Tranquilli
e3502e2e5f Merge branch 'main' into redsun82/swift-open-redirection 2023-01-17 09:43:00 +01:00
Alex Denisov
63b4e5ef5c Swift: do not trace lsregister 2023-01-17 09:26:31 +01:00
Erik Krogh Kristensen
51bd1ef1e1 Merge pull request #11884 from erik-krogh/qlWin
QL/Ryby: fix qltest on Windows
2023-01-16 21:57:01 +01:00
Antoine Taillefer
660e6d7085 Fix partial path traversal Java example
The Java recommendation example for the "Partial path traversal vulnerability from remote" query doesn't seem right to me. Indeed, the following statement doesn't compile, since `dir.getCanonicalPath()` returns a String:
```
dir.getCanonicalPath().toPath()
```
Maybe the author wanted to state `dir.getCanonicalFile().toPath()`, which would compile, but is useless compared to `dir.getCanonicalPath()`.

Moreover, `parent.getCanonicalFile().toPath()` or `parent.getCanonicalPath()` will **not** be slash-terminated, contrary to what the description says.
From what I can see (and test), the correct fix is to concatenate `File.separator` to the parent canonical path.
2023-01-16 21:14:29 +01:00
erik-krogh
dcc1c3d487 add --working-dir=. to pre-finalize for c# 2023-01-16 18:09:00 +01:00
Tony Torralba
bd5619147d Merge pull request #11590 from atorralba/atorralba/swift/sensitive-info-logs
Swift: Add Cleartext Logging query
2023-01-16 16:22:20 +01:00
erik-krogh
713599963b add --working-dir to Ruby qltest.cmd to fix Windows 2023-01-16 15:37:35 +01:00
erik-krogh
9e153cfb0d change the Ruby-build test such that Windows fails 2023-01-16 15:37:35 +01:00
erik-krogh
587adea809 QL: add --working-dir to qltest.cmd to fix qltest 2023-01-16 15:37:14 +01:00
erik-krogh
2c1ecb507d fix windows 2023-01-16 15:36:57 +01:00
erik-krogh
1de65131fe add compilation cache to QL-for-QL tests 2023-01-16 15:36:57 +01:00
erik-krogh
0685732e3f delete ql/ specific format step now that we have an all-languages format check 2023-01-16 15:36:57 +01:00
erik-krogh
1d62751e15 test QL-for-QL on mac/win 2023-01-16 15:36:55 +01:00
Tony Torralba
0017461e2d Update swift/ql/src/queries/Security/CWE-312/CleartextLogging.ql
Co-authored-by: Ben Ahmady <32935794+subatoi@users.noreply.github.com>
2023-01-16 15:35:58 +01:00
Michael Nebel
8981d4c06b C#: Add change note. 2023-01-16 13:43:26 +01:00
Michael Nebel
2f602a629f C#: Add upgrade and downgrade scripts. 2023-01-16 13:27:37 +01:00
Erik Krogh Kristensen
8ccc384043 Merge pull request #11858 from erik-krogh/moreSpawn
JS: track shell:true more in js/shell-command-constructed-from-input
2023-01-16 13:24:50 +01:00
Erik Krogh Kristensen
59a8b21851 Merge pull request #10862 from erik-krogh/unsafeCodeConstruction
Rb: Add an `unsafe-code-construction` query
2023-01-16 13:22:58 +01:00
Michael Nebel
3552a41552 C#: Add test case for static abstract and static virtual interface members. 2023-01-16 13:07:50 +01:00
Michael Nebel
dc50b6bad3 C#: Support for operators in implements relations. 2023-01-16 13:07:50 +01:00
Michael Nebel
8c2931cbb8 C#: Operators are now allowed to be declared virtual. 2023-01-16 13:07:50 +01:00
erik-krogh
d072ed969e update clap to 3.0 in QL-for-QL 2023-01-16 12:34:56 +01:00
Paolo Tranquilli
874fe2b8f9 Swift: introduce an in-memory file hash cache
File hashing is now done internally in `SwiftFileInterception` (and
exported as a `getHashOfRealFile` function for future use in linkage
awareness), and using a per-process in-memory cache. The persistent
caching of paths is removed, so the solution is now robust against input
file changes during the build.

For the same reason, the hash to artifact mapping have the symlinks
reversed now. The artifacts themselves are stored using the hash as
filenames, and the original paths of the artifacts are reacreated in the
scratch dir with symlinks mostly for debugging purposes (to understand
what artifact each hash corresponds to, and to follow what was built by
the extractor).
2023-01-16 12:05:36 +01:00
Tony Torralba
fdb3b65bce Apply suggestions from code review
Co-authored-by: Ben Ahmady <32935794+subatoi@users.noreply.github.com>
2023-01-16 11:57:37 +01:00
Tony Torralba
7f880a24df Merge pull request #11886 from jelaiw/jelaiw-patch-1
Fix small typo in good/bad code sample.
2023-01-16 09:43:23 +01:00
Paolo Tranquilli
738412260f Merge branch 'main' into redsun82/swift-open-redirection 2023-01-16 09:09:10 +01:00
jelaiw
cf7189bb28 Fix small typo in good/bad code sample. 2023-01-13 19:16:11 -06:00
Geoffrey White
1a416884d4 C++: Do something similar with the other three cases. 2023-01-14 00:09:01 +00:00
Geoffrey White
316117f5c9 C++: Reduce number of regexps. 2023-01-13 18:50:41 +00:00
Geoffrey White
2f09f0e2c1 C++: Turn the huge list into a predicate. 2023-01-13 18:47:18 +00:00
Geoffrey White
13ae15b867 C++: Add tests for more edge cases. 2023-01-13 18:38:29 +00:00
Jami Cogswell
fb6725ddaa Java: add WithoutElement comment for clear methods 2023-01-13 13:20:45 -05:00
Mathias Vorreiter Pedersen
2dbacbc302 Merge pull request #11841 from MathiasVP/swift-add-integral-types
Swift: Add integral type classes
2023-01-13 17:30:57 +00:00
Mathias Vorreiter Pedersen
c5038ed281 Merge pull request #11883 from MathiasVP/fold-definitions
C++: Fix bad join in `definitionOf`
2023-01-13 16:28:26 +00:00
Mathias Vorreiter Pedersen
6e6f2115c0 Merge pull request #11857 from MathiasVP/speedup-missing-check-scanf
C++: Speedup `cpp/missing-check-scanf`
2023-01-13 16:11:16 +00:00
Michael Nebel
2d46272295 Merge pull request #11881 from michaelnebel/java/modeldiffignore
Java: Ignore missing html artifacts in the Model Diff workflow.
2023-01-13 14:11:19 +01:00
Michael Nebel
b36be009d4 Merge pull request #11834 from michaelnebel/csharp/operators
C# 11: Extractor and library support for Unsigned right shift.
2023-01-13 13:21:02 +01:00
erik-krogh
71af8ab022 simplifications inspired by review 2023-01-13 13:18:52 +01:00
Mathias Vorreiter Pedersen
2283eacc0b C++: Fix bad join in 'definitionOf'. 2023-01-13 11:42:15 +00:00
Mathias Vorreiter Pedersen
59072f9e81 C++: Improve QLDoc. 2023-01-13 11:01:23 +00:00
Mathias Vorreiter Pedersen
dd8bead21a C++: Fix spurious backticks. 2023-01-13 10:57:44 +00:00
Mathias Vorreiter Pedersen
cf9998b932 Merge pull request #5 from geoffw0/integraltypes
Swift: Work on integral type classes
2023-01-13 10:01:23 +00:00
Michael Nebel
600412db48 Java: Ignore missing html artifacts. 2023-01-13 08:58:53 +01:00
Michael Nebel
3b15f2359b Merge pull request #11861 from michaelnebel/java/testmodeldiff
Java: Update the Model Difference workflow to use the `gh api`.
2023-01-13 08:20:18 +01:00
Jami Cogswell
a43f3cf95f Java: remove Supplier.get model 2023-01-12 17:09:13 -05:00
Jami Cogswell
f040ff2d8d Java: undo change to Function.apply test case 2023-01-12 17:01:58 -05:00
Jami Cogswell
c3a1d088ac Java: update change note 2023-01-12 16:32:52 -05:00
Jami Cogswell
a39b2aaaac Java: remove endsWith test case 2023-01-12 16:24:57 -05:00
Jami Cogswell
ffb267937a Java: add endsWith additionalTaintStep to ConditionalBypassFlowConfig 2023-01-12 16:24:05 -05:00
Arthur Baars
af8cb65b2e Merge pull request #11877 from aibaars/ql-ql-cross
QL/Ruby: include OS version in cache keys for Rust binaries
2023-01-12 20:02:25 +01:00
Michael Nebel
fd80974210 Java: Download databases using the gh api instead of lgtm. 2023-01-12 19:30:12 +01:00
Michael Nebel
c1c0ff4308 C#: Update database stats. 2023-01-12 19:06:29 +01:00
Michael Nebel
1384aa669b C#: Add change note. 2023-01-12 19:06:29 +01:00
Michael Nebel
5e89119b3d C#: Add upgrade- and downgrade scripts for unsigned right shift operators. 2023-01-12 19:06:29 +01:00
Michael Nebel
529be7ef18 C++: Sync files. 2023-01-12 19:06:29 +01:00
Michael Nebel
5c466f3319 Java: Sync files and update other relavant files related to the new naming of shift. 2023-01-12 19:06:29 +01:00
Michael Nebel
49a87e152a C#: Add unsigned right shift operator test case. 2023-01-12 19:06:28 +01:00
Michael Nebel
30738103f0 C#: Add unsigned right shift operator class. 2023-01-12 19:06:28 +01:00
Michael Nebel
148dc6de5a C#: Rename shift operator classes. 2023-01-12 19:06:28 +01:00
Michael Nebel
f48eda829f C#: Rename some of the TBinarySignOperation constructors. 2023-01-12 19:06:28 +01:00
Michael Nebel
d92b226041 C#: Add test example for unsigned right shift assignment in intermediate representation. 2023-01-12 19:06:28 +01:00
Michael Nebel
5bb8f8ed5c C#: Support for unsigned shift right in the experimental intermediate representation. 2023-01-12 19:06:28 +01:00
Michael Nebel
f74c7c28ae C#: Auto format test file and update expected test output. 2023-01-12 19:06:28 +01:00
Michael Nebel
0f032c5be9 C#: Sign analysis testcase for unsigned right shift. 2023-01-12 19:06:28 +01:00
Michael Nebel
2568318460 C#: Sign analysis support for unsigned right shift. 2023-01-12 19:06:28 +01:00
Michael Nebel
d06a877709 C#: Introduce test cases and expected result for unsigned right shift. 2023-01-12 19:06:28 +01:00
Michael Nebel
9eb7933778 C#: Implement library support for unsigned right shift. 2023-01-12 19:06:28 +01:00
Michael Nebel
99b7bc3b73 C#: Implement extractor support for unsigned right shift. 2023-01-12 19:06:28 +01:00
Michael Nebel
14c92e6eb3 C#: Add expressions kind including dummy stats for unsigned right shift and unsigned right shift assigment. 2023-01-12 19:06:28 +01:00
Michael Nebel
902b0a60d0 C#: Fixup ShiftExpr rename. 2023-01-12 19:06:28 +01:00
Michael Nebel
36980bbf42 C#: Rename shift expression classes. 2023-01-12 19:06:27 +01:00
Michael Nebel
a9f1c95513 C#: Rename shift assignment expression classes. 2023-01-12 19:06:27 +01:00
Chris Smowton
8aa2c23ba8 Merge pull request #11700 from JLLeitschuh/doc/JLL/improve-java-unsafe-deserialization-documentation
[Java] Document fixes for deserialization vulnerabilities by framework
2023-01-12 18:04:13 +00:00
Chris Smowton
09d8a50494 Spelling 2023-01-12 17:46:00 +00:00
Michael Nebel
aefb43324b Merge pull request #11738 from michaelnebel/go/maddataextensions
Go: Models as Data using extensions.
2023-01-12 18:42:35 +01:00
Erik Krogh Kristensen
8f9ad1f5ba Merge pull request #11872 from erik-krogh/jsAst
JS: Fixup some problems in PrintAST
2023-01-12 16:56:56 +01:00
Geoffrey White
7f31c9c7e5 Swift: Add a test. 2023-01-12 15:19:57 +00:00
Jami Cogswell
e0444449c8 Java: remove Function.apply model 2023-01-12 09:58:53 -05:00
Arthur Baars
e29e077a03 Ruby/QL4QL: include OS version in cache keys 2023-01-12 15:47:10 +01:00
erik-krogh
7ae27bcc34 fix errors in JS printAst 2023-01-12 15:37:52 +01:00
Henry Mercer
15ead6d0e6 Merge pull request #11864 from github/codeql-ci/atm/release-0.4.5
JS: Bump version numbers of ML-powered packs after 0.4.5 release
2023-01-12 13:51:24 +00:00
Henry Mercer
70f1015fba Merge branch 'main' into codeql-ci/atm/release-0.4.5 2023-01-12 12:32:25 +00:00
Ian Lynagh
9ebe59d353 Merge pull request #11637 from igfoo/igfoo/kotlin-1.8
Kotlin: Add 1.8 support
2023-01-12 12:15:00 +00:00
Geoffrey White
3d1b2fdbda Swift: Rename NumericOrCharType.qll -> Numer> NumericType.qll. 2023-01-12 11:46:51 +00:00
Geoffrey White
418d593a97 Swift: Replace NumericOrCharType with a more basic NumericType, and rename classes for consistency with other static languages. 2023-01-12 11:43:20 +00:00
Geoffrey White
d0eb167d47 Swift: Merge FloatingPointType.qll into NumericOrCharType.qll, because it is a numeric type and other stuff like CharacterType is there. 2023-01-12 11:42:36 +00:00
Michael Nebel
48d0eccbf6 Go: Cleanup and renaming. 2023-01-12 11:13:34 +01:00
Michael Nebel
3749a1bd4d Go: Migrate unit tests to use data extensions for Models as Data. 2023-01-12 11:13:33 +01:00
Michael Nebel
218f553fef Go: Convert remaining CSV production models to use data extensions. 2023-01-12 11:13:33 +01:00
Michael Nebel
ebb3485a73 Go: Use the extensible predicates for model definitions. 2023-01-12 11:13:33 +01:00
Michael Nebel
5fd687d3df Go: Add MaD related extensible predicates. 2023-01-12 11:13:33 +01:00
Michael Nebel
0f993a0d26 Go: Prepare library for adding extensions. 2023-01-12 11:13:28 +01:00
Mathias Vorreiter Pedersen
1ae52b6c7e C++: Speedup 'MissingCheckScanf'. 2023-01-12 10:13:02 +00:00
Paolo Tranquilli
4f5f0aad45 Merge branch 'main' into redsun82/swift-open-redirection 2023-01-12 10:54:04 +01:00
Michael Nebel
18a815ca8b Merge pull request #11721 from michaelnebel/csharpjava/refactorprovenance
C#/Java: Re-factor provenance related predicates.
2023-01-12 10:50:31 +01:00
yoff
006eaf3e2a Merge pull request #11088 from yoff/python/inline-query-tests
Python: Inline query tests
2023-01-12 10:32:26 +01:00
Jami Cogswell
fd593fd4f0 Java: undo changes to tests that were affected by numeric-flow summary models 2023-01-11 22:34:19 -05:00
Jami Cogswell
ce74c9d959 Java: Date models as neutral 2023-01-11 22:15:41 -05:00
Jami Cogswell
6bb865ad05 Java: make numeric flow models neutral 2023-01-11 18:04:43 -05:00
Henning Makholm
1d4b2fd0bb Merge pull request #11870 from github/hmakholm/pr/mergeback-2.12.0
Merge codeql-cli-2.12.0 back to main
2023-01-11 23:51:56 +01:00
Pierre
4e1f772f23 Merge pull request #11702 from github/turbo/experimental/combined
Introduce the security-experimental CodeQL suite and experimental tag
2023-01-11 20:37:42 +01:00
Jami Cogswell
0c7ffb0554 Java: update System.getProperty model 2023-01-11 12:04:22 -05:00
Pierre
c3116b3f0f Merge branch 'main' into turbo/experimental/combined 2023-01-11 18:02:55 +01:00
Jami Cogswell
2a99af0e6d Java: remove summary model for String.endsWith 2023-01-11 10:58:46 -05:00
Jami Cogswell
99ee6c95a1 Java: remove models for Consumer.accept and Collectors.toMap 2023-01-11 10:44:38 -05:00
Jami Cogswell
ac064ac2a7 Java: remove model for Collectors.joining 2023-01-11 10:30:49 -05:00
Michael Nebel
7e4f7a0c17 C#: Address review comments and sync files. 2023-01-11 16:29:24 +01:00
Michael Nebel
67cbe38255 Sync files. 2023-01-11 16:20:55 +01:00
Michael Nebel
8112058a0a Java: Adapt TopJdpApi library to the re-factor. 2023-01-11 16:20:55 +01:00
Michael Nebel
372ecf402f Go: Delete unused summaryModel predicate. 2023-01-11 16:20:55 +01:00
Michael Nebel
80a4197604 Swift: Re-factor provenance related predicates for summarized callable. 2023-01-11 16:20:55 +01:00
Michael Nebel
c01361a1fd Ruby: Re-factor provenance related predicates for summarized callable. 2023-01-11 16:20:55 +01:00
Michael Nebel
59a9e255c7 Python: Re-factor provenance related predicates for summarized callable. 2023-01-11 16:20:55 +01:00
Michael Nebel
6622eda04c Go: Re-factor provenance related predicates for summarized callable. 2023-01-11 16:20:55 +01:00
Michael Nebel
6a047d6916 Java: Re-factor provenance related predicates for summarized callable. 2023-01-11 16:20:55 +01:00
Michael Nebel
ea173f9516 Sync files. 2023-01-11 16:20:55 +01:00
Michael Nebel
7422029e49 C#: Re-factor provenance related predicates for summarized callable. 2023-01-11 16:20:48 +01:00
Michael Nebel
4b47b08ed2 Merge pull request #11760 from michaelnebel/movemodelgenerator
C#/Java: Move the modelgenerator.
2023-01-11 16:02:36 +01:00
Tony Torralba
c6d9e1ec81 Merge pull request #11742 from atorralba/atorralba/swift/more-path-injection-sinks
Swift: Add more path injection sinks
2023-01-11 15:15:42 +01:00
Tony Torralba
c115a9fee4 Add more path injection sinks 2023-01-11 14:28:24 +01:00
Tony Torralba
5d54482c71 Merge pull request #11770 from atorralba/atorralba/ql/omittable-exists
QL: Add OmittableExists query
2023-01-11 14:27:40 +01:00
Michael Nebel
11ca3f49f6 C#/Java: Adjust imports after moving files. 2023-01-11 13:13:33 +01:00
Michael Nebel
787b4743ee C#/Java: Rename the directories containing the model generator and tests. 2023-01-11 13:13:33 +01:00
Michael Nebel
178fd0e9e1 C#/Java: Remove all dashes in mode-generator. 2023-01-11 13:13:33 +01:00
erik-krogh
6914e9a17a Merge branch 'main' into atorralba/ql/omittable-exists 2023-01-11 13:09:38 +01:00
Erik Krogh Kristensen
466f24663e Merge pull request #11867 from erik-krogh/qlFix
QL: move queries folder instead of .cache folder now that we got .qlx
2023-01-11 13:03:47 +01:00
Erik Krogh Kristensen
3fa6a7cbff cache -> queries
Co-authored-by: Tony Torralba <atorralba@users.noreply.github.com>
2023-01-11 12:29:15 +01:00
Tony Torralba
a4f813183e Merge pull request #11785 from atorralba/atorralba/swift/grdb-sinks
Swift: Add sinks for the GRDB library
2023-01-11 11:49:37 +01:00
erik-krogh
74a58f64aa move queries folder instead of .cache folder now that we got .qlx 2023-01-11 11:13:42 +01:00
erik-krogh
ed2dd87bda update the codeql-action version used in QL-for-QL 2023-01-11 11:13:06 +01:00
Tony Torralba
ecf568629b Add ExprAggregate as a negative edge in getConjunctionParentRec 2023-01-11 09:41:16 +01:00
Jami Cogswell
181a711f04 Java: switch Collectors.joining model from neutral to summary 2023-01-10 21:06:03 -05:00
github-actions[bot]
76e121e359 JS: Bump version of ML-powered library and query packs to 0.4.6 2023-01-10 21:11:23 +00:00
github-actions[bot]
dc88bdccc7 JS: Bump patch version of ML-powered library and query packs 2023-01-10 21:04:31 +00:00
Edward Minnix III
ce06df3152 Merge pull request #11628 from egregius313/egregius313/android-webview-addjavascriptinterface-dataflow
Java: Add parameters of methods annotated @JavascriptInterface as remote flow sources
2023-01-10 12:41:52 -05:00
Florin Coada
4c1c12dd70 suggestions in list format 2023-01-10 11:18:56 -05:00
Jonathan Leitschuh
1d7881e03f Apply suggestions from code review
Co-authored-by: Chris Smowton <smowton@github.com>
2023-01-10 11:18:56 -05:00
Tony Torralba
b7364f5428 Update UnsafeDeserialization.qhelp
Move the table under <recommendation>, minor fixes.
2023-01-10 11:18:56 -05:00
Jonathan Leitschuh
3fa11c21c3 [Java] Document fixes for deserialization vulnerabilities by framework
Related https://github.com/github/codeql/issues/11603
2023-01-10 11:18:56 -05:00
Paolo Tranquilli
0ad585cfe6 Merge pull request #11860 from github/redsun82/swift-clang-14
Swift: make compilation with newer STL possible
2023-01-10 17:17:56 +01:00
Erik Krogh Kristensen
54c780bdf9 Merge pull request #11853 from erik-krogh/assignMore
JS: add local flow when recognizing Object.assign calls for library-inputs
2023-01-10 17:04:29 +01:00
Tony Torralba
ae8c75ac97 Generalize ConjunctionParent 2023-01-10 16:08:42 +01:00
Tony Torralba
72a11e737d Merge pull request #11775 from atorralba/atorralba/all/omittable-exists
All: Remove omittable exists variables
2023-01-10 16:07:06 +01:00
Ian Lynagh
3367da82c4 Kotlin: Accept test changes
We get better locations with Kotlin 1.8.0.
2023-01-10 14:41:30 +00:00
Ian Lynagh
b7eb521fa0 Kotlin: Fix custom_plugin test for Kotlin 1.8.0 2023-01-10 14:41:30 +00:00
Ian Lynagh
c71ea80029 Kotlin: Accept test changes
We now get better locations, with Kotlin 1.8.0.
2023-01-10 14:41:30 +00:00
Ian Lynagh
20b35e5d02 Kotlin: 1.8.0 changes 2023-01-10 14:41:30 +00:00
Ian Lynagh
c4119761cc Kotlin: Another 1.8 build fix 2023-01-10 14:41:30 +00:00
Ian Lynagh
89b3363761 Kotlin: Bump CI version to 1.8.0-Beta 2023-01-10 14:41:30 +00:00
Ian Lynagh
b51c3aae85 Kotlin: Logs test: Allow for -Beta versions etc when parsing the logs 2023-01-10 14:41:29 +00:00
Ian Lynagh
6fbda1a9f0 Kotlin: Accept test changes with 1.8 2023-01-10 14:41:29 +00:00
Ian Lynagh
f7d8d16ed3 Kotlin: Fix build for 1.8.0-Beta
The build no longer works for Kotlin < 1.8: We get

    error: class 'org.jetbrains.kotlin.ir.IrElement' was compiled
           with an incompatible version of Kotlin. The binary version
           of its metadata is 1.8.0, expected version is 1.6.0.
2023-01-10 14:41:29 +00:00
erik-krogh
62b69bbd3e autoformat 2023-01-10 15:38:13 +01:00
Erik Krogh Kristensen
6623e5fbf3 Merge pull request #11852 from erik-krogh/jsInfiniteChar
JS: recognize an infinite repetition of a char-class like regex as a char-class like regex
2023-01-10 15:32:22 +01:00
Erik Krogh Kristensen
ce8836fb65 Update javascript/ql/lib/semmle/javascript/PackageExports.qll
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2023-01-10 15:30:44 +01:00
erik-krogh
43696f5e27 add explicit this 2023-01-10 15:27:37 +01:00
erik-krogh
23a847b1cf track shell:true more in js/shell-command-constructed-from-input 2023-01-10 15:27:37 +01:00
Erik Krogh Kristensen
9f8d10de11 Merge pull request #11851 from erik-krogh/jsFixMissingThis
JS: fix bad join-order in js/missing-this-qualifier
2023-01-10 15:23:25 +01:00
Paolo Tranquilli
2fb5621527 Swift: replace $(CC) with clang
On macOS `$(CC)` points to a wrapper that requires `DEVELOPER_DIR` to be
set in the environment. Using `clang` is slightly less generic, but
that's our default any way. Even if we do set a different clang version
somewhere, the selected version of GCC would not change, and the test
is targeting that.
2023-01-10 14:58:21 +01:00
Paolo Tranquilli
943763a026 Swift: add -Wno-pragma-once-outside-header to check 2023-01-10 14:30:35 +01:00
Paolo Tranquilli
28d79eeb77 Swift: make compilation with different STL versions possible
Previous to this patch the code contained a workaround for the standard
defect

https://cplusplus.github.io/LWG/issue3657

where `std::filesystem::path` did not have a `std::hash` implementation.

This patch allows compiling against versions of the STL that contain the
fix to the above issue. This is done by running the compiler against
code defining `std::hash<std::filesystem::path>`: if compilation
succeeds, it means the fix is not there and we need to use the
workaround, contained in `PathHash.h.workaround`. Otherwise, the fix is
there and we use `PathHash.h.fixed` instead, which only includes the
standard headers included by `PathHash.h.workaround`, so that one is a
drop-in replacement of the other.
2023-01-10 14:14:33 +01:00
Jeroen Ketema
1a4048d238 Merge pull request #11830 from jketema/frontend-update
C++: Changes for frontend update
2023-01-10 14:01:46 +01:00
erik-krogh
5c388c554c fix that the TypeTracker was unrestricted for the base-case of nonFirstLocationType 2023-01-10 13:39:50 +01:00
erik-krogh
e02b67af63 add failing test 2023-01-10 13:39:50 +01:00
Tony Torralba
50cd40ed20 Swift: Remove omittable exists variables 2023-01-10 13:39:50 +01:00
Tony Torralba
7ef8099a8b Shared: Remove omittable exists variables 2023-01-10 13:39:50 +01:00
Tony Torralba
c9d1cd97fb Ruby: Remove omittable exists variables 2023-01-10 13:39:49 +01:00
Tony Torralba
f6c3f77602 QL: Remove omittable exists variables 2023-01-10 13:37:58 +01:00
Tony Torralba
d87c8c75d6 Python: Remove omittable exists variables 2023-01-10 13:37:35 +01:00
Tony Torralba
3b6dae41cd JavaScript: Remove omittable exists variables 2023-01-10 13:37:21 +01:00
Tony Torralba
32471d326e Java: Remove omittable exists variables 2023-01-10 13:37:19 +01:00
Tony Torralba
7a92970d89 Go: Remove omittable exists variables 2023-01-10 13:36:48 +01:00
Tony Torralba
2ca0df0369 C#: Remove omittable exists variables 2023-01-10 13:36:25 +01:00
Tony Torralba
3fcc99e5cb C++: Remove omittable exists variables 2023-01-10 13:36:01 +01:00
Erik Krogh Kristensen
f2658a0936 apply suggestions from doc review
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2023-01-10 12:56:22 +01:00
Tony Torralba
da90ae0e8f Update java/ql/lib/semmle/code/java/dataflow/FlowSources.qll 2023-01-10 11:18:53 +01:00
Jeroen Ketema
8d46642de3 C++: Update dbscheme stats file 2023-01-10 10:41:43 +01:00
Jeroen Ketema
2fc6484162 C++: Add dbscheme upgrade and downgrade scripts 2023-01-10 10:41:43 +01:00
Jeroen Ketema
1bab950023 C++: Introduce (_Complex) _Float16 type which is needed after frontend update 2023-01-10 10:41:43 +01:00
Jeroen Ketema
282ca1094e C++: Accept test changes after improving size of _Float128 in frontend 2023-01-10 10:41:43 +01:00
Jeroen Ketema
e215c4c94c C++: Accept test changes after frontend update
The location of a reference dereference has changed slightly.
2023-01-10 10:41:43 +01:00
Michael Nebel
16cd148961 Merge pull request #11711 from michaelnebel/externalflowcleanup
C#/Java: Delete deprecated ModelCsv classes and related predicates.
2023-01-10 10:22:50 +01:00
Michael Nebel
1729319ebe Merge pull request #11804 from michaelnebel/csharp/alignqueryids
C#: Align query IDs.
2023-01-10 10:14:07 +01:00
Michael Nebel
18a0abdb4c Merge pull request #11740 from michaelnebel/csharp/updatestats
C#: Update stats based on projects.
2023-01-10 10:09:53 +01:00
Ed Minnix
293a203756 Move JavascriptInterfaceMethod to WebView.qll 2023-01-09 15:10:23 -05:00
Rasmus Lerchedahl Petersen
2edbfbf8bc python: update test expectations
...now the bug is fixed
2023-01-09 20:35:20 +01:00
Mathias Vorreiter Pedersen
7f5344e025 Update swift/ql/lib/codeql/swift/elements/type/NumericOrCharType.qll
Co-authored-by: Tony Torralba <atorralba@users.noreply.github.com>
2023-01-09 17:08:27 +00:00
Tony Torralba
8e0a018673 Consider Int8 and UInt8 as OsLogNonRedactedTypes 2023-01-09 18:05:18 +01:00
Tony Torralba
49a41c98ee Test that hashed passwords are 'safe' to log
This doesn't seem completely right, but the heuristic approach we have regarding sensitive expressions has to draw the line somewhere.
2023-01-09 18:01:07 +01:00
Tony Torralba
160d89fb4e Add qhelp examples 2023-01-09 18:01:07 +01:00
Tony Torralba
33029b0ed8 Fix sanitizer QLDoc 2023-01-09 18:01:07 +01:00
Tony Torralba
7e0869965c Uncomment tests 2023-01-09 18:01:07 +01:00
Tony Torralba
c1f19dd145 Add stub so that tests work on Linux 2023-01-09 18:01:07 +01:00
Tony Torralba
b203a9eb6e Add a sanitizer for OSLogPrivacy options
Add test cases to verify how the sanitizer behaves depending on the argument type and the privacy option being used.
2023-01-09 18:01:07 +01:00
Tony Torralba
aad56097ac Add Cleartext Loggin query for Swift.
With some caveats: see TODO comments and failing tests.
2023-01-09 18:01:07 +01:00
Rasmus Lerchedahl Petersen
c142495a8b python: simplify code 2023-01-09 17:51:45 +01:00
Rasmus Lerchedahl Petersen
5fe62e293a python: fix bug, add clarifying comment 2023-01-09 17:45:50 +01:00
erik-krogh
9f100ef2c6 add local flow when recognizing Object.assign calls for library-inputs 2023-01-09 17:44:11 +01:00
Tony Torralba
eb78661c1f Add missing SQL injection tests for the GRDB SQL class 2023-01-09 17:36:54 +01:00
erik-krogh
90f9e3f825 recognize an infinite repetition of a char-class like regex as a char-class like regex 2023-01-09 17:25:08 +01:00
Sarita Iyer
be06469a19 Merge pull request #11835 from github/saritai/pr/qlx
Docs: CodeQL pack compatibility
2023-01-09 10:15:08 -05:00
Ed Minnix
909b1d70d9 Rename files to say "Allow" instead of "Permit" 2023-01-09 10:11:03 -05:00
Ed Minnix
c723df3ca7 Fix alert message in expected file 2023-01-09 10:08:19 -05:00
erik-krogh
785c21f462 fix bad join-order in js/missing-this-qualifier 2023-01-09 16:06:26 +01:00
Ed Minnix
f626d4794a Change wording from "permit" to "allow" in id and name 2023-01-09 10:03:12 -05:00
Ed Minnix
972b4629c8 Fix typo in change note 2023-01-09 10:01:38 -05:00
Ed Minnix
64668883a4 Add good example to documentation 2023-01-09 09:59:38 -05:00
Ed Minnix
2ec73c50f9 Mention WebView in alert message 2023-01-09 09:55:09 -05:00
Arthur Baars
664fdc3b2a Merge pull request #11815 from aibaars/too-many-fields
Ruby: use record_parse_error_for_node to report extractor error
2023-01-09 15:40:19 +01:00
Erik Krogh Kristensen
5157d4df7b Merge pull request #11581 from erik-krogh/stdin
Rb: add stdin as source for unsafe-deserialization
2023-01-09 13:57:47 +01:00
Chris Smowton
e9bbb5d7fa Merge pull request #11730 from smowton/smowton/admin/improve-sql-unescaped-docs
Java: improve naming and description of SqlUnescaped.ql
2023-01-09 12:50:27 +00:00
yoff
c01ce955ba Merge pull request #11778 from yoff/shared/inline-tests
Shared: Inline test expectations
2023-01-09 13:21:18 +01:00
Chris Smowton
2e26fb1171 Merge pull request #11819 from smowton/smowton/admin/port-java-autobuilder-tests
Add Java autobuilder integration tests
2023-01-09 12:17:39 +00:00
Chris Smowton
efe23c1da7 Note that alerts should not be re-raised 2023-01-09 10:56:13 +00:00
Chris Smowton
994a46289f Add change note 2023-01-09 10:56:13 +00:00
Chris Smowton
ef27f9fe96 Replace one more mention of escaping 2023-01-09 10:56:13 +00:00
Chris Smowton
45c732a6f9 Java: improve naming and description of SqlUnescaped.ql
Since the main thing it's objecting to is concatenation not lack of escaping (in particular it doesn't look for escaping sanitizers), rename and re-describe it accordingly.
2023-01-09 10:56:13 +00:00
Mathias Vorreiter Pedersen
381301e552 Update swift/ql/lib/swift.qll
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
2023-01-09 10:32:52 +00:00
Geoffrey White
9333e80def Swift: Add getVaList stub to the test. 2023-01-09 10:29:37 +00:00
Taus
06ea249997 Merge pull request #11820 from yoff/python/fix-downgrades
Python: fix downgrade script
2023-01-09 11:24:41 +01:00
Mathias Vorreiter Pedersen
6bb09ef289 Swift: Add integral type classes. 2023-01-09 09:43:09 +00:00
Mathias Vorreiter Pedersen
9be9636816 Merge pull request #11670 from atorralba/atorralba/swift/predicate-injection
Swift: Add predicate injection query
2023-01-09 08:54:13 +00:00
Harry Maclean
5b117084db Merge pull request #11534 from hmac/array-inclusion-barrier-guard-constant
Ruby: Make array inclusion barrier more sensitive
2023-01-09 20:57:09 +13:00
Paolo Tranquilli
82d9edfabf Merge branch 'main' into redsun82/swift-open-redirection 2023-01-09 08:44:02 +01:00
Jami Cogswell
a3c7b2c3a2 Java: move java.lang.Math.min to the correct file 2023-01-06 14:35:09 -05:00
Jeroen Ketema
a743fbcc95 Merge pull request #11799 from jketema/case-uncomment
C++: Uncomment cases in dbscheme
2023-01-06 19:26:53 +01:00
Sarita Iyer
d7bf2d9375 docs for codeql pack compatibility 2023-01-06 12:07:24 -05:00
Sarita Iyer
a9867a266e fixed link 2023-01-06 11:50:07 -05:00
Sarita Iyer
d68cfc7d4f codeql pack compatibility docs 2023-01-06 11:17:02 -05:00
Chris Smowton
831255e9c0 Merge pull request #11832 from github/mbg/fix/go-version-warnings
Go: Handle output from `go version` more gracefully
2023-01-06 14:05:39 +00:00
Jeroen Ketema
c1bc097355 C++: Add upgrade/downgrade scripts for dbscheme update 2023-01-06 14:26:24 +01:00
Jeroen Ketema
cdb34bb1f9 C++: Update database stats file 2023-01-06 14:26:23 +01:00
Jeroen Ketema
b9b0c8091f C++: Uncomment cases in dbscheme
Note that the builtin types `__int{8,16,32,64}` are not uncommented,
as these are never and could have never been generated by the
extractor.
2023-01-06 14:26:23 +01:00
Geoffrey White
f3914ffe25 Merge pull request #11823 from geoffw0/heuristicalloc
C++: Use HeuristicAllocationExpr in more queries
2023-01-06 13:13:14 +00:00
Jami
f5e5f6dfd1 Merge pull request #11821 from jcogs33/jcogs33/fix-mad-typos
Java: fix typos in MaD row `name` columns for `MappingSqlQuery` and `MappingSqlQueryWithParameters`
2023-01-06 07:59:30 -05:00
Rasmus Lerchedahl Petersen
03bd6cb414 python: Allow optional result=OK
Also add a further test case
2023-01-06 13:33:12 +01:00
Nick Rolfe
4c5f149afd Merge pull request #11831 from github/post-release-prep/codeql-cli-2.12.0
Post-release preparation for codeql-cli-2.12.0
2023-01-06 12:15:17 +00:00
Michael B. Gale
1ef1d63c11 Add test for parseGoVersion 2023-01-06 11:20:51 +00:00
Michael B. Gale
9af9b32722 Find the last line of output from go version 2023-01-06 11:20:39 +00:00
Geoffrey White
bb451f3911 C++: Fix result duplication. 2023-01-06 11:05:47 +00:00
github-actions[bot]
cdb8f67601 Post-release preparation for codeql-cli-2.12.0 2023-01-06 10:36:34 +00:00
Rasmus Lerchedahl Petersen
8d9e94a00f swift: fix typo 2023-01-06 11:22:49 +01:00
erik-krogh
0a1769657d add change-note 2023-01-06 09:09:09 +01:00
erik-krogh
19d2b49562 drive-by: make Base64.decode64(..) into a flowsummary that is shared with all queries 2023-01-06 09:04:37 +01:00
erik-krogh
1a27441cfb drive-by: delete code-execution sinks from unsafe-deserialization, we risked duplicate alerts 2023-01-06 09:04:36 +01:00
erik-krogh
0e6028a7f3 add stdin as source for unsafe-deserialization 2023-01-06 09:04:36 +01:00
Rasmus Lerchedahl Petersen
d42bb119fe python: align annotations with Ruby
use `result=BAD` for expected alert
and `result=OK` on sinks where alerts are not wanted.
2023-01-05 21:41:28 +01:00
Rasmus Lerchedahl Petersen
ad95225272 python: improve code
according to alert and reviewer's suggestion
2023-01-05 20:42:29 +01:00
erik-krogh
f98ff65b11 use eval() instead of send() in test 2023-01-05 20:04:04 +01:00
Erik Krogh Kristensen
d9176541c6 Apply suggestions from code review
Co-authored-by: Alex Ford <alexrford@users.noreply.github.com>
2023-01-05 20:02:54 +01:00
Nick Rolfe
44213f0144 Merge pull request #11826 from github/nickrolfe/check-change-note
CI: fail if a changenote filename doesn't have the right format
2023-01-05 16:55:30 +00:00
Nick Rolfe
4e6baf83c8 Update .github/workflows/check-change-note.yml
Co-authored-by: Taus <tausbn@github.com>
2023-01-05 16:26:43 +00:00
Nick Rolfe
0beca9d96c CI: fail if a changenote filename doesn't have the right format 2023-01-05 16:01:07 +00:00
Jeroen Ketema
f370cd840c Merge pull request #11818 from jketema/downgrade-fix
C++: Fix the expression kind in two of the downgrade scripts
2023-01-05 16:33:16 +01:00
Geoffrey White
b3e82498fa C++: Change note. 2023-01-05 15:06:40 +00:00
Jami Cogswell
f03f687d61 Java: add change note 2023-01-05 09:08:04 -05:00
Rasmus Lerchedahl Petersen
bb26c31f84 Python: fix downgrade script
When new kinds are inserted, new indices exists that do not
correspond to any old indices.
These were previously mapped, now they are not.
2023-01-05 14:56:52 +01:00
Jami Cogswell
0640bd9d8b Java: fix typos in the MaD row name columns for MappingSqlQuery and MappingSqlQueryWithParameters 2023-01-05 08:32:22 -05:00
Rasmus Lerchedahl Petersen
8afb541718 cpp/swift: fix qldoc 2023-01-05 14:30:13 +01:00
yoff
a74062cd51 Update go/ql/test/TestUtilities/InlineExpectationsTest.qll
Co-authored-by: Owen Mansel-Chan <62447351+owen-mc@users.noreply.github.com>
2023-01-05 14:12:16 +01:00
Geoffrey White
3b31da8a62 C++: Update the experimental query as well. 2023-01-05 12:48:17 +00:00
Geoffrey White
46baf9d5e5 C++: Add test cases for an experimental query as well. 2023-01-05 12:48:16 +00:00
Geoffrey White
c160e0b2a4 C++: Add a warning on HeuristicAllocationExpr.getSizeBytes() and similar methods. 2023-01-05 12:47:52 +00:00
Geoffrey White
823c767aac C++: Undo changes to SizeCheck.ql, SizeCheck2.ql. 2023-01-05 12:34:12 +00:00
Chris Smowton
52297c0b23 Add Java autobuilder integration tests 2023-01-05 12:19:25 +00:00
Jonas Jensen
c8f35ea1ea Merge pull request #11810 from kaspersv/kaspersv/inline-late-pragma
Add inline_late pragma to QL language spec
2023-01-05 13:15:12 +01:00
Geoffrey White
2023abdc60 C++: Update the queries. 2023-01-05 11:33:58 +00:00
Geoffrey White
a9aa67177b C++: Add test cases for HeuristicAllocationExpr in queries. 2023-01-05 11:30:21 +00:00
Geoffrey White
10ca2dac19 C++: Remove unnecessary 'semmle' directory. 2023-01-05 11:30:15 +00:00
Jeroen Ketema
14283f01ac C++: Fix the expression kind in two of the downgrade scripts
A 0 value for the expression kind is not valid, as 0 does not occur in the
relevant case split. This should have been the value of `@errorexpr`, which
is 1.
2023-01-05 11:04:31 +01:00
Rasmus Lerchedahl Petersen
c3b3c05cf3 Revert "Merge pull request #37 from erik-krogh/shared/inline-tests"
This reverts commit 65fe9abcfe, reversing
changes made to 08e9d3391f.
2023-01-05 09:19:43 +01:00
Rasmus Lerchedahl Petersen
2e46919e10 java: nicer code as suggested by review 2023-01-04 19:50:29 +01:00
Geoffrey White
e45750a8ca Merge branch 'main' into format 2023-01-04 18:00:59 +00:00
Arthur Baars
799e0c1bcc Ruby: use record_parse_error_for_node to report extractor error 2023-01-04 17:35:47 +01:00
yoff
65fe9abcfe Merge pull request #37 from erik-krogh/shared/inline-tests
inline Location into the shared implementation of InlineExpectationsTest
2023-01-04 17:08:23 +01:00
Kasper Svendsen
9ad572fa29 Add inline_late pragma to QL language spec 2023-01-04 11:28:08 +01:00
Harry Maclean
4d228bcddf Ruby: Recognise more string-valued variables
This increases the sensitivity of our barrier guards.
2023-01-04 11:45:10 +13:00
Harry Maclean
9944252c43 Ruby: Add test for barrier guards
This demonstrates that we are missing a guard when a case branch
compares against a string-valued variable rather than a string literal.
2023-01-04 11:45:10 +13:00
Harry Maclean
698a679c78 Ruby: add test 2023-01-04 11:45:10 +13:00
Harry Maclean
0fbb6bf608 Ruby: Make array inclusion barrier more sensitive 2023-01-04 11:45:09 +13:00
Jami Cogswell
abe501c1af Java: add change note 2023-01-03 17:15:50 -05:00
Jami Cogswell
5d92792e40 Java: update test case affected by Function.apply model 2023-01-03 16:14:08 -05:00
Jami Cogswell
feaae16f7c Java: adjust comments 2023-01-03 16:08:14 -05:00
Ed Minnix
0be8648a9d Add changenote 2023-01-03 15:55:53 -05:00
Ed Minnix
28f555c2b2 Add simple test case for @JavascriptInterface parameter flow 2023-01-03 15:31:40 -05:00
Ed Minnix
ab7ca1d642 Java: Add parameters of @JavascriptInterface methods as a remote flow sources 2023-01-03 15:31:40 -05:00
Ed Minnix
f9b8200009 Add stub for android.webkit.JavascriptInterface annoation 2023-01-03 15:31:40 -05:00
Edward Minnix III
69fd5e93bc Merge pull request #28 from egregius313/egregisu313/webview-setAllowContentAccess-single-query
Merge `setAllowContentAccess` queries into singular query
2023-01-03 15:27:09 -05:00
Ed Minnix
81df89f93e Use proper @id in changenote 2023-01-03 15:19:26 -05:00
Ed Minnix
28ad9d00fb Merge both setAllowContentAccess queries into one query
Previously, the query to detect whether or not access to `content://`
links was done using two queries.

Now they can be merged into one query
2023-01-03 15:17:07 -05:00
Jami Cogswell
29221ae426 Java: add summary model for System.getProperty, adjust comments 2023-01-03 15:11:21 -05:00
Jami Cogswell
21a018e5c5 Java: add summary model and test for File.getName 2023-01-03 13:12:24 -05:00
Geoffrey White
fc646a6d48 Swift: Update .expected following a toString change in main. 2023-01-03 16:25:14 +00:00
Geoffrey White
e05bb7fcee Merge branch 'main' into format 2023-01-03 15:14:55 +00:00
Michael Nebel
17cd182d72 C#: Update stats based on projects. 2023-01-03 15:44:47 +01:00
Michael Nebel
9d608a78a3 C#: Add change note on renamed query ids. 2023-01-03 15:18:22 +01:00
Michael Nebel
bfe5a0c438 C#: Rename query id's to be prefixed with cs instead of csharp. 2023-01-03 15:13:54 +01:00
erik-krogh
3811eae679 simplify the qhelp for unsafe-code-construction
The `send()` example is not flagged by any current query, so it was weird talking about it as "vulnerable".
2023-01-02 13:33:56 +01:00
erik-krogh
3815a5a096 fix qhelp syntax 2023-01-02 10:19:05 +01:00
Ed Minnix
35de551f6b Formatting 2022-12-31 17:19:49 -05:00
Ed Minnix
515fa21aad Change notes 2022-12-31 17:18:37 -05:00
Ed Minnix
df1a4d2ed1 Documentation fix: Add state1 and state2 to documentation 2022-12-31 15:25:37 -05:00
Ed Minnix
68392aa8d8 Fix test expectations 2022-12-31 15:25:25 -05:00
Ed Minnix
02f70f3536 Add @security-severity tag 2022-12-31 15:00:28 -05:00
Edward Minnix III
1d345c6101 Refactoring and simplification
Co-authored-by: Tony Torralba <atorralba@users.noreply.github.com>
2022-12-31 15:00:28 -05:00
Ed Minnix
9ef319f659 Java: setAllowContentAccess query tests 2022-12-31 15:00:28 -05:00
Ed Minnix
5265cb4b03 Merge two dataflow configurations into one taint tracking 2022-12-31 15:00:28 -05:00
Ed Minnix
973f649e76 Break dataflow into two steps in order to capture flow from WebView to settings call 2022-12-31 15:00:28 -05:00
Ed Minnix
0e15dd9fa9 Query metadata 2022-12-31 15:00:28 -05:00
Edward Minnix III
778749184b Change id to use android/ instead of prepending android-
Co-authored-by: Tony Torralba <atorralba@users.noreply.github.com>
2022-12-31 15:00:28 -05:00
Ed Minnix
da25c586e6 Dataflow query for detecting paths that disable content access
Since the default value is `true`, we need to determine whether or not
the `setAllowContentAccess` method is ever called using dataflow.
2022-12-31 15:00:28 -05:00
Ed Minnix
8a763015e6 Reduce precision rating to medium
This query won't always be a security problem, so it should have a lower
precision rating than `high`.
2022-12-31 15:00:28 -05:00
Ed Minnix
7cc53126f3 Java: WebView setAllowContentAccess query test cases 2022-12-31 15:00:28 -05:00
Ed Minnix
a023726c03 Java: add Android stubs to options file for CWE-200 tests 2022-12-31 15:00:28 -05:00
Ed Minnix
e4e13d38b7 Java: query for Android WebView setAllowContentAccess 2022-12-31 15:00:28 -05:00
Ed Minnix
e259ef5d1d Java: Add class for android.webkit.WebSettings.setAllowContentAccess 2022-12-31 15:00:28 -05:00
Harry Maclean
a6571a05ab Ruby: Include send example in qhelp 2022-12-28 11:34:55 +13:00
Harry Maclean
d3812f5906 Ruby: Add another code injection example to qhelp 2022-12-28 11:20:56 +13:00
Tony Torralba
07d99bd643 Add path injection sinks 2022-12-23 17:16:06 +01:00
Tony Torralba
4215a89bc8 Add cleartext storage database sinks 2022-12-23 17:15:59 +01:00
Tony Torralba
ac39aeb6b6 Add SQLi sinks 2022-12-23 17:03:31 +01:00
Jami Cogswell
939279af38 Java: add comments 2022-12-22 16:25:12 -05:00
Jami Cogswell
673d37cc3d Java: update Math.min test case 2022-12-22 14:36:06 -05:00
Jami Cogswell
a81c54b58c Java: updates to order alphabetically 2022-12-22 13:22:12 -05:00
Jami Cogswell
e6331dc2e6 Java: update test case affected by Long.parseLong summary model 2022-12-22 12:57:37 -05:00
Jami Cogswell
997219a280 Java: update test case affected by Class.isAssignableFrom neutral model 2022-12-22 12:54:02 -05:00
Jami Cogswell
6007827dd3 Java: update test cases 2022-12-22 12:29:57 -05:00
Tony Torralba
36ca97e4f6 Add exclusions to reduce FP
Predicate parameters that have a database type are excluded.

Also, uses of the exists variable in an agreggation or another quantifier are excluded.
2022-12-22 11:15:07 +01:00
erik-krogh
b3dd50bc36 inline Location into the shared implementation of InlineExpectationsTest 2022-12-22 11:09:43 +01:00
Rasmus Lerchedahl Petersen
08e9d3391f swift: use shared inline tests
- add util shared pack to swift
 - remove from identical-files
2022-12-22 10:20:07 +01:00
Rasmus Lerchedahl Petersen
b0d7998342 go: use shared inline tests
- remove from identical-files
2022-12-22 10:20:07 +01:00
Rasmus Lerchedahl Petersen
f28eb6bf31 ql4ql: use shared inline tests
- add util shared pack to ql
 - remove from identical-files
2022-12-22 10:20:07 +01:00
Rasmus Lerchedahl Petersen
0d6c643d77 ruby: use shared inline tests
- remove from identical-files
2022-12-22 10:20:07 +01:00
Rasmus Lerchedahl Petersen
4667068017 java: use shared inline tests
- remove from identical-files
2022-12-22 10:20:06 +01:00
Rasmus Lerchedahl Petersen
a9b232bff4 csharp: use shared inline tests
- remove from identical-files
2022-12-22 10:20:06 +01:00
Rasmus Lerchedahl Petersen
d97e185994 cpp: use shared inline tests
- remove from identical-files
2022-12-22 10:20:06 +01:00
Rasmus Lerchedahl Petersen
e8d3802ee5 Python: use shared inline tests
- remove from identical-files
2022-12-22 10:20:05 +01:00
Rasmus Lerchedahl Petersen
b767dcfd18 shared: Add shared inline expectation test library 2022-12-22 10:20:05 +01:00
Jami Cogswell
de5965525f Java: add initial test cases for summary models 2022-12-21 16:19:37 -05:00
Jami Cogswell
c251da799f Java: update TopJdkApis test 2022-12-21 13:19:09 -05:00
Jami Cogswell
16de30e07e Java: add java.util.stream models 2022-12-21 13:05:23 -05:00
Jami Cogswell
1db829e55c Java: add java.util models 2022-12-21 13:03:57 -05:00
Jami Cogswell
573de92441 Java: add java.util.function models 2022-12-21 12:59:58 -05:00
Jami Cogswell
a8c55ee4b7 Java: add java.util.concurrent models 2022-12-21 12:59:00 -05:00
Jami Cogswell
db0d24fdd1 Java: add java.util.concurrent.atomic models 2022-12-21 12:57:22 -05:00
Jami Cogswell
cfe075ef54 Java: add java.time models 2022-12-21 12:54:35 -05:00
Jami Cogswell
8e20aeb314 Java: add java.text models 2022-12-21 12:51:44 -05:00
Jami Cogswell
b9ce588076 Java: add java.sql models 2022-12-21 12:49:29 -05:00
Jami Cogswell
1544f49f91 Java: add java.math models 2022-12-21 12:47:32 -05:00
Jami Cogswell
ed534b06d5 Java: add java.lang models 2022-12-21 12:45:12 -05:00
Jami Cogswell
99ddd484be Java: add java.io models 2022-12-21 12:34:26 -05:00
Tony Torralba
7d0018c897 Update ql/ql/src/queries/style/OmittableExists.ql 2022-12-21 17:16:34 +01:00
Tony Torralba
ac0c42c5c6 Apply suggestions from code review
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2022-12-21 16:16:58 +01:00
Tony Torralba
227e099854 Apply code review suggestions
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2022-12-21 12:40:29 +01:00
Tony Torralba
aa1d49cb95 Add OmittableExists QL-for-QL query 2022-12-21 12:26:58 +01:00
Paolo Tranquilli
454af0d721 Swift: fix locking of output swiftmodule trap 2022-12-20 15:34:18 +01:00
Paolo Tranquilli
a1161c6efe Swift: remove header patch which is not needed any more 2022-12-20 15:28:52 +01:00
Paolo Tranquilli
725861626c Merge branch 'main' into redsun82/swift-open-redirection 2022-12-20 15:28:30 +01:00
Tony Torralba
30aa9b230c Apply suggestions from code review
Co-authored-by: Ben Ahmady <32935794+subatoi@users.noreply.github.com>
2022-12-20 14:14:05 +01:00
turbo
d1d4163b79 Exclude cpp/wrong-use-of-the-umask 2022-12-18 15:55:04 +01:00
turbo
b7c33734b1 Merge remote-tracking branch 'origin/turbo/experimental/combined' into turbo/experimental/combined 2022-12-18 15:44:53 +01:00
turbo
1e5426fca2 Create security-experimental suite helper and all language suite implementations 2022-12-18 15:44:08 +01:00
Geoffrey White
640f894b00 Merge branch 'main' into format 2022-12-16 11:42:03 +00:00
Tony Torralba
46ea067449 Add bidirectional import in ExternalFlow.qll 2022-12-16 09:59:48 +01:00
Geoffrey White
1f7d96a74a Merge branch 'main' into format 2022-12-15 15:17:54 +00:00
Michael Nebel
2034b00772 C#: Remove deprecated ModelCsv classes. 2022-12-15 15:22:52 +01:00
Michael Nebel
0f038ee93a Java: Remove deprecated ModelCsv classes. 2022-12-15 15:22:44 +01:00
Paolo Tranquilli
7f505d8715 Swift: do not filter frontend actions 2022-12-15 14:39:43 +01:00
Paolo Tranquilli
208388e04d Swift: hard code libc.dylib path on macOS
Also, handle the corner case where loading libc fails.
2022-12-15 13:30:23 +01:00
Tony Torralba
6837af97bc Apply suggestions from code review
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
2022-12-15 12:35:54 +01:00
Tony Torralba
11c03fb8c9 Add 'good' test cases 2022-12-15 12:35:47 +01:00
Paolo Tranquilli
3084eda28a Swift: add swiftmodule hash map testing to frontend_invocations 2022-12-15 10:33:47 +01:00
Paolo Tranquilli
e42ae09e1c Swift: fix interaction between bash wrapper and open redirection on macOS 2022-12-15 09:50:31 +01:00
turbo
5fd5ebc26e Create security-experimental suite helper and all language suite implementations 2022-12-14 23:35:32 +01:00
Paolo Tranquilli
793de3196b Revert "Swift: accept test changes"
This reverts commit 26ae8f177b.
2022-12-14 18:34:12 +01:00
Paolo Tranquilli
14fd89d482 Swift: generalize output redirection code 2022-12-14 18:26:48 +01:00
Paolo Tranquilli
45c0c7fe6c Merge branch 'main' into redsun82/swift-open-redirection 2022-12-14 18:26:16 +01:00
turbo
b35a1d4206 Adjust docs referring to experimental queries to include details on new tagging system 2022-12-14 17:16:38 +01:00
turbo
4ec401a3f6 Tag all security queries in supported languages' experimental directories with an experimental tag 2022-12-14 17:15:50 +01:00
erik-krogh
d95a4a7baf add a second example of how to use module_eval without constructing a code-string 2022-12-13 19:33:45 +01:00
erik-krogh
ccf520a5cd Merge branch 'main' into unsafeCodeConstruction 2022-12-13 18:31:49 +01:00
Tony Torralba
85b3092b16 Add security-severity and fix alert message 2022-12-13 12:01:01 +01:00
Tony Torralba
d72d096c86 Add predicate injection query 2022-12-13 10:27:29 +01:00
Paolo Tranquilli
250ac686a2 Merge branch 'main' into redsun82/swift-open-redirection 2022-12-12 08:46:23 +01:00
Paolo Tranquilli
a93e361aca Merge branch 'main' into redsun82/swift-open-redirection 2022-12-09 12:19:38 +01:00
Paolo Tranquilli
7162692656 Swift: exit directly on actions not requiring extraction 2022-12-09 10:00:01 +01:00
Paolo Tranquilli
4a41bb4061 Merge branch 'main' into redsun82/swift-open-redirection 2022-12-09 09:59:21 +01:00
Paolo Tranquilli
26ae8f177b Swift: accept test changes
Downgrading the emit object action to a type check one has some
unexpected side effects, that seem however acceptable:
* experimental false static assertions do not make compilation fail in
  type check mode
* the implicit module loading of `SwiftOnoneSupport` is not happening.
  That module contains some "pre-specializations", it does not seem
  really relevant for analysis
2022-12-08 17:13:00 +01:00
Paolo Tranquilli
d35c5e90ee Swift: remove fishhook 2022-12-08 16:10:44 +01:00
Paolo Tranquilli
bf1b32f210 Swift: rework file redirection
The hash map mechanism that was already in use for reading swiftmodule
files on macOS is now in use also on Linux. The output replacing
mechanism has been also reworked so that:
* frontend module emission modes have the remapping done directly in
  the internal frontend options instead of painstakingly modifying input
  flags (this requires a patch on the swift headers though)
* object emission mode is silenced to be just a type checking pass,
  thus producing no output files
* all other passes but some debugging and version related ones become
  noops

The open file read redirection uses a global weak pointer instance to
maximize robustness in the face of possibly multi-threaded calls to open
happening while `main` is exiting. Possibly overkill, but better safe
than sorry.
2022-12-08 16:10:44 +01:00
Paolo Tranquilli
944adfe727 Swift: allow modifying frontend outputs 2022-12-08 16:10:25 +01:00
Paolo Tranquilli
219ed64b74 Swift: reorganize bazel third party dependencies 2022-12-08 16:10:25 +01:00
Geoffrey White
24ce1c27bc Swift: Autoformat. 2022-12-08 13:09:37 +00:00
Geoffrey White
07ea006cee Swift: Add support for CSV modelled sinks as well. 2022-12-08 11:36:55 +00:00
Geoffrey White
dba344451f Swift: Add UncontrolledFormatStringExtensions.qll. 2022-12-08 11:32:50 +00:00
Geoffrey White
cf3345ee8f Swift: Revert security-severity on CWE-321, for now. 2022-12-02 12:01:43 +00:00
Geoffrey White
85a0a42da9 Swift: try again to satisfy ql-for-ql. 2022-12-02 10:15:11 +00:00
Geoffrey White
f7ebd1312e Swift: Corrections. 2022-12-01 20:13:56 +00:00
Geoffrey White
157a7829ca Swift: correct the example. 2022-12-01 18:35:10 +00:00
Geoffrey White
ad05cc3cb1 Swift: Separate out a FormatString library as well. 2022-12-01 18:09:46 +00:00
Geoffrey White
43596869e7 Swift: Move query logic to a .qll. 2022-12-01 18:09:45 +00:00
Geoffrey White
87fa159384 Swift: Add security-severity, and correct one for another query that apparently wasn't right. 2022-12-01 18:09:39 +00:00
Geoffrey White
58e9a0436e Swift: Add metadata. 2022-12-01 18:09:33 +00:00
Geoffrey White
2b61f26a64 Swift: Add doc. 2022-12-01 16:32:34 +00:00
Geoffrey White
32c4728f83 Swift: Add tests. 2022-12-01 16:32:33 +00:00
Geoffrey White
a2210959b5 Swift: Uncontrolled format string query (initial version). 2022-12-01 16:32:33 +00:00
erik-krogh
fd7442868f fix copy-pate error in UnsafeCodeConstructionQuery.qll 2022-11-28 13:45:24 +01:00
erik-krogh
f75b853ae4 add change-note 2022-11-25 11:08:14 +01:00
erik-krogh
53f24a5281 fix QL-for-QL warning 2022-11-25 10:32:06 +01:00
erik-krogh
0817238177 drive-by: same change in unsafe-shell-command-construction 2022-11-25 10:32:06 +01:00
erik-krogh
378cc1aed2 add support for string-like-literals 2022-11-25 10:32:06 +01:00
erik-krogh
80c92dc3e6 add support for array pushes 2022-11-25 10:32:05 +01:00
erik-krogh
3461404bbb add basic support for arrays 2022-11-25 10:31:35 +01:00
erik-krogh
0f2a48f461 fix QL-for-QL warnings 2022-11-25 10:26:24 +01:00
erik-krogh
2033dd2dcc remove parameters named "code" as source 2022-11-25 10:25:31 +01:00
erik-krogh
e7c6571f52 remove the "send(..)" and similar from unsafe-code-construction 2022-11-25 10:25:31 +01:00
erik-krogh
f1668801d3 add a rb/unsafe-code-construction query
rebase
2022-11-25 10:25:30 +01:00
erik-krogh
5f6cb1684b move the code-injection tests into a subfolder 2022-11-24 17:23:25 +01:00
Rasmus Lerchedahl Petersen
0a7cfad048 python: inline query tests for command injection
note how the test file is partially annotated
and those annotations can now be expressed

In this particular test file, absolute line numbers
might have been better than relative ones.
We might remove line numbers altogether,
but should check more querries to see how it looks.
2022-11-02 16:21:59 +01:00
Rasmus Lerchedahl Petersen
f486c44b00 python: library for inline query tests
similar to the consistency queires used in js
but based on the inline expectations framework
2022-11-02 16:18:36 +01:00
1203 changed files with 86828 additions and 22560 deletions

32
.github/actions/os-version/action.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
name: OS Version
description: Get OS version.
outputs:
version:
description: "OS version"
value: ${{ steps.version.outputs.version }}
runs:
using: composite
steps:
- if: runner.os == 'Linux'
shell: bash
run: |
. /etc/os-release
echo "VERSION=${NAME} ${VERSION}" >> $GITHUB_ENV
- if: runner.os == 'Windows'
shell: powershell
run: |
$objects = systeminfo.exe /FO CSV | ConvertFrom-Csv
"VERSION=$($objects.'OS Name') $($objects.'OS Version')" >> $env:GITHUB_ENV
- if: runner.os == 'macOS'
shell: bash
run: |
echo "VERSION=$(sw_vers -productName) $(sw_vers -productVersion)" >> $GITHUB_ENV
- name: Emit OS version
id: version
shell: bash
run: |
echo "$VERSION"
echo "version=${VERSION}" >> $GITHUB_OUTPUT

View File

@@ -26,3 +26,9 @@ jobs:
run: | run: |
gh api 'repos/${{github.repository}}/pulls/${{github.event.number}}/files' --paginate --jq 'any(.[].filename ; test("/change-notes/.*[.]md$"))' | gh api 'repos/${{github.repository}}/pulls/${{github.event.number}}/files' --paginate --jq 'any(.[].filename ; test("/change-notes/.*[.]md$"))' |
grep true -c grep true -c
- name: Fail if the change note filename doesn't match the expected format. The file name must be of the form 'YYYY-MM-DD.md' or 'YYYY-MM-DD-{title}.md', where '{title}' is arbitrary text.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api 'repos/${{github.repository}}/pulls/${{github.event.number}}/files' --paginate --jq '[.[].filename | select(test("/change-notes/.*[.]md$"))] | all(test("/change-notes/[0-9]{4}-[0-9]{2}-[0-9]{2}.*[.]md$"))' |
grep true -c

View File

@@ -11,7 +11,7 @@ on:
branches: branches:
- main - main
paths: paths:
- "java/ql/src/utils/model-generator/**/*.*" - "java/ql/src/utils/modelgenerator/**/*.*"
- ".github/workflows/mad_modelDiff.yml" - ".github/workflows/mad_modelDiff.yml"
permissions: permissions:
@@ -40,12 +40,12 @@ jobs:
- name: Download database - name: Download database
env: env:
SLUG: ${{ matrix.slug }} SLUG: ${{ matrix.slug }}
GH_TOKEN: ${{ github.token }}
run: | run: |
set -x set -x
mkdir lib-dbs mkdir lib-dbs
SHORTNAME=${SLUG//[^a-zA-Z0-9_]/} SHORTNAME=${SLUG//[^a-zA-Z0-9_]/}
projectId=`curl -s https://lgtm.com/api/v1.0/projects/g/${SLUG} | jq .id` gh api -H "Accept: application/zip" "/repos/${SLUG}/code-scanning/codeql/databases/java" > "$SHORTNAME.zip"
curl -L "https://lgtm.com/api/v1.0/snapshots/$projectId/java" -o "$SHORTNAME.zip"
unzip -q -d "${SHORTNAME}-db" "${SHORTNAME}.zip" unzip -q -d "${SHORTNAME}-db" "${SHORTNAME}.zip"
mkdir "lib-dbs/$SHORTNAME/" mkdir "lib-dbs/$SHORTNAME/"
mv "${SHORTNAME}-db/"$(ls -1 "${SHORTNAME}"-db)/* "lib-dbs/${SHORTNAME}/" mv "${SHORTNAME}-db/"$(ls -1 "${SHORTNAME}"-db)/* "lib-dbs/${SHORTNAME}/"
@@ -61,7 +61,7 @@ jobs:
DATABASE=$2 DATABASE=$2
cd codeql-$QL_VARIANT cd codeql-$QL_VARIANT
SHORTNAME=`basename $DATABASE` SHORTNAME=`basename $DATABASE`
python java/ql/src/utils/model-generator/GenerateFlowModel.py --with-summaries --with-sinks $DATABASE ${SHORTNAME}.temp.model.yml python java/ql/src/utils/modelgenerator/GenerateFlowModel.py --with-summaries --with-sinks $DATABASE ${SHORTNAME}.temp.model.yml
mv java/ql/lib/ext/generated/${SHORTNAME}.temp.model.yml $MODELS/${SHORTNAME}Generated_${QL_VARIANT}.model.yml mv java/ql/lib/ext/generated/${SHORTNAME}.temp.model.yml $MODELS/${SHORTNAME}Generated_${QL_VARIANT}.model.yml
cd .. cd ..
} }
@@ -100,4 +100,6 @@ jobs:
with: with:
name: diffs name: diffs
path: tmp-models/*.html path: tmp-models/*.html
# An html file is only produced if the generated models differ.
if-no-files-found: ignore
retention-days: 20 retention-days: 20

View File

@@ -50,7 +50,7 @@ jobs:
SLUG: ${{ matrix.slug }} SLUG: ${{ matrix.slug }}
run: | run: |
SHORTNAME=${SLUG//[^a-zA-Z0-9_]/} SHORTNAME=${SLUG//[^a-zA-Z0-9_]/}
java/ql/src/utils/model-generator/RegenerateModels.py "${SLUG}" dbs/${SHORTNAME} java/ql/src/utils/modelgenerator/RegenerateModels.py "${SLUG}" dbs/${SHORTNAME}
- name: Stage changes - name: Stage changes
run: | run: |
find java -name "*.model.yml" -print0 | xargs -0 git add find java -name "*.model.yml" -print0 | xargs -0 git add

View File

@@ -27,7 +27,7 @@ jobs:
uses: ./.github/actions/find-latest-bundle uses: ./.github/actions/find-latest-bundle
- name: Find codeql - name: Find codeql
id: find-codeql id: find-codeql
uses: github/codeql-action/init@77a8d2d10c0b403a8b4aadbd223dc489ecd22683 uses: github/codeql-action/init@45955cb1830b640e2c1603ad72ad542a49d47b96
with: with:
languages: javascript # does not matter languages: javascript # does not matter
tools: ${{ steps.find-latest-bundle.outputs.url }} tools: ${{ steps.find-latest-bundle.outputs.url }}
@@ -38,12 +38,14 @@ jobs:
shell: bash shell: bash
env: env:
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }} CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
- uses: ./.github/actions/os-version
id: os_version
- name: Cache entire pack - name: Cache entire pack
id: cache-pack id: cache-pack
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: ${{ runner.temp }}/pack path: ${{ runner.temp }}/pack
key: ${{ runner.os }}-pack-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}-${{ hashFiles('ql/**/*.ql*') }}-${{ hashFiles('ql/**/qlpack.yml') }}-${{ hashFiles('ql/ql/src/ql.dbscheme*') }}-${{ steps.get-codeql-version.outputs.version }}--${{ hashFiles('.github/workflows/ql-for-ql-build.yml') }} key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-pack-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}-${{ hashFiles('ql/**/*.ql*') }}-${{ hashFiles('ql/**/qlpack.yml') }}-${{ hashFiles('ql/ql/src/ql.dbscheme*') }}-${{ steps.get-codeql-version.outputs.version }}--${{ hashFiles('.github/workflows/ql-for-ql-build.yml') }}
- name: Cache queries - name: Cache queries
if: steps.cache-pack.outputs.cache-hit != 'true' if: steps.cache-pack.outputs.cache-hit != 'true'
id: cache-queries id: cache-queries
@@ -77,7 +79,7 @@ jobs:
ql/target/release/ql-autobuilder.exe ql/target/release/ql-autobuilder.exe
ql/target/release/ql-extractor ql/target/release/ql-extractor
ql/target/release/ql-extractor.exe ql/target/release/ql-extractor.exe
key: ${{ runner.os }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }} key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}
- name: Cache cargo - name: Cache cargo
if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true' if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
uses: actions/cache@v3 uses: actions/cache@v3
@@ -86,7 +88,7 @@ jobs:
~/.cargo/registry ~/.cargo/registry
~/.cargo/git ~/.cargo/git
ql/target ql/target
key: ${{ runner.os }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }} key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
- name: Check formatting - name: Check formatting
if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true' if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
run: cd ql; cargo fmt --all -- --check run: cd ql; cargo fmt --all -- --check
@@ -137,20 +139,20 @@ jobs:
env: env:
CONF: ./ql-for-ql-config.yml CONF: ./ql-for-ql-config.yml
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@77a8d2d10c0b403a8b4aadbd223dc489ecd22683 uses: github/codeql-action/init@45955cb1830b640e2c1603ad72ad542a49d47b96
with: with:
languages: ql languages: ql
db-location: ${{ runner.temp }}/db db-location: ${{ runner.temp }}/db
config-file: ./ql-for-ql-config.yml config-file: ./ql-for-ql-config.yml
tools: ${{ steps.find-latest-bundle.outputs.url }} tools: ${{ steps.find-latest-bundle.outputs.url }}
- name: Move pack cache - name: Move pack queries
run: | run: |
cp -r ${PACK}/.cache ql/ql/src/.cache cp -r ${PACK}/queries ql/ql/src
env: env:
PACK: ${{ runner.temp }}/pack PACK: ${{ runner.temp }}/pack
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@77a8d2d10c0b403a8b4aadbd223dc489ecd22683 uses: github/codeql-action/analyze@45955cb1830b640e2c1603ad72ad542a49d47b96
with: with:
category: "ql-for-ql" category: "ql-for-ql"
- name: Copy sarif file to CWD - name: Copy sarif file to CWD
@@ -172,4 +174,4 @@ jobs:
with: with:
name: ql-for-ql-langs name: ql-for-ql-langs
path: split-sarif path: split-sarif
retention-days: 1 retention-days: 1

View File

@@ -25,16 +25,18 @@ jobs:
- name: Find codeql - name: Find codeql
id: find-codeql id: find-codeql
uses: github/codeql-action/init@77a8d2d10c0b403a8b4aadbd223dc489ecd22683 uses: github/codeql-action/init@45955cb1830b640e2c1603ad72ad542a49d47b96
with: with:
languages: javascript # does not matter languages: javascript # does not matter
- uses: ./.github/actions/os-version
id: os_version
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: | path: |
~/.cargo/registry ~/.cargo/registry
~/.cargo/git ~/.cargo/git
ql/target ql/target
key: ${{ runner.os }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }} key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
- name: Build Extractor - name: Build Extractor
run: cd ql; env "PATH=$PATH:`dirname ${CODEQL}`" ./scripts/create-extractor-pack.sh run: cd ql; env "PATH=$PATH:`dirname ${CODEQL}`" ./scripts/create-extractor-pack.sh
env: env:

View File

@@ -22,28 +22,84 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Find codeql - name: Find codeql
id: find-codeql id: find-codeql
uses: github/codeql-action/init@77a8d2d10c0b403a8b4aadbd223dc489ecd22683 uses: github/codeql-action/init@45955cb1830b640e2c1603ad72ad542a49d47b96
with: with:
languages: javascript # does not matter languages: javascript # does not matter
- uses: ./.github/actions/os-version
id: os_version
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: | path: |
~/.cargo/registry ~/.cargo/registry
~/.cargo/git ~/.cargo/git
ql/target ql/target
key: ${{ runner.os }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }} key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/rust-toolchain.toml', 'ql/**/Cargo.lock') }}
- name: Build extractor - name: Build extractor
run: | run: |
cd ql; cd ql;
codeqlpath=$(dirname ${{ steps.find-codeql.outputs.codeql-path }}); codeqlpath=$(dirname ${{ steps.find-codeql.outputs.codeql-path }});
env "PATH=$PATH:$codeqlpath" ./scripts/create-extractor-pack.sh env "PATH=$PATH:$codeqlpath" ./scripts/create-extractor-pack.sh
- name: Cache compilation cache
id: query-cache
uses: ./.github/actions/cache-query-compilation
with:
key: ql-for-ql-tests
- name: Run QL tests - name: Run QL tests
run: | run: |
"${CODEQL}" test run --check-databases --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --search-path "${{ github.workspace }}/ql/extractor-pack" --consistency-queries ql/ql/consistency-queries ql/ql/test "${CODEQL}" test run --check-databases --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --search-path "${{ github.workspace }}/ql/extractor-pack" --consistency-queries ql/ql/consistency-queries --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}" ql/ql/test
env: env:
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }} CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
- name: Check QL formatting
other-os:
strategy:
matrix:
os: [macos-latest, windows-latest]
needs: [qltest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install GNU tar
if: runner.os == 'macOS'
run: | run: |
find ql/ql/src "(" -name "*.ql" -or -name "*.qll" ")" -print0 | xargs -0 "${CODEQL}" query format --check-only brew install gnu-tar
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
- name: Find codeql
id: find-codeql
uses: github/codeql-action/init@77a8d2d10c0b403a8b4aadbd223dc489ecd22683
with:
languages: javascript # does not matter
- uses: ./.github/actions/os-version
id: os_version
- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
ql/target
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/rust-toolchain.toml', 'ql/**/Cargo.lock') }}
- name: Build extractor
if: runner.os != 'Windows'
run: |
cd ql;
codeqlpath=$(dirname ${{ steps.find-codeql.outputs.codeql-path }});
env "PATH=$PATH:$codeqlpath" ./scripts/create-extractor-pack.sh
- name: Build extractor (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cd ql;
$Env:PATH += ";$(dirname ${{ steps.find-codeql.outputs.codeql-path }})"
pwsh ./scripts/create-extractor-pack.ps1
- name: Run a single QL tests - Unix
if: runner.os != 'Windows'
run: |
"${CODEQL}" test run --check-databases --search-path "${{ github.workspace }}/ql/extractor-pack" ql/ql/test/queries/style/DeadCode/DeadCode.qlref
env: env:
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }} CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
- name: Run a single QL tests - Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
$Env:PATH += ";$(dirname ${{ steps.find-codeql.outputs.codeql-path }})"
codeql test run --check-databases --search-path "${{ github.workspace }}/ql/extractor-pack" ql/ql/test/queries/style/DeadCode/DeadCode.qlref

View File

@@ -48,6 +48,8 @@ jobs:
run: | run: |
brew install gnu-tar brew install gnu-tar
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
- uses: ./.github/actions/os-version
id: os_version
- name: Cache entire extractor - name: Cache entire extractor
uses: actions/cache@v3 uses: actions/cache@v3
id: cache-extractor id: cache-extractor
@@ -58,7 +60,7 @@ jobs:
ruby/target/release/ruby-extractor ruby/target/release/ruby-extractor
ruby/target/release/ruby-extractor.exe ruby/target/release/ruby-extractor.exe
ruby/ql/lib/codeql/ruby/ast/internal/TreeSitter.qll ruby/ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
key: ${{ runner.os }}-ruby-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}--${{ hashFiles('ruby/**/*.rs') }} key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}--${{ hashFiles('ruby/**/*.rs') }}
- uses: actions/cache@v3 - uses: actions/cache@v3
if: steps.cache-extractor.outputs.cache-hit != 'true' if: steps.cache-extractor.outputs.cache-hit != 'true'
with: with:
@@ -66,7 +68,7 @@ jobs:
~/.cargo/registry ~/.cargo/registry
~/.cargo/git ~/.cargo/git
ruby/target ruby/target
key: ${{ runner.os }}-ruby-rust-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }} key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-rust-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}
- name: Check formatting - name: Check formatting
if: steps.cache-extractor.outputs.cache-hit != 'true' if: steps.cache-extractor.outputs.cache-hit != 'true'
run: cargo fmt --all -- --check run: cargo fmt --all -- --check
@@ -203,11 +205,6 @@ jobs:
- name: Fetch CodeQL - name: Fetch CodeQL
uses: ./.github/actions/fetch-codeql uses: ./.github/actions/fetch-codeql
- uses: actions/checkout@v3
with:
repository: Shopify/example-ruby-app
ref: 67a0decc5eb550f3a9228eda53925c3afd40dfe9
- name: Download Ruby bundle - name: Download Ruby bundle
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
@@ -216,26 +213,15 @@ jobs:
- name: Unzip Ruby bundle - name: Unzip Ruby bundle
shell: bash shell: bash
run: unzip -q -d "${{ runner.temp }}/ruby-bundle" "${{ runner.temp }}/codeql-ruby-bundle.zip" run: unzip -q -d "${{ runner.temp }}/ruby-bundle" "${{ runner.temp }}/codeql-ruby-bundle.zip"
- name: Prepare test files
shell: bash
run: |
echo "import codeql.ruby.AST select count(File f)" > "test.ql"
echo "| 4 |" > "test.expected"
echo 'name: sample-tests
version: 0.0.0
dependencies:
codeql/ruby-all: "*"
extractor: ruby
tests: .
' > qlpack.yml
- name: Run QL test - name: Run QL test
shell: bash shell: bash
run: | run: |
codeql test run --search-path "${{ runner.temp }}/ruby-bundle" --additional-packs "${{ runner.temp }}/ruby-bundle" . codeql test run --search-path "${{ runner.temp }}/ruby-bundle" --additional-packs "${{ runner.temp }}/ruby-bundle" ruby/ql/test/library-tests/ast/constants/
- name: Create database - name: Create database
shell: bash shell: bash
run: | run: |
codeql database create --search-path "${{ runner.temp }}/ruby-bundle" --language ruby --source-root . ../database codeql database create --search-path "${{ runner.temp }}/ruby-bundle" --language ruby --source-root ruby/ql/test/library-tests/ast/constants/ ../database
- name: Analyze database - name: Analyze database
shell: bash shell: bash
run: | run: |

View File

@@ -25,6 +25,7 @@ If you have an idea for a query that you would like to share with other CodeQL u
Each language-specific directory contains further subdirectories that group queries based on their `@tags` or purpose. Each language-specific directory contains further subdirectories that group queries based on their `@tags` or purpose.
- Experimental queries and libraries are stored in the `experimental` subdirectory within each language-specific directory in the [CodeQL repository](https://github.com/github/codeql). For example, experimental Java queries and libraries are stored in `java/ql/src/experimental` and any corresponding tests in `java/ql/test/experimental`. - Experimental queries and libraries are stored in the `experimental` subdirectory within each language-specific directory in the [CodeQL repository](https://github.com/github/codeql). For example, experimental Java queries and libraries are stored in `java/ql/src/experimental` and any corresponding tests in `java/ql/test/experimental`.
- Experimental queries need to include `experimental` in their `@tags`
- The structure of an `experimental` subdirectory mirrors the structure of its parent directory. - The structure of an `experimental` subdirectory mirrors the structure of its parent directory.
- Select or create an appropriate directory in `experimental` based on the existing directory structure of `experimental` or its parent directory. - Select or create an appropriate directory in `experimental` based on the existing directory structure of `experimental` or its parent directory.

View File

@@ -402,16 +402,6 @@
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/ControlFlowReachability.qll", "csharp/ql/lib/semmle/code/csharp/dataflow/internal/ControlFlowReachability.qll",
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/ControlFlowReachability.qll" "csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/ControlFlowReachability.qll"
], ],
"Inline Test Expectations": [
"cpp/ql/test/TestUtilities/InlineExpectationsTest.qll",
"csharp/ql/test/TestUtilities/InlineExpectationsTest.qll",
"java/ql/test/TestUtilities/InlineExpectationsTest.qll",
"python/ql/test/TestUtilities/InlineExpectationsTest.qll",
"ruby/ql/test/TestUtilities/InlineExpectationsTest.qll",
"ql/ql/test/TestUtilities/InlineExpectationsTest.qll",
"go/ql/test/TestUtilities/InlineExpectationsTest.qll",
"swift/ql/test/TestUtilities/InlineExpectationsTest.qll"
],
"C++ ExternalAPIs": [ "C++ ExternalAPIs": [
"cpp/ql/src/Security/CWE/CWE-020/ExternalAPIs.qll", "cpp/ql/src/Security/CWE/CWE-020/ExternalAPIs.qll",
"cpp/ql/src/Security/CWE/CWE-020/ir/ExternalAPIs.qll" "cpp/ql/src/Security/CWE/CWE-020/ir/ExternalAPIs.qll"

View File

@@ -13,5 +13,5 @@ predicate isExprWithNewBuiltin(Expr expr) {
from Expr expr, int kind, int kind_new, Location location from Expr expr, int kind, int kind_new, Location location
where where
exprs(expr, kind, location) and exprs(expr, kind, location) and
if isExprWithNewBuiltin(expr) then kind_new = 0 else kind_new = kind if isExprWithNewBuiltin(expr) then kind_new = 1 else kind_new = kind
select expr, kind_new, location select expr, kind_new, location

View File

@@ -9,5 +9,5 @@ class Location extends @location_expr {
from Expr expr, int kind, int kind_new, Location location from Expr expr, int kind, int kind_new, Location location
where where
exprs(expr, kind, location) and exprs(expr, kind, location) and
if expr instanceof @blockassignexpr then kind_new = 0 else kind_new = kind if expr instanceof @blockassignexpr then kind_new = 1 else kind_new = kind
select expr, kind_new, location select expr, kind_new, location

View File

@@ -0,0 +1,11 @@
class BuiltinType extends @builtintype {
string toString() { none() }
}
from BuiltinType type, string name, int kind, int kind_new, int size, int sign, int alignment
where
builtintypes(type, name, kind, size, sign, alignment) and
if type instanceof @float16 or type instanceof @complex_float16
then kind_new = 2
else kind_new = kind
select type, name, kind_new, size, sign, alignment

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
description: Introduce (_Complex) _Float16 type
compatibility: backwards
builtintypes.rel: run builtintypes.qlo

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
description: Uncomment case splits in dbscheme
compatibility: full

View File

@@ -123,6 +123,13 @@ private predicate constructorCallTypeMention(ConstructorCall cc, TypeMention tm)
) )
} }
/** Holds if `loc` has the container `container` and is on the line starting at `startLine`. */
pragma[nomagic]
private predicate hasContainerAndStartLine(Location loc, Container container, int startLine) {
loc.getStartLine() = startLine and
loc.getContainer() = container
}
/** /**
* Gets an element, of kind `kind`, that element `e` uses, if any. * Gets an element, of kind `kind`, that element `e` uses, if any.
* Attention: This predicate yields multiple definitions for a single location. * Attention: This predicate yields multiple definitions for a single location.
@@ -159,9 +166,9 @@ Top definitionOf(Top e, string kind) {
// Multiple type mentions can be generated when a typedef is used, and // Multiple type mentions can be generated when a typedef is used, and
// in such cases we want to exclude all but the originating typedef. // in such cases we want to exclude all but the originating typedef.
not exists(Type secondary | not exists(Type secondary |
exists(TypeMention tm, File f, int startline, int startcol | exists(File f, int startline, int startcol |
typeMentionStartLoc(e, result, f, startline, startcol) and typeMentionStartLoc(e, result, f, startline, startcol) and
typeMentionStartLoc(tm, secondary, f, startline, startcol) and typeMentionStartLoc(_, secondary, f, startline, startcol) and
( (
result = secondary.(TypedefType).getBaseType() or result = secondary.(TypedefType).getBaseType() or
result = secondary.(TypedefType).getBaseType().(SpecifiedType).getBaseType() result = secondary.(TypedefType).getBaseType().(SpecifiedType).getBaseType()
@@ -184,11 +191,9 @@ Top definitionOf(Top e, string kind) {
kind = "I" and kind = "I" and
result = e.(Include).getIncludedFile() and result = e.(Include).getIncludedFile() and
// exclude `#include` directives containing macros // exclude `#include` directives containing macros
not exists(MacroInvocation mi, Location l1, Location l2 | not exists(MacroInvocation mi, Container container, int startLine |
l1 = e.(Include).getLocation() and hasContainerAndStartLine(e.(Include).getLocation(), container, startLine) and
l2 = mi.getLocation() and hasContainerAndStartLine(mi.getLocation(), container, startLine)
l1.getContainer() = l2.getContainer() and
l1.getStartLine() = l2.getStartLine()
// (an #include directive must be always on it's own line) // (an #include directive must be always on it's own line)
) )
) and ) and

View File

@@ -876,9 +876,9 @@ private module Stage1 implements StageSig {
pragma[nomagic] pragma[nomagic]
private predicate revFlowOut(ReturnPosition pos, Configuration config) { private predicate revFlowOut(ReturnPosition pos, Configuration config) {
exists(DataFlowCall call, NodeEx out | exists(NodeEx out |
revFlow(out, _, config) and revFlow(out, _, config) and
viableReturnPosOutNodeCandFwd1(call, pos, out, config) viableReturnPosOutNodeCandFwd1(_, pos, out, config)
) )
} }
@@ -1731,8 +1731,8 @@ private module MkStage<StageSig PrevStage> {
) )
or or
// flow through a callable // flow through a callable
exists(DataFlowCall call, ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(DataFlowCall call, ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config)
) )
or or
@@ -1901,8 +1901,8 @@ private module MkStage<StageSig PrevStage> {
pragma[nomagic] pragma[nomagic]
predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) { predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) {
exists(RetNodeEx ret, ReturnPosition pos | exists(ReturnPosition pos |
returnFlowsThrough(ret, pos, _, _, p, ap, _, config) and returnFlowsThrough(_, pos, _, _, p, ap, _, config) and
parameterFlowsThroughRev(p, ap, pos, _, config) parameterFlowsThroughRev(p, ap, pos, _, config)
) )
} }
@@ -1923,8 +1923,8 @@ private module MkStage<StageSig PrevStage> {
DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp, DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp,
Ap ap, Configuration config Ap ap, Configuration config
) { ) {
exists(ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config)
) )
} }
@@ -3749,8 +3749,8 @@ private predicate paramFlowsThrough(
ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap,
AccessPathApprox apa, Configuration config AccessPathApprox apa, Configuration config
) { ) {
exists(PathNodeMid mid, RetNodeEx ret | exists(RetNodeEx ret |
pathNode(mid, ret, state, cc, sc, ap, config, _) and pathNode(_, ret, state, cc, sc, ap, config, _) and
kind = ret.getKind() and kind = ret.getKind() and
apa = ap.getApprox() and apa = ap.getApprox() and
parameterFlowThroughAllowed(sc.getParamNode(), kind) parameterFlowThroughAllowed(sc.getParamNode(), kind)
@@ -4212,17 +4212,15 @@ private module FlowExploration {
ap = TRevPartialNil() and ap = TRevPartialNil() and
exists(config.explorationLimit()) exists(config.explorationLimit())
or or
exists(PartialPathNodeRev mid | revPartialPathStep(_, node, state, sc1, sc2, sc3, ap, config) and
revPartialPathStep(mid, node, state, sc1, sc2, sc3, ap, config) and not clearsContentEx(node, ap.getHead()) and
not clearsContentEx(node, ap.getHead()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead())
expectsContentEx(node, ap.getHead()) ) and
) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
)
} }
pragma[nomagic] pragma[nomagic]
@@ -4230,19 +4228,17 @@ private module FlowExploration {
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config
) { ) {
exists(PartialPathNodeFwd mid | partialPathStep(_, node, state, cc, sc1, sc2, sc3, ap, config) and
partialPathStep(mid, node, state, cc, sc1, sc2, sc3, ap, config) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and not clearsContentEx(node, ap.getHead().getContent()) and
not clearsContentEx(node, ap.getHead().getContent()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead().getContent())
expectsContentEx(node, ap.getHead().getContent()) ) and
) and if node.asNode() instanceof CastingNode
if node.asNode() instanceof CastingNode then compatibleTypes(node.getDataFlowType(), ap.getType())
then compatibleTypes(node.getDataFlowType(), ap.getType()) else any()
else any()
)
} }
/** /**

View File

@@ -876,9 +876,9 @@ private module Stage1 implements StageSig {
pragma[nomagic] pragma[nomagic]
private predicate revFlowOut(ReturnPosition pos, Configuration config) { private predicate revFlowOut(ReturnPosition pos, Configuration config) {
exists(DataFlowCall call, NodeEx out | exists(NodeEx out |
revFlow(out, _, config) and revFlow(out, _, config) and
viableReturnPosOutNodeCandFwd1(call, pos, out, config) viableReturnPosOutNodeCandFwd1(_, pos, out, config)
) )
} }
@@ -1731,8 +1731,8 @@ private module MkStage<StageSig PrevStage> {
) )
or or
// flow through a callable // flow through a callable
exists(DataFlowCall call, ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(DataFlowCall call, ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config)
) )
or or
@@ -1901,8 +1901,8 @@ private module MkStage<StageSig PrevStage> {
pragma[nomagic] pragma[nomagic]
predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) { predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) {
exists(RetNodeEx ret, ReturnPosition pos | exists(ReturnPosition pos |
returnFlowsThrough(ret, pos, _, _, p, ap, _, config) and returnFlowsThrough(_, pos, _, _, p, ap, _, config) and
parameterFlowsThroughRev(p, ap, pos, _, config) parameterFlowsThroughRev(p, ap, pos, _, config)
) )
} }
@@ -1923,8 +1923,8 @@ private module MkStage<StageSig PrevStage> {
DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp, DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp,
Ap ap, Configuration config Ap ap, Configuration config
) { ) {
exists(ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config)
) )
} }
@@ -3749,8 +3749,8 @@ private predicate paramFlowsThrough(
ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap,
AccessPathApprox apa, Configuration config AccessPathApprox apa, Configuration config
) { ) {
exists(PathNodeMid mid, RetNodeEx ret | exists(RetNodeEx ret |
pathNode(mid, ret, state, cc, sc, ap, config, _) and pathNode(_, ret, state, cc, sc, ap, config, _) and
kind = ret.getKind() and kind = ret.getKind() and
apa = ap.getApprox() and apa = ap.getApprox() and
parameterFlowThroughAllowed(sc.getParamNode(), kind) parameterFlowThroughAllowed(sc.getParamNode(), kind)
@@ -4212,17 +4212,15 @@ private module FlowExploration {
ap = TRevPartialNil() and ap = TRevPartialNil() and
exists(config.explorationLimit()) exists(config.explorationLimit())
or or
exists(PartialPathNodeRev mid | revPartialPathStep(_, node, state, sc1, sc2, sc3, ap, config) and
revPartialPathStep(mid, node, state, sc1, sc2, sc3, ap, config) and not clearsContentEx(node, ap.getHead()) and
not clearsContentEx(node, ap.getHead()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead())
expectsContentEx(node, ap.getHead()) ) and
) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
)
} }
pragma[nomagic] pragma[nomagic]
@@ -4230,19 +4228,17 @@ private module FlowExploration {
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config
) { ) {
exists(PartialPathNodeFwd mid | partialPathStep(_, node, state, cc, sc1, sc2, sc3, ap, config) and
partialPathStep(mid, node, state, cc, sc1, sc2, sc3, ap, config) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and not clearsContentEx(node, ap.getHead().getContent()) and
not clearsContentEx(node, ap.getHead().getContent()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead().getContent())
expectsContentEx(node, ap.getHead().getContent()) ) and
) and if node.asNode() instanceof CastingNode
if node.asNode() instanceof CastingNode then compatibleTypes(node.getDataFlowType(), ap.getType())
then compatibleTypes(node.getDataFlowType(), ap.getType()) else any()
else any()
)
} }
/** /**

View File

@@ -876,9 +876,9 @@ private module Stage1 implements StageSig {
pragma[nomagic] pragma[nomagic]
private predicate revFlowOut(ReturnPosition pos, Configuration config) { private predicate revFlowOut(ReturnPosition pos, Configuration config) {
exists(DataFlowCall call, NodeEx out | exists(NodeEx out |
revFlow(out, _, config) and revFlow(out, _, config) and
viableReturnPosOutNodeCandFwd1(call, pos, out, config) viableReturnPosOutNodeCandFwd1(_, pos, out, config)
) )
} }
@@ -1731,8 +1731,8 @@ private module MkStage<StageSig PrevStage> {
) )
or or
// flow through a callable // flow through a callable
exists(DataFlowCall call, ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(DataFlowCall call, ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config)
) )
or or
@@ -1901,8 +1901,8 @@ private module MkStage<StageSig PrevStage> {
pragma[nomagic] pragma[nomagic]
predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) { predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) {
exists(RetNodeEx ret, ReturnPosition pos | exists(ReturnPosition pos |
returnFlowsThrough(ret, pos, _, _, p, ap, _, config) and returnFlowsThrough(_, pos, _, _, p, ap, _, config) and
parameterFlowsThroughRev(p, ap, pos, _, config) parameterFlowsThroughRev(p, ap, pos, _, config)
) )
} }
@@ -1923,8 +1923,8 @@ private module MkStage<StageSig PrevStage> {
DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp, DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp,
Ap ap, Configuration config Ap ap, Configuration config
) { ) {
exists(ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config)
) )
} }
@@ -3749,8 +3749,8 @@ private predicate paramFlowsThrough(
ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap,
AccessPathApprox apa, Configuration config AccessPathApprox apa, Configuration config
) { ) {
exists(PathNodeMid mid, RetNodeEx ret | exists(RetNodeEx ret |
pathNode(mid, ret, state, cc, sc, ap, config, _) and pathNode(_, ret, state, cc, sc, ap, config, _) and
kind = ret.getKind() and kind = ret.getKind() and
apa = ap.getApprox() and apa = ap.getApprox() and
parameterFlowThroughAllowed(sc.getParamNode(), kind) parameterFlowThroughAllowed(sc.getParamNode(), kind)
@@ -4212,17 +4212,15 @@ private module FlowExploration {
ap = TRevPartialNil() and ap = TRevPartialNil() and
exists(config.explorationLimit()) exists(config.explorationLimit())
or or
exists(PartialPathNodeRev mid | revPartialPathStep(_, node, state, sc1, sc2, sc3, ap, config) and
revPartialPathStep(mid, node, state, sc1, sc2, sc3, ap, config) and not clearsContentEx(node, ap.getHead()) and
not clearsContentEx(node, ap.getHead()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead())
expectsContentEx(node, ap.getHead()) ) and
) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
)
} }
pragma[nomagic] pragma[nomagic]
@@ -4230,19 +4228,17 @@ private module FlowExploration {
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config
) { ) {
exists(PartialPathNodeFwd mid | partialPathStep(_, node, state, cc, sc1, sc2, sc3, ap, config) and
partialPathStep(mid, node, state, cc, sc1, sc2, sc3, ap, config) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and not clearsContentEx(node, ap.getHead().getContent()) and
not clearsContentEx(node, ap.getHead().getContent()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead().getContent())
expectsContentEx(node, ap.getHead().getContent()) ) and
) and if node.asNode() instanceof CastingNode
if node.asNode() instanceof CastingNode then compatibleTypes(node.getDataFlowType(), ap.getType())
then compatibleTypes(node.getDataFlowType(), ap.getType()) else any()
else any()
)
} }
/** /**

View File

@@ -876,9 +876,9 @@ private module Stage1 implements StageSig {
pragma[nomagic] pragma[nomagic]
private predicate revFlowOut(ReturnPosition pos, Configuration config) { private predicate revFlowOut(ReturnPosition pos, Configuration config) {
exists(DataFlowCall call, NodeEx out | exists(NodeEx out |
revFlow(out, _, config) and revFlow(out, _, config) and
viableReturnPosOutNodeCandFwd1(call, pos, out, config) viableReturnPosOutNodeCandFwd1(_, pos, out, config)
) )
} }
@@ -1731,8 +1731,8 @@ private module MkStage<StageSig PrevStage> {
) )
or or
// flow through a callable // flow through a callable
exists(DataFlowCall call, ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(DataFlowCall call, ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config)
) )
or or
@@ -1901,8 +1901,8 @@ private module MkStage<StageSig PrevStage> {
pragma[nomagic] pragma[nomagic]
predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) { predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) {
exists(RetNodeEx ret, ReturnPosition pos | exists(ReturnPosition pos |
returnFlowsThrough(ret, pos, _, _, p, ap, _, config) and returnFlowsThrough(_, pos, _, _, p, ap, _, config) and
parameterFlowsThroughRev(p, ap, pos, _, config) parameterFlowsThroughRev(p, ap, pos, _, config)
) )
} }
@@ -1923,8 +1923,8 @@ private module MkStage<StageSig PrevStage> {
DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp, DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp,
Ap ap, Configuration config Ap ap, Configuration config
) { ) {
exists(ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config)
) )
} }
@@ -3749,8 +3749,8 @@ private predicate paramFlowsThrough(
ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap,
AccessPathApprox apa, Configuration config AccessPathApprox apa, Configuration config
) { ) {
exists(PathNodeMid mid, RetNodeEx ret | exists(RetNodeEx ret |
pathNode(mid, ret, state, cc, sc, ap, config, _) and pathNode(_, ret, state, cc, sc, ap, config, _) and
kind = ret.getKind() and kind = ret.getKind() and
apa = ap.getApprox() and apa = ap.getApprox() and
parameterFlowThroughAllowed(sc.getParamNode(), kind) parameterFlowThroughAllowed(sc.getParamNode(), kind)
@@ -4212,17 +4212,15 @@ private module FlowExploration {
ap = TRevPartialNil() and ap = TRevPartialNil() and
exists(config.explorationLimit()) exists(config.explorationLimit())
or or
exists(PartialPathNodeRev mid | revPartialPathStep(_, node, state, sc1, sc2, sc3, ap, config) and
revPartialPathStep(mid, node, state, sc1, sc2, sc3, ap, config) and not clearsContentEx(node, ap.getHead()) and
not clearsContentEx(node, ap.getHead()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead())
expectsContentEx(node, ap.getHead()) ) and
) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
)
} }
pragma[nomagic] pragma[nomagic]
@@ -4230,19 +4228,17 @@ private module FlowExploration {
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config
) { ) {
exists(PartialPathNodeFwd mid | partialPathStep(_, node, state, cc, sc1, sc2, sc3, ap, config) and
partialPathStep(mid, node, state, cc, sc1, sc2, sc3, ap, config) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and not clearsContentEx(node, ap.getHead().getContent()) and
not clearsContentEx(node, ap.getHead().getContent()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead().getContent())
expectsContentEx(node, ap.getHead().getContent()) ) and
) and if node.asNode() instanceof CastingNode
if node.asNode() instanceof CastingNode then compatibleTypes(node.getDataFlowType(), ap.getType())
then compatibleTypes(node.getDataFlowType(), ap.getType()) else any()
else any()
)
} }
/** /**

View File

@@ -45,6 +45,16 @@ module Consistency {
) { ) {
none() none()
} }
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodeAtPosition`. */
predicate uniqueParameterNodeAtPositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodePosition`. */
predicate uniqueParameterNodePositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
} }
private class RelevantNode extends Node { private class RelevantNode extends Node {
@@ -101,9 +111,7 @@ module Consistency {
exists(int c | exists(int c |
c = c =
strictcount(Node n | strictcount(Node n |
not exists(string filepath, int startline, int startcolumn, int endline, int endcolumn | not n.hasLocationInfo(_, _, _, _, _) and
n.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
) and
not any(ConsistencyConfiguration conf).missingLocationExclude(n) not any(ConsistencyConfiguration conf).missingLocationExclude(n)
) and ) and
msg = "Nodes without location: " + c msg = "Nodes without location: " + c
@@ -248,6 +256,7 @@ module Consistency {
query predicate uniqueParameterNodeAtPosition( query predicate uniqueParameterNodeAtPosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg DataFlowCallable c, ParameterPosition pos, Node p, string msg
) { ) {
not any(ConsistencyConfiguration conf).uniqueParameterNodeAtPositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and isParameterNode(p, c, pos) and
not exists(unique(Node p0 | isParameterNode(p0, c, pos))) and not exists(unique(Node p0 | isParameterNode(p0, c, pos))) and
msg = "Parameters with overlapping positions." msg = "Parameters with overlapping positions."
@@ -256,6 +265,7 @@ module Consistency {
query predicate uniqueParameterNodePosition( query predicate uniqueParameterNodePosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg DataFlowCallable c, ParameterPosition pos, Node p, string msg
) { ) {
not any(ConsistencyConfiguration conf).uniqueParameterNodePositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and isParameterNode(p, c, pos) and
not exists(unique(ParameterPosition pos0 | isParameterNode(p, c, pos0))) and not exists(unique(ParameterPosition pos0 | isParameterNode(p, c, pos0))) and
msg = "Parameter node with multiple positions." msg = "Parameter node with multiple positions."

View File

@@ -218,7 +218,7 @@ private predicate allocation(Instruction array, Length length, int delta) {
length.(VNLength).getInstruction().getConvertedResultExpression() = lengthExpr length.(VNLength).getInstruction().getConvertedResultExpression() = lengthExpr
) )
or or
not exists(int d | deconstructMallocSizeExpr(alloc.getSizeExpr(), _, d)) and not deconstructMallocSizeExpr(alloc.getSizeExpr(), _, _) and
length.(VNLength).getInstruction().getConvertedResultExpression() = alloc.getSizeExpr() and length.(VNLength).getInstruction().getConvertedResultExpression() = alloc.getSizeExpr() and
delta = 0 delta = 0
) )

View File

@@ -543,9 +543,7 @@ private predicate boundedPhiCand(
PhiInstruction phi, boolean upper, Bound b, int delta, boolean fromBackEdge, int origdelta, PhiInstruction phi, boolean upper, Bound b, int delta, boolean fromBackEdge, int origdelta,
Reason reason Reason reason
) { ) {
exists(PhiInputOperand op | boundedPhiInp(phi, _, b, delta, upper, fromBackEdge, origdelta, reason)
boundedPhiInp(phi, op, b, delta, upper, fromBackEdge, origdelta, reason)
)
} }
/** /**

View File

@@ -664,9 +664,7 @@ private predicate boundedPhiCand(
SemSsaPhiNode phi, boolean upper, SemBound b, int delta, boolean fromBackEdge, int origdelta, SemSsaPhiNode phi, boolean upper, SemBound b, int delta, boolean fromBackEdge, int origdelta,
SemReason reason SemReason reason
) { ) {
exists(SemSsaVariable inp, SemSsaReadPositionPhiInputEdge edge | boundedPhiInp(phi, _, _, b, delta, upper, fromBackEdge, origdelta, reason)
boundedPhiInp(phi, inp, edge, b, delta, upper, fromBackEdge, origdelta, reason)
)
} }
/** /**

View File

@@ -1,5 +1,5 @@
name: codeql/cpp-all name: codeql/cpp-all
version: 0.5.0 version: 0.5.1-dev
groups: cpp groups: cpp
dbscheme: semmlecode.cpp.dbscheme dbscheme: semmlecode.cpp.dbscheme
extractor: cpp extractor: cpp

View File

@@ -318,7 +318,7 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
MetricFunction getMetrics() { result = this } MetricFunction getMetrics() { result = this }
/** Holds if this function calls the function `f`. */ /** Holds if this function calls the function `f`. */
predicate calls(Function f) { exists(Locatable l | this.calls(f, l)) } predicate calls(Function f) { this.calls(f, _) }
/** /**
* Holds if this function calls the function `f` in the `FunctionCall` * Holds if this function calls the function `f` in the `FunctionCall`
@@ -335,7 +335,7 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
} }
/** Holds if this function accesses a function or variable or enumerator `a`. */ /** Holds if this function accesses a function or variable or enumerator `a`. */
predicate accesses(Declaration a) { exists(Locatable l | this.accesses(a, l)) } predicate accesses(Declaration a) { this.accesses(a, _) }
/** /**
* Holds if this function accesses a function or variable or enumerator `a` * Holds if this function accesses a function or variable or enumerator `a`

View File

@@ -10,12 +10,14 @@ import semmle.code.cpp.File
*/ */
class Location extends @location { class Location extends @location {
/** Gets the container corresponding to this location. */ /** Gets the container corresponding to this location. */
pragma[nomagic]
Container getContainer() { this.fullLocationInfo(result, _, _, _, _) } Container getContainer() { this.fullLocationInfo(result, _, _, _, _) }
/** Gets the file corresponding to this location, if any. */ /** Gets the file corresponding to this location, if any. */
File getFile() { result = this.getContainer() } File getFile() { result = this.getContainer() }
/** Gets the 1-based line number (inclusive) where this location starts. */ /** Gets the 1-based line number (inclusive) where this location starts. */
pragma[nomagic]
int getStartLine() { this.fullLocationInfo(_, result, _, _, _) } int getStartLine() { this.fullLocationInfo(_, result, _, _, _) }
/** Gets the 1-based column number (inclusive) where this location starts. */ /** Gets the 1-based column number (inclusive) where this location starts. */

View File

@@ -816,6 +816,12 @@ private predicate floatingPointTypeMapping(
or or
// _Float128x // _Float128x
kind = 50 and base = 2 and domain = TRealDomain() and realKind = 50 and extended = true kind = 50 and base = 2 and domain = TRealDomain() and realKind = 50 and extended = true
or
// _Float16
kind = 52 and base = 2 and domain = TRealDomain() and realKind = 52 and extended = false
or
// _Complex _Float16
kind = 53 and base = 2 and domain = TComplexDomain() and realKind = 52 and extended = false
} }
/** /**

View File

@@ -33,7 +33,7 @@ DependencyOptions getDependencyOptions() { any() }
class DependsSource extends Element { class DependsSource extends Element {
DependsSource() { DependsSource() {
// not inside a template instantiation // not inside a template instantiation
not exists(Element other | this.isFromTemplateInstantiation(other)) or not this.isFromTemplateInstantiation(_) or
// allow DeclarationEntrys of template specializations // allow DeclarationEntrys of template specializations
this.(DeclarationEntry).getDeclaration().(Function).isConstructedFrom(_) or this.(DeclarationEntry).getDeclaration().(Function).isConstructedFrom(_) or
this.(DeclarationEntry).getDeclaration().(Class).isConstructedFrom(_) this.(DeclarationEntry).getDeclaration().(Class).isConstructedFrom(_)

View File

@@ -69,12 +69,9 @@ predicate functionContainsDisabledCode(Function f) {
*/ */
predicate functionContainsPreprocCode(Function f) { predicate functionContainsPreprocCode(Function f) {
// `f` contains a preprocessor branch // `f` contains a preprocessor branch
exists( exists(string file, int pbdStartLine, int fBlockStartLine, int fBlockEndLine |
PreprocessorBranchDirective pbd, string file, int pbdStartLine, int fBlockStartLine,
int fBlockEndLine
|
functionLocation(f, file, fBlockStartLine, fBlockEndLine) and functionLocation(f, file, fBlockStartLine, fBlockEndLine) and
pbdLocation(pbd, file, pbdStartLine) and pbdLocation(_, file, pbdStartLine) and
pbdStartLine <= fBlockEndLine and pbdStartLine <= fBlockEndLine and
pbdStartLine >= fBlockStartLine pbdStartLine >= fBlockStartLine
) )

View File

@@ -244,9 +244,7 @@ class ScanfFormatLiteral extends Expr {
/** /**
* Gets the maximum width option of the nth input (empty string if none is given). * Gets the maximum width option of the nth input (empty string if none is given).
*/ */
string getMaxWidthOpt(int n) { string getMaxWidthOpt(int n) { this.parseConvSpec(n, _, result, _, _) }
exists(string spec, string len, string conv | this.parseConvSpec(n, spec, result, len, conv))
}
/** /**
* Gets the maximum width of the nth input. * Gets the maximum width of the nth input.
@@ -256,18 +254,12 @@ class ScanfFormatLiteral extends Expr {
/** /**
* Gets the length flag of the nth conversion specifier. * Gets the length flag of the nth conversion specifier.
*/ */
string getLength(int n) { string getLength(int n) { this.parseConvSpec(n, _, _, result, _) }
exists(string spec, string width, string conv |
this.parseConvSpec(n, spec, width, result, conv)
)
}
/** /**
* Gets the conversion character of the nth conversion specifier. * Gets the conversion character of the nth conversion specifier.
*/ */
string getConversionChar(int n) { string getConversionChar(int n) { this.parseConvSpec(n, _, _, _, result) }
exists(string spec, string width, string len | this.parseConvSpec(n, spec, width, len, result))
}
/** /**
* Gets the maximum length of the string that can be produced by the nth * Gets the maximum length of the string that can be produced by the nth

View File

@@ -54,7 +54,7 @@ class SubBasicBlock extends ControlFlowNodeBase {
* only condition under which a `SubBasicBlock` may have multiple * only condition under which a `SubBasicBlock` may have multiple
* predecessors. * predecessors.
*/ */
predicate firstInBB() { exists(BasicBlock bb | this.getRankInBasicBlock(bb) = 1) } predicate firstInBB() { this.getRankInBasicBlock(_) = 1 }
/** /**
* Holds if this `SubBasicBlock` comes last in its basic block. This is the * Holds if this `SubBasicBlock` comes last in its basic block. This is the

View File

@@ -441,8 +441,8 @@ library class ExprEvaluator extends int {
req = mid.(AssignExpr).getRValue() req = mid.(AssignExpr).getRValue()
) )
or or
exists(VariableAccess va, Variable v, boolean sub1 | exists(Variable v, boolean sub1 |
this.interestingVariableAccess(e, va, v, sub1) and this.interestingVariableAccess(e, _, v, sub1) and
req = v.getAnAssignedValue() and req = v.getAnAssignedValue() and
(sub1 = true implies not this.ignoreVariableAssignment(e, v, req)) and (sub1 = true implies not this.ignoreVariableAssignment(e, v, req)) and
sub = false sub = false
@@ -876,7 +876,7 @@ private predicate nonAnalyzableVariableDefinition(Variable v, StmtParent def) {
* empirically to have effect only on a few rare and pathological examples. * empirically to have effect only on a few rare and pathological examples.
*/ */
private predicate tractableVariable(Variable v) { private predicate tractableVariable(Variable v) {
not exists(StmtParent def | nonAnalyzableVariableDefinition(v, def)) or not nonAnalyzableVariableDefinition(v, _) or
strictcount(StmtParent def | nonAnalyzableVariableDefinition(v, def)) < 1000 strictcount(StmtParent def | nonAnalyzableVariableDefinition(v, def)) < 1000
} }

View File

@@ -876,9 +876,9 @@ private module Stage1 implements StageSig {
pragma[nomagic] pragma[nomagic]
private predicate revFlowOut(ReturnPosition pos, Configuration config) { private predicate revFlowOut(ReturnPosition pos, Configuration config) {
exists(DataFlowCall call, NodeEx out | exists(NodeEx out |
revFlow(out, _, config) and revFlow(out, _, config) and
viableReturnPosOutNodeCandFwd1(call, pos, out, config) viableReturnPosOutNodeCandFwd1(_, pos, out, config)
) )
} }
@@ -1731,8 +1731,8 @@ private module MkStage<StageSig PrevStage> {
) )
or or
// flow through a callable // flow through a callable
exists(DataFlowCall call, ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(DataFlowCall call, ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config)
) )
or or
@@ -1901,8 +1901,8 @@ private module MkStage<StageSig PrevStage> {
pragma[nomagic] pragma[nomagic]
predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) { predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) {
exists(RetNodeEx ret, ReturnPosition pos | exists(ReturnPosition pos |
returnFlowsThrough(ret, pos, _, _, p, ap, _, config) and returnFlowsThrough(_, pos, _, _, p, ap, _, config) and
parameterFlowsThroughRev(p, ap, pos, _, config) parameterFlowsThroughRev(p, ap, pos, _, config)
) )
} }
@@ -1923,8 +1923,8 @@ private module MkStage<StageSig PrevStage> {
DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp, DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp,
Ap ap, Configuration config Ap ap, Configuration config
) { ) {
exists(ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config)
) )
} }
@@ -3749,8 +3749,8 @@ private predicate paramFlowsThrough(
ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap,
AccessPathApprox apa, Configuration config AccessPathApprox apa, Configuration config
) { ) {
exists(PathNodeMid mid, RetNodeEx ret | exists(RetNodeEx ret |
pathNode(mid, ret, state, cc, sc, ap, config, _) and pathNode(_, ret, state, cc, sc, ap, config, _) and
kind = ret.getKind() and kind = ret.getKind() and
apa = ap.getApprox() and apa = ap.getApprox() and
parameterFlowThroughAllowed(sc.getParamNode(), kind) parameterFlowThroughAllowed(sc.getParamNode(), kind)
@@ -4212,17 +4212,15 @@ private module FlowExploration {
ap = TRevPartialNil() and ap = TRevPartialNil() and
exists(config.explorationLimit()) exists(config.explorationLimit())
or or
exists(PartialPathNodeRev mid | revPartialPathStep(_, node, state, sc1, sc2, sc3, ap, config) and
revPartialPathStep(mid, node, state, sc1, sc2, sc3, ap, config) and not clearsContentEx(node, ap.getHead()) and
not clearsContentEx(node, ap.getHead()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead())
expectsContentEx(node, ap.getHead()) ) and
) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
)
} }
pragma[nomagic] pragma[nomagic]
@@ -4230,19 +4228,17 @@ private module FlowExploration {
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config
) { ) {
exists(PartialPathNodeFwd mid | partialPathStep(_, node, state, cc, sc1, sc2, sc3, ap, config) and
partialPathStep(mid, node, state, cc, sc1, sc2, sc3, ap, config) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and not clearsContentEx(node, ap.getHead().getContent()) and
not clearsContentEx(node, ap.getHead().getContent()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead().getContent())
expectsContentEx(node, ap.getHead().getContent()) ) and
) and if node.asNode() instanceof CastingNode
if node.asNode() instanceof CastingNode then compatibleTypes(node.getDataFlowType(), ap.getType())
then compatibleTypes(node.getDataFlowType(), ap.getType()) else any()
else any()
)
} }
/** /**

View File

@@ -876,9 +876,9 @@ private module Stage1 implements StageSig {
pragma[nomagic] pragma[nomagic]
private predicate revFlowOut(ReturnPosition pos, Configuration config) { private predicate revFlowOut(ReturnPosition pos, Configuration config) {
exists(DataFlowCall call, NodeEx out | exists(NodeEx out |
revFlow(out, _, config) and revFlow(out, _, config) and
viableReturnPosOutNodeCandFwd1(call, pos, out, config) viableReturnPosOutNodeCandFwd1(_, pos, out, config)
) )
} }
@@ -1731,8 +1731,8 @@ private module MkStage<StageSig PrevStage> {
) )
or or
// flow through a callable // flow through a callable
exists(DataFlowCall call, ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(DataFlowCall call, ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config)
) )
or or
@@ -1901,8 +1901,8 @@ private module MkStage<StageSig PrevStage> {
pragma[nomagic] pragma[nomagic]
predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) { predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) {
exists(RetNodeEx ret, ReturnPosition pos | exists(ReturnPosition pos |
returnFlowsThrough(ret, pos, _, _, p, ap, _, config) and returnFlowsThrough(_, pos, _, _, p, ap, _, config) and
parameterFlowsThroughRev(p, ap, pos, _, config) parameterFlowsThroughRev(p, ap, pos, _, config)
) )
} }
@@ -1923,8 +1923,8 @@ private module MkStage<StageSig PrevStage> {
DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp, DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp,
Ap ap, Configuration config Ap ap, Configuration config
) { ) {
exists(ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config)
) )
} }
@@ -3749,8 +3749,8 @@ private predicate paramFlowsThrough(
ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap,
AccessPathApprox apa, Configuration config AccessPathApprox apa, Configuration config
) { ) {
exists(PathNodeMid mid, RetNodeEx ret | exists(RetNodeEx ret |
pathNode(mid, ret, state, cc, sc, ap, config, _) and pathNode(_, ret, state, cc, sc, ap, config, _) and
kind = ret.getKind() and kind = ret.getKind() and
apa = ap.getApprox() and apa = ap.getApprox() and
parameterFlowThroughAllowed(sc.getParamNode(), kind) parameterFlowThroughAllowed(sc.getParamNode(), kind)
@@ -4212,17 +4212,15 @@ private module FlowExploration {
ap = TRevPartialNil() and ap = TRevPartialNil() and
exists(config.explorationLimit()) exists(config.explorationLimit())
or or
exists(PartialPathNodeRev mid | revPartialPathStep(_, node, state, sc1, sc2, sc3, ap, config) and
revPartialPathStep(mid, node, state, sc1, sc2, sc3, ap, config) and not clearsContentEx(node, ap.getHead()) and
not clearsContentEx(node, ap.getHead()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead())
expectsContentEx(node, ap.getHead()) ) and
) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
)
} }
pragma[nomagic] pragma[nomagic]
@@ -4230,19 +4228,17 @@ private module FlowExploration {
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config
) { ) {
exists(PartialPathNodeFwd mid | partialPathStep(_, node, state, cc, sc1, sc2, sc3, ap, config) and
partialPathStep(mid, node, state, cc, sc1, sc2, sc3, ap, config) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and not clearsContentEx(node, ap.getHead().getContent()) and
not clearsContentEx(node, ap.getHead().getContent()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead().getContent())
expectsContentEx(node, ap.getHead().getContent()) ) and
) and if node.asNode() instanceof CastingNode
if node.asNode() instanceof CastingNode then compatibleTypes(node.getDataFlowType(), ap.getType())
then compatibleTypes(node.getDataFlowType(), ap.getType()) else any()
else any()
)
} }
/** /**

View File

@@ -876,9 +876,9 @@ private module Stage1 implements StageSig {
pragma[nomagic] pragma[nomagic]
private predicate revFlowOut(ReturnPosition pos, Configuration config) { private predicate revFlowOut(ReturnPosition pos, Configuration config) {
exists(DataFlowCall call, NodeEx out | exists(NodeEx out |
revFlow(out, _, config) and revFlow(out, _, config) and
viableReturnPosOutNodeCandFwd1(call, pos, out, config) viableReturnPosOutNodeCandFwd1(_, pos, out, config)
) )
} }
@@ -1731,8 +1731,8 @@ private module MkStage<StageSig PrevStage> {
) )
or or
// flow through a callable // flow through a callable
exists(DataFlowCall call, ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(DataFlowCall call, ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config)
) )
or or
@@ -1901,8 +1901,8 @@ private module MkStage<StageSig PrevStage> {
pragma[nomagic] pragma[nomagic]
predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) { predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) {
exists(RetNodeEx ret, ReturnPosition pos | exists(ReturnPosition pos |
returnFlowsThrough(ret, pos, _, _, p, ap, _, config) and returnFlowsThrough(_, pos, _, _, p, ap, _, config) and
parameterFlowsThroughRev(p, ap, pos, _, config) parameterFlowsThroughRev(p, ap, pos, _, config)
) )
} }
@@ -1923,8 +1923,8 @@ private module MkStage<StageSig PrevStage> {
DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp, DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp,
Ap ap, Configuration config Ap ap, Configuration config
) { ) {
exists(ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config)
) )
} }
@@ -3749,8 +3749,8 @@ private predicate paramFlowsThrough(
ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap,
AccessPathApprox apa, Configuration config AccessPathApprox apa, Configuration config
) { ) {
exists(PathNodeMid mid, RetNodeEx ret | exists(RetNodeEx ret |
pathNode(mid, ret, state, cc, sc, ap, config, _) and pathNode(_, ret, state, cc, sc, ap, config, _) and
kind = ret.getKind() and kind = ret.getKind() and
apa = ap.getApprox() and apa = ap.getApprox() and
parameterFlowThroughAllowed(sc.getParamNode(), kind) parameterFlowThroughAllowed(sc.getParamNode(), kind)
@@ -4212,17 +4212,15 @@ private module FlowExploration {
ap = TRevPartialNil() and ap = TRevPartialNil() and
exists(config.explorationLimit()) exists(config.explorationLimit())
or or
exists(PartialPathNodeRev mid | revPartialPathStep(_, node, state, sc1, sc2, sc3, ap, config) and
revPartialPathStep(mid, node, state, sc1, sc2, sc3, ap, config) and not clearsContentEx(node, ap.getHead()) and
not clearsContentEx(node, ap.getHead()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead())
expectsContentEx(node, ap.getHead()) ) and
) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
)
} }
pragma[nomagic] pragma[nomagic]
@@ -4230,19 +4228,17 @@ private module FlowExploration {
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config
) { ) {
exists(PartialPathNodeFwd mid | partialPathStep(_, node, state, cc, sc1, sc2, sc3, ap, config) and
partialPathStep(mid, node, state, cc, sc1, sc2, sc3, ap, config) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and not clearsContentEx(node, ap.getHead().getContent()) and
not clearsContentEx(node, ap.getHead().getContent()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead().getContent())
expectsContentEx(node, ap.getHead().getContent()) ) and
) and if node.asNode() instanceof CastingNode
if node.asNode() instanceof CastingNode then compatibleTypes(node.getDataFlowType(), ap.getType())
then compatibleTypes(node.getDataFlowType(), ap.getType()) else any()
else any()
)
} }
/** /**

View File

@@ -876,9 +876,9 @@ private module Stage1 implements StageSig {
pragma[nomagic] pragma[nomagic]
private predicate revFlowOut(ReturnPosition pos, Configuration config) { private predicate revFlowOut(ReturnPosition pos, Configuration config) {
exists(DataFlowCall call, NodeEx out | exists(NodeEx out |
revFlow(out, _, config) and revFlow(out, _, config) and
viableReturnPosOutNodeCandFwd1(call, pos, out, config) viableReturnPosOutNodeCandFwd1(_, pos, out, config)
) )
} }
@@ -1731,8 +1731,8 @@ private module MkStage<StageSig PrevStage> {
) )
or or
// flow through a callable // flow through a callable
exists(DataFlowCall call, ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(DataFlowCall call, ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config)
) )
or or
@@ -1901,8 +1901,8 @@ private module MkStage<StageSig PrevStage> {
pragma[nomagic] pragma[nomagic]
predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) { predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) {
exists(RetNodeEx ret, ReturnPosition pos | exists(ReturnPosition pos |
returnFlowsThrough(ret, pos, _, _, p, ap, _, config) and returnFlowsThrough(_, pos, _, _, p, ap, _, config) and
parameterFlowsThroughRev(p, ap, pos, _, config) parameterFlowsThroughRev(p, ap, pos, _, config)
) )
} }
@@ -1923,8 +1923,8 @@ private module MkStage<StageSig PrevStage> {
DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp, DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp,
Ap ap, Configuration config Ap ap, Configuration config
) { ) {
exists(ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config)
) )
} }
@@ -3749,8 +3749,8 @@ private predicate paramFlowsThrough(
ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap,
AccessPathApprox apa, Configuration config AccessPathApprox apa, Configuration config
) { ) {
exists(PathNodeMid mid, RetNodeEx ret | exists(RetNodeEx ret |
pathNode(mid, ret, state, cc, sc, ap, config, _) and pathNode(_, ret, state, cc, sc, ap, config, _) and
kind = ret.getKind() and kind = ret.getKind() and
apa = ap.getApprox() and apa = ap.getApprox() and
parameterFlowThroughAllowed(sc.getParamNode(), kind) parameterFlowThroughAllowed(sc.getParamNode(), kind)
@@ -4212,17 +4212,15 @@ private module FlowExploration {
ap = TRevPartialNil() and ap = TRevPartialNil() and
exists(config.explorationLimit()) exists(config.explorationLimit())
or or
exists(PartialPathNodeRev mid | revPartialPathStep(_, node, state, sc1, sc2, sc3, ap, config) and
revPartialPathStep(mid, node, state, sc1, sc2, sc3, ap, config) and not clearsContentEx(node, ap.getHead()) and
not clearsContentEx(node, ap.getHead()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead())
expectsContentEx(node, ap.getHead()) ) and
) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
)
} }
pragma[nomagic] pragma[nomagic]
@@ -4230,19 +4228,17 @@ private module FlowExploration {
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config
) { ) {
exists(PartialPathNodeFwd mid | partialPathStep(_, node, state, cc, sc1, sc2, sc3, ap, config) and
partialPathStep(mid, node, state, cc, sc1, sc2, sc3, ap, config) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and not clearsContentEx(node, ap.getHead().getContent()) and
not clearsContentEx(node, ap.getHead().getContent()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead().getContent())
expectsContentEx(node, ap.getHead().getContent()) ) and
) and if node.asNode() instanceof CastingNode
if node.asNode() instanceof CastingNode then compatibleTypes(node.getDataFlowType(), ap.getType())
then compatibleTypes(node.getDataFlowType(), ap.getType()) else any()
else any()
)
} }
/** /**

View File

@@ -45,6 +45,16 @@ module Consistency {
) { ) {
none() none()
} }
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodeAtPosition`. */
predicate uniqueParameterNodeAtPositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodePosition`. */
predicate uniqueParameterNodePositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
} }
private class RelevantNode extends Node { private class RelevantNode extends Node {
@@ -101,9 +111,7 @@ module Consistency {
exists(int c | exists(int c |
c = c =
strictcount(Node n | strictcount(Node n |
not exists(string filepath, int startline, int startcolumn, int endline, int endcolumn | not n.hasLocationInfo(_, _, _, _, _) and
n.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
) and
not any(ConsistencyConfiguration conf).missingLocationExclude(n) not any(ConsistencyConfiguration conf).missingLocationExclude(n)
) and ) and
msg = "Nodes without location: " + c msg = "Nodes without location: " + c
@@ -248,6 +256,7 @@ module Consistency {
query predicate uniqueParameterNodeAtPosition( query predicate uniqueParameterNodeAtPosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg DataFlowCallable c, ParameterPosition pos, Node p, string msg
) { ) {
not any(ConsistencyConfiguration conf).uniqueParameterNodeAtPositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and isParameterNode(p, c, pos) and
not exists(unique(Node p0 | isParameterNode(p0, c, pos))) and not exists(unique(Node p0 | isParameterNode(p0, c, pos))) and
msg = "Parameters with overlapping positions." msg = "Parameters with overlapping positions."
@@ -256,6 +265,7 @@ module Consistency {
query predicate uniqueParameterNodePosition( query predicate uniqueParameterNodePosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg DataFlowCallable c, ParameterPosition pos, Node p, string msg
) { ) {
not any(ConsistencyConfiguration conf).uniqueParameterNodePositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and isParameterNode(p, c, pos) and
not exists(unique(ParameterPosition pos0 | isParameterNode(p, c, pos0))) and not exists(unique(ParameterPosition pos0 | isParameterNode(p, c, pos0))) and
msg = "Parameter node with multiple positions." msg = "Parameter node with multiple positions."

View File

@@ -876,9 +876,9 @@ private module Stage1 implements StageSig {
pragma[nomagic] pragma[nomagic]
private predicate revFlowOut(ReturnPosition pos, Configuration config) { private predicate revFlowOut(ReturnPosition pos, Configuration config) {
exists(DataFlowCall call, NodeEx out | exists(NodeEx out |
revFlow(out, _, config) and revFlow(out, _, config) and
viableReturnPosOutNodeCandFwd1(call, pos, out, config) viableReturnPosOutNodeCandFwd1(_, pos, out, config)
) )
} }
@@ -1731,8 +1731,8 @@ private module MkStage<StageSig PrevStage> {
) )
or or
// flow through a callable // flow through a callable
exists(DataFlowCall call, ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(DataFlowCall call, ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config)
) )
or or
@@ -1901,8 +1901,8 @@ private module MkStage<StageSig PrevStage> {
pragma[nomagic] pragma[nomagic]
predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) { predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) {
exists(RetNodeEx ret, ReturnPosition pos | exists(ReturnPosition pos |
returnFlowsThrough(ret, pos, _, _, p, ap, _, config) and returnFlowsThrough(_, pos, _, _, p, ap, _, config) and
parameterFlowsThroughRev(p, ap, pos, _, config) parameterFlowsThroughRev(p, ap, pos, _, config)
) )
} }
@@ -1923,8 +1923,8 @@ private module MkStage<StageSig PrevStage> {
DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp, DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp,
Ap ap, Configuration config Ap ap, Configuration config
) { ) {
exists(ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config)
) )
} }
@@ -3749,8 +3749,8 @@ private predicate paramFlowsThrough(
ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap,
AccessPathApprox apa, Configuration config AccessPathApprox apa, Configuration config
) { ) {
exists(PathNodeMid mid, RetNodeEx ret | exists(RetNodeEx ret |
pathNode(mid, ret, state, cc, sc, ap, config, _) and pathNode(_, ret, state, cc, sc, ap, config, _) and
kind = ret.getKind() and kind = ret.getKind() and
apa = ap.getApprox() and apa = ap.getApprox() and
parameterFlowThroughAllowed(sc.getParamNode(), kind) parameterFlowThroughAllowed(sc.getParamNode(), kind)
@@ -4212,17 +4212,15 @@ private module FlowExploration {
ap = TRevPartialNil() and ap = TRevPartialNil() and
exists(config.explorationLimit()) exists(config.explorationLimit())
or or
exists(PartialPathNodeRev mid | revPartialPathStep(_, node, state, sc1, sc2, sc3, ap, config) and
revPartialPathStep(mid, node, state, sc1, sc2, sc3, ap, config) and not clearsContentEx(node, ap.getHead()) and
not clearsContentEx(node, ap.getHead()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead())
expectsContentEx(node, ap.getHead()) ) and
) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
)
} }
pragma[nomagic] pragma[nomagic]
@@ -4230,19 +4228,17 @@ private module FlowExploration {
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config
) { ) {
exists(PartialPathNodeFwd mid | partialPathStep(_, node, state, cc, sc1, sc2, sc3, ap, config) and
partialPathStep(mid, node, state, cc, sc1, sc2, sc3, ap, config) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and not clearsContentEx(node, ap.getHead().getContent()) and
not clearsContentEx(node, ap.getHead().getContent()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead().getContent())
expectsContentEx(node, ap.getHead().getContent()) ) and
) and if node.asNode() instanceof CastingNode
if node.asNode() instanceof CastingNode then compatibleTypes(node.getDataFlowType(), ap.getType())
then compatibleTypes(node.getDataFlowType(), ap.getType()) else any()
else any()
)
} }
/** /**

View File

@@ -450,10 +450,8 @@ module FlowVar_internal {
} }
override string toString() { override string toString() {
exists(Expr e | this.definedByExpr(_, _) and
this.definedByExpr(e, _) and result = "assignment to " + v
result = "assignment to " + v
)
or or
this.definedByInitialValue(_) and this.definedByInitialValue(_) and
result = "initial value of " + v result = "initial value of " + v

View File

@@ -54,7 +54,7 @@ class SubBasicBlock extends ControlFlowNodeBase {
* only condition under which a `SubBasicBlock` may have multiple * only condition under which a `SubBasicBlock` may have multiple
* predecessors. * predecessors.
*/ */
predicate firstInBB() { exists(BasicBlock bb | this.getRankInBasicBlock(bb) = 1) } predicate firstInBB() { this.getRankInBasicBlock(_) = 1 }
/** /**
* Holds if this `SubBasicBlock` comes last in its basic block. This is the * Holds if this `SubBasicBlock` comes last in its basic block. This is the

View File

@@ -70,8 +70,8 @@ module VirtualDispatch {
* that is, `c` or one of its supertypes overrides `f`. * that is, `c` or one of its supertypes overrides `f`.
*/ */
private predicate cannotInherit(Class c, MemberFunction f) { private predicate cannotInherit(Class c, MemberFunction f) {
exists(Class overridingType, MemberFunction override | exists(MemberFunction override |
cannotInheritHelper(c, f, overridingType, override) and cannotInheritHelper(c, f, _, override) and
override.overrides+(f) override.overrides+(f)
) )
} }

View File

@@ -53,7 +53,7 @@ class Expr extends StmtParent, @expr {
Declaration getEnclosingDeclaration() { result = exprEnclosingElement(this) } Declaration getEnclosingDeclaration() { result = exprEnclosingElement(this) }
/** Gets a child of this expression. */ /** Gets a child of this expression. */
Expr getAChild() { exists(int n | result = this.getChild(n)) } Expr getAChild() { result = this.getChild(_) }
/** Gets the parent of this expression, if any. */ /** Gets the parent of this expression, if any. */
Element getParent() { exprparents(underlyingElement(this), _, unresolveElement(result)) } Element getParent() { exprparents(underlyingElement(this), _, unresolveElement(result)) }

View File

@@ -876,9 +876,9 @@ private module Stage1 implements StageSig {
pragma[nomagic] pragma[nomagic]
private predicate revFlowOut(ReturnPosition pos, Configuration config) { private predicate revFlowOut(ReturnPosition pos, Configuration config) {
exists(DataFlowCall call, NodeEx out | exists(NodeEx out |
revFlow(out, _, config) and revFlow(out, _, config) and
viableReturnPosOutNodeCandFwd1(call, pos, out, config) viableReturnPosOutNodeCandFwd1(_, pos, out, config)
) )
} }
@@ -1731,8 +1731,8 @@ private module MkStage<StageSig PrevStage> {
) )
or or
// flow through a callable // flow through a callable
exists(DataFlowCall call, ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(DataFlowCall call, ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config)
) )
or or
@@ -1901,8 +1901,8 @@ private module MkStage<StageSig PrevStage> {
pragma[nomagic] pragma[nomagic]
predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) { predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) {
exists(RetNodeEx ret, ReturnPosition pos | exists(ReturnPosition pos |
returnFlowsThrough(ret, pos, _, _, p, ap, _, config) and returnFlowsThrough(_, pos, _, _, p, ap, _, config) and
parameterFlowsThroughRev(p, ap, pos, _, config) parameterFlowsThroughRev(p, ap, pos, _, config)
) )
} }
@@ -1923,8 +1923,8 @@ private module MkStage<StageSig PrevStage> {
DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp, DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp,
Ap ap, Configuration config Ap ap, Configuration config
) { ) {
exists(ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config)
) )
} }
@@ -3749,8 +3749,8 @@ private predicate paramFlowsThrough(
ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap,
AccessPathApprox apa, Configuration config AccessPathApprox apa, Configuration config
) { ) {
exists(PathNodeMid mid, RetNodeEx ret | exists(RetNodeEx ret |
pathNode(mid, ret, state, cc, sc, ap, config, _) and pathNode(_, ret, state, cc, sc, ap, config, _) and
kind = ret.getKind() and kind = ret.getKind() and
apa = ap.getApprox() and apa = ap.getApprox() and
parameterFlowThroughAllowed(sc.getParamNode(), kind) parameterFlowThroughAllowed(sc.getParamNode(), kind)
@@ -4212,17 +4212,15 @@ private module FlowExploration {
ap = TRevPartialNil() and ap = TRevPartialNil() and
exists(config.explorationLimit()) exists(config.explorationLimit())
or or
exists(PartialPathNodeRev mid | revPartialPathStep(_, node, state, sc1, sc2, sc3, ap, config) and
revPartialPathStep(mid, node, state, sc1, sc2, sc3, ap, config) and not clearsContentEx(node, ap.getHead()) and
not clearsContentEx(node, ap.getHead()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead())
expectsContentEx(node, ap.getHead()) ) and
) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
)
} }
pragma[nomagic] pragma[nomagic]
@@ -4230,19 +4228,17 @@ private module FlowExploration {
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config
) { ) {
exists(PartialPathNodeFwd mid | partialPathStep(_, node, state, cc, sc1, sc2, sc3, ap, config) and
partialPathStep(mid, node, state, cc, sc1, sc2, sc3, ap, config) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and not clearsContentEx(node, ap.getHead().getContent()) and
not clearsContentEx(node, ap.getHead().getContent()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead().getContent())
expectsContentEx(node, ap.getHead().getContent()) ) and
) and if node.asNode() instanceof CastingNode
if node.asNode() instanceof CastingNode then compatibleTypes(node.getDataFlowType(), ap.getType())
then compatibleTypes(node.getDataFlowType(), ap.getType()) else any()
else any()
)
} }
/** /**

View File

@@ -876,9 +876,9 @@ private module Stage1 implements StageSig {
pragma[nomagic] pragma[nomagic]
private predicate revFlowOut(ReturnPosition pos, Configuration config) { private predicate revFlowOut(ReturnPosition pos, Configuration config) {
exists(DataFlowCall call, NodeEx out | exists(NodeEx out |
revFlow(out, _, config) and revFlow(out, _, config) and
viableReturnPosOutNodeCandFwd1(call, pos, out, config) viableReturnPosOutNodeCandFwd1(_, pos, out, config)
) )
} }
@@ -1731,8 +1731,8 @@ private module MkStage<StageSig PrevStage> {
) )
or or
// flow through a callable // flow through a callable
exists(DataFlowCall call, ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(DataFlowCall call, ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config)
) )
or or
@@ -1901,8 +1901,8 @@ private module MkStage<StageSig PrevStage> {
pragma[nomagic] pragma[nomagic]
predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) { predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) {
exists(RetNodeEx ret, ReturnPosition pos | exists(ReturnPosition pos |
returnFlowsThrough(ret, pos, _, _, p, ap, _, config) and returnFlowsThrough(_, pos, _, _, p, ap, _, config) and
parameterFlowsThroughRev(p, ap, pos, _, config) parameterFlowsThroughRev(p, ap, pos, _, config)
) )
} }
@@ -1923,8 +1923,8 @@ private module MkStage<StageSig PrevStage> {
DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp, DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp,
Ap ap, Configuration config Ap ap, Configuration config
) { ) {
exists(ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config)
) )
} }
@@ -3749,8 +3749,8 @@ private predicate paramFlowsThrough(
ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap,
AccessPathApprox apa, Configuration config AccessPathApprox apa, Configuration config
) { ) {
exists(PathNodeMid mid, RetNodeEx ret | exists(RetNodeEx ret |
pathNode(mid, ret, state, cc, sc, ap, config, _) and pathNode(_, ret, state, cc, sc, ap, config, _) and
kind = ret.getKind() and kind = ret.getKind() and
apa = ap.getApprox() and apa = ap.getApprox() and
parameterFlowThroughAllowed(sc.getParamNode(), kind) parameterFlowThroughAllowed(sc.getParamNode(), kind)
@@ -4212,17 +4212,15 @@ private module FlowExploration {
ap = TRevPartialNil() and ap = TRevPartialNil() and
exists(config.explorationLimit()) exists(config.explorationLimit())
or or
exists(PartialPathNodeRev mid | revPartialPathStep(_, node, state, sc1, sc2, sc3, ap, config) and
revPartialPathStep(mid, node, state, sc1, sc2, sc3, ap, config) and not clearsContentEx(node, ap.getHead()) and
not clearsContentEx(node, ap.getHead()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead())
expectsContentEx(node, ap.getHead()) ) and
) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
)
} }
pragma[nomagic] pragma[nomagic]
@@ -4230,19 +4228,17 @@ private module FlowExploration {
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config
) { ) {
exists(PartialPathNodeFwd mid | partialPathStep(_, node, state, cc, sc1, sc2, sc3, ap, config) and
partialPathStep(mid, node, state, cc, sc1, sc2, sc3, ap, config) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and not clearsContentEx(node, ap.getHead().getContent()) and
not clearsContentEx(node, ap.getHead().getContent()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead().getContent())
expectsContentEx(node, ap.getHead().getContent()) ) and
) and if node.asNode() instanceof CastingNode
if node.asNode() instanceof CastingNode then compatibleTypes(node.getDataFlowType(), ap.getType())
then compatibleTypes(node.getDataFlowType(), ap.getType()) else any()
else any()
)
} }
/** /**

View File

@@ -876,9 +876,9 @@ private module Stage1 implements StageSig {
pragma[nomagic] pragma[nomagic]
private predicate revFlowOut(ReturnPosition pos, Configuration config) { private predicate revFlowOut(ReturnPosition pos, Configuration config) {
exists(DataFlowCall call, NodeEx out | exists(NodeEx out |
revFlow(out, _, config) and revFlow(out, _, config) and
viableReturnPosOutNodeCandFwd1(call, pos, out, config) viableReturnPosOutNodeCandFwd1(_, pos, out, config)
) )
} }
@@ -1731,8 +1731,8 @@ private module MkStage<StageSig PrevStage> {
) )
or or
// flow through a callable // flow through a callable
exists(DataFlowCall call, ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(DataFlowCall call, ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config)
) )
or or
@@ -1901,8 +1901,8 @@ private module MkStage<StageSig PrevStage> {
pragma[nomagic] pragma[nomagic]
predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) { predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) {
exists(RetNodeEx ret, ReturnPosition pos | exists(ReturnPosition pos |
returnFlowsThrough(ret, pos, _, _, p, ap, _, config) and returnFlowsThrough(_, pos, _, _, p, ap, _, config) and
parameterFlowsThroughRev(p, ap, pos, _, config) parameterFlowsThroughRev(p, ap, pos, _, config)
) )
} }
@@ -1923,8 +1923,8 @@ private module MkStage<StageSig PrevStage> {
DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp, DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp,
Ap ap, Configuration config Ap ap, Configuration config
) { ) {
exists(ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config)
) )
} }
@@ -3749,8 +3749,8 @@ private predicate paramFlowsThrough(
ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap,
AccessPathApprox apa, Configuration config AccessPathApprox apa, Configuration config
) { ) {
exists(PathNodeMid mid, RetNodeEx ret | exists(RetNodeEx ret |
pathNode(mid, ret, state, cc, sc, ap, config, _) and pathNode(_, ret, state, cc, sc, ap, config, _) and
kind = ret.getKind() and kind = ret.getKind() and
apa = ap.getApprox() and apa = ap.getApprox() and
parameterFlowThroughAllowed(sc.getParamNode(), kind) parameterFlowThroughAllowed(sc.getParamNode(), kind)
@@ -4212,17 +4212,15 @@ private module FlowExploration {
ap = TRevPartialNil() and ap = TRevPartialNil() and
exists(config.explorationLimit()) exists(config.explorationLimit())
or or
exists(PartialPathNodeRev mid | revPartialPathStep(_, node, state, sc1, sc2, sc3, ap, config) and
revPartialPathStep(mid, node, state, sc1, sc2, sc3, ap, config) and not clearsContentEx(node, ap.getHead()) and
not clearsContentEx(node, ap.getHead()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead())
expectsContentEx(node, ap.getHead()) ) and
) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
)
} }
pragma[nomagic] pragma[nomagic]
@@ -4230,19 +4228,17 @@ private module FlowExploration {
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config
) { ) {
exists(PartialPathNodeFwd mid | partialPathStep(_, node, state, cc, sc1, sc2, sc3, ap, config) and
partialPathStep(mid, node, state, cc, sc1, sc2, sc3, ap, config) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and not clearsContentEx(node, ap.getHead().getContent()) and
not clearsContentEx(node, ap.getHead().getContent()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead().getContent())
expectsContentEx(node, ap.getHead().getContent()) ) and
) and if node.asNode() instanceof CastingNode
if node.asNode() instanceof CastingNode then compatibleTypes(node.getDataFlowType(), ap.getType())
then compatibleTypes(node.getDataFlowType(), ap.getType()) else any()
else any()
)
} }
/** /**

View File

@@ -876,9 +876,9 @@ private module Stage1 implements StageSig {
pragma[nomagic] pragma[nomagic]
private predicate revFlowOut(ReturnPosition pos, Configuration config) { private predicate revFlowOut(ReturnPosition pos, Configuration config) {
exists(DataFlowCall call, NodeEx out | exists(NodeEx out |
revFlow(out, _, config) and revFlow(out, _, config) and
viableReturnPosOutNodeCandFwd1(call, pos, out, config) viableReturnPosOutNodeCandFwd1(_, pos, out, config)
) )
} }
@@ -1731,8 +1731,8 @@ private module MkStage<StageSig PrevStage> {
) )
or or
// flow through a callable // flow through a callable
exists(DataFlowCall call, ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(DataFlowCall call, ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, node, p, _, ap, innerReturnAp, config)
) )
or or
@@ -1901,8 +1901,8 @@ private module MkStage<StageSig PrevStage> {
pragma[nomagic] pragma[nomagic]
predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) { predicate parameterMayFlowThrough(ParamNodeEx p, Ap ap, Configuration config) {
exists(RetNodeEx ret, ReturnPosition pos | exists(ReturnPosition pos |
returnFlowsThrough(ret, pos, _, _, p, ap, _, config) and returnFlowsThrough(_, pos, _, _, p, ap, _, config) and
parameterFlowsThroughRev(p, ap, pos, _, config) parameterFlowsThroughRev(p, ap, pos, _, config)
) )
} }
@@ -1923,8 +1923,8 @@ private module MkStage<StageSig PrevStage> {
DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp, DataFlowCall call, ArgNodeEx arg, FlowState state, ReturnCtx returnCtx, ApOption returnAp,
Ap ap, Configuration config Ap ap, Configuration config
) { ) {
exists(ParamNodeEx p, ReturnPosition pos, Ap innerReturnAp | exists(ParamNodeEx p, Ap innerReturnAp |
revFlowThrough(call, returnCtx, p, state, pos, returnAp, ap, innerReturnAp, config) and revFlowThrough(call, returnCtx, p, state, _, returnAp, ap, innerReturnAp, config) and
flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config) flowThroughIntoCall(call, arg, p, _, ap, innerReturnAp, config)
) )
} }
@@ -3749,8 +3749,8 @@ private predicate paramFlowsThrough(
ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap, ReturnKindExt kind, FlowState state, CallContextCall cc, SummaryCtxSome sc, AccessPath ap,
AccessPathApprox apa, Configuration config AccessPathApprox apa, Configuration config
) { ) {
exists(PathNodeMid mid, RetNodeEx ret | exists(RetNodeEx ret |
pathNode(mid, ret, state, cc, sc, ap, config, _) and pathNode(_, ret, state, cc, sc, ap, config, _) and
kind = ret.getKind() and kind = ret.getKind() and
apa = ap.getApprox() and apa = ap.getApprox() and
parameterFlowThroughAllowed(sc.getParamNode(), kind) parameterFlowThroughAllowed(sc.getParamNode(), kind)
@@ -4212,17 +4212,15 @@ private module FlowExploration {
ap = TRevPartialNil() and ap = TRevPartialNil() and
exists(config.explorationLimit()) exists(config.explorationLimit())
or or
exists(PartialPathNodeRev mid | revPartialPathStep(_, node, state, sc1, sc2, sc3, ap, config) and
revPartialPathStep(mid, node, state, sc1, sc2, sc3, ap, config) and not clearsContentEx(node, ap.getHead()) and
not clearsContentEx(node, ap.getHead()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead())
expectsContentEx(node, ap.getHead()) ) and
) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
distSink(node.getEnclosingCallable(), config) <= config.explorationLimit()
)
} }
pragma[nomagic] pragma[nomagic]
@@ -4230,19 +4228,17 @@ private module FlowExploration {
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2, NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config TSummaryCtx3 sc3, PartialAccessPath ap, Configuration config
) { ) {
exists(PartialPathNodeFwd mid | partialPathStep(_, node, state, cc, sc1, sc2, sc3, ap, config) and
partialPathStep(mid, node, state, cc, sc1, sc2, sc3, ap, config) and not fullBarrier(node, config) and
not fullBarrier(node, config) and not stateBarrier(node, state, config) and
not stateBarrier(node, state, config) and not clearsContentEx(node, ap.getHead().getContent()) and
not clearsContentEx(node, ap.getHead().getContent()) and (
( notExpectsContent(node) or
notExpectsContent(node) or expectsContentEx(node, ap.getHead().getContent())
expectsContentEx(node, ap.getHead().getContent()) ) and
) and if node.asNode() instanceof CastingNode
if node.asNode() instanceof CastingNode then compatibleTypes(node.getDataFlowType(), ap.getType())
then compatibleTypes(node.getDataFlowType(), ap.getType()) else any()
else any()
)
} }
/** /**

View File

@@ -45,6 +45,16 @@ module Consistency {
) { ) {
none() none()
} }
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodeAtPosition`. */
predicate uniqueParameterNodeAtPositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
/** Holds if `(c, pos, p)` should be excluded from the consistency test `uniqueParameterNodePosition`. */
predicate uniqueParameterNodePositionExclude(DataFlowCallable c, ParameterPosition pos, Node p) {
none()
}
} }
private class RelevantNode extends Node { private class RelevantNode extends Node {
@@ -101,9 +111,7 @@ module Consistency {
exists(int c | exists(int c |
c = c =
strictcount(Node n | strictcount(Node n |
not exists(string filepath, int startline, int startcolumn, int endline, int endcolumn | not n.hasLocationInfo(_, _, _, _, _) and
n.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
) and
not any(ConsistencyConfiguration conf).missingLocationExclude(n) not any(ConsistencyConfiguration conf).missingLocationExclude(n)
) and ) and
msg = "Nodes without location: " + c msg = "Nodes without location: " + c
@@ -248,6 +256,7 @@ module Consistency {
query predicate uniqueParameterNodeAtPosition( query predicate uniqueParameterNodeAtPosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg DataFlowCallable c, ParameterPosition pos, Node p, string msg
) { ) {
not any(ConsistencyConfiguration conf).uniqueParameterNodeAtPositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and isParameterNode(p, c, pos) and
not exists(unique(Node p0 | isParameterNode(p0, c, pos))) and not exists(unique(Node p0 | isParameterNode(p0, c, pos))) and
msg = "Parameters with overlapping positions." msg = "Parameters with overlapping positions."
@@ -256,6 +265,7 @@ module Consistency {
query predicate uniqueParameterNodePosition( query predicate uniqueParameterNodePosition(
DataFlowCallable c, ParameterPosition pos, Node p, string msg DataFlowCallable c, ParameterPosition pos, Node p, string msg
) { ) {
not any(ConsistencyConfiguration conf).uniqueParameterNodePositionExclude(c, pos, p) and
isParameterNode(p, c, pos) and isParameterNode(p, c, pos) and
not exists(unique(ParameterPosition pos0 | isParameterNode(p, c, pos0))) and not exists(unique(ParameterPosition pos0 | isParameterNode(p, c, pos0))) and
msg = "Parameter node with multiple positions." msg = "Parameter node with multiple positions."

View File

@@ -30,6 +30,7 @@ private newtype TOpcode =
TNegate() or TNegate() or
TShiftLeft() or TShiftLeft() or
TShiftRight() or TShiftRight() or
TUnsignedShiftRight() or
TBitAnd() or TBitAnd() or
TBitOr() or TBitOr() or
TBitXor() or TBitXor() or
@@ -652,6 +653,15 @@ module Opcode {
final override string toString() { result = "ShiftRight" } final override string toString() { result = "ShiftRight" }
} }
/**
* The `Opcode` for a `UnsignedShiftRightInstruction`.
*
* See the `UnsignedShiftRightInstruction` documentation for more details.
*/
class UnsignedShiftRight extends BinaryBitwiseOpcode, TUnsignedShiftRight {
final override string toString() { result = "UnsignedShiftRight" }
}
/** /**
* The `Opcode` for a `BitAndInstruction`. * The `Opcode` for a `BitAndInstruction`.
* *

View File

@@ -1204,6 +1204,17 @@ class ShiftRightInstruction extends BinaryBitwiseInstruction {
ShiftRightInstruction() { this.getOpcode() instanceof Opcode::ShiftRight } ShiftRightInstruction() { this.getOpcode() instanceof Opcode::ShiftRight }
} }
/**
* An instruction that shifts its left operand to the right by the number of bits specified by its
* right operand.
*
* Both operands must have an integer type. The result has the same type as the left operand.
* The leftmost bits are zero-filled.
*/
class UnsignedShiftRightInstruction extends BinaryBitwiseInstruction {
UnsignedShiftRightInstruction() { this.getOpcode() instanceof Opcode::UnsignedShiftRight }
}
/** /**
* An instruction that performs a binary arithmetic operation involving at least one pointer * An instruction that performs a binary arithmetic operation involving at least one pointer
* operand. * operand.

View File

@@ -45,7 +45,7 @@ class Operand extends TStageOperand {
this = reusedPhiOperand(use, def, predecessorBlock, _) this = reusedPhiOperand(use, def, predecessorBlock, _)
) )
or or
exists(Instruction use | this = chiOperand(use, _)) this = chiOperand(_, _)
} }
/** Gets a textual representation of this element. */ /** Gets a textual representation of this element. */

View File

@@ -329,12 +329,12 @@ private module Cached {
cached cached
Instruction getChiInstructionTotalOperand(ChiInstruction chiInstr) { Instruction getChiInstructionTotalOperand(ChiInstruction chiInstr) {
exists( exists(
Alias::VirtualVariable vvar, OldInstruction oldInstr, Alias::MemoryLocation defLocation, Alias::VirtualVariable vvar, OldInstruction oldInstr, OldBlock defBlock, int defRank,
OldBlock defBlock, int defRank, int defOffset, OldBlock useBlock, int useRank int defOffset, OldBlock useBlock, int useRank
| |
chiInstr = getChi(oldInstr) and chiInstr = getChi(oldInstr) and
vvar = Alias::getResultMemoryLocation(oldInstr).getVirtualVariable() and vvar = Alias::getResultMemoryLocation(oldInstr).getVirtualVariable() and
hasDefinitionAtRank(vvar, defLocation, defBlock, defRank, defOffset) and hasDefinitionAtRank(vvar, _, defBlock, defRank, defOffset) and
hasUseAtRank(vvar, useBlock, useRank, oldInstr) and hasUseAtRank(vvar, useBlock, useRank, oldInstr) and
definitionReachesUse(vvar, defBlock, defRank, useBlock, useRank) and definitionReachesUse(vvar, defBlock, defRank, useBlock, useRank) and
result = getDefinitionOrChiInstruction(defBlock, defOffset, vvar, _) result = getDefinitionOrChiInstruction(defBlock, defOffset, vvar, _)

View File

@@ -1204,6 +1204,17 @@ class ShiftRightInstruction extends BinaryBitwiseInstruction {
ShiftRightInstruction() { this.getOpcode() instanceof Opcode::ShiftRight } ShiftRightInstruction() { this.getOpcode() instanceof Opcode::ShiftRight }
} }
/**
* An instruction that shifts its left operand to the right by the number of bits specified by its
* right operand.
*
* Both operands must have an integer type. The result has the same type as the left operand.
* The leftmost bits are zero-filled.
*/
class UnsignedShiftRightInstruction extends BinaryBitwiseInstruction {
UnsignedShiftRightInstruction() { this.getOpcode() instanceof Opcode::UnsignedShiftRight }
}
/** /**
* An instruction that performs a binary arithmetic operation involving at least one pointer * An instruction that performs a binary arithmetic operation involving at least one pointer
* operand. * operand.

View File

@@ -45,7 +45,7 @@ class Operand extends TStageOperand {
this = reusedPhiOperand(use, def, predecessorBlock, _) this = reusedPhiOperand(use, def, predecessorBlock, _)
) )
or or
exists(Instruction use | this = chiOperand(use, _)) this = chiOperand(_, _)
} }
/** Gets a textual representation of this element. */ /** Gets a textual representation of this element. */

View File

@@ -298,11 +298,11 @@ class TranslatedStringLiteralInitialization extends TranslatedDirectInitializati
opcode instanceof Opcode::Store and opcode instanceof Opcode::Store and
resultType = getTypeForPRValue(expr.getType()) resultType = getTypeForPRValue(expr.getType())
or or
exists(int startIndex, int elementCount | exists(int elementCount |
// If the initializer string isn't large enough to fill the target, then // If the initializer string isn't large enough to fill the target, then
// we have to generate another instruction sequence to store a constant // we have to generate another instruction sequence to store a constant
// zero into the remainder of the array. // zero into the remainder of the array.
zeroInitRange(startIndex, elementCount) and zeroInitRange(_, elementCount) and
( (
// Create a constant zero whose size is the size of the remaining // Create a constant zero whose size is the size of the remaining
// space in the target array. // space in the target array.

View File

@@ -1204,6 +1204,17 @@ class ShiftRightInstruction extends BinaryBitwiseInstruction {
ShiftRightInstruction() { this.getOpcode() instanceof Opcode::ShiftRight } ShiftRightInstruction() { this.getOpcode() instanceof Opcode::ShiftRight }
} }
/**
* An instruction that shifts its left operand to the right by the number of bits specified by its
* right operand.
*
* Both operands must have an integer type. The result has the same type as the left operand.
* The leftmost bits are zero-filled.
*/
class UnsignedShiftRightInstruction extends BinaryBitwiseInstruction {
UnsignedShiftRightInstruction() { this.getOpcode() instanceof Opcode::UnsignedShiftRight }
}
/** /**
* An instruction that performs a binary arithmetic operation involving at least one pointer * An instruction that performs a binary arithmetic operation involving at least one pointer
* operand. * operand.

View File

@@ -45,7 +45,7 @@ class Operand extends TStageOperand {
this = reusedPhiOperand(use, def, predecessorBlock, _) this = reusedPhiOperand(use, def, predecessorBlock, _)
) )
or or
exists(Instruction use | this = chiOperand(use, _)) this = chiOperand(_, _)
} }
/** Gets a textual representation of this element. */ /** Gets a textual representation of this element. */

View File

@@ -329,12 +329,12 @@ private module Cached {
cached cached
Instruction getChiInstructionTotalOperand(ChiInstruction chiInstr) { Instruction getChiInstructionTotalOperand(ChiInstruction chiInstr) {
exists( exists(
Alias::VirtualVariable vvar, OldInstruction oldInstr, Alias::MemoryLocation defLocation, Alias::VirtualVariable vvar, OldInstruction oldInstr, OldBlock defBlock, int defRank,
OldBlock defBlock, int defRank, int defOffset, OldBlock useBlock, int useRank int defOffset, OldBlock useBlock, int useRank
| |
chiInstr = getChi(oldInstr) and chiInstr = getChi(oldInstr) and
vvar = Alias::getResultMemoryLocation(oldInstr).getVirtualVariable() and vvar = Alias::getResultMemoryLocation(oldInstr).getVirtualVariable() and
hasDefinitionAtRank(vvar, defLocation, defBlock, defRank, defOffset) and hasDefinitionAtRank(vvar, _, defBlock, defRank, defOffset) and
hasUseAtRank(vvar, useBlock, useRank, oldInstr) and hasUseAtRank(vvar, useBlock, useRank, oldInstr) and
definitionReachesUse(vvar, defBlock, defRank, useBlock, useRank) and definitionReachesUse(vvar, defBlock, defRank, useBlock, useRank) and
result = getDefinitionOrChiInstruction(defBlock, defOffset, vvar, _) result = getDefinitionOrChiInstruction(defBlock, defOffset, vvar, _)

View File

@@ -67,9 +67,7 @@ class Class = Cpp::Class; // Used for inheritance conversions
predicate getIdentityString = Print::getIdentityString/1; predicate getIdentityString = Print::getIdentityString/1;
predicate hasCaseEdge(string minValue, string maxValue) { predicate hasCaseEdge(string minValue, string maxValue) { hasCaseEdge(_, minValue, maxValue) }
exists(Cpp::SwitchCase switchCase | hasCaseEdge(switchCase, minValue, maxValue))
}
predicate hasPositionalArgIndex(int argIndex) { predicate hasPositionalArgIndex(int argIndex) {
exists(Cpp::FunctionCall call | exists(call.getArgument(argIndex))) or exists(Cpp::FunctionCall call | exists(call.getArgument(argIndex))) or

View File

@@ -99,10 +99,10 @@ class MetricClass extends Class {
} }
/** Gets any method that accesses some local field. */ /** Gets any method that accesses some local field. */
Function getAccessingMethod() { exists(Field f | this.accessesLocalField(result, f)) } Function getAccessingMethod() { this.accessesLocalField(result, _) }
/** Gets any field that is accessed by a local method. */ /** Gets any field that is accessed by a local method. */
Field getAccessedField() { exists(Function func | this.accessesLocalField(func, result)) } Field getAccessedField() { this.accessesLocalField(_, result) }
/** Gets the Henderson-Sellers lack-of-cohesion metric. */ /** Gets the Henderson-Sellers lack-of-cohesion metric. */
float getLackOfCohesionHS() { float getLackOfCohesionHS() {
@@ -517,10 +517,10 @@ private predicate dependsOnClassSimple(Class source, Class dest) {
) )
or or
// a class depends on classes for which a call to its member function is done from a function // a class depends on classes for which a call to its member function is done from a function
exists(MemberFunction target, MemberFunction f, Locatable l | exists(MemberFunction target, MemberFunction f |
f.getDeclaringType() = source and f.getDeclaringType() = source and
f instanceof MemberFunction and f instanceof MemberFunction and
f.calls(target, l) and f.calls(target, _) and
target instanceof MemberFunction and target instanceof MemberFunction and
target.getDeclaringType() = dest target.getDeclaringType() = dest
) )

View File

@@ -133,13 +133,15 @@ abstract class HeuristicAllocationExpr extends Expr {
/** /**
* Gets a constant multiplier for the allocation size given by `getSizeExpr`, * Gets a constant multiplier for the allocation size given by `getSizeExpr`,
* in bytes. * in bytes. This predicate should be used with caution as it can be
* inaccurate for allocations identified using heuristics.
*/ */
int getSizeMult() { none() } int getSizeMult() { none() }
/** /**
* Gets the size of this allocation in bytes, if it is a fixed size and that * Gets the size of this allocation in bytes, if it is a fixed size and that
* size can be determined. * size can be determined. This predicate should be used with caution as it
* can be inaccurate for allocations identified using heuristics.
*/ */
int getSizeBytes() { none() } int getSizeBytes() { none() }

View File

@@ -296,7 +296,7 @@ private predicate analyzableExpr(Expr e) {
or or
// Also allow variable accesses, provided that they have SSA // Also allow variable accesses, provided that they have SSA
// information. // information.
exists(RangeSsaDefinition def, StackVariable v | e = def.getAUse(v)) exists(RangeSsaDefinition def | e = def.getAUse(_))
or or
e instanceof UnsignedBitwiseAndExpr e instanceof UnsignedBitwiseAndExpr
or or

View File

@@ -127,9 +127,9 @@ deprecated private predicate betweenFunctionsValueMoveTo(
not unreachable(src) and not unreachable(src) and
not unreachable(dest) and not unreachable(dest) and
( (
exists(Call call, Function called, int i | exists(Call call, int i |
src = call.getArgument(i) and src = call.getArgument(i) and
resolveCallWithParam(call, called, i, dest) and resolveCallWithParam(call, _, i, dest) and
destFromArg = true destFromArg = true
) )
or or
@@ -151,8 +151,8 @@ deprecated private predicate betweenFunctionsValueMoveTo(
) )
or or
// If a parameter of type reference is tainted inside a function, taint the argument too // If a parameter of type reference is tainted inside a function, taint the argument too
exists(Call call, Function f, int pi, Parameter p | exists(Call call, int pi, Parameter p |
resolveCallWithParam(call, f, pi, p) and resolveCallWithParam(call, _, pi, p) and
p.getType() instanceof ReferenceType and p.getType() instanceof ReferenceType and
src = p and src = p and
dest = call.getArgument(pi) and dest = call.getArgument(pi) and

View File

@@ -34,7 +34,7 @@ class Stmt extends StmtParent, @stmt {
} }
/** Gets a child of this statement. */ /** Gets a child of this statement. */
Element getAChild() { exists(int n | result = this.getChild(n)) } Element getAChild() { result = this.getChild(_) }
/** Gets the parent of this statement, if any. */ /** Gets the parent of this statement, if any. */
StmtParent getParent() { stmtparents(underlyingElement(this), _, unresolveElement(result)) } StmtParent getParent() { stmtparents(underlyingElement(this), _, unresolveElement(result)) }

View File

@@ -475,9 +475,7 @@ private predicate mk_NonmemberFunctionCall(Function fcn, HC_Args args, FunctionC
fc.getTarget() = fcn and fc.getTarget() = fcn and
analyzableNonmemberFunctionCall(fc) and analyzableNonmemberFunctionCall(fc) and
( (
exists(HashCons head, HC_Args tail | mk_ArgConsInner(_, _, fc.getNumberOfArguments() - 1, args, fc)
mk_ArgConsInner(head, tail, fc.getNumberOfArguments() - 1, args, fc)
)
or or
fc.getNumberOfArguments() = 0 and fc.getNumberOfArguments() = 0 and
args = HC_EmptyArgs() args = HC_EmptyArgs()
@@ -494,9 +492,7 @@ private predicate analyzableExprCall(ExprCall ec) {
private predicate mk_ExprCall(HashCons hc, HC_Args args, ExprCall ec) { private predicate mk_ExprCall(HashCons hc, HC_Args args, ExprCall ec) {
hc.getAnExpr() = ec.getExpr() and hc.getAnExpr() = ec.getExpr() and
( (
exists(HashCons head, HC_Args tail | mk_ArgConsInner(_, _, ec.getNumberOfArguments() - 1, args, ec)
mk_ArgConsInner(head, tail, ec.getNumberOfArguments() - 1, args, ec)
)
or or
ec.getNumberOfArguments() = 0 and ec.getNumberOfArguments() = 0 and
args = HC_EmptyArgs() args = HC_EmptyArgs()
@@ -516,9 +512,7 @@ private predicate mk_MemberFunctionCall(Function fcn, HashCons qual, HC_Args arg
analyzableMemberFunctionCall(fc) and analyzableMemberFunctionCall(fc) and
hashCons(fc.getQualifier().getFullyConverted()) = qual and hashCons(fc.getQualifier().getFullyConverted()) = qual and
( (
exists(HashCons head, HC_Args tail | mk_ArgConsInner(_, _, fc.getNumberOfArguments() - 1, args, fc)
mk_ArgConsInner(head, tail, fc.getNumberOfArguments() - 1, args, fc)
)
or or
fc.getNumberOfArguments() = 0 and fc.getNumberOfArguments() = 0 and
args = HC_EmptyArgs() args = HC_EmptyArgs()
@@ -541,10 +535,8 @@ private predicate mk_ArgCons(HashCons hc, int i, HC_Args list, Call c) {
analyzableCall(c) and analyzableCall(c) and
hc = hashCons(c.getArgument(i).getFullyConverted()) and hc = hashCons(c.getArgument(i).getFullyConverted()) and
( (
exists(HashCons head, HC_Args tail | mk_ArgConsInner(_, _, i - 1, list, c) and
mk_ArgConsInner(head, tail, i - 1, list, c) and i > 0
i > 0
)
or or
i = 0 and i = 0 and
list = HC_EmptyArgs() list = HC_EmptyArgs()

View File

@@ -303,12 +303,11 @@ affectedbymacroexpansion(
int inv: @macroinvocation ref int inv: @macroinvocation ref
); );
/* case @macroinvocation.kind of
case @macroinvocations.kind of 1 = @macro_expansion
1 = macro expansion | 2 = @other_macro_reference
| 2 = other macro reference ;
;
*/
macroinvocations( macroinvocations(
unique int id: @macroinvocation, unique int id: @macroinvocation,
int macro_id: @ppd_define ref, int macro_id: @ppd_define ref,
@@ -345,28 +344,37 @@ macro_argument_expanded(
); );
/* /*
case @function.kind of case @function.kind of
1 = normal 1 = @normal_function
| 2 = constructor | 2 = @constructor
| 3 = destructor | 3 = @destructor
| 4 = conversion | 4 = @conversion_function
| 5 = operator | 5 = @operator
| 6 = builtin // GCC built-in functions, e.g. __builtin___memcpy_chk | 6 = @builtin_function // GCC built-in functions, e.g. __builtin___memcpy_chk
; ;
*/ */
functions( functions(
unique int id: @function, unique int id: @function,
string name: string ref, string name: string ref,
int kind: int ref int kind: int ref
); );
function_entry_point(int id: @function ref, unique int entry_point: @stmt ref); function_entry_point(
int id: @function ref,
unique int entry_point: @stmt ref
);
function_return_type(int id: @function ref, int return_type: @type ref); function_return_type(
int id: @function ref,
int return_type: @type ref
);
/** If `function` is a coroutine, then this gives the /**
std::experimental::resumable_traits instance associated with it, * If `function` is a coroutine, then this gives the `std::experimental::resumable_traits`
and the variables representing the `handle` and `promise` for it. */ * instance associated with it, and the variables representing the `handle` and `promise`
* for it.
*/
coroutine( coroutine(
unique int function: @function ref, unique int function: @function ref,
int traits: @type ref, int traits: @type ref,
@@ -392,7 +400,10 @@ function_deleted(unique int id: @function ref);
function_defaulted(unique int id: @function ref); function_defaulted(unique int id: @function ref);
member_function_this_type(unique int id: @function ref, int this_type: @type ref); member_function_this_type(
unique int id: @function ref,
int this_type: @type ref
);
#keyset[id, type_id] #keyset[id, type_id]
fun_decls( fun_decls(
@@ -495,7 +506,10 @@ params(
int type_id: @type ref int type_id: @type ref
); );
overrides(int new: @function ref, int old: @function ref); overrides(
int new: @function ref,
int old: @function ref
);
#keyset[id, type_id] #keyset[id, type_id]
membervariables( membervariables(
@@ -541,63 +555,65 @@ enumconstants(
@localscopevariable = @localvariable | @parameter; @localscopevariable = @localvariable | @parameter;
/* /**
Built-in types are the fundamental types, e.g., integral, floating, and void. * Built-in types are the fundamental types, e.g., integral, floating, and void.
*/
case @builtintype.kind of
1 = @errortype
| 2 = @unknowntype
| 3 = @void
| 4 = @boolean
| 5 = @char
| 6 = @unsigned_char
| 7 = @signed_char
| 8 = @short
| 9 = @unsigned_short
| 10 = @signed_short
| 11 = @int
| 12 = @unsigned_int
| 13 = @signed_int
| 14 = @long
| 15 = @unsigned_long
| 16 = @signed_long
| 17 = @long_long
| 18 = @unsigned_long_long
| 19 = @signed_long_long
// ... 20 Microsoft-specific __int8
// ... 21 Microsoft-specific __int16
// ... 22 Microsoft-specific __int32
// ... 23 Microsoft-specific __int64
| 24 = @float
| 25 = @double
| 26 = @long_double
| 27 = @complex_float // C99-specific _Complex float
| 28 = @complex_double // C99-specific _Complex double
| 29 = @complex_long_double // C99-specific _Complex long double
| 30 = @imaginary_float // C99-specific _Imaginary float
| 31 = @imaginary_double // C99-specific _Imaginary double
| 32 = @imaginary_long_double // C99-specific _Imaginary long double
| 33 = @wchar_t // Microsoft-specific
| 34 = @decltype_nullptr // C++11
| 35 = @int128 // __int128
| 36 = @unsigned_int128 // unsigned __int128
| 37 = @signed_int128 // signed __int128
| 38 = @float128 // __float128
| 39 = @complex_float128 // _Complex __float128
| 40 = @decimal32 // _Decimal32
| 41 = @decimal64 // _Decimal64
| 42 = @decimal128 // _Decimal128
| 43 = @char16_t
| 44 = @char32_t
| 45 = @std_float32 // _Float32
| 46 = @float32x // _Float32x
| 47 = @std_float64 // _Float64
| 48 = @float64x // _Float64x
| 49 = @std_float128 // _Float128
| 50 = @float128x // _Float128x
| 51 = @char8_t
| 52 = @float16 // _Float16
| 53 = @complex_float16 // _Complex _Float16
;
case @builtintype.kind of
1 = error
| 2 = unknown
| 3 = void
| 4 = boolean
| 5 = char
| 6 = unsigned_char
| 7 = signed_char
| 8 = short
| 9 = unsigned_short
| 10 = signed_short
| 11 = int
| 12 = unsigned_int
| 13 = signed_int
| 14 = long
| 15 = unsigned_long
| 16 = signed_long
| 17 = long_long
| 18 = unsigned_long_long
| 19 = signed_long_long
| 20 = __int8 // Microsoft-specific
| 21 = __int16 // Microsoft-specific
| 22 = __int32 // Microsoft-specific
| 23 = __int64 // Microsoft-specific
| 24 = float
| 25 = double
| 26 = long_double
| 27 = _Complex_float // C99-specific
| 28 = _Complex_double // C99-specific
| 29 = _Complex_long double // C99-specific
| 30 = _Imaginary_float // C99-specific
| 31 = _Imaginary_double // C99-specific
| 32 = _Imaginary_long_double // C99-specific
| 33 = wchar_t // Microsoft-specific
| 34 = decltype_nullptr // C++11
| 35 = __int128
| 36 = unsigned___int128
| 37 = signed___int128
| 38 = __float128
| 39 = _Complex___float128
| 40 = _Decimal32
| 41 = _Decimal64
| 42 = _Decimal128
| 43 = char16_t
| 44 = char32_t
| 45 = _Float32
| 46 = _Float32x
| 47 = _Float64
| 48 = _Float64x
| 49 = _Float128
| 50 = _Float128x
| 51 = char8_t
;
*/
builtintypes( builtintypes(
unique int id: @builtintype, unique int id: @builtintype,
string name: string ref, string name: string ref,
@@ -607,23 +623,23 @@ builtintypes(
int alignment: int ref int alignment: int ref
); );
/* /**
Derived types are types that are directly derived from existing types and * Derived types are types that are directly derived from existing types and
point to, refer to, transform type data to return a new type. * point to, refer to, transform type data to return a new type.
*/
case @derivedtype.kind of case @derivedtype.kind of
1 = pointer 1 = @pointer
| 2 = reference | 2 = @reference
| 3 = type_with_specifiers | 3 = @type_with_specifiers
| 4 = array | 4 = @array
| 5 = gnu_vector | 5 = @gnu_vector
| 6 = routineptr | 6 = @routineptr
| 7 = routinereference | 7 = @routinereference
| 8 = rvalue_reference // C++11 | 8 = @rvalue_reference // C++11
// ... 9 type_conforming_to_protocols deprecated // ... 9 type_conforming_to_protocols deprecated
| 10 = block | 10 = @block
; ;
*/
derivedtypes( derivedtypes(
unique int id: @derivedtype, unique int id: @derivedtype,
string name: string ref, string name: string ref,
@@ -675,23 +691,24 @@ decltypes(
); );
/* /*
case @usertype.kind of case @usertype.kind of
1 = struct 1 = @struct
| 2 = class | 2 = @class
| 3 = union | 3 = @union
| 4 = enum | 4 = @enum
| 5 = typedef // classic C: typedef typedef type name | 5 = @typedef // classic C: typedef typedef type name
| 6 = template | 6 = @template
| 7 = template_parameter | 7 = @template_parameter
| 8 = template_template_parameter | 8 = @template_template_parameter
| 9 = proxy_class // a proxy class associated with a template parameter | 9 = @proxy_class // a proxy class associated with a template parameter
// ... 10 objc_class deprecated // ... 10 objc_class deprecated
// ... 11 objc_protocol deprecated // ... 11 objc_protocol deprecated
// ... 12 objc_category deprecated // ... 12 objc_category deprecated
| 13 = scoped_enum | 13 = @scoped_enum
| 14 = using_alias // a using name = type style typedef | 14 = @using_alias // a using name = type style typedef
; ;
*/ */
usertypes( usertypes(
unique int id: @usertype, unique int id: @usertype,
string name: string ref, string name: string ref,
@@ -1162,7 +1179,10 @@ case @funbindexpr.kind of
| 2 = @adl_call // a call whose target is only found by ADL | 2 = @adl_call // a call whose target is only found by ADL
; ;
*/ */
iscall(unique int caller: @funbindexpr ref, int kind: int ref); iscall(
unique int caller: @funbindexpr ref,
int kind: int ref
);
numtemplatearguments( numtemplatearguments(
unique int expr_id: @expr ref, unique int expr_id: @expr ref,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
description: Uncomment case splits in dbscheme
compatibility: full

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
description: Introduce (_Complex) _Float16 type
compatibility: full

View File

@@ -44,14 +44,11 @@ predicate eraDate(int year, int month, int day) {
} }
predicate badStructInitialization(Element target, string message) { predicate badStructInitialization(Element target, string message) {
exists( exists(StructLikeClass s, YearFieldAccess year, int yearValue, int monthValue, int dayValue |
StructLikeClass s, YearFieldAccess year, MonthFieldAccess month, DayFieldAccess day,
int yearValue, int monthValue, int dayValue
|
eraDate(yearValue, monthValue, dayValue) and eraDate(yearValue, monthValue, dayValue) and
assignedYear(s, year, yearValue) and assignedYear(s, year, yearValue) and
assignedMonth(s, month, monthValue) and assignedMonth(s, _, monthValue) and
assignedDay(s, day, dayValue) and assignedDay(s, _, dayValue) and
target = year and target = year and
message = "A time struct that is initialized with exact Japanese calendar era start date." message = "A time struct that is initialized with exact Japanese calendar era start date."
) )

View File

@@ -129,9 +129,7 @@ predicate literalIsEnumInitializer(Literal literal) {
exists(EnumConstant ec | ec.getInitializer().getExpr() = literal) exists(EnumConstant ec | ec.getInitializer().getExpr() = literal)
} }
predicate literalInArrayInitializer(Literal literal) { predicate literalInArrayInitializer(Literal literal) { arrayInitializerChild(_, literal) }
exists(AggregateLiteral arrayInit | arrayInitializerChild(arrayInit, literal))
}
predicate arrayInitializerChild(AggregateLiteral parent, Expr e) { predicate arrayInitializerChild(AggregateLiteral parent, Expr e) {
e = parent e = parent

View File

@@ -29,7 +29,7 @@ predicate openDefinition(StackVariable v, ControlFlowNode def) {
} }
predicate openReaches(ControlFlowNode def, ControlFlowNode node) { predicate openReaches(ControlFlowNode def, ControlFlowNode node) {
exists(StackVariable v | openDefinition(v, def) and node = def.getASuccessor()) openDefinition(_, def) and node = def.getASuccessor()
or or
exists(StackVariable v, ControlFlowNode mid | exists(StackVariable v, ControlFlowNode mid |
openDefinition(v, def) and openDefinition(v, def) and

View File

@@ -20,81 +20,190 @@ import semmle.code.cpp.dataflow.DataFlow
import semmle.code.cpp.ir.IR import semmle.code.cpp.ir.IR
import semmle.code.cpp.ir.ValueNumbering import semmle.code.cpp.ir.ValueNumbering
/** An expression appearing as an output argument to a `scanf`-like call */ /**
class ScanfOutput extends Expr { * Holds if `call` is a `scanf`-like function that may write to `output` at index `index`.
ScanfFunctionCall call; *
int varargIndex; * Furthermore, `instr` is the instruction that defines the address of the `index`'th argument
Instruction instr; * of `call`, and `vn` is the value number of `instr.`
ValueNumber valNum; */
predicate isSource(ScanfFunctionCall call, int index, Instruction instr, ValueNumber vn, Expr output) {
output = call.getOutputArgument(index).getFullyConverted() and
instr.getConvertedResultExpression() = output and
vn.getAnInstruction() = instr
}
ScanfOutput() { /**
this = call.getOutputArgument(varargIndex).getFullyConverted() and * Holds if `instr` is control-flow reachable in 0 or more steps from
instr.getConvertedResultExpression() = this and * a call to a `scanf`-like function.
valueNumber(instr) = valNum */
} pragma[nomagic]
predicate fwdFlow0(Instruction instr) {
isSource(_, _, instr, _, _)
or
exists(Instruction prev |
fwdFlow0(prev) and
prev.getASuccessor() = instr
)
}
ScanfFunctionCall getCall() { result = call } /**
* Holds if `instr` is part of the IR translation of `access` that
* is not an expression being deallocated, and `instr` has value
* number `vn`.
*/
predicate isSink(Instruction instr, Access access, ValueNumber vn) {
instr.getAst() = access and
not any(DeallocationExpr dealloc).getFreedExpr() = access and
vn.getAnInstruction() = instr
}
/** /**
* Returns the smallest possible `scanf` return value that would indicate * Holds if `instr` is part of a path from a call to a `scanf`-like function
* success in writing this output argument. * to a use of the written variable.
*/ */
int getMinimumGuardConstant() { pragma[nomagic]
result = predicate revFlow0(Instruction instr) {
varargIndex + 1 - fwdFlow0(instr) and
count(ScanfFormatLiteral f, int n | (
// Special case: %n writes to an argument without reading any input. isSink(instr, _, _)
// It does not increase the count returned by `scanf`.
n <= varargIndex and f.getUse() = call and f.getConversionChar(n) = "n"
)
}
predicate hasGuardedAccess(Access e, boolean isGuarded) {
e = this.getAnAccess() and
if
exists(int value, int minGuard | minGuard = this.getMinimumGuardConstant() |
e.getBasicBlock() = blockGuardedBy(value, "==", call) and minGuard <= value
or
e.getBasicBlock() = blockGuardedBy(value, "<", call) and minGuard - 1 <= value
or
e.getBasicBlock() = blockGuardedBy(value, "<=", call) and minGuard <= value
)
then isGuarded = true
else isGuarded = false
}
/**
* Get a subsequent access of the same underlying storage,
* but before it gets reset or reused in another `scanf` call.
*/
Access getAnAccess() {
exists(Instruction dst |
this.bigStep() = dst and
dst.getAst() = result and
valueNumber(dst) = valNum
)
}
private Instruction bigStep() {
result = this.smallStep(instr)
or or
exists(Instruction i | i = this.bigStep() | result = this.smallStep(i)) exists(Instruction succ | revFlow0(succ) | instr.getASuccessor() = succ)
} )
}
private Instruction smallStep(Instruction i) { /**
instr.getASuccessor*() = i and * Holds if `instr` is part of a path from a call to a `scanf`-like function
i.getASuccessor() = result and * that writes to a variable with value number `vn`, without passing through
not this.isBarrier(result) * redefinitions of the variable.
} */
pragma[nomagic]
private predicate isBarrier(Instruction i) { private predicate fwdFlow(Instruction instr, ValueNumber vn) {
valueNumber(i) = valNum and revFlow0(instr) and
exists(Expr e | i.getAst() = e | (
i = any(StoreInstruction s).getDestinationAddress() isSource(_, _, instr, vn, _)
or or
[e, e.getParent().(AddressOfExpr)] instanceof ScanfOutput exists(Instruction prev |
fwdFlow(prev, vn) and
prev.getASuccessor() = instr and
not isBarrier(instr, vn)
) )
} )
}
/**
* Holds if `instr` is part of a path from a call to a `scanf`-like function
* that writes to a variable with value number `vn`, without passing through
* redefinitions of the variable.
*
* Note: This predicate only holds for the `(intr, vn)` pairs that are also
* control-flow reachable from an argument to a `scanf`-like function call.
*/
pragma[nomagic]
predicate revFlow(Instruction instr, ValueNumber vn) {
fwdFlow(instr, vn) and
(
isSink(instr, _, vn)
or
exists(Instruction succ | revFlow(succ, vn) |
instr.getASuccessor() = succ and
not isBarrier(succ, vn)
)
)
}
/**
* A type that bundles together a reachable instruction with the appropriate
* value number (i.e., the value number that's transferred from the source
* to the sink).
*/
newtype TNode = MkNode(Instruction instr, ValueNumber vn) { revFlow(instr, vn) }
class Node extends MkNode {
ValueNumber vn;
Instruction instr;
Node() { this = MkNode(instr, vn) }
final string toString() { result = instr.toString() }
final Node getASuccessor() { result = MkNode(instr.getASuccessor(), vn) }
final Location getLocation() { result = instr.getLocation() }
}
/**
* Holds if `instr` is an instruction with value number `vn` that is
* used in a store operation, or is overwritten by another call to
* a `scanf`-like function.
*/
private predicate isBarrier(Instruction instr, ValueNumber vn) {
// We only need to compute barriers for instructions that we
// managed to hit during the initial flow stage.
revFlow0(pragma[only_bind_into](instr)) and
valueNumber(instr) = vn and
exists(Expr e | instr.getAst() = e |
instr = any(StoreInstruction s).getDestinationAddress()
or
isSource(_, _, _, _, [e, e.getParent().(AddressOfExpr)])
)
}
/** Holds if `n1` steps to `n2` in a single step. */
predicate isSuccessor(Node n1, Node n2) { n1.getASuccessor() = n2 }
predicate hasFlow(Node n1, Node n2) = fastTC(isSuccessor/2)(n1, n2)
Node getNode(Instruction instr, ValueNumber vn) { result = MkNode(instr, vn) }
/**
* Holds if `source` is the `index`'th argument to the `scanf`-like call `call`, and `sink` is
* an instruction that is part of the translation of `access` which is a transitive
* control-flow successor of `call`.
*
* Furthermore, `source` and `sink` have identical global value numbers.
*/
predicate hasFlow(
Instruction source, ScanfFunctionCall call, int index, Instruction sink, Access access
) {
exists(ValueNumber vn |
isSource(call, index, source, vn, _) and
hasFlow(getNode(source, vn), getNode(sink, vn)) and
isSink(sink, access, vn)
)
}
/**
* Gets the smallest possible `scanf` return value of `call` that would indicate
* success in writing the output argument at index `index`.
*/
int getMinimumGuardConstant(ScanfFunctionCall call, int index) {
isSource(call, index, _, _, _) and
result =
index + 1 -
count(ScanfFormatLiteral f, int n |
// Special case: %n writes to an argument without reading any input.
// It does not increase the count returned by `scanf`.
n <= index and f.getUse() = call and f.getConversionChar(n) = "n"
)
}
/**
* Holds the access to `e` isn't guarded by a check that ensures that `call` returned
* at least `minGuard`.
*/
predicate hasNonGuardedAccess(ScanfFunctionCall call, Access e, int minGuard) {
exists(int index |
hasFlow(_, call, index, _, e) and
minGuard = getMinimumGuardConstant(call, index)
|
not exists(int value |
e.getBasicBlock() = blockGuardedBy(value, "==", call) and minGuard <= value
or
e.getBasicBlock() = blockGuardedBy(value, "<", call) and minGuard - 1 <= value
or
e.getBasicBlock() = blockGuardedBy(value, "<=", call) and minGuard <= value
)
)
} }
/** Returns a block guarded by the assertion of `value op call` */ /** Returns a block guarded by the assertion of `value op call` */
@@ -112,12 +221,9 @@ BasicBlock blockGuardedBy(int value, string op, ScanfFunctionCall call) {
) )
} }
from ScanfOutput output, ScanfFunctionCall call, Access access from ScanfFunctionCall call, Access access, int minGuard
where where hasNonGuardedAccess(call, access, minGuard)
output.getCall() = call and
output.hasGuardedAccess(access, false) and
not exists(DeallocationExpr dealloc | dealloc.getFreedExpr() = access)
select access, select access,
"This variable is read, but may not have been written. " + "This variable is read, but may not have been written. " +
"It should be guarded by a check that the $@ returns at least " + "It should be guarded by a check that the $@ returns at least " + minGuard + ".", call,
output.getMinimumGuardConstant() + ".", call, call.toString() call.toString()

View File

@@ -159,8 +159,8 @@ predicate freeExprOrIndirect(Expr free, Expr freed, string kind) {
freeExpr(free, freed, kind) freeExpr(free, freed, kind)
or or
// indirect free via function call // indirect free via function call
exists(Expr internalFree, Expr internalFreed, int arg | exists(Expr internalFreed, int arg |
freeExprOrIndirect(internalFree, internalFreed, kind) and freeExprOrIndirect(_, internalFreed, kind) and
free.(FunctionCall).getTarget().getParameter(arg) = internalFreed.(VariableAccess).getTarget() and free.(FunctionCall).getTarget().getParameter(arg) = internalFreed.(VariableAccess).getTarget() and
free.(FunctionCall).getArgument(arg) = freed free.(FunctionCall).getArgument(arg) = freed
) )

View File

@@ -119,7 +119,7 @@ class CommentBlock extends Comment {
( (
this instanceof CppStyleComment this instanceof CppStyleComment
implies implies
not exists(CppStyleComment pred, File f | lineInFile(pred, f) + 1 = lineInFile(this, f)) not exists(File f | lineInFile(_, f) + 1 = lineInFile(this, f))
) and ) and
// Ignore comments on the same line as a preprocessor directive. // Ignore comments on the same line as a preprocessor directive.
not exists(Location l | not exists(Location l |

View File

@@ -134,8 +134,8 @@ class NonConstFlow extends TaintTracking::Configuration {
from FormattingFunctionCall call, Expr formatString from FormattingFunctionCall call, Expr formatString
where where
call.getArgument(call.getFormatParameterIndex()) = formatString and call.getArgument(call.getFormatParameterIndex()) = formatString and
exists(NonConstFlow cf, DataFlow::Node source, DataFlow::Node sink | exists(NonConstFlow cf, DataFlow::Node sink |
cf.hasFlow(source, sink) and cf.hasFlowTo(sink) and
sink.asExpr() = formatString sink.asExpr() = formatString
) )
select formatString, select formatString,

View File

@@ -48,9 +48,7 @@ predicate isOptionSet(ConstructorCall cc, int flag, FunctionCall fcSetOptions) {
} }
bindingset[flag] bindingset[flag]
predicate isOptionNotSet(ConstructorCall cc, int flag) { predicate isOptionNotSet(ConstructorCall cc, int flag) { not isOptionSet(cc, flag, _) }
not exists(FunctionCall fcSetOptions | isOptionSet(cc, flag, fcSetOptions))
}
from from
BoostorgAsio::SslContextCallTlsProtocolConfig configConstructor, Expr protocolSource, BoostorgAsio::SslContextCallTlsProtocolConfig configConstructor, Expr protocolSource,

View File

@@ -28,8 +28,8 @@ private newtype LibraryT =
lib.getVersion() = version lib.getVersion() = version
} or } or
LibraryTExternalPackage(@external_package ep, string name, string version) { LibraryTExternalPackage(@external_package ep, string name, string version) {
exists(string namespace, string package_name | exists(string package_name |
external_packages(ep, namespace, package_name, version) and external_packages(ep, _, package_name, version) and
name = package_name name = package_name
) )
} }
@@ -42,8 +42,8 @@ class Library extends LibraryT {
string version; string version;
Library() { Library() {
exists(LibraryElement lib | this = LibraryTElement(lib, name, version)) or this = LibraryTElement(_, name, version) or
exists(@external_package ep | this = LibraryTExternalPackage(ep, name, version)) this = LibraryTExternalPackage(_, name, version)
} }
string getName() { result = name } string getName() { result = name }

View File

@@ -54,7 +54,7 @@ private PreprocessorDirective next(PreprocessorDirective ppd) {
private int level(PreprocessorDirective ppd) { private int level(PreprocessorDirective ppd) {
relevantDirective(ppd, _, _) and relevantDirective(ppd, _, _) and
not exists(PreprocessorDirective previous | ppd = next(previous)) and not ppd = next(_) and
result = 0 result = 0
or or
exists(PreprocessorDirective previous | exists(PreprocessorDirective previous |
@@ -101,8 +101,8 @@ predicate headerGuard(PreprocessorDirective notdef, File f) {
} }
predicate headerGuardChild(PreprocessorDirective open) { predicate headerGuardChild(PreprocessorDirective open) {
exists(File f, PreprocessorDirective headerGuard | exists(File f |
headerGuard(headerGuard, f) and headerGuard(_, f) and
openWithDepth(1, f, open, _) openWithDepth(1, f, open, _)
) )
} }

View File

@@ -64,7 +64,7 @@ class VarargsFunction extends Function {
totalCount = this.totalCount() and totalCount = this.totalCount() and
100 * cnt / totalCount >= 80 and 100 * cnt / totalCount >= 80 and
// terminator value is not used in a non-terminating position // terminator value is not used in a non-terminating position
not exists(FunctionCall fc, int index | this.nonTrailingVarArgValue(fc, index) = result) not this.nonTrailingVarArgValue(_, _) = result
} }
predicate isWhitelisted() { this.hasGlobalName(["open", "fcntl", "ptrace", "mremap"]) } predicate isWhitelisted() { this.hasGlobalName(["open", "fcntl", "ptrace", "mremap"]) }

View File

@@ -21,7 +21,7 @@ import semmle.code.cpp.models.interfaces.ArrayFunction
import semmle.code.cpp.models.interfaces.Allocation import semmle.code.cpp.models.interfaces.Allocation
import semmle.code.cpp.commons.NullTermination import semmle.code.cpp.commons.NullTermination
predicate terminationProblem(AllocationExpr malloc, string msg) { predicate terminationProblem(HeuristicAllocationExpr malloc, string msg) {
// malloc(strlen(...)) // malloc(strlen(...))
exists(StrlenCall strlen | DataFlow::localExprFlow(strlen, malloc.getSizeExpr())) and exists(StrlenCall strlen | DataFlow::localExprFlow(strlen, malloc.getSizeExpr())) and
// flows to a call that implies this is a null-terminated string // flows to a call that implies this is a null-terminated string

View File

@@ -25,9 +25,8 @@ import DataFlow::PathGraph
* Holds if `alloc` is an allocation, and `tainted` is a child of it that is a * Holds if `alloc` is an allocation, and `tainted` is a child of it that is a
* taint sink. * taint sink.
*/ */
predicate allocSink(Expr alloc, DataFlow::Node sink) { predicate allocSink(HeuristicAllocationExpr alloc, DataFlow::Node sink) {
exists(Expr e | e = sink.asConvertedExpr() | exists(Expr e | e = sink.asConvertedExpr() |
isAllocationExpr(alloc) and
e = alloc.getAChild() and e = alloc.getAChild() and
e.getUnspecifiedType() instanceof IntegralType e.getUnspecifiedType() instanceof IntegralType
) )
@@ -89,6 +88,10 @@ class TaintedAllocationSizeConfiguration extends TaintTracking::Configuration {
readsVariable(access.getDef(), checkedVar) and readsVariable(access.getDef(), checkedVar) and
nodeIsBarrierEqualityCandidate(node, access, checkedVar) nodeIsBarrierEqualityCandidate(node, access, checkedVar)
) )
or
// block flow to inside of identified allocation functions (this flow leads
// to duplicate results)
any(HeuristicAllocationFunction f).getAParameter() = node.asParameter()
} }
} }

View File

@@ -15,76 +15,24 @@
import semmle.code.cpp.ir.dataflow.internal.DefaultTaintTrackingImpl import semmle.code.cpp.ir.dataflow.internal.DefaultTaintTrackingImpl
import TaintedWithPath import TaintedWithPath
string getATopLevelDomain() {
result =
[
"com", "ru", "net", "org", "de", "jp", "uk", "br", "pl", "in", "it", "fr", "au", "info", "nl",
"cn", "ir", "es", "cz", "biz", "ca", "eu", "ua", "kr", "za", "co", "gr", "ro", "se", "tw",
"vn", "mx", "ch", "tr", "at", "be", "hu", "tv", "dk", "me", "ar", "us", "no", "sk", "fi",
"id", "cl", "nz", "by", "xyz", "pt", "ie", "il", "kz", "my", "hk", "lt", "cc", "sg", "io",
"edu", "gov"
]
}
predicate hardCodedAddressOrIP(StringLiteral txt) { predicate hardCodedAddressOrIP(StringLiteral txt) {
exists(string s | s = txt.getValueText() | exists(string s | s = txt.getValueText() |
// Hard-coded ip addresses, such as 127.0.0.1 // Hard-coded ip addresses, such as 127.0.0.1
s.regexpMatch("\"[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+\"") or s.regexpMatch("\"[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+\"") or
// Hard-coded addresses such as www.mycompany.com // Hard-coded addresses such as www.mycompany.com
s.matches("\"www.%\"") or s.regexpMatch("\"(www\\.|http:|https:).*\"") or
s.matches("\"http:%\"") or s.regexpMatch("\".*\\.(" + strictconcat(getATopLevelDomain(), "|") + ")\"")
s.matches("\"https:%\"") or
s.matches("\"%.com\"") or
s.matches("\"%.ru\"") or
s.matches("\"%.net\"") or
s.matches("\"%.org\"") or
s.matches("\"%.de\"") or
s.matches("\"%.jp\"") or
s.matches("\"%.uk\"") or
s.matches("\"%.br\"") or
s.matches("\"%.pl\"") or
s.matches("\"%.in\"") or
s.matches("\"%.it\"") or
s.matches("\"%.fr\"") or
s.matches("\"%.au\"") or
s.matches("\"%.info\"") or
s.matches("\"%.nl\"") or
s.matches("\"%.cn\"") or
s.matches("\"%.ir\"") or
s.matches("\"%.es\"") or
s.matches("\"%.cz\"") or
s.matches("\"%.biz\"") or
s.matches("\"%.ca\"") or
s.matches("\"%.eu\"") or
s.matches("\"%.ua\"") or
s.matches("\"%.kr\"") or
s.matches("\"%.za\"") or
s.matches("\"%.co\"") or
s.matches("\"%.gr\"") or
s.matches("\"%.ro\"") or
s.matches("\"%.se\"") or
s.matches("\"%.tw\"") or
s.matches("\"%.vn\"") or
s.matches("\"%.mx\"") or
s.matches("\"%.ch\"") or
s.matches("\"%.tr\"") or
s.matches("\"%.at\"") or
s.matches("\"%.be\"") or
s.matches("\"%.hu\"") or
s.matches("\"%.tv\"") or
s.matches("\"%.dk\"") or
s.matches("\"%.me\"") or
s.matches("\"%.ar\"") or
s.matches("\"%.us\"") or
s.matches("\"%.no\"") or
s.matches("\"%.sk\"") or
s.matches("\"%.fi\"") or
s.matches("\"%.id\"") or
s.matches("\"%.cl\"") or
s.matches("\"%.nz\"") or
s.matches("\"%.by\"") or
s.matches("\"%.xyz\"") or
s.matches("\"%.pt\"") or
s.matches("\"%.ie\"") or
s.matches("\"%.il\"") or
s.matches("\"%.kz\"") or
s.matches("\"%.my\"") or
s.matches("\"%.hk\"") or
s.matches("\"%.lt\"") or
s.matches("\"%.cc\"") or
s.matches("\"%.sg\"") or
s.matches("\"%.io\"") or
s.matches("\"%.edu\"") or
s.matches("\"%.gov\"")
) )
} }

View File

@@ -54,8 +54,8 @@ predicate filenameOperation(FunctionCall op, Expr path) {
} }
predicate isFileName(GVN gvn) { predicate isFileName(GVN gvn) {
exists(FunctionCall op, Expr path | exists(Expr path |
filenameOperation(op, path) and filenameOperation(_, path) and
gvn = globalValueNumber(path) gvn = globalValueNumber(path)
) )
} }

View File

@@ -106,8 +106,8 @@ predicate checksPath(Expr check, Expr checkPath) {
// access to a member variable on the stat buf // access to a member variable on the stat buf
// (morally, this should be a use-use pair, but it seems unlikely // (morally, this should be a use-use pair, but it seems unlikely
// that this variable will get reused in practice) // that this variable will get reused in practice)
exists(Expr call, Expr e, Variable v | exists(Expr e, Variable v |
statCallWithPointer(checkPath, call, e, v) and statCallWithPointer(checkPath, _, e, v) and
check.(VariableAccess).getTarget() = v and check.(VariableAccess).getTarget() = v and
not e.getAChild*() = check // the call that writes to the pointer is not where the pointer is checked. not e.getAChild*() = check // the call that writes to the pointer is not where the pointer is checked.
) )

View File

@@ -100,14 +100,14 @@ predicate isQuotedOrNoSpaceApplicationNameOnCmd(string s) {
from CreateProcessFunctionCall call, string msg1, string msg2 from CreateProcessFunctionCall call, string msg1, string msg2
where where
exists(Expr source, Expr appName, NullAppNameCreateProcessFunctionConfiguration nullAppConfig | exists(Expr appName, NullAppNameCreateProcessFunctionConfiguration nullAppConfig |
appName = call.getArgument(call.getApplicationNameArgumentId()) and appName = call.getArgument(call.getApplicationNameArgumentId()) and
nullAppConfig.hasFlow(DataFlow2::exprNode(source), DataFlow2::exprNode(appName)) and nullAppConfig.hasFlowToExpr(appName) and
msg1 = call.toString() + " with lpApplicationName == NULL (" + appName + ")" msg1 = call.toString() + " with lpApplicationName == NULL (" + appName + ")"
) and ) and
exists(Expr source, Expr cmd, QuotedCommandInCreateProcessFunctionConfiguration quotedConfig | exists(Expr cmd, QuotedCommandInCreateProcessFunctionConfiguration quotedConfig |
cmd = call.getArgument(call.getCommandLineArgumentId()) and cmd = call.getArgument(call.getCommandLineArgumentId()) and
quotedConfig.hasFlow(DataFlow2::exprNode(source), DataFlow2::exprNode(cmd)) and quotedConfig.hasFlowToExpr(cmd) and
msg2 = msg2 =
" and with an unquoted lpCommandLine (" + cmd + " and with an unquoted lpCommandLine (" + cmd +
") introduces a security vulnerability if the path contains spaces." ") introduces a security vulnerability if the path contains spaces."

View File

@@ -100,7 +100,7 @@ Type baseType(Type t) {
*/ */
predicate exprSourceType(Expr use, Type sourceType, Location sourceLoc) { predicate exprSourceType(Expr use, Type sourceType, Location sourceLoc) {
// Reaching definitions. // Reaching definitions.
if exists(SsaDefinition def, StackVariable v | use = def.getAUse(v)) if exists(SsaDefinition def | use = def.getAUse(_))
then then
exists(SsaDefinition def, StackVariable v | use = def.getAUse(v) | exists(SsaDefinition def, StackVariable v | use = def.getAUse(v) |
defSourceType(def, v, sourceType, sourceLoc) defSourceType(def, v, sourceType, sourceLoc)

View File

@@ -83,16 +83,13 @@ where
call.getArgument(2) = nullExpr call.getArgument(2) = nullExpr
) )
or or
exists( exists(VariableAccess var, NullDaclConfig nullDaclConfig, NonNullDaclConfig nonNullDaclConfig |
Expr constassign, VariableAccess var, NullDaclConfig nullDaclConfig,
NonNullDaclConfig nonNullDaclConfig
|
message = message =
"Setting a DACL to NULL in a SECURITY_DESCRIPTOR using variable " + var + "Setting a DACL to NULL in a SECURITY_DESCRIPTOR using variable " + var +
" that is set to NULL will result in an unprotected object." " that is set to NULL will result in an unprotected object."
| |
var = call.getArgument(2) and var = call.getArgument(2) and
nullDaclConfig.hasFlow(DataFlow::exprNode(constassign), DataFlow::exprNode(var)) and nullDaclConfig.hasFlowToExpr(var) and
not nonNullDaclConfig.hasFlow(_, DataFlow::exprNode(var)) not nonNullDaclConfig.hasFlowToExpr(var)
) )
select call, message select call, message

View File

@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* The `cpp/no-space-for-terminator` and `cpp/uncontrolled-allocation-size` queries have been enhanced with heuristic detection of allocations. These queries now find more results.

View File

@@ -0,0 +1,9 @@
- description: Extended and experimental security queries for C and C++
- queries: .
- apply: security-experimental-selectors.yml
from: codeql/suite-helpers
- apply: codeql-suites/exclude-slow-queries.yml
# Excluding problematically slow experimental queries
- exclude:
query path:
- experimental/Security/CWE/CWE-266/IncorrectPrivilegeAssignment.ql

View File

@@ -6,6 +6,7 @@
* @id cpp/off-by-one-array-access * @id cpp/off-by-one-array-access
* @tags reliability * @tags reliability
* security * security
* experimental
*/ */
import cpp import cpp

View File

@@ -7,6 +7,7 @@
* @id cpp/overrun-write * @id cpp/overrun-write
* @tags reliability * @tags reliability
* security * security
* experimental
* external/cwe/cwe-119 * external/cwe/cwe-119
* external/cwe/cwe-131 * external/cwe/cwe-131
*/ */

Some files were not shown because too many files have changed in this diff Show More