Compare commits

..

2729 Commits

Author SHA1 Message Date
James Fletcher
589a097197 Merge pull request #4321 from jf205/sd-216-ql
CodeQL docs: mention `generate query-help` CLI command
2020-09-29 06:40:44 +01:00
james
c2d4a670c9 mention new cli command in query help style guide 2020-09-22 14:23:44 +01:00
james
024e588503 mention new cli command 2020-09-22 14:15:18 +01:00
Tom Hvitved
83340e2a62 Merge pull request #4212 from hvitved/csharp/path-transformers
C#: Implement support for path transformers
2020-09-22 09:20:53 +02:00
Rasmus Wriedt Larsen
637ea4ad6f Merge pull request #4226 from RasmusWL/python-missing-1.25-change-notes
Python: Add missing 1.25 change notes
2020-09-14 13:18:24 +02:00
Tom Hvitved
e549377561 C#: Construct File::TransformedPathLazy lazily
This avoids calling the path transformer for `GeneratedFile`s.
2020-09-14 11:03:00 +02:00
Calum Grant
3414063f2e Update change-notes/1.25/analysis-python.md
Co-authored-by: Rasmus Wriedt Larsen <rasmuswl@github.com>
2020-09-11 13:16:26 +01:00
Rasmus Wriedt Larsen
038688a55c Python: Minor updates to 1.25 change notes
backporting fixes from `@sj`
2020-09-09 10:34:40 +02:00
Anders Schack-Mulligen
86755215ad Merge pull request #4225 from aschackmull/java/changenote-1.25
Java: Add 1.25 change notes.
2020-09-08 14:50:46 +02:00
Anders Schack-Mulligen
02da80aa25 Java: Remove "New Queries" section. 2020-09-08 14:40:33 +02:00
Rasmus Wriedt Larsen
2979f9813e Python: Add missing change notes
I looked through PRs between rc/1.24 and rc/1.25 and added missing change notes for:

- https://github.com/github/codeql/pull/3314
- https://github.com/github/codeql/pull/3302
- https://github.com/github/codeql/pull/3212
- https://github.com/github/codeql/pull/3453
- https://github.com/github/codeql/pull/3407
- https://github.com/github/codeql/pull/3563

```
git log --grep="Merge pull request" --format=oneline rc/1.24..rc/1.25 -- python/
```
2020-09-08 14:27:12 +02:00
Anders Schack-Mulligen
b1e6e3a6f2 Java: Add 1.25 change notes. 2020-09-08 14:18:20 +02:00
Tom Hvitved
4d0a1ee857 Address review comments 2020-09-08 12:54:12 +02:00
Tom Hvitved
37f1ce3122 C#: Implement support for path transformers 2020-09-07 15:02:50 +02:00
Tom Hvitved
14567f5314 C#: Support wild-cards in file patterns
Implements the specification at https://wiki.semmle.com/display/SDmaster/project-layout+format
by compiling file path specifications to regular expressions.
2020-09-07 09:03:56 +02:00
Tom Hvitved
26639a113e C#: Rename Layout.Condition to FilePattern and move to separate file 2020-09-02 19:41:22 +02:00
Jonas Jensen
8e8c65a164 Merge pull request #4146 from jbj/partiallyDefinesVariableAt
C++: Fix two join orders in FlowVar.qll
2020-09-02 13:11:29 +02:00
Jonas Jensen
e949c167fa C++: Add back getSubBasicBlockStart
It turns out this predicate was used in a test, and that use can't be
replaced with the new `partiallyDefinesVariableAt` predicate since
`partiallyDefinesVariableAt` doesn't hold for a `PartialDefinition` that
defines something other than a variable.
2020-08-27 11:14:47 +02:00
Jonas Jensen
f3e98c3bea C++: Fix join order of FlowVar::definedPartiallyAt
This predicate was very slow on kamailio/kamailio:

    (696s) Tuple counts for FlowVar::FlowVar::definedPartiallyAt_dispred#ff:
    703569     ~3%     {3} r1 = SCAN FlowVar::FlowVar_internal::TBlockVar#fff AS I OUTPUT I.<1>, I.<0>, I.<2>
    7679540588 ~3%     {3} r2 = JOIN r1 WITH FlowVar::PartialDefinitions::PartialDefinition::partiallyDefines_dispred#ff_10#join_rhs AS R ON FIRST 1 OUTPUT R.<1>, r1.<1>, r1.<2>
    567217     ~2%     {2} r3 = JOIN r2 WITH project#FlowVar::PartialDefinitions::PartialDefinition#class#fff#2 AS R ON FIRST 2 OUTPUT r2.<2>, r2.<0>
                       return r3

After this change, the predicate takes no time at all:

    (22s) Tuple counts for FlowVar::FlowVar::definedPartiallyAt_dispred#ff:
    703569  ~3%     {3} r1 = SCAN FlowVar::FlowVar_internal::TBlockVar#fff AS I OUTPUT I.<1>, I.<0>, I.<2>
    567217  ~2%     {2} r2 = JOIN r1 WITH FlowVar::PartialDefinitions::PartialDefinition::partiallyDefinesVariableAt#fff_120#join_rhs AS R ON FIRST 2 OUTPUT r1.<2>, R.<2>
                    return r2

Looking at the code, it turned out that the predicates
`partiallyDefines` and `getSubBasicBlockStart` were almost always used
together and could therefore be merged into a single predicate to get
better join orderings. The predicate `partiallyDefinesThis` was never
used.
2020-08-27 09:52:22 +02:00
Jonas Jensen
2b720b332b C++: Fix join order in reachesWithoutAssignment
The negation in this predicate did not get pulled into an
`#antijoin_rhs` predicate but got materialized as part of each
iteration, which meant that the temporary `ControlFlowNode` column did
not get projected away. The tuple counts looked like this on
kamailio/kamailio (iteration 20):

    5724      ~13%      {3} r9 = JOIN r8 WITH BasicBlocks::Cached::bb_successor_cached#ff@staged_ext AS R ON FIRST 2 OUTPUT r8.<2>, r8.<3>, r8.<1>
    5724      ~12%      {3} r10 = JOIN r8 WITH BasicBlocks::Cached::bb_successor_cached#ff@staged_ext AS R ON FIRST 2 OUTPUT r8.<3>, r8.<2>, r8.<1>
    124717061 ~11%      {4} r11 = JOIN r10 WITH project#FlowVar::FlowVar_internal::assignmentLikeOperation#ffff_10#join_rhs AS R ON FIRST 1 OUTPUT R.<1>, r10.<2>, r10.<1>, r10.<0>
    66        ~0%       {3} r12 = JOIN r11 WITH project#BasicBlocks::Cached::basic_block_member AS R ON FIRST 2 OUTPUT r11.<2>, r11.<3>, r11.<1>
    66                  {3} r13 = MATERIALIZE r12 AS antijoin_rhs
    5658      ~14%      {3} r14 = r9 AND NOT r13(r9.<0>, r9.<1>, r9.<2>)

After manually pulling out the join inside the negation, the time per
iteration drops from ~30 to <1s. The pipeline above is replaced with

    892394  ~0%      {4} r6 = r5 AND NOT FlowVar::FlowVar_internal::assignsToVar#fb AS R(r5.<3>, r5.<2>)
    892394  ~0%      {4} r7 = SCAN r6 OUTPUT r6.<1>, r6.<3>, r6.<0>, r6.<2>
    5658    ~11%     {3} r8 = JOIN r7 WITH BasicBlocks::Cached::bb_successor_cached#ff@staged_ext AS R ON FIRST 2 OUTPUT r7.<2>, r7.<1>, r7.<3>
2020-08-27 09:52:22 +02:00
Max Schaefer
c9e22ab271 Merge pull request #4133 from owen-mc/docs/add-go-frameworks
Add go frameworks to docs
2020-08-26 07:47:28 +01:00
Owen Mansel-Chan
b4c3ea41d1 Add go frameworks to docs 2020-08-26 07:26:31 +01:00
James Fletcher
97c107b926 Merge pull request #4091 from jf205/link-quotes-ql-handbook
QL language reference: update links to match GitHub docs style
2020-08-18 14:37:55 +01:00
Shati Patel
378e3b2df4 Merge pull request #4075 from shati-patel/docs-branch-rename
Docs: Rename default branch
2020-08-18 14:26:34 +01:00
james
8ad6947308 add quotes to several more links 2020-08-18 13:19:23 +01:00
james
b6b424dd00 remove spurious spaces 2020-08-17 21:14:08 +01:00
james
b150c6497f update links 2020-08-17 21:08:33 +01:00
CodeQL CI
a19963e9b7 Merge pull request #3930 from erik-krogh/fastProp
Approved by esbena
2020-08-17 13:42:12 +01:00
Shati Patel
b212af08a6 Docs: Rename default branch 2020-08-14 12:03:00 +01:00
Shati Patel
1d4978aa6e Merge pull request #4046 from jf205/link-quotes-learn-ql
Learning CodeQL docs: update links to match GitHub docs style
2020-08-14 11:57:09 +01:00
Robert Marsh
4a07bd5a15 Merge pull request #4032 from jbj/asExpr-docs
C++: Clarify the docs on DataFlow::Node::asExpr
2020-08-13 16:54:09 -04:00
Jonas Jensen
36373fce9b C++: Deprecate DataFlow::definitionByReferenceNode
This predicate name was only used in IR data flow, not in AST data flow.
2020-08-13 15:27:35 +02:00
Jonas Jensen
3f383784cd C++: QLDoc formatting fixup 2020-08-13 15:27:35 +02:00
Jonas Jensen
f70a17b858 C++: clearer wording in asExpr doc
Co-authored-by: Aditya Sharad <6874315+adityasharad@users.noreply.github.com>
2020-08-13 15:27:35 +02:00
Jonas Jensen
5ae8b02bde C++: Clarify the docs on DataFlow::Node::asExpr
For IR data flow I also added a `definitionByReferenceNodeFromArgument`
predicate to improve compatibility with AST data flow.
2020-08-13 15:27:35 +02:00
Shati Patel
b1be3672e7 Merge pull request #4058 from shati-patel/metadata
Docs: Add metadata option missing from reference table
2020-08-13 11:31:52 +01:00
james
5fed92b2d0 remove new line 2020-08-12 20:30:24 +01:00
Shati Patel
78948139fd Add metadata option missing from reference table 2020-08-12 17:25:54 +01:00
james
bc02348a83 fix up table and remove another extra space 2020-08-12 09:54:42 +01:00
James Fletcher
f9f5a69a9f Apply suggestions from @hubwriter's code review
Co-authored-by: Alistair Christie <54933897+hubwriter@users.noreply.github.com>
2020-08-12 09:53:12 +01:00
james
4d723ba276 remove some spurious spaces 2020-08-12 09:48:00 +01:00
james
0dbe64eee7 address some review comments
stray quote
2020-08-12 09:38:00 +01:00
CodeQL CI
e603f5cc48 Merge pull request #4052 from github/max-schaefer-patch-2
Approved by shati-patel
2020-08-12 09:29:37 +01:00
Max Schaefer
6dad027eb6 Go: Claim support for 1.15
Go 1.15 was just released, and there are [no changes](https://golang.org/doc/go1.15#language) to the language, so we might as well list it as supported.
2020-08-12 09:11:57 +01:00
james
0ff10c319d update lots of links 2020-08-11 17:31:50 +01:00
Erik Krogh Kristensen
a1394c363a more consistent naming of predicates 2020-08-11 14:49:51 +02:00
Erik Krogh Kristensen
2974c4923f introduce and use isAPropertyWrite 2020-08-11 14:43:25 +02:00
Erik Krogh Kristensen
8f6721e087 add explanation for purity-check in getANodeAfterWrite/getANodeBeforeWrite and move them into an internal module 2020-08-11 14:40:13 +02:00
Erik Krogh Kristensen
9e768375ce mention purity check in docstring for maybeAssignsAccessedPropInBlock 2020-08-11 14:40:02 +02:00
Erik Krogh Kristensen
374b1b7b97 apply manual magic in both cases in maybeAssignsAccessedPropInBlock 2020-08-11 14:24:49 +02:00
CodeQL CI
d214cecf4d Merge pull request #4028 from asger-semmle/js/scope-manager-npe
Approved by max-schaefer
2020-08-10 09:47:09 +01:00
Asger Feldthaus
64f58b74f6 JS: Fix extractor crash when some parameters have no type annotation 2020-08-07 11:56:54 +01:00
James Fletcher
7f8bf21325 Merge pull request #4016 from jf205/learn-codeql/styles
CodeQL docs: update CSS and master page template
2020-08-05 14:20:13 +01:00
james
364cc19dea docs: update styles 2020-08-05 11:39:43 +01:00
Tom Hvitved
63115a36f7 Merge pull request #3994 from hvitved/csharp/dataflow/library-aps-adjust
C#: More type-based adjustment of library-flow access paths
2020-08-04 14:33:54 +02:00
Anders Schack-Mulligen
68441bdf99 Merge pull request #3987 from Marcono1234/patch-1
[Java] Improve InsecureJavaMail.qhelp references
2020-08-04 12:12:38 +02:00
Anders Schack-Mulligen
cdea0f05b0 Merge pull request #3946 from aibaars/util-collections-2
Java: Clean up ContainerFlow: address outstanding comments
2020-08-04 10:27:22 +02:00
Erik Krogh Kristensen
eccfade928 rewrite parts of the DeadStoreOfProperty query 2020-08-04 10:25:05 +02:00
Erik Krogh Kristensen
e629e6bbb0 changes based on review 2020-08-04 10:25:05 +02:00
Erik Krogh Kristensen
8131618382 revert making rankedAccessPath private 2020-08-04 10:25:05 +02:00
Erik Krogh Kristensen
97aa3cc8a3 rewrite DeadStoreOfProperty to improve worst-case complexity 2020-08-04 10:25:05 +02:00
Erik Krogh Kristensen
dbeef312ca add some TypeScript tests to DeadStoreOfProperty 2020-08-04 10:25:05 +02:00
Tom Hvitved
71933a4d8a Merge pull request #4009 from hvitved/csharp/extractor-pack-files
C#: Add CodeQL extractor pack files
2020-08-03 19:33:26 +02:00
CodeQL CI
8855ab8c8c Merge pull request #3835 from Raz0r/js/xss-protocol-sinks
Approved by erik-krogh
2020-08-03 15:40:05 +01:00
CodeQL CI
a4f8b19ae4 Merge pull request #3876 from erik-krogh/CWE078-Correctness
Approved by esbena
2020-08-03 15:38:51 +01:00
Tom Hvitved
d1db7b350f C#: Add CodeQL extractor pack files 2020-08-03 14:36:06 +02:00
CodeQL CI
c8e5db189a Merge pull request #3913 from erik-krogh/topmost
Approved by asgerf
2020-08-03 13:18:22 +01:00
Erik Krogh Kristensen
f5cc14f980 fix typo 2020-08-03 13:49:21 +02:00
CodeQL CI
0bbdc70cdb Merge pull request #3864 from erik-krogh/exprString
Approved by asgerf, esbena
2020-08-03 09:25:17 +01:00
Tamás Vajk
dd1a8e9b28 Merge pull request #3991 from tamasvajk/feature/vscode
Add VS Code tasks to build and test the C# bits
2020-08-03 09:52:46 +02:00
Calum Grant
595ab442e6 Merge pull request #3996 from yoff/SharedDataflow_Syntax
Python: Test all expressions that incur dataflow
2020-07-31 17:45:00 +01:00
Rasmus Lerchedahl Petersen
3e13056140 Python: Address most review comments 2020-07-31 17:20:58 +02:00
Tamás Vajk
c8dc2ee611 Merge pull request #3993 from tamasvajk/remove-noise
Turn off C# auto-compile on topmost folder
2020-07-31 16:59:36 +02:00
Tamas Vajk
17e256b2c7 C#: Add VS Code tasks to build and test the C# bits 2020-07-31 16:56:51 +02:00
Rasmus Lerchedahl Petersen
e8ce62e211 Python: Fix missing flow annotation 2020-07-31 15:28:27 +02:00
Rasmus Lerchedahl Petersen
e13cf2e126 Python: fix formatting 2020-07-31 14:25:09 +02:00
Tom Hvitved
54ce73b40e Merge pull request #3995 from hvitved/csharp/fix-alerts
C#: Fix a few alerts
2020-07-31 14:07:35 +02:00
Rasmus Lerchedahl Petersen
29493f5bd7 Python: Make the coverage test a path query 2020-07-31 12:38:57 +02:00
CodeQL CI
18fa6b613d Merge pull request #3998 from ceh-forks/ceh-fix-typos
Approved by shati-patel
2020-07-31 11:08:58 +01:00
Emil Hessman
246ae575be Fix typos 2020-07-31 06:59:55 +02:00
Arthur Baars
7e72ef350e Merge pull request #3975 from aibaars/lgtm-suites
CodeQL: complete LGTM suites
2020-07-30 18:39:01 +02:00
Rasmus Lerchedahl Petersen
133e18edd9 Python: Annotate missing flow 2020-07-30 18:13:39 +02:00
Rasmus Lerchedahl Petersen
1467d6b419 Python: Test all expressions that incur dataflow 2020-07-30 17:51:17 +02:00
semmle-qlci
5b1d25591e Merge pull request #3979 from max-schaefer/js/more-comand-injection-models
Approved by asgerf
2020-07-30 15:10:46 +01:00
Tom Hvitved
e08e7cdf34 C#: Fix a few alerts 2020-07-30 16:03:36 +02:00
Tom Hvitved
07f1e133f3 C#: More type-based adjustment of library-flow access paths
This change removes the restriction that only access paths of length 1 can
have the head adjusted, based on type information from the call to the relevant
library-code callable.
2020-07-30 15:48:41 +02:00
Shati Patel
437baf160e Merge pull request #3973 from shati-patel/sd-189
Add basic LGTM tutorials to CodeQL sphinx project
2020-07-30 14:37:48 +01:00
Tamas Vajk
0ea5f347f7 Turn off C# auto-compile on topmost folder
If the C# extension is installed, then it reports 25k+ errors on the C# extractor until it is properly built. This is pure noise because the solution would be opened and built from the correct subdirectory. This commit disables the C# compilation altogether.
2020-07-30 15:26:16 +02:00
Tom Hvitved
632713c475 Merge pull request #3986 from hvitved/csharp/null-maybe-null-coalescing-assignment
C#: Fix false-positives in `cs/dereferenced-value-may-be-null`
2020-07-30 14:20:00 +02:00
Tom Hvitved
05307b8757 C#: Remove more FPs in cs/dereferenced-value-may-be-null 2020-07-30 12:16:59 +02:00
Tom Hvitved
4f4d9d35be C#: Add more nullness tests 2020-07-30 12:15:49 +02:00
Shati Patel
4da74dea28 Update C# example 2020-07-30 10:57:17 +01:00
Shati Patel
0a4b828432 Update docs/language/learn-ql/java/basic-query-java.rst
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2020-07-30 11:55:28 +02:00
Shati Patel
9aaf20e6f2 Update docs/language/learn-ql/java/basic-query-java.rst
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2020-07-30 11:55:14 +02:00
Robert Marsh
ddbec50c07 Merge pull request #3990 from MathiasVP/mathiasvp/fix-qldoc-SemanticStackVariable
C++: Fix QLDoc for `SemanticStackVariable`
2020-07-29 12:27:29 -07:00
Tom Hvitved
bec415c5c1 Merge pull request #3988 from hvitved/csharp/collection-flow-change-note
C#: Add change note
2020-07-29 19:58:54 +02:00
Arthur Baars
5bad003c0c Add qlpack.yml files for example queries 2020-07-29 16:57:04 +02:00
Mathias Vorreiter Pedersen
978bf3aefc C++: Make QLDoc comment represent a valid C++ template 2020-07-29 15:59:19 +02:00
Tom Hvitved
f91043e08e C#: Add change note 2020-07-29 10:27:40 +02:00
Tom Hvitved
4345b167ec Merge pull request #3935 from github/henrymercer/fix-broken-doc-link
C#: Fix broken link to ECMA-335
2020-07-29 10:04:08 +02:00
Marcono1234
5942bc6a43 Improve InsecureJavaMail.qhelp references 2020-07-29 01:45:27 +02:00
Arthur Baars
c4041e55ba CodeQL: complete LGTM suites 2020-07-28 20:40:44 +02:00
Tom Hvitved
d39a33655f C#: Fix false-positives in cs/dereferenced-value-may-be-null
Dereferencing an expression of a nullable type should only be reported when
the expression is not clearly non-null.
2020-07-28 16:27:36 +02:00
Shati Patel
a79f09f1de Add basic query for Go 2020-07-28 15:25:59 +02:00
Shati Patel
8e8c43a25b Add basic query for JavaScript 2020-07-28 13:54:06 +02:00
Shati Patel
9edf1646c9 Add basic queries for C#, Java, and Python 2020-07-28 12:18:45 +02:00
Shati Patel
0f3599039f Update docs/language/learn-ql/cpp/basic-query-cpp.rst
Co-authored-by: James Fletcher <42464962+jf205@users.noreply.github.com>
2020-07-28 11:49:17 +02:00
Tom Hvitved
ce2368de96 C#: Add tests for null-coalescing assignment 2020-07-28 11:07:47 +02:00
Tom Hvitved
c5a4a6be05 Merge pull request #3871 from hvitved/csharp/autobuilder/dotnet-delegate
C#: Introduce delegate type in autobuilder
2020-07-27 16:51:24 +02:00
Taus
f40242dc3f Merge pull request #3396 from porcupineyhairs/python-ssti
Python : Add query to detect Server Side Template Injection
2020-07-27 14:43:39 +02:00
Max Schaefer
91762ec274 JavaScript: Add partial model for opener.
3.5M weekly downloads.

Note that we do not treat the first argument as a command-injection sink. While it is possible to inject commands that way, it is more likely to cause false positives where the user input is concatenated with some prefix that makes the opening heuristic decide to treat it as a URL.
2020-07-27 11:42:32 +01:00
Max Schaefer
9aa26fa4bc JavaScript: Add model for foreground-child.
>1M weekly downloads, so seems worth doing.
2020-07-27 11:37:06 +01:00
Max Schaefer
2f842042ea JavaScript: Model another execa function relevant for command injection. 2020-07-27 11:34:04 +01:00
Tom Hvitved
f5c1de8a17 Merge pull request #3960 from calumgrant/cs/tag-inefficient-containskey
C#: Fix tags typo
2020-07-27 11:44:58 +02:00
Calum Grant
09f45ac9fe Merge pull request #3877 from calumgrant/cs/autobuilder-alerts
C#: Make fields readonly
2020-07-27 10:43:04 +01:00
Shati Patel
db09ca7b68 Update queries + outdated note 2020-07-27 11:42:10 +02:00
Shati Patel
bb05db5c98 Convert C/C++ article 2020-07-24 12:07:17 +02:00
Porcupiney Hairs
7a71ca3e0f fix tests. 2020-07-24 00:57:19 +05:30
Rasmus Wriedt Larsen
c49311e69e Python: Fix JinjaSSTISinks.expected 2020-07-23 20:11:27 +02:00
Rasmus Wriedt Larsen
03d22fa8e3 Python: Fix filenames in qhelp 2020-07-23 17:32:01 +02:00
Rasmus Wriedt Larsen
e283d289fd Python: Update TemplateInjection.qhelp
Moved things around so there is only a single `<example>` tag (and had to rewrite contents a bit).
2020-07-23 17:23:26 +02:00
Porcupiney Hairs
1e7921e575 add qhelp and fix tests. 2020-07-23 20:04:32 +05:30
porcupineyhairs
8e85dc755a Apply suggestions from code review
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
2020-07-23 19:37:40 +05:30
semmle-qlci
bb5b161d72 Merge pull request #3972 from shati-patel/merge-rc
Approved by mchammer01
2020-07-23 11:30:45 +01:00
Shati Patel
2326f31749 Merge branch 'rc/1.24' into merge-rc 2020-07-23 12:18:30 +02:00
Rasmus Wriedt Larsen
a97f942a17 Python: Autoformat 2020-07-23 11:38:34 +02:00
Felicity Chapman
40c998fa13 Merge pull request #3969 from alexey-tereshenkov-oxb/master
Python: Fix typo in qhelp file
2020-07-23 10:37:37 +01:00
Mathias Vorreiter Pedersen
a4242bcb5d Merge pull request #3962 from rdmarsh2/ir-barrierguard-checks-expr
C++: make IR BarrierGuard::checks match AST
2020-07-23 09:21:37 +02:00
Alexey Tereshenkov
7840dfce3b Put the closing tag back 2020-07-22 20:51:29 +01:00
Alexey Tereshenkov
e2939377e9 Update python/ql/src/Expressions/WrongNumberArgumentsForFormat.qhelp
Co-authored-by: intrigus-lgtm <60750685+intrigus-lgtm@users.noreply.github.com>
2020-07-22 20:07:34 +01:00
Alexey Tereshenkov
a6eb3caa5f Update python/ql/src/Expressions/WrongNumberArgumentsForFormat.qhelp
Co-authored-by: Felicity Chapman <felicitymay@github.com>
2020-07-22 20:07:27 +01:00
Alexey Tereshenkov
a5f566b563 Fix typo 2020-07-22 15:39:50 +01:00
Rasmus Wriedt Larsen
91e6222662 Python: Fix SSTI query by importing UntrustedStringKind
Without a concrete ExternalStringKind class, there will be no flow for
ExternalStringKind by default.
2020-07-21 18:01:27 +05:30
Rasmus Wriedt Larsen
9dbd280d31 Python: Fix syntax error 2020-07-21 18:01:27 +05:30
Porcupiney Hairs
49df4169cf Python : Add query to detect Server Side Template Injection 2020-07-21 18:01:27 +05:30
Robert Marsh
0bb6d0c7ca C++: make IR BarrierGuard::checks match AST 2020-07-17 15:43:57 -07:00
Calum Grant
79f412ff54 C#: Fix tags typo 2020-07-17 15:30:33 +01:00
Geoffrey White
2e5af67626 Merge pull request #3952 from MathiasVP/output-parameter-index-for-UserDefinedFormattingFunction
C++: Add getOutputParameterIndex override to UserDefinedFormattingFunction class.
2020-07-15 18:11:09 +01:00
Nick Rolfe
c7b668193b Merge pull request #3929 from igfoo/static_assert
C++: Give static assertions an enclosing element
2020-07-15 18:03:26 +01:00
Mathias Vorreiter Pedersen
289a908eb8 C++: Update qldoc in reponse to PR comments 2020-07-15 16:24:47 +02:00
Mathias Vorreiter Pedersen
c4b97a3a62 C++: Accept more test changes 2020-07-15 16:19:51 +02:00
Mathias Vorreiter Pedersen
edc33b6516 C++: Add getOutputParameterIndex override to UserDefinedFormattingFunction and accept test changes 2020-07-15 14:46:08 +02:00
Mathias Vorreiter Pedersen
d711c22cd2 C++: Add testcase demonstrating lost query results 2020-07-15 14:42:45 +02:00
Robert Marsh
7dd2677746 Merge pull request #3950 from MathiasVP/simple-range-analysis-unsigned-multiplication-tests
C++: Add test cases for range analysis for unsigned multiplication
2020-07-14 14:18:06 -07:00
Mathias Vorreiter Pedersen
174b30461a C++: Fix syntax error in testfile 2020-07-14 19:47:21 +02:00
Calum Grant
dcff87fb2e Merge pull request #3366 from hvitved/csharp/dataflow/arrays
C#: Precise data-flow for collections
2020-07-14 17:12:29 +01:00
Mathias Vorreiter Pedersen
834ad92453 C++: Add test cases for unsigned multiplication and fix missing return value in existing tests 2020-07-14 16:57:47 +02:00
semmle-qlci
0bee0687cb Merge pull request #3911 from RasmusWL/python-call-graph-tracing
Approved by tausbn
2020-07-14 15:33:45 +01:00
Ian Lynagh
616bad7b5c C++: Add an upgrade script 2020-07-14 13:53:46 +01:00
Ian Lynagh
c254de464a C++: Update stats following static_asserts change 2020-07-14 13:53:01 +01:00
Rasmus Wriedt Larsen
f1601d643a Python: autoformat 2020-07-14 14:12:56 +02:00
Rasmus Wriedt Larsen
1d9c3b3bcd Python: call-graph tracing: callable => callee
to use consistent naming
2020-07-14 14:12:02 +02:00
semmle-qlci
f8c03dcae6 Merge pull request #3924 from RasmusWL/python-metrics-queries-for-dist-compare
Approved by tausbn
2020-07-14 13:03:02 +01:00
Rasmus Wriedt Larsen
ee42d0839e Python: Rename target => callee
To use a standardised naming :)
2020-07-14 11:26:05 +02:00
Rasmus Wriedt Larsen
d913d33289 Python: Autoformat 2020-07-14 11:21:55 +02:00
Taus
ee13e87f3b Merge pull request #3947 from RasmusWL/python-fix-tests
Python: Make experimental/library-tests/CallGraph pass for Python 2
2020-07-13 22:10:34 +02:00
Arthur Baars
67b6018079 Merge pull request #3729 from luchua-bc/java-hardcoded-aws-credentials
Java: Hardcoded AWS credentials
2020-07-13 18:04:42 +02:00
Rasmus Wriedt Larsen
dc7d92ba2f Python: Autoformat experimental/library-tests/CallGraph/ 2020-07-13 16:20:02 +02:00
Rasmus Wriedt Larsen
83bd14b687 Python: Make experimental/library-tests/CallGraph pass for Python 2
The import doesn't actually work the intended way, so running
```
$ python python/ql/test/experimental/library-tests/CallGraph/test.py
```

will procude no output. but our extractor will extract the things we need, so
for a quick fix this will need to suffice.
2020-07-13 14:52:28 +02:00
luchua-bc
12803f1f53 Merge Hardcoded AWS Credentials check into the mail source folder 2020-07-13 12:22:34 +00:00
Arthur Baars
b1e604b490 Java: treat Stack.push as data flow instead of taint flow 2020-07-13 11:36:34 +02:00
Arthur Baars
a484aff76d Java: improve comments 2020-07-13 11:09:05 +02:00
Geoffrey White
6519629472 Merge pull request #3942 from MathiasVP/remove-abstract-preprocessor
C++: Remove abstract classes from Preprocessor.qll
2020-07-13 10:00:50 +01:00
Rasmus Wriedt Larsen
3127bb27d0 Python: Remove strange empty line 2020-07-13 10:55:43 +02:00
Rasmus Wriedt Larsen
0b6c3ff99d Python: Don't use PointsTo module name in metrics query
To avoid confusion with the normal PointsTo module in
python/ql/src/semmle/python/pointsto/PointsTo.qll
2020-07-13 10:46:03 +02:00
Rasmus Wriedt Larsen
a7d23063de Python: Fix grammar
Co-authored-by: Taus <tausbn@github.com>
2020-07-13 10:44:19 +02:00
Mathias Vorreiter Pedersen
d6da318645 C++: Remove abstract classes from Preprocessor.qll 2020-07-10 21:55:14 +02:00
Dave Bartolomeo
912c50a881 Merge pull request #3937 from MathiasVP/replace-result-type-with-ir-result-type
C++: Replace getResultType() with getResultIRType()
2020-07-10 13:37:30 -04:00
Geoffrey White
456a05ecd5 Merge pull request #3940 from MathiasVP/remove-abstract-stmt
C++: Remove abstract classes and predicates from Stmt.qll
2020-07-10 16:41:45 +01:00
Mathias Vorreiter Pedersen
7cc83da97a C++: Remove @stmt_while from the TConditionalStmt union type. 2020-07-10 15:51:34 +02:00
Taus
df3eb9f9c5 Merge pull request #3790 from RasmusWL/python-add-annotated-callgraph-tests
Python: Add annotated call-graph tests
2020-07-10 15:38:38 +02:00
Geoffrey White
2941f413f9 Merge pull request #3931 from aeisenberg/aeisenberg/cpp-print-ast
Add the printAst.ql contextual query for C++
2020-07-10 14:08:25 +01:00
Mathias Vorreiter Pedersen
567984af3d C++: Remove abstract classes from Stmt.qll 2020-07-10 14:21:56 +02:00
Anders Schack-Mulligen
a1d272e870 Merge pull request #3918 from aibaars/organise-container-flow
Java: Clean up ContainerFlow, consider more methods
2020-07-10 14:19:44 +02:00
Arthur Baars
43b61038e9 Drop Map.merge as taint step 2020-07-10 13:00:14 +02:00
Robert Marsh
05685cc896 Merge pull request #3919 from dbartol/dbartol/IgnoreAutoBuilder
C++: Add `.gitignore` for autobuilder
2020-07-09 15:02:52 -07:00
Andrew Eisenberg
782759d58e Add the printAst.ql contextual query for C++
This query will be used by the VS Code extension for viewing
ASTs of C/C++ files.
2020-07-09 08:28:49 -07:00
Arthur Baars
0d33a77ee3 Fix modelling of Stack.push
Stack.push(E) returns its argument, it does not propagate taint from
the stack to the return value.
2020-07-09 16:16:29 +02:00
Anders Schack-Mulligen
879551fc6a Merge pull request #3936 from aibaars/object-clone
Java: model Object.clone
2020-07-09 16:09:01 +02:00
Anders Schack-Mulligen
c8b9b779ae Merge pull request #3927 from rvermeulen/java-importable-cwe-601
Java: Move `UrlRedirectSink` into importable library
2020-07-09 16:03:29 +02:00
Anders Schack-Mulligen
99a4f8fd0b Merge pull request #3926 from rvermeulen/java-importable-cwe-089
Java: Move `QueryInjectionSink` into importable library
2020-07-09 16:00:56 +02:00
Mathias Vorreiter Pedersen
002f930dba C#: Sync identical files 2020-07-09 15:54:42 +02:00
Jonas Jensen
2fa54552f0 Merge pull request #3914 from geoffw0/cc_followup
C++: Repair swap taint tests
2020-07-09 15:54:40 +02:00
Mathias Vorreiter Pedersen
85a8280b30 C++: Replace getResultType() with getResultIRType() in IR dataflow 2020-07-09 15:54:15 +02:00
Mathias Vorreiter Pedersen
7029739691 C++: Replace getResultType() with getResultIRType() in IR range analysis 2020-07-09 15:53:54 +02:00
Mathias Vorreiter Pedersen
a405a95b68 C++: Introduce isSigned() and isUnsigned() predicates on IRIntegerType to mirror IntegralType 2020-07-09 15:52:09 +02:00
Jonas Jensen
277185a792 Merge pull request #3925 from geoffw0/rangefixup
C++: Add getFullyConverted() where missing in SimpleRangeAnalysis
2020-07-09 15:45:58 +02:00
Remco Vermeulen
7428a8cd95 Add missing java import 2020-07-09 15:06:26 +02:00
Remco Vermeulen
d3db4fa5b2 Add missing java import 2020-07-09 15:04:16 +02:00
Remco Vermeulen
54d6c8b5f4 Mark ServletUrlRedirectSink private 2020-07-09 15:03:51 +02:00
Arthur Baars
e183171fea Java: model Object.clone 2020-07-09 14:50:29 +02:00
Henry Mercer
3d711b8cd1 C#: Fix broken link to ECMA-335 2020-07-09 13:15:22 +01:00
Remco Vermeulen
1212feab28 Add file-level qldoc 2020-07-09 14:11:59 +02:00
Remco Vermeulen
99228d8bc2 Optimize imports 2020-07-09 14:09:39 +02:00
Remco Vermeulen
ba9f3e2a1e Join ServletUrlRedirectSink with UrlRedirectSink 2020-07-09 14:08:43 +02:00
Remco Vermeulen
88f4b224c3 Extend UrlRedirectSink from DataFlow::Node 2020-07-09 14:05:54 +02:00
Remco Vermeulen
f8078f1125 Remove superfluous imports 2020-07-09 13:43:10 +02:00
Arthur Baars
d3d58795f1 Java: ContainerFlow add comments
Some method variants are captured by a super class. Added some comments
to indicate where this happens to make review of missing methods easier
in the future.
2020-07-09 12:46:57 +02:00
semmle-qlci
e167b87150 Merge pull request #3932 from max-schaefer/portals-additions
Approved by esbena
2020-07-09 11:43:45 +01:00
Remco Vermeulen
9a84abf259 Generalize QueryInjectionSink
Extends from the more general DataFlow::Node instead of
DataFlow::ExprNode
2020-07-09 12:32:17 +02:00
Arthur Baars
24c6e506aa Java: ContainerFlow: RValue -> Expr
While most flow for a qualifierToArgumentStep goes through a variable use
this is not always the case. Therefore it is best to remove the restriction
to RValue to allow taint steps to use postupdate nodes.

See also: ba86dea657
2020-07-09 12:20:48 +02:00
Arthur Baars
0bd103ac05 Java: add tests for Container taint steps 2020-07-09 12:15:38 +02:00
Rasmus Wriedt Larsen
e7c89dc24b Python: Fix grammar
Co-authored-by: intrigus-lgtm <60750685+intrigus-lgtm@users.noreply.github.com>
2020-07-09 10:39:58 +02:00
Remco Vermeulen
c01844a39e Add file-level qldoc 2020-07-09 10:30:31 +02:00
Max Schaefer
7a1410e0d5 JavaScript: Update and expand tests. 2020-07-09 09:25:52 +01:00
Remco Vermeulen
42e261ac02 Move SqlInjectionSink and PersistenceQueryInjectionSink
Join SqlInjectionSink and PersistenceQueryInjectionSink with
QueryInjectionSink to make its definition more transparent.
2020-07-09 10:21:24 +02:00
Remco Vermeulen
d07d21c9e2 Fix import 2020-07-09 10:20:53 +02:00
Anders Schack-Mulligen
777dc6305c Merge pull request #3893 from aibaars/set-map-list-copy-of
Java: model some new Set,List,Map methods
2020-07-09 10:18:12 +02:00
Max Schaefer
1c47260bde JavaScript: Add support for global variables to portals. 2020-07-09 09:12:56 +01:00
Max Schaefer
c40ef0556a JavaScript: Broaden scope of imports considered relevant to portals.
Previously, we only considered an import relevant to portals if the path it imported was declared as a dependency. This falls down for deep imports where a specific module inside the package is imported rather than the default entry point, for imports of built-in modules like `fs`, and in cases where a developer simply forgets to declare a dependency.

So instead we now consider all imports relevant whose path does not start with a dot or a slash.
2020-07-09 09:09:44 +01:00
Max Schaefer
8b4b5781e6 JavaScript: Add utility predicate getBasePortal(i).
This iterates the existing `getBasePortal()` predicate `i` times.
2020-07-09 09:08:18 +01:00
Robert Marsh
0e66d0892b Merge pull request #3785 from MathiasVP/dataflow-operand-nodes
C++: Operands as dataflow nodes
2020-07-08 14:50:54 -07:00
Arthur Baars
6367eb9ee8 Address review comments 2020-07-08 22:08:27 +02:00
Ian Lynagh
71b70b4bd0 C++: Give static_assert's an enclosing element 2020-07-08 17:10:43 +01:00
Remco Vermeulen
170be9ffe8 Move UrlRedirectSink into importable library
- The `UrlRedirect` class is renamed to `ServletUrlRedirect`.
- Abstract class `UrlRedirectSink` is defined that can be imported and
used to customise CWE-601 via Customizations.qll
2020-07-08 16:47:51 +02:00
Jonas Jensen
0bbbfe58cf Merge pull request #3916 from geoffw0/cc_followup2
C++: Add missing constructor taint test
2020-07-08 16:35:47 +02:00
Remco Vermeulen
06517c6f82 Move QueryInjectionSink into importable library
This enables defining of new sinks to customise the CWE-089 queries.
2020-07-08 16:24:06 +02:00
Arthur Baars
e8f216c761 Merge remote-tracking branch 'upstream/master' into set-map-list-copy-of 2020-07-08 15:11:13 +02:00
Anders Schack-Mulligen
bf5c5297d3 Merge pull request #3897 from aibaars/util-objects
Java: data flow for `java.util.Objects`
2020-07-08 15:07:50 +02:00
Anders Schack-Mulligen
528f250af3 Merge pull request #3653 from lcartey/java/improve-spring-support
Java: Improve modelling of Spring requests, flow steps and XSS sinks
2020-07-08 15:00:14 +02:00
Luke Cartey
443c13d516 Merge pull request #2 from aschackmull/java/spring-3653-2
Java: Fix qltests for https://github.com/github/codeql/pull/3653
2020-07-08 13:19:45 +01:00
Anders Schack-Mulligen
b88ebd69c1 Java: Fix OgnlInjection qltest 2020-07-08 14:12:27 +02:00
Anders Schack-Mulligen
a4fe4f41b9 Java: Fix JndiInjection qltest 2020-07-08 14:09:08 +02:00
Anders Schack-Mulligen
581d496167 Java: Fix LdapInjection qltest 2020-07-08 14:04:01 +02:00
Arthur Baars
72a24972e7 Apply suggestions from code review
Co-authored-by: Anders Schack-Mulligen <aschackmull@users.noreply.github.com>
2020-07-08 13:30:24 +02:00
Rasmus Wriedt Larsen
32219e58c0 Python: Add basic call-graph metric queries
For use with dist-compare
2020-07-08 13:29:54 +02:00
Anders Schack-Mulligen
48e4759632 Merge branch 'master' into java/spring-3653-2 2020-07-08 13:06:51 +02:00
semmle-qlci
6ef7288848 Merge pull request #3922 from aschackmull/java/stub-cleanup
Approved by aibaars
2020-07-08 12:04:39 +01:00
Geoffrey White
61dfebceb9 C++: Add getFullyConverted() as suggested. 2020-07-08 11:28:39 +01:00
Erik Krogh Kristensen
022cafebd3 make sure the consisntecy-checking library does not mix configurations 2020-07-08 10:28:41 +02:00
Anders Schack-Mulligen
b38839e84e Merge pull request #3920 from Marcono1234/patch-3
Improve VariableAssign.getSource documentation
2020-07-08 10:25:13 +02:00
Erik Krogh Kristensen
ec38df69b3 update consistency comments for CWE-918 2020-07-08 10:24:55 +02:00
Erik Krogh Kristensen
c5285f7418 update inconsistency comment for CWE-843 2020-07-08 10:16:43 +02:00
Erik Krogh Kristensen
45b6906a0d move comments to match alert location for CWE-834 2020-07-08 10:16:04 +02:00
Erik Krogh Kristensen
71a3d49d2b update comments to match alert location for CWE-807 2020-07-08 10:15:26 +02:00
Erik Krogh Kristensen
d814e73023 update comment position to match alert location for CWE-798 2020-07-08 10:12:12 +02:00
Erik Krogh Kristensen
bcffc97de7 update comment position to match alert location for CWE-776 2020-07-08 10:10:31 +02:00
Erik Krogh Kristensen
2235634347 update consistency comments for CWE-754 2020-07-08 10:08:51 +02:00
Anders Schack-Mulligen
6eac8e82a3 Java: Consolidate spring-ldap-2.3.2 stubs. 2020-07-08 10:08:44 +02:00
Erik Krogh Kristensen
0d64a0f2c8 update consistency comment for CWE-730 2020-07-08 10:07:34 +02:00
Erik Krogh Kristensen
5a87628478 update consistency comments for CWE-611 2020-07-08 10:03:03 +02:00
Erik Krogh Kristensen
1f1c09af02 update consistency comments for CWE-601 2020-07-08 10:02:29 +02:00
Erik Krogh Kristensen
ce6a211340 update inconsistency comment for CWE-506 2020-07-08 10:01:40 +02:00
Erik Krogh Kristensen
bf36137834 update inconsistency comment for CWE-346 2020-07-08 10:01:04 +02:00
Erik Krogh Kristensen
16b0427dc4 update inconsistency comment for CWE-338 2020-07-08 10:00:19 +02:00
Anders Schack-Mulligen
40b9d34ab9 Java: Consolidate springframework-5.2.3 stubs 2020-07-08 09:57:48 +02:00
Erik Krogh Kristensen
9bcbedde46 update consistency comment in passwords.js 2020-07-08 09:55:00 +02:00
Erik Krogh Kristensen
664c5e64b4 add [INCONSISTENCY] comment in CodeInjection test 2020-07-08 09:48:12 +02:00
Erik Krogh Kristensen
00e900f1b1 only include named topmost package.json files for js/shell-command-constructed-from-input 2020-07-08 09:25:08 +02:00
Anders Schack-Mulligen
c166fee198 Merge pull request #3894 from aibaars/util-arrays
Java: model taint for java.util.Arrays
2020-07-08 09:06:40 +02:00
Marcono1234
00a61816c0 Improve VariableAssign.getSource documentation 2020-07-07 22:37:58 +02:00
Dave Bartolomeo
6f7a8d029c C++: Move .gitignore into autobuilder directory
On second thought, I'm going to make this apply only to the AutoBuilder directory. C# has it in the root of `csharp`, but they need it for their extractor as well.
2020-07-07 16:31:46 -04:00
Dave Bartolomeo
d3bcc1dae4 C++: Add .gitignore for autobuilder
C# has its own additional `.gitignore` to ignore the output files of the AutoBuilder build. Now that we have our own AutoBuilder in C++, we need the same thing.
2020-07-07 16:27:43 -04:00
Taus
548fceb306 Merge pull request #3917 from RasmusWL/python-fix-experimental-tests
Python: Fix experimental tests
2020-07-07 22:05:47 +02:00
Arthur Baars
441bf98ce7 Java: add Vector::copyInto, BlockingQueue::drainTo 2020-07-07 20:35:02 +02:00
Arthur Baars
c9ae2c8b2c Java: ContainerFlow: organize taintPreservingArgumentToQualifier 2020-07-07 20:32:10 +02:00
Arthur Baars
5d73b99fd1 Java: ContainerFlow: organize taintPreservingQualifierToMethod 2020-07-07 19:53:11 +02:00
Rasmus Wriedt Larsen
7306f58e57 Python: Fix experimental tests 2020-07-07 19:44:43 +02:00
Rasmus Wriedt Larsen
1d5ef381ae Merge pull request #3915 from tausbn/python-qlformat-everything-again
Python: Autoformat everything using `qlformat`.
2020-07-07 18:48:05 +02:00
Arthur Baars
940fec5669 Drop taint tracking for Arrays.{deepToString,toString} 2020-07-07 17:26:49 +02:00
Arthur Baars
583f7f914e Drop taint tracking for Arrays.{setAll, parallelSetAll, parallelPrefix} 2020-07-07 17:22:30 +02:00
Taus Brock-Nannestad
45eccb2521 Python: Fix test failures. 2020-07-07 17:01:17 +02:00
Geoffrey White
bc7c83a5d6 C++: Add taint test cases confirming that constructor definitions do no need to be present. 2020-07-07 16:01:13 +01:00
Arthur Baars
9cf6601d02 Java: Data flow for java.util.Objects 2020-07-07 16:58:22 +02:00
Ian Lynagh
22666dd46e Merge pull request #3875 from igfoo/is_constexpr
C++: Accept test changes for is_constexpr
2020-07-07 15:47:28 +01:00
Taus
df4d145490 Merge branch 'master' into python-qlformat-everything-again 2020-07-07 16:33:21 +02:00
Jonas Jensen
32fcfcf97c Merge pull request #3912 from aschackmull/location-doc
C++/C#/JavaScript/Python: Port Location qldoc update.
2020-07-07 15:54:34 +02:00
Taus Brock-Nannestad
f07a7bf8cf Python: Autoformat everything using qlformat.
Will need subsequent PRs fixing up test failures (due to deprecated
methods moving around), but other than that everything should be
straight-forward.
2020-07-07 15:43:52 +02:00
Raz0r
3487ec17d0 add tests 2020-07-07 16:26:14 +03:00
Erik Krogh Kristensen
d85d9b9b5b autoformat 2020-07-07 16:21:03 +03:00
Arseny Reutov
b46b49586a Apply suggestions from code review
`interpretsValueAsJavaScript` -> `interpretsValueAsJavaScriptUrl`

Co-authored-by: Asger F <asgerf@github.com>
2020-07-07 16:21:03 +03:00
Raz0r
54db6c4a39 [js/client-side-unvalidated-url-redirection] add interpretsValueAsJavaScript predicate 2020-07-07 16:21:03 +03:00
Luke Cartey
3fef5cabf1 Merge pull request #1 from aschackmull/java/spring-3653
Java: Review changes for https://github.com/github/codeql/pull/3653
2020-07-07 12:07:33 +01:00
Anders Schack-Mulligen
67db1df00c C++/C#/JavaScript/Python: Port Location qldoc update. 2020-07-07 11:39:27 +02:00
Rasmus Wriedt Larsen
42227c625d Python: Fix grammar
Co-authored-by: intrigus-lgtm <60750685+intrigus-lgtm@users.noreply.github.com>
2020-07-07 11:33:54 +02:00
Rasmus Wriedt Larsen
27d1512a75 Python: MWE for call-graph tracing and ql comparison 2020-07-07 11:05:03 +02:00
Shati Patel
eaec2d722c Merge pull request #3888 from shati-patel/go-docs
Learning CodeQL: Add new library modeling guide (Go)
2020-07-07 09:54:39 +01:00
Anders Schack-Mulligen
993506d781 Merge pull request #3820 from Marcono1234/patch-2
Add missing java.nio.file.Files methods to FileReadWrite.qll
2020-07-07 10:29:17 +02:00
Anders Schack-Mulligen
173e108606 Merge pull request #3907 from Marcono1234/patch-1
Java: Clarify documentation for Location predicate results
2020-07-07 07:58:39 +02:00
semmle-qlci
f2ce125e61 Merge pull request #3902 from Marcono1234/fix-outdated-query-links
Approved by shati-patel
2020-07-06 21:13:05 +01:00
Marcono1234
5649254dbd Fix broken link formatting in introduce-libraries-java.rst
Co-authored-by: Shati Patel <42641846+shati-patel@users.noreply.github.com>
2020-07-06 20:35:11 +02:00
Ian Lynagh
0d9b18dbd7 C++: Accept test changes for is_constexpr
Generated copy and move constructors may now be marked as constexpr.
2020-07-06 19:24:39 +01:00
Geoffrey White
0caa17ab10 C++: Test the new methods. 2020-07-06 18:47:56 +01:00
Geoffrey White
52e501c41d C++: Extend the 'swap' taint tests with methods that do not have recognizable signatures (copy/move assignment). 2020-07-06 18:44:37 +01:00
Shati Patel
f98491a052 Apply suggestions from code review
Co-authored-by: James Fletcher <42464962+jf205@users.noreply.github.com>
2020-07-06 18:30:01 +01:00
Erik Krogh Kristensen
442ee8d1cc add consistency-checking for CWE-089 2020-07-06 19:02:50 +02:00
Marcono1234
0a9686709b Fix wrong method name 2020-07-06 18:52:07 +02:00
semmle-qlci
fe0c5a9ea6 Merge pull request #3892 from asger-semmle/js/redirect-starts-with-sanitizer
Approved by esbena
2020-07-06 17:04:30 +01:00
Rasmus Wriedt Larsen
d00e7396c4 Python: Consistently use camelCase in annotated call-graph tests 2020-07-06 17:59:16 +02:00
Rasmus Wriedt Larsen
65c4e6c02a Python: Disable class instantiation annotation for now
Adjusting test setup properly requires some deep thinking, and I don't think I'm
ready to do that right now. Added a TODO instead.
2020-07-06 17:48:15 +02:00
Rasmus Wriedt Larsen
cd8ea78420 Python: Autoformat 2020-07-06 17:34:19 +02:00
Rasmus Wriedt Larsen
9e252d5465 Python: Explain random example 2020-07-06 17:30:49 +02:00
Rasmus Wriedt Larsen
849159b279 Python: Unlimited import depth 2020-07-06 17:30:26 +02:00
Rasmus Wriedt Larsen
acfc62cad6 Python: Fix grammar
Co-authored-by: Taus <tausbn@gmail.com>
2020-07-06 17:21:29 +02:00
Anders Schack-Mulligen
f98460cfd0 Java: Use SpringHttpEntity class. 2020-07-06 16:54:20 +02:00
Anders Schack-Mulligen
ae21de90b6 Java: Misc grammar and formatting. 2020-07-06 16:19:42 +02:00
Anders Schack-Mulligen
b06d1c715a Java: More qldoc and some formatting. 2020-07-06 16:04:14 +02:00
Marcono1234
6ff8508d01 Java: Clarify documentation for Location predicate results 2020-07-06 15:46:11 +02:00
semmle-qlci
6d80445f24 Merge pull request #3851 from erik-krogh/queryStuff
Approved by esbena
2020-07-06 14:40:41 +01:00
Anders Schack-Mulligen
5e9e7feddc Java: Add some qldoc and minor formatting. 2020-07-06 15:39:20 +02:00
Anders Schack-Mulligen
e6658c5110 Java: Cleanup TaintTrackingUtil.qll 2020-07-06 15:35:16 +02:00
Erik Krogh Kristensen
9a944625d1 autoformat 2020-07-06 15:17:15 +02:00
Anders Schack-Mulligen
5d8f9a79f1 Java: Misc grammar fixes. 2020-07-06 14:50:33 +02:00
Anders Schack-Mulligen
a80e663ab5 Java: Minor typo fix and autoformat 2020-07-06 14:43:01 +02:00
Anders Schack-Mulligen
2ce0921935 Java: Clean up SpringHttp.qll 2020-07-06 14:35:53 +02:00
Anders Schack-Mulligen
2ae15f9ace Java: Remove list, map, and StringReplaceMethod flow steps. 2020-07-06 14:19:13 +02:00
Anders Schack-Mulligen
a41c2d8abf Java: Make a few predicates private and autoformat SpringController. 2020-07-06 14:18:16 +02:00
Erik Krogh Kristensen
2a8b37e004 update consistency comments in unsafe-jquery-plugin.js
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-07-06 14:15:23 +02:00
Erik Krogh Kristensen
c986f3bb7c add consistency checking for CWE-079 2020-07-06 13:42:35 +02:00
Erik Krogh Kristensen
dc8042adeb introduce conistency-checking for CWE-078 2020-07-06 12:47:56 +02:00
semmle-qlci
13c3513d76 Merge pull request #3905 from erik-krogh/unsafeShellTypo
Approved by esbena
2020-07-06 11:41:56 +01:00
Arthur Baars
f917b9e3cb Merge pull request #3608 from aschackmull/java/backport-switchexpr-cfg-fix
Java: Backport missing CFG edge fix for switch expressions
2020-07-06 11:43:16 +02:00
Arthur Baars
d2734b2903 Merge pull request #3684 from aschackmull/java/javadoctag-qldoc
Java: Improve qldoc for JavadocTag.
2020-07-06 11:42:04 +02:00
Arthur Baars
98d24101b1 Merge pull request #3687 from aschackmull/java/getanenclosingstmt
Java: Add Expr.getAnEnclosingStmt.
2020-07-06 11:41:21 +02:00
semmle-qlci
73d606d2c3 Merge pull request #3844 from github/esbena-patch-3
Approved by erik-krogh
2020-07-06 09:47:59 +01:00
Erik Krogh Kristensen
8585312271 fix typo in js/shell-command-constructed-from-input 2020-07-06 10:33:49 +02:00
Marcono1234
2d9b52f750 Update query console links in source-locations.rst, replace deprecated predicates
Removes 'eclipse-cdt/cdt' and 'gradle/gradle' from the queried projects
because they cannot be queried currently, and instead queries all demo
projects which are currently available.
2020-07-05 22:32:53 +02:00
Marcono1234
7b4960c9a7 Update query console links in javadoc.rst
Removes 'gradle/gradle' from the queried projects because it cannot be
queried currently, and instead queries all demo projects which are currently
available.
2020-07-05 22:06:39 +02:00
Marcono1234
b835d7879c Update query console links in introduce-libraries-java.rst
Removes 'eclipse-cdt/cdt' and 'gradle/gradle' from the queried projects
because they cannot be queried currently, and instead queries all demo
projects which are currently available.
2020-07-05 22:06:26 +02:00
Marcono1234
2b3b64cdbc Update query console links in expressions-statements.rst
Removes 'eclipse-cdt/cdt' and 'gradle/gradle' from the queried projects
because they cannot be queried currently, and instead queries all demo
projects which are currently available.
2020-07-05 20:04:36 +02:00
Marcono1234
c10a598670 Update query console links in call-graph.rst
Removes 'eclipse-cdt/cdt' and 'gradle/gradle' from the queried projects
because they cannot be queried currently, and instead queries all demo
projects which are currently available.
2020-07-05 19:54:27 +02:00
Marcono1234
ab2456630c Update query console links in annotations.rst
Removes 'eclipse-cdt/cdt' and 'gradle/gradle' from the queried projects
because they cannot be queried currently, and instead queries all demo
projects which are currently available.
2020-07-05 19:43:48 +02:00
Marcono1234
13ffd7307c Update query console links in types-class-hierarchy.rst
Removes 'gradle/gradle' from the queried projects because it cannot be
queried currently, and instead queries all demo projects which are currently
available.
2020-07-05 19:20:42 +02:00
Marcono1234
f8e474f89a Add missing java.nio.file.Files methods to FileReadWrite.qll 2020-07-05 18:39:26 +02:00
Arthur Baars
19a481f809 Java: Arrays: add tests 2020-07-03 17:15:17 +02:00
Arthur Baars
0b89efbee4 Java: model Arrays::addList 2020-07-03 17:15:17 +02:00
Arthur Baars
a07af79fff Java: model java.util.Arrays 2020-07-03 17:15:17 +02:00
Arthur Baars
1485f7c876 Java: model some new Set,List,Map methods
Models the taint propagation for the copyOf(..),
of(..), ofEntries(..) and entry(..) methods
2020-07-03 17:14:53 +02:00
Max Schaefer
163257a6c5 Merge pull request #3891 from aibaars/exclude-experimental
CodeQL: exclude `experimental`  queries from LGTM suites
2020-07-03 16:14:29 +01:00
Arthur Baars
c629f6b13a Merge pull request #3869 from aibaars/util-collections
Java: model java.util.Collections
2020-07-03 17:09:14 +02:00
yoff
687bb4dfc8 Merge pull request #3890 from github/tausbn-add-paths-ignore-to-code-scanning-config
Code Scanning: Don't scan the Python directory.
2020-07-03 16:03:41 +02:00
Taus
01c4852360 Merge pull request #3701 from yoff/SharedDataflow
Python: Start using the shared data flow libraries
2020-07-03 16:03:20 +02:00
Asger Feldthaus
b5104ae42d JS: Add StartsWith sanitizer 2020-07-03 14:46:07 +01:00
Asger Feldthaus
4c06eb8bfe JS: Add test showing FPs 2020-07-03 14:45:42 +01:00
Rasmus Lerchedahl Petersen
fe9520b50b Python: correct doc for toString 2020-07-03 15:04:54 +02:00
Arthur Baars
5fff41f35b Don't track taint on Map keys 2020-07-03 14:47:25 +02:00
Rasmus Lerchedahl Petersen
33cf96ccb8 Python: Address review comments 2020-07-03 14:11:58 +02:00
Anders Schack-Mulligen
6de612a566 Java: Split SpringWebRequestGetMethod into its own class. 2020-07-03 14:06:54 +02:00
Arthur Baars
2b248fb24f CodeQL: exclude queries from CodeScanning suites 2020-07-03 14:03:00 +02:00
Arthur Baars
bb01dbd2ae CodeQL: exclude queries from LGTM suites 2020-07-03 14:01:20 +02:00
Taus
b99ec29f6e Code Scanning: Additionally exclude Java and C++. 2020-07-03 13:56:25 +02:00
Taus
39bc978573 Code Scanning: Don't scan the Python directory.
... Possibly some of the other language teams want to get on this? 🙂 
If so, give me a shout!
2020-07-03 13:46:30 +02:00
yoff
d201eb2c12 Update python/ql/src/experimental/dataflow/internal/DataFlowPrivate.qll
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
2020-07-03 13:33:27 +02:00
yoff
59d611ddd5 Update python/ql/src/experimental/dataflow/internal/DataFlowPublic.qll
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
2020-07-03 13:32:03 +02:00
yoff
8891fbf006 Update python/ql/src/experimental/dataflow/internal/DataFlowPublic.qll
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
2020-07-03 13:31:38 +02:00
yoff
40a6728748 Update python/ql/src/experimental/dataflow/internal/TaintTrackingPrivate.qll
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
2020-07-03 13:30:10 +02:00
Rasmus Lerchedahl Petersen
e3666004cf Python: add some links to readme 2020-07-03 10:37:38 +02:00
Shati Patel
45bd492161 Learning CodeQL: Add new library modeling guide (Go) 2020-07-03 08:10:44 +01:00
Rasmus Lerchedahl Petersen
a9e0288e5b Python: exclude global vars from local flow 2020-07-03 08:41:10 +02:00
Rasmus Lerchedahl Petersen
bdc68ce6b6 Python: refactor Node class 2020-07-03 08:01:44 +02:00
Erik Krogh Kristensen
078b6a8df2 autoformat 2020-07-03 00:21:55 +02:00
semmle-qlci
04a0d47ab9 Merge pull request #3870 from hvitved/csharp/cfg/cond-out-param
Approved by calumgrant
2020-07-02 18:48:05 +01:00
Arthur Baars
5f2a5f1b55 Java: Collections: add tests 2020-07-02 19:18:02 +02:00
Calum Grant
03cc4e179e C#: Make fields readonly 2020-07-02 17:47:17 +01:00
Taus
ba634af86e Merge pull request #3362 from RasmusWL/python-keyword-only-args
Python: properly support keyword only arguments
2020-07-02 18:21:59 +02:00
Rasmus Lerchedahl Petersen
5f18fb427a Python: update TODO 2020-07-02 16:20:38 +02:00
Erik Krogh Kristensen
261821b32c Merge remote-tracking branch 'upstream/master' into queryStuff 2020-07-02 16:08:05 +02:00
semmle-qlci
b5c8f2238b Merge pull request #3805 from esbena/js/seal-freeze-flow
Approved by asgerf
2020-07-02 13:54:54 +01:00
Rasmus Wriedt Larsen
513c2974bd Merge branch 'master' into python-keyword-only-args 2020-07-02 14:48:32 +02:00
Erik Krogh Kristensen
ceb19292cb autoformat 2020-07-02 14:47:08 +02:00
Erik Krogh Kristensen
2b0a091921 split out type-tracking into two predicates, to avoid catastrophic join-order 2020-07-02 14:28:28 +02:00
Rasmus Wriedt Larsen
b2f8638ff0 Python: Update dbscheme with new comment 2020-07-02 14:17:55 +02:00
Taus
eecc3ca5dd Merge pull request #3503 from RasmusWL/python-fix-django-taint-sinks
Python: Fix django taint sinks
2020-07-02 13:32:35 +02:00
Tom Hvitved
7dfc584159 C#: Introduce delegate type in autobuilder 2020-07-02 13:29:49 +02:00
Tom Hvitved
527a099a26 C#: Fix CFG for conditional method calls with out parameters 2020-07-02 13:12:53 +02:00
Tom Hvitved
090205d9e9 C#: Add CFG test for conditional call to method with out parameter 2020-07-02 13:09:40 +02:00
Arthur Baars
21a4b8d6c0 Java: remove useless casts 2020-07-02 13:03:15 +02:00
Arthur Baars
d80bf3395f Add Navigable variants and sort method names 2020-07-02 13:02:38 +02:00
semmle-qlci
97128b1475 Merge pull request #3829 from asger-semmle/js/xss-substr
Approved by erik-krogh
2020-07-02 11:58:32 +01:00
Arthur Baars
e7b495e7d3 Java: model Collections::addAll 2020-07-02 12:38:22 +02:00
Rasmus Wriedt Larsen
26b7a301d6 Merge branch 'master' into python-keyword-only-args 2020-07-02 12:27:02 +02:00
Arthur Baars
5cf5c77b09 Java: model java.util.Collections 2020-07-02 12:25:55 +02:00
Tom Hvitved
d01904d404 Merge pull request #3846 from hvitved/csharp/autobuilder-refactor
C#: Factor C++ parts out of autobuilder
2020-07-02 12:02:04 +02:00
Rasmus Wriedt Larsen
67be45f045 Merge branch 'master' into python-fix-django-taint-sinks 2020-07-02 11:55:42 +02:00
Rasmus Wriedt Larsen
9a82927187 Python: Autoformat 2020-07-02 11:54:41 +02:00
Rasmus Wriedt Larsen
a947d151e5 Python: Django changes now backwards compatible deprecation 2020-07-02 11:53:25 +02:00
Rasmus Wriedt Larsen
4a7bfbe091 Python: Use .matches instead of .indexOf() = 0 2020-07-02 11:43:23 +02:00
Anders Schack-Mulligen
50fee5c4a1 Merge pull request #3817 from Marcono1234/patch-1
Fix outdated query console link
2020-07-02 11:41:19 +02:00
Erik Krogh Kristensen
f60a7489b5 ignore parents that doesn't have all constant roots when deciding which roots to compute getStringValue for 2020-07-02 10:39:41 +02:00
Erik Krogh Kristensen
bbdeca367b use getUnderlyingValue() to find leafs of a string-concat 2020-07-02 10:38:02 +02:00
Erik Krogh Kristensen
226e066db8 use strictconcat instead of concat 2020-07-02 10:12:43 +02:00
semmle-qlci
0bf1f75274 Merge pull request #3850 from aschackmull/dataflow/doc
Approved by hvitved
2020-07-02 09:04:35 +01:00
semmle-qlci
bfb734e1d7 Merge pull request #3832 from asger-semmle/js/typescript-in-html-files3
Approved by erik-krogh
2020-07-02 08:30:45 +01:00
Anders Schack-Mulligen
c78427569e Update docs/ql-libraries/dataflow/dataflow.md
Co-authored-by: Tom Hvitved <hvitved@github.com>
2020-07-02 09:24:33 +02:00
Jonas Jensen
2bd84a3a5e Merge pull request #3865 from geoffw0/bufferwrite-fixup
C++: 'modelling' -> 'modeling' part 2.
2020-07-02 08:37:19 +02:00
Jonas Jensen
62a656de0f Merge pull request #3860 from dbartol/codeql-c-analysis-team/40/2
C++: QLDoc cleanup
2020-07-02 08:32:44 +02:00
semmle-qlci
45ef3ec4a8 Merge pull request #3619 from erik-krogh/CWE022-Correctness
Approved by asgerf
2020-07-01 20:07:58 +01:00
Erik Krogh Kristensen
6f54bb1613 only calculate getStringValue for concatenation roots 2020-07-01 20:48:20 +02:00
Tom Hvitved
398a95c65f C#: Remove unused field 2020-07-01 20:06:46 +02:00
Tom Hvitved
498ee9b5f5 C#: Factor C++ parts out of autobuilder 2020-07-01 20:06:46 +02:00
Geoffrey White
a260df9035 C++: 'modelling' -> 'modeling'. 2020-07-01 17:49:22 +01:00
Mathias Vorreiter Pedersen
bb9c8881d6 Merge pull request #3786 from geoffw0/bufferwritecleanup
C++: Clean up BufferWrite.qll
2020-07-01 18:33:26 +02:00
Dave Bartolomeo
f0215d1748 C++: Fix typo 2020-07-01 11:57:56 -04:00
Geoffrey White
8d8e47dc29 C++: QLDoc other straightforward model implementations. 2020-07-01 16:25:24 +01:00
Geoffrey White
e39c115746 C++: QLDoc Strcpy (as demanded by the tests). 2020-07-01 16:23:50 +01:00
semmle-qlci
66a6fe7317 Merge pull request #3853 from max-schaefer/js/canonical-names
Approved by asgerf
2020-07-01 16:08:59 +01:00
Rasmus Lerchedahl Petersen
0b11e77457 Python: make compile 2020-07-01 16:55:44 +02:00
Rasmus Lerchedahl Petersen
0175d5be0c Sync dataflow files 2020-07-01 16:44:11 +02:00
Rasmus Lerchedahl Petersen
7fb97d75f4 Merge branch 'master' of github.com:github/codeql into SharedDataflow
to get updated dataflow files
2020-07-01 16:43:14 +02:00
Dave Bartolomeo
566d7fad63 C++: Autoformat some more 2020-07-01 10:14:35 -04:00
Shati Patel
6429fe48aa Merge pull request #3862 from shati-patel/shati-patel-patch-1
Small terminology update
2020-07-01 14:58:50 +01:00
Max Schaefer
a6d8073987 JavaScript: Make getADefinition and getAnAccess available on all CanonicalNames. 2020-07-01 14:42:03 +01:00
Esben Sparre Andreasen
3ca6031ae5 JS: rename predicate 2020-07-01 15:27:28 +02:00
Esben Sparre Andreasen
75451e349a JS: teach the dataflow library identity functions Object.freeze/seal 2020-07-01 15:27:28 +02:00
Esben Sparre Andreasen
33c52761d4 JS: more dataflow and global access path testing 2020-07-01 15:26:25 +02:00
Anders Schack-Mulligen
20aed81476 Merge pull request #3863 from intrigus-lgtm/patch-2
Fix typo, add Oxford comma
2020-07-01 15:01:49 +02:00
Tom Hvitved
9e3a6e8d5e Merge remote-tracking branch 'upstream/master' into csharp/dataflow/arrays 2020-07-01 14:50:26 +02:00
intrigus-lgtm
cabd275baa Fix typo, add Oxford comma 2020-07-01 14:49:09 +02:00
Anders Schack-Mulligen
4aac70d3da Dataflow: update doc based on review. 2020-07-01 14:45:49 +02:00
Shati Patel
5af5f40ae1 Small terminology update 2020-07-01 13:41:50 +01:00
Anders Schack-Mulligen
7d057598d8 Merge pull request #3857 from jbj/flowthrough-bigstep-perf
C++: Remove big-step relation in flow-through code
2020-07-01 14:23:23 +02:00
Jonas Jensen
50cd759718 Merge pull request #3733 from geoffw0/models5
C++: Constructor and assignment models
2020-07-01 13:58:27 +02:00
Erik Krogh Kristensen
3157cd724d add noSQL tests for type-tracking req.query 2020-07-01 11:45:09 +02:00
Erik Krogh Kristensen
bace2994c3 add test for type-tracking req.params 2020-07-01 11:38:54 +02:00
Anders Schack-Mulligen
38b73ff684 Merge pull request #3854 from hvitved/dataflow/node-type-interface
Data flow: Replace `getErasedRepr()` and `Node::getTypeBound()` with `getNodeType()`
2020-07-01 11:37:19 +02:00
Erik Krogh Kristensen
8227010463 also use new type-tracking in isUserControlledObject 2020-07-01 11:32:51 +02:00
Rasmus Lerchedahl Petersen
79e4f1ee93 Python: Enable consistency check (currently fails) 2020-07-01 09:21:36 +02:00
semmle-qlci
ef109d91ed Merge pull request #3842 from hvitved/csharp/dataflow/remove-viable-impl
Approved by aschackmull
2020-07-01 08:14:57 +01:00
Tom Hvitved
ed2077b2f4 Merge pull request #3841 from gavinl/master
QHELP: Encryption using ECB.qhelp grammar
2020-07-01 08:45:35 +02:00
Dave Bartolomeo
10bbd566d4 C++: Autoformat 2020-07-01 02:28:53 -04:00
Rasmus Lerchedahl Petersen
7787900bed Python: make compile and simplify 2020-07-01 07:36:00 +02:00
Rasmus Lerchedahl Petersen
825f24a953 Python: simplify according to review comments 2020-07-01 07:20:26 +02:00
Rasmus Lerchedahl Petersen
3388ca44ed Python: sync dataflow library 2020-07-01 07:16:59 +02:00
Rasmus Lerchedahl Petersen
e259281821 Merge branch 'master' of github.com:github/codeql into SharedDataflow
to receive updates from data flow library
2020-07-01 07:15:32 +02:00
Robert Marsh
e9777913a3 Merge pull request #3856 from geoffw0/qldoc5follow
C++: Make getSecureAlgorithmRegex() work as expected.
2020-06-30 16:17:37 -07:00
Dave Bartolomeo
6592f8c1bb C++: QLDoc cleanup
This PR just fixes a few bits of PR feedback from my previous QLDoc PR.
2020-06-30 17:33:52 -04:00
Jonas Jensen
cff0f48d34 C++: Work around join-order issue in flow-through
In this non-linear recursion, a `#prev` relation was joined earlier than
the `#prev_delta` relation. As a result, each iteration of the predicate
processes every tuple from previous iterations.

This quadratic behavior caused severe slowdowns on oneapi-src/oneDNN.
2020-06-30 21:12:57 +02:00
Jonas Jensen
17beb2d867 C++: Remove big-step relation in flow-through code
This relation was originally introduced to improve performance but may
no longer be necessary. The `localFlowStepPlus` predicate had an
explosion of tuples on oneapi-src/oneDNN for C++.
2020-06-30 21:06:45 +02:00
Geoffrey White
8bdcc47a50 C++: Add a test. 2020-06-30 17:46:08 +01:00
Geoffrey White
54b8f8e662 C++: Make getSecureAlgorithmRegex() return a single regexp as expected, and as getInsecureAlgorithmRegex() does. 2020-06-30 16:51:16 +01:00
Mathias Vorreiter Pedersen
286c09183f Merge pull request #3837 from geoffw0/qldoc5
C++/Java: Update QLDoc and terminology in Encryption.qll
2020-06-30 17:44:59 +02:00
Mathias Vorreiter Pedersen
cb39525f3b Merge pull request #3847 from nickrolfe/71-this-followup
C++: make MemberFunction::getTypeOfThis() return PointerType
2020-06-30 17:44:32 +02:00
Tom Hvitved
f1179cc202 Java: Follow-up changes 2020-06-30 17:44:16 +02:00
Tom Hvitved
de3dc734ff C++: Follow-up changes 2020-06-30 17:44:16 +02:00
Tom Hvitved
1fa58bd82d Data flow: Sync files 2020-06-30 17:37:16 +02:00
Tom Hvitved
6bcb8a3a5b C#: Replace getErasedRepr() and getTypeBound() with getNodeType() 2020-06-30 17:37:16 +02:00
James Fletcher
8ff8b3e22c Merge pull request #3852 from jf205/1.24-mergeback
1.24 -> master mergeback
2020-06-30 16:21:49 +01:00
Jonas Jensen
63de58c557 Merge pull request #3819 from dbartol/codeql-c-analysis-team/40/2
C++: More IR QLDoc (including `Opcode.qll`)
2020-06-30 17:09:15 +02:00
yoff
989b57c51d Merge pull request #3822 from tausbn/python-document-internal-ast-classes
Python: Document internal AST classes.
2020-06-30 16:48:14 +02:00
james
5a929def95 Merge branch 'rc/1.24' into 1.24-mergeback 2020-06-30 15:44:29 +01:00
James Fletcher
d5c6433245 Merge pull request #3849 from asger-semmle/js/vue-support-rc
JS: Add Vue to list of supported frameworks
2020-06-30 15:43:04 +01:00
Jonas Jensen
4a5299e368 Merge pull request #3843 from geoffw0/qldoc6
C++: Bit more QLDoc
2020-06-30 16:21:37 +02:00
Erik Krogh Kristensen
ed48efe5b4 recognize access to a query object through function calls 2020-06-30 15:52:08 +02:00
semmle-qlci
224289c55f Merge pull request #3845 from max-schaefer/js/walk-sync
Approved by asgerf
2020-06-30 14:45:41 +01:00
Geoffrey White
cf75397ef1 Java: Rename tests. 2020-06-30 14:33:05 +01:00
Geoffrey White
3bdfab8d8c C++: Autoformat. 2020-06-30 14:12:34 +01:00
Anders Schack-Mulligen
4dabbac19b Dataflow: Add documentation language maintainers. 2020-06-30 14:57:56 +02:00
Asger Feldthaus
472501bd6f JS: Add Vue to list of supported frameworks 2020-06-30 13:47:25 +01:00
Nick Rolfe
09e13ca2f2 C++: make MemberFunction::getTypeOfThis() return PointerType
The dbscheme technically allows for any Type, but in practice it will
always be a PointerType, so this should make it easier for users to
understand.
2020-06-30 13:45:21 +01:00
Matthew Gretton-Dann
ab876b8b78 Merge pull request #3814 from nickrolfe/71-this
C++: add MemberFunction::getTypeOfThis()
2020-06-30 13:31:14 +01:00
semmle-qlci
42bca1a3fa Merge pull request #3824 from asger-semmle/js/static-regexp-capture-group-step
Approved by erik-krogh, esbena
2020-06-30 13:20:14 +01:00
semmle-qlci
c850938af0 Merge pull request #3833 from asger-semmle/js/vue-class-component
Approved by erik-krogh
2020-06-30 13:16:42 +01:00
semmle-qlci
15a0297ca2 Merge pull request #3834 from asger-semmle/js/vue-classification
Approved by erik-krogh
2020-06-30 13:14:25 +01:00
Geoffrey White
5c11c9ee43 Java: Rename additional private predicates. 2020-06-30 13:05:46 +01:00
Geoffrey White
f8425b8a58 Java: Update uses. 2020-06-30 13:02:48 +01:00
Geoffrey White
db0500b9ef Java: Direct port of changes to Java. 2020-06-30 13:02:48 +01:00
Geoffrey White
51db1475ff Apply suggestions from code review
Co-authored-by: Jonas Jensen <jbj@github.com>
2020-06-30 12:42:12 +01:00
Geoffrey White
4c088b19ad C++: Delete outdated bit. 2020-06-30 12:38:02 +01:00
semmle-qlci
4b7d60a217 Merge pull request #3803 from esbena/js/more-fs-promises
Approved by erik-krogh
2020-06-30 12:33:35 +01:00
Geoffrey White
bbb9396300 C++: Improvement in Overflow.qll. 2020-06-30 12:20:19 +01:00
Geoffrey White
0ee73cce51 Update cpp/ql/src/semmle/code/cpp/security/FunctionWithWrappers.qll
Co-authored-by: Jonas Jensen <jbj@github.com>
2020-06-30 12:16:20 +01:00
Geoffrey White
de25bc6c78 C++: Improvement in Synchronization.qll. 2020-06-30 12:14:56 +01:00
Geoffrey White
3a3cc9a60a C++: Autoformat. 2020-06-30 12:06:18 +01:00
Max Schaefer
62d56a3d7c JavaScript: Fix module name for walk-sync package. 2020-06-30 11:57:16 +01:00
Esben Sparre Andreasen
80981ec8f5 Update UnsafeHtmlExpansion-transformed.html 2020-06-30 12:01:02 +02:00
Taus Brock-Nannestad
7e97bd1d36 Python: Address review comments. 2020-06-30 11:36:26 +02:00
Mathias Vorreiter Pedersen
c52f68e337 Merge pull request #3808 from geoffw0/qldoc4
C++: Yet more QLDoc
2020-06-30 10:33:29 +02:00
Geoffrey White
5c51bb7979 C++: QLDoc Literal.qll. 2020-06-30 09:32:48 +01:00
Asger Feldthaus
7a2c65f638 JS: Fix virtual source root in AutoBuildTest 2020-06-30 09:25:06 +01:00
Jonas Jensen
f79299883a Merge pull request #3831 from MathiasVP/remove-abstract-decl-var-call
C++: Remove abstractness from DeclarationEntry, AccessHolder and Call
2020-06-30 10:21:55 +02:00
Geoffrey White
40e02bee53 C++: QLDoc Overflow.qll. 2020-06-30 09:19:41 +01:00
Geoffrey White
0102322544 C++: QLDoc FunctionWithWrappers.qll. 2020-06-30 09:10:21 +01:00
Jonas Jensen
47bb007b9a C++: Autoformat fixups 2020-06-30 09:56:39 +02:00
Anders Schack-Mulligen
13cb853af5 Merge pull request #3294 from ggolawski/ognl-injection
CodeQL query to detect OGNL injections
2020-06-30 09:46:02 +02:00
Mathias Vorreiter Pedersen
acee9eb7ab C++: Add comment to pseudo-abstract predicates 2020-06-30 09:19:47 +02:00
Mathias Vorreiter Pedersen
50709b235e C++: Replace implication with disjunction in charpred for Call 2020-06-30 09:18:52 +02:00
Esben Sparre Andreasen
c7f67fafd9 JS: support additional promisification of the fs-module members 2020-06-30 09:10:30 +02:00
Mathias Vorreiter Pedersen
667bb323ac C++: Rename union types to follow the naming convention of IPA types (and make them private) 2020-06-30 08:40:46 +02:00
Tom Hvitved
3efe1a9d10 C#: Remove unused viableImpl predicate 2020-06-30 08:31:30 +02:00
Tom Hvitved
b57cfc965a Merge pull request #3804 from aschackmull/dataflow/dispatch-refactor
Dataflow: Refactor dispatch with call context.
2020-06-30 08:28:27 +02:00
Gavin Lang
7a023a65b0 Grammatical issues in Encryption using ECB.qhelp 2020-06-30 15:33:05 +10:00
Dave Bartolomeo
42657dbe3f C++: Miscellaneous IR QLDoc 2020-06-29 14:30:12 -04:00
Asger Feldthaus
182e4ce727 JS: Autoformat 2020-06-29 19:10:28 +01:00
Dave Bartolomeo
1fa38474e9 C++: Autoformat 2020-06-29 14:09:53 -04:00
Nick Rolfe
4b6908c5bf C++: test template classes with MemberFunction::getTypeOfThis() 2020-06-29 18:05:58 +01:00
Geoffrey White
fc69c16ba6 C++: Deprecate some old terminology. 2020-06-29 18:03:16 +01:00
Geoffrey White
71492f90ac C++: QLDoc Encryption.qll, improve existing QLDoc, and update terminology. 2020-06-29 18:03:15 +01:00
Dave Bartolomeo
c52653270e C++: QLDoc for IRConfiguration.qll 2020-06-29 12:43:51 -04:00
Dave Bartolomeo
87f0b0ef97 C++: QLDoc for EdgeKind.qll 2020-06-29 12:43:50 -04:00
Dave Bartolomeo
440ea6a069 C++: QLDoc for PrintIR.qll 2020-06-29 12:43:50 -04:00
Dave Bartolomeo
2043d9c7c4 C++: QLDoc for Operand.qll 2020-06-29 12:43:50 -04:00
Dave Bartolomeo
ead2a143e0 C++: QLDoc for IRVariable
Moved a couple of predicates that were only needed by IR construction into `TranslatedElement.qll`
2020-06-29 12:43:50 -04:00
Dave Bartolomeo
1423ea0591 C++: More IR.qll QLDoc 2020-06-29 12:43:50 -04:00
Dave Bartolomeo
98348a9353 C++: QLDoc for IR.qll 2020-06-29 12:43:50 -04:00
Dave Bartolomeo
88f89b3334 C++: QLDoc for IRFunction.qll 2020-06-29 12:43:49 -04:00
Dave Bartolomeo
d0af9f5808 C++: QLDoc all of IRBlock.qll 2020-06-29 12:43:49 -04:00
Dave Bartolomeo
77bf564136 C++: Finish Instruction.qll QLDoc 2020-06-29 12:43:49 -04:00
Dave Bartolomeo
6de3d5bc3d C++: Change opcode QLDocs to refer to instruction QLDocs
As discussed in today's C++ analysis team meeting. `Opcode` is rarely used directly, so we'll just refer to the documentation for the corresponding `Instruction` class.

I've preserved the script in case we want to do a bulk change of all of the `Opcode` comments, but I don't expect it will be needed if we just add a new `Opcode` or two.
2020-06-29 12:41:36 -04:00
Geoffrey White
a8a7df4e5c C++: QLDoc SensitiveExprs.qll. 2020-06-29 17:08:44 +01:00
Geoffrey White
e2e5e9b2a9 C++: QLDoc Synchronization.qll and improve existing QLDoc. 2020-06-29 16:56:01 +01:00
Asger Feldthaus
cb12d894a6 JS: Add test 2020-06-29 15:54:06 +01:00
Asger Feldthaus
326c7af4eb JS: Fix incorrect classification of Vue files 2020-06-29 15:49:07 +01:00
Anders Schack-Mulligen
d297ce2279 Merge pull request #3436 from artem-smotrakov/revocation-checking
Java: Added a query for disabled certificate revocation checking
2020-06-29 16:42:36 +02:00
Anders Schack-Mulligen
b53b90501b Merge pull request #3550 from luchua-bc/java-unsafe-cert-trust
Java: CWE-273 Unsafe certificate trust
2020-06-29 16:39:39 +02:00
Anders Schack-Mulligen
0bd81eb4b8 Dataflow: Fix reference to viableCallable. 2020-06-29 16:22:58 +02:00
Geoffrey White
55883f60f7 C++: Autoformat. 2020-06-29 14:48:15 +01:00
semmle-qlci
da8725aa5c Merge pull request #3823 from dellalibera/js/fancy-log
Approved by erik-krogh
2020-06-29 14:46:51 +01:00
semmle-qlci
b3e68ef81c Merge pull request #3806 from erik-krogh/moreDownloads
Approved by asgerf
2020-06-29 13:53:10 +01:00
Asger Feldthaus
b05942b599 JS: Add HTML file example 2020-06-29 13:45:01 +01:00
Asger Feldthaus
3938856e61 JS: Make this work in qltest 2020-06-29 13:42:55 +01:00
Asger Feldthaus
1a16d7339a JS: Set SourceType correctly 2020-06-29 13:42:22 +01:00
Geoffrey White
441d4c077a Update cpp/ql/src/semmle/code/cpp/exprs/Cast.qll
Co-authored-by: Jonas Jensen <jbj@github.com>
2020-06-29 13:13:00 +01:00
Taus Brock-Nannestad
b469d55d17 Python: Fix a few things in Stmts.qll. 2020-06-29 13:32:36 +02:00
Nick Rolfe
ab1dc64eea C++: expand qldoc on MemberFunction::getTypeOfThis() 2020-06-29 11:54:28 +01:00
Asger Feldthaus
fcb365188b JS: Add change note 2020-06-29 09:59:17 +01:00
Asger Feldthaus
e46a9dac65 JS: Count lines of code correctly 2020-06-29 09:59:17 +01:00
Asger Feldthaus
9c65318f99 JS: Extract TypeScript in HTML files to a snippet in virtual source root 2020-06-29 09:59:17 +01:00
Asger Feldthaus
da58fb5e62 JS: Resolve relative imports across real and virtual source roots 2020-06-29 09:44:48 +01:00
Asger Feldthaus
d3b9ebe1d2 JS: Perform glob matching across source roots 2020-06-29 09:44:48 +01:00
Asger Feldthaus
1297d0f414 JS: Extract HTML before TypeScript 2020-06-29 09:44:48 +01:00
Asger Feldthaus
2c1567aedd JS: Don't extract TypeScript from HTML 2020-06-29 09:44:48 +01:00
Asger Feldthaus
805deb13c0 JS: Fix whitespace 2020-06-29 09:44:45 +01:00
Asger Feldthaus
1e5f846168 JS: Use StringReplaceCall 2020-06-29 09:31:56 +01:00
Mathias Vorreiter Pedersen
6b27652b99 C++: Remove abstractness from a couple of AST classes 2020-06-29 10:27:16 +02:00
Erik Krogh Kristensen
27b2c02693 remove todo comment
Co-authored-by: Asger F <asgerf@github.com>
2020-06-29 09:58:59 +02:00
Asger Feldthaus
8632c2a3b2 JS: Factor out VirtualSourceRoot 2020-06-29 08:18:29 +01:00
Asger Feldthaus
bfedcb01c4 JS: Make TypeScript aware of custom extractor extensions 2020-06-29 08:16:58 +01:00
Asger Feldthaus
d55e3300f3 JS: Bundle FileExtractors into a class 2020-06-29 08:16:58 +01:00
Asger Feldthaus
ea6b99e726 JS: Add shouldExtract predicate 2020-06-29 08:16:58 +01:00
Asger Feldthaus
164a18f02d JS: Factor out extractFiles 2020-06-29 08:16:05 +01:00
Asger Feldthaus
da3d1a3b5f JS: Recognize 'lang' attribute of script tags 2020-06-29 08:15:52 +01:00
Asger F
bdb7e3def3 Apply suggestions from code review
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-06-29 07:55:15 +01:00
Asger Feldthaus
03c91a66c5 JS: Update expected output 2020-06-29 07:52:25 +01:00
ubuntu
bb06014f3d Add fancy-log 2020-06-28 22:02:02 +02:00
Alessio Della Libera
ce32d646dc Update javascript/ql/src/semmle/javascript/frameworks/Logging.qll
Co-authored-by: intrigus-lgtm <60750685+intrigus-lgtm@users.noreply.github.com>
2020-06-28 21:58:45 +02:00
Mathias Vorreiter Pedersen
5fbf30590e C++: Accept test changes. 2020-06-28 20:21:51 +02:00
Taus Brock-Nannestad
5744356dbc Python: Add a bunch more toString docs. 2020-06-28 14:55:45 +02:00
Taus Brock-Nannestad
e72e662f68 Python: Autogenerate QLDoc for toString AST methods.
Only adds these for the methods that do not `override` other
methods (as these presumably have their own `toString` documentation).
2020-06-28 14:41:45 +02:00
Mathias Vorreiter Pedersen
9c0f877172 C++: Keep old instruction -> instruction flow in simpleInstructionLocalFlowStep. This means we don't have to add general operand -> instruction to the simpleLocalFlowStep relation, which seems to add a 10% performance regression. 2020-06-28 11:28:43 +02:00
Asger Feldthaus
9ca25d5bef JS: Support .hash extraction via a few more methods 2020-06-28 01:38:59 +01:00
Asger Feldthaus
19db418395 JS: Add missing store step in Xss query 2020-06-28 01:26:11 +01:00
Asger Feldthaus
3e616e998e JS: Add test 2020-06-27 21:31:40 +01:00
Asger Feldthaus
84d21074e5 JS: Support Vue class components 2020-06-27 21:24:46 +01:00
Grzegorz Golawski
aff0e0eb25 Cleanup according to review comments. 2020-06-27 18:30:36 +02:00
Artem Smotrakov
f5f30ce25e Java: Simplified the query for disabled certificate revocation checking
Removed a dataflow cofiguration for setting a revocation checker.
Instead, the query just checks if addCertPathChecker() or setCertPathCheckers()
methods are called.
2020-06-27 11:37:20 +03:00
Artem Smotrakov
a2fa03e4f5 Java: Improved the query for disabled certificate revocation checking
- Added a taint propagation step for List.of() methods
- Added a testcase with one of the List.of() method
- Simplified conditions
- Fixed typos
2020-06-27 11:37:20 +03:00
Artem Smotrakov
06e3f101ce Java: Added a query for disabled certificate revocation checking
- Added experimental/Security/CWE/CWE-299/DisabledRevocationChecking.ql
  The query looks for PKIXParameters.setRevocationEnabled(false) calls.
- Added RevocationCheckingLib.qll
- Added a qhelp file with examples
- Added tests in java/ql/test/experimental/Security/CWE/CWE-299
2020-06-27 11:37:20 +03:00
Asger Feldthaus
ac5b9cd168 JS: Autoformat 2020-06-26 23:15:04 +01:00
Dave Bartolomeo
4dcdd8a0ee C++: Add last remaining QLDoc to Opcode.qll 2020-06-26 17:25:30 -04:00
Dave Bartolomeo
bdf121f3b8 C++: Update opcode QLDoc script to handle abstract base classes
This auto-generates even more QLDoc for `Opcode.qll`
2020-06-26 16:04:33 -04:00
ubuntu
9135bbd5c8 JS: model fancy-log (and recognize the 'dir' log level) 2020-06-26 21:33:52 +02:00
Asger Feldthaus
6707e3424d JS: Prevent bad join ordering 2020-06-26 20:21:56 +01:00
Taus Brock-Nannestad
24daf2c4d1 Python: Document internal AST classes.
We already document these in the classes that override them, so I
simply added a pointer to this information.
2020-06-26 21:15:30 +02:00
Asger Feldthaus
06dd3ab2ca JS: Propagate into RegExp.$x 2020-06-26 18:58:43 +01:00
Asger Feldthaus
17af8f7650 JS: Add test for taint propagating into RegExp.$1 2020-06-26 18:58:43 +01:00
Dave Bartolomeo
e00a8f7670 Merge pull request #3815 from jbj/getAPrimaryQlClass
C++: getCanonicalQLClass -> getAPrimaryQlClass
2020-06-26 13:52:16 -04:00
Dave Bartolomeo
5f290520ab C++: Accept test diffs due to opcode rename 2020-06-26 13:45:41 -04:00
semmle-qlci
3aefb7fad9 Merge pull request #3613 from erik-krogh/Reassigned
Approved by asgerf
2020-06-26 17:05:45 +01:00
Dave Bartolomeo
281985b845 C++: Sync Opcode.qll QLDoc with Instruction.qll QLDoc
For every concrete `Opcode`, there is a corresponding `Instruction` class. Rather than duplicate all of the QLDoc by hand, I wrote a quick Python script to copy the QLDoc from `Instruction.qll` to `Opcode.qll`. I don't expect that we will need to do this often, so I'm not hooking it up to a PR check or anything like that, but I did commit the script itself in case we need it again.
2020-06-26 11:42:32 -04:00
Dave Bartolomeo
023e1dc0a2 Instruction and opcode cleanup
- Renamed `DynamicCastToVoid` to the more descriptive `CompleteObjectAddress`
- Split verbose description from summary in a few Instruction QLDoc comments.
- Added `Instruction` classes for the few remaining `Opcode`s that didn't have one.
- Removed a use of "e.g."
2020-06-26 11:39:10 -04:00
Jonas Jensen
a22fb7662e C++: Autoformat fixup 2020-06-26 16:57:06 +02:00
Marcono1234
7443c9c5ad Fix outdated query console link
#3546 changed the query but did not adjust the query link.
Additionally the old query could not be re-run because some of the projects it
targeted (gradle/gradle and eclipse-cdt/cdt) cannot be queried currently.
It now queries all available demo projects of the query console instead.
2020-06-26 16:40:19 +02:00
Nick Rolfe
0ae5fb0357 C++: auto-format test query 2020-06-26 15:35:55 +01:00
Nick Rolfe
309a8e60c8 C++: add more test cases for the type of this 2020-06-26 14:20:46 +01:00
Nick Rolfe
e79625ed14 Accept suggested qldoc change
Co-authored-by: Dave Bartolomeo <dbartol@github.com>
2020-06-26 14:20:46 +01:00
Nick Rolfe
9e9d69238a C++: add test for MemberFunction::getTypeOfThis() 2020-06-26 14:20:46 +01:00
Nick Rolfe
8bd3be6e7b C++: add MemberFunction::getTypeOfThis() 2020-06-26 14:20:46 +01:00
Nick Rolfe
ca25971955 C++: upgrade script for member_function_this_type 2020-06-26 14:20:45 +01:00
Nick Rolfe
3b15d39ec6 C++: update stats for new member_function_this_type table 2020-06-26 14:20:45 +01:00
Nick Rolfe
133838dbf3 C++: update tests to expect type of this 2020-06-26 14:20:45 +01:00
Nick Rolfe
d1d7fac4ca C++: add member_function_this_type to dbscheme 2020-06-26 14:20:45 +01:00
semmle-qlci
b015c735d0 Merge pull request #3809 from max-schaefer/util-deprecate
Approved by asgerf
2020-06-26 14:20:14 +01:00
semmle-qlci
1b4df57426 Merge pull request #3731 from asger-semmle/js/monorepo-bugfixes
Approved by erik-krogh
2020-06-26 14:18:35 +01:00
Erik Krogh Kristensen
0b050204ad add missing dot in qldoc 2020-06-26 15:07:12 +02:00
Dave Bartolomeo
f48948c604 C++: Opcode cleanup
- Remove unused `MemoryAccessOpcode`
- Make `OpcodeWithCondition` private
- Add QLDoc for `Opcode` module
2020-06-26 09:04:37 -04:00
Mathias Vorreiter Pedersen
beb66299e9 Merge pull request #3796 from dbartol/codeql-c-analysis-team/40/2
C++: QLDoc for all of `Instruction.qll`
2020-06-26 14:04:48 +02:00
Erik Krogh Kristensen
e4fe236d37 autoformat 2020-06-26 13:59:06 +02:00
Tom Hvitved
795c5784b0 C#: Precise data flow for collections 2020-06-26 13:40:05 +02:00
Dave Bartolomeo
11c702331a Merge pull request #3795 from rdmarsh2/rdmarsh/cpp/add-qldoc-3
C++: QLDoc for PrintAST and AST-based range analysis
2020-06-26 07:38:10 -04:00
Rasmus Wriedt Larsen
3f0975f5a1 Merge pull request #3770 from tausbn/python-add-a-bunch-of-documentation
Python: Add a bunch of documentation.
2020-06-26 13:30:45 +02:00
Jonas Jensen
c1b26d71c3 C++: getCanonicalQLClass -> getAPrimaryQlClass
Also updated the QLDoc for `getAPrimaryQlClass` to match the Go version.
2020-06-26 13:20:36 +02:00
Rasmus Lerchedahl Petersen
64af5f585c Python: Update status description 2020-06-26 13:18:07 +02:00
Rasmus Lerchedahl Petersen
f84adb3c26 Python: stub for clearsContent
also remove all `CastNode`s (seems to help)
2020-06-26 13:09:35 +02:00
Taus
e5d23b2082 Merge pull request #3801 from RasmusWL/python-3521-revived
Python: Add support for detecting XSLT Injection (#3521 revived)
2020-06-26 13:05:28 +02:00
Max Schaefer
640c194c92 JavaScript: Model util.deprecate as a pre call-graph step. 2020-06-26 11:47:19 +01:00
Max Schaefer
712a216461 Add self-verifying type-tracking tests. 2020-06-26 11:47:19 +01:00
Rasmus Lerchedahl Petersen
248717473e Python: quick status added to readme.md 2020-06-26 12:25:17 +02:00
Rasmus Wriedt Larsen
b164f2695d Python: One more minor doc fix from review 2020-06-26 12:08:12 +02:00
Rasmus Wriedt Larsen
08384e30af Python: Minor doc fixes from review 2020-06-26 12:06:31 +02:00
Rasmus Lerchedahl Petersen
6e5f71bf43 Python: sync dataflow files 2020-06-26 12:02:14 +02:00
Rasmus Lerchedahl Petersen
e147e59652 Merge branch 'master' of github.com:github/codeql into SharedDataflow
To sync files
2020-06-26 12:01:01 +02:00
Rasmus Lerchedahl Petersen
43f85ef265 Python: typo 2020-06-26 12:00:24 +02:00
Tom Hvitved
6efbd5f9d1 C#: Add data-flow test for List.Clear() 2020-06-26 11:44:08 +02:00
Jonas Jensen
9d8052a434 Merge pull request #3813 from MathiasVP/is-argument-for-parameter-join-order
C++: Improve join order for AliasAnalysis::isArgumentForParameter
2020-06-26 11:34:33 +02:00
Calum Grant
8725e09053 Merge pull request #3798 from hvitved/csharp/dataflow/async-tests
C#: Move async data-flow tests from local to global
2020-06-26 10:14:28 +01:00
semmle-qlci
f81fc77e9e Merge pull request #3782 from erik-krogh/promiseSteps
Approved by asgerf
2020-06-26 10:11:10 +01:00
Mathias Vorreiter Pedersen
63752dddef C++/C#: Sync identical files 2020-06-26 09:08:44 +02:00
Mathias Vorreiter Pedersen
3af679e83d C++: Put unique around getEnclosingFunction, and specialize function argument, to improve join order. 2020-06-26 09:08:35 +02:00
semmle-qlci
92cc59b47b Merge pull request #3800 from esbena/js/npmlog
Approved by erik-krogh
2020-06-26 07:54:08 +01:00
Dave Bartolomeo
7e3f2dbe4c C++: Improve QLDoc for getElementSize() 2020-06-25 17:04:32 -04:00
Erik Krogh Kristensen
7cb6516bc4 make internal predicates within DominatingPaths smaller. 2020-06-25 23:00:52 +02:00
Erik Krogh Kristensen
1ec2c549d2 autoformat 2020-06-25 23:00:52 +02:00
Erik Krogh Kristensen
8b3ca73c1c autoformat 2020-06-25 23:00:52 +02:00
Erik Krogh Kristensen
081b03c8f4 add tests that access-path domination can happen within a statement 2020-06-25 23:00:52 +02:00
Erik Krogh Kristensen
47d52870f2 Use a ControlFlowNode based API to determine domination 2020-06-25 23:00:52 +02:00
Erik Krogh Kristensen
926f2c139f require that a write must dominate the enclosing stmt of a read 2020-06-25 23:00:52 +02:00
Erik Krogh Kristensen
55565a51df don't use getEnclosingStmt 2020-06-25 23:00:52 +02:00
Erik Krogh Kristensen
34d6a4dcf8 use Rhs of a prop-write
Co-authored-by: Asger F <asgerf@github.com>
2020-06-25 23:00:52 +02:00
Erik Krogh Kristensen
cc2e61531e update expected output 2020-06-25 23:00:52 +02:00
Erik Krogh Kristensen
f7c42ca1b5 autoformat 2020-06-25 23:00:52 +02:00
Erik Krogh Kristensen
252f805db4 performance improvement 2020-06-25 23:00:52 +02:00
Erik Krogh Kristensen
21e5a522b0 give the same rank to all expressions inside a single stmt 2020-06-25 23:00:52 +02:00
Erik Krogh Kristensen
e467d3ccbf use dominating write check in js/path-injection 2020-06-25 23:00:52 +02:00
Erik Krogh Kristensen
6bc821b1ab add tests for dominating writes 2020-06-25 23:00:52 +02:00
Erik Krogh Kristensen
2b2d691e45 don't treated a property from a tainted object as tainted when there exists a dominating write 2020-06-25 23:00:52 +02:00
Erik Krogh Kristensen
5e4acfbe19 implement predicate for finding dominating writes to an access-path 2020-06-25 23:00:52 +02:00
Jonas Jensen
d4c5887122 Merge pull request #3807 from geoffw0/qldoc3
C++: Even more QLDoc
2020-06-25 19:29:35 +02:00
Geoffrey White
168f9404f0 Merge branch 'master' into models5 2020-06-25 17:42:08 +01:00
semmle-qlci
056e1a8c4b Merge pull request #3599 from asger-semmle/js/nameditem
Approved by esbena
2020-06-25 17:34:14 +01:00
Geoffrey White
488d41f797 C++: QLDoc Cast.qll. 2020-06-25 17:30:45 +01:00
Geoffrey White
6639d6de83 C++: QLDoc exprs\ObjectiveC.qll (deprecated). 2020-06-25 17:30:45 +01:00
Geoffrey White
1df843c8f6 C++: QLDoc multiple files in the exprs directory. 2020-06-25 17:30:44 +01:00
Geoffrey White
b7730fb1ad C++: QLDoc PrintfLike.qll. 2020-06-25 17:30:44 +01:00
Robert Marsh
9a1f909129 C++: Fix QLDoc for PrintAST.qll nodes/edges 2020-06-25 09:07:20 -07:00
Robert Marsh
b3072b9544 Apply suggestions from code review
Co-authored-by: Dave Bartolomeo <dbartol@github.com>
2020-06-25 08:54:17 -07:00
Calum Grant
b759856ccb Merge pull request #3792 from calumgrant/cs/qldoc-coverage1
C#: Improve qldoc coverage
2020-06-25 16:34:52 +01:00
Erik Krogh Kristensen
690bde47aa remove a .getALocalSource() that isn't needed 2020-06-25 16:51:10 +02:00
Asger Feldthaus
e28284bd01 JS: Fix javadoc 2020-06-25 15:39:00 +01:00
Asger Feldthaus
ad48c4e54d JS: Always prepare package.json files 2020-06-25 15:38:20 +01:00
Asger Feldthaus
675c64d9d4 JS: Prefer extracting file with tsconfig that included it 2020-06-25 15:38:19 +01:00
Asger Feldthaus
4c4acd50bd JS: Factor out loading of tsconfig files 2020-06-25 15:38:19 +01:00
Asger Feldthaus
cc3e62f535 JS: Move stack trace limit to top of file 2020-06-25 15:38:19 +01:00
Asger Feldthaus
cf78475799 JS: Only extract included files with a given tsconfig 2020-06-25 15:38:19 +01:00
Asger Feldthaus
6ff81377d5 JS: Also sort files in legacy extractor 2020-06-25 15:38:18 +01:00
Asger Feldthaus
6d15397fdc JS: Ensure we never write outside the scratch dir 2020-06-25 15:38:18 +01:00
Asger Feldthaus
ba5d6bb2e9 JS: Actually set fields 2020-06-25 15:38:18 +01:00
Asger Feldthaus
dceb211021 JS: Pass source root to Node.js process 2020-06-25 15:38:18 +01:00
Asger Feldthaus
aaf141782f JS: Fix source root 2020-06-25 15:38:17 +01:00
Asger Feldthaus
cb0a2498b0 JS: Sort files 2020-06-25 15:38:17 +01:00
Calum Grant
c4d43bafa4 Merge pull request #3797 from hvitved/csharp/dataflow/more-collection-tests
C#: More data-flow collection tests
2020-06-25 15:38:04 +01:00
Rasmus Lerchedahl Petersen
c5c1c4c0af Python: started adding some coverage tests 2020-06-25 16:29:41 +02:00
semmle-qlci
cf0cd00458 Merge pull request #3627 from asger-semmle/js/unneeded-defensive-return
Approved by erik-krogh
2020-06-25 15:28:57 +01:00
Geoffrey White
d526a10981 C++: QLDoc TestFile.qll, StringAnalysis.qll. 2020-06-25 15:20:18 +01:00
semmle-qlci
c39dce4d66 Merge pull request #3781 from asger-semmle/js/deprecate-type-member-lookup
Approved by erik-krogh
2020-06-25 14:56:17 +01:00
Erik Krogh Kristensen
c3b52fadcc add missing qldoc 2020-06-25 15:54:36 +02:00
Geoffrey White
7aa44fd357 C++: QLDoc Parameter.qll, Specifier.qll, commons/File.qll. 2020-06-25 14:42:44 +01:00
Geoffrey White
a722bd4bd0 C++: QLDoc UserType.qll. 2020-06-25 14:39:11 +01:00
Geoffrey White
c8fc8af340 C++: QLDoc Struct.qll, TypedefType.qll, Union.qll, Variable.qll. 2020-06-25 14:39:10 +01:00
Geoffrey White
908c3b4005 C++: QLDoc SecurityOptions.qll. 2020-06-25 14:39:10 +01:00
Dave Bartolomeo
b889d3687e C++: Fix QLDoc review feedback 2020-06-25 09:33:43 -04:00
Erik Krogh Kristensen
09d969a8ad recognize sensitive files by file-system writes 2020-06-25 15:19:42 +02:00
Erik Krogh Kristensen
8f5a3e9f4f add support for getASavePath() to js/insecure-download 2020-06-25 15:18:31 +02:00
Erik Krogh Kristensen
dafca8fd81 introduce flow-labels to js/insecure-download 2020-06-25 15:17:57 +02:00
Erik Krogh Kristensen
9bdedb3f48 introduce getASavePath to ClientRequest 2020-06-25 15:17:19 +02:00
Dave Bartolomeo
3b4cd700c2 Remove accidentally added file 2020-06-25 09:08:30 -04:00
Anders Schack-Mulligen
6c679c328d Dataflow: Refactor dispatch with call context. 2020-06-25 14:28:35 +02:00
Taus Brock-Nannestad
4dbc8e515a Python: Address a few more review comments. 2020-06-25 14:19:18 +02:00
Taus
1608758219 Python: Apply suggestions from documentation review.
Co-authored-by: Felicity Chapman <felicitymay@github.com>
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
2020-06-25 14:16:44 +02:00
Jonas Jensen
3ce4cff183 Merge pull request #3802 from geoffw0/modeling
C++: 'modelling' -> 'modeling'.
2020-06-25 14:07:57 +02:00
Jonas Jensen
f2ef088d4f Merge pull request #3783 from geoffw0/qldoc2
C++: More QLDoc
2020-06-25 14:06:00 +02:00
Mathias Vorreiter Pedersen
a0bfbda51c C++: Improve performance by not calling getDef, but instead refer to isDefinitionInexact. This gives roughly the same tuple numbers we had with only instruction nodes. 2020-06-25 13:37:14 +02:00
Dave Bartolomeo
6dc02c719b C++: Fix typos 2020-06-25 07:19:15 -04:00
Geoffrey White
099e5891ae C++: 'modelling' -> 'modeling'. 2020-06-25 11:50:43 +01:00
Geoffrey White
f956112042 C++: Autoformat. 2020-06-25 11:48:10 +01:00
Geoffrey White
b515c09946 C++: Autoformat. 2020-06-25 11:46:51 +01:00
Geoffrey White
6201796122 C++: modelling -> modeling
Co-authored-by: Jonas Jensen <jbj@github.com>
2020-06-25 11:42:57 +01:00
Geoffrey White
89bea604d9 C++: Fix false positive. 2020-06-25 11:32:25 +01:00
Geoffrey White
720ac026dc C++: Add false positive. 2020-06-25 11:21:08 +01:00
Geoffrey White
5489bb9946 C++: Autoformat. 2020-06-25 11:13:13 +01:00
Geoffrey White
8f6e56cb41 C++: Suggested change. 2020-06-25 11:13:00 +01:00
Asger Feldthaus
f9b796231b JS: Add regression tests 2020-06-25 11:10:27 +01:00
Rasmus Wriedt Larsen
22ad8f717f Python: Remove usage of .getASuccessor() in XSLT.qll 2020-06-25 12:07:45 +02:00
Rasmus Wriedt Larsen
1e5eeb8009 Python: Move lxml.etree library stub to reduce clutter 2020-06-25 12:07:41 +02:00
Esben Sparre Andreasen
4bfce4b8a3 JS: model npmlog (and recognize the "verbose" log level) 2020-06-25 12:06:51 +02:00
semmle-qlci
b24fba8df0 Merge pull request #3734 from dellalibera/loginjection
Approved by esbena
2020-06-25 11:06:25 +01:00
Asger Feldthaus
a109c1fc96 JS: Change note 2020-06-25 11:04:08 +01:00
Asger Feldthaus
ea3560fe07 JS: Ignore document.all checks explicitly 2020-06-25 11:03:06 +01:00
Rasmus Wriedt Larsen
3cc566f703 Merge branch 'master' into python-3521-revived 2020-06-25 12:02:21 +02:00
Asger Feldthaus
b867512db4 JS: Update test 2020-06-25 11:01:10 +01:00
Rasmus Wriedt Larsen
e60af68b29 Python: Move lxml.etree library stub (so merge is easy) 2020-06-25 11:54:34 +02:00
Rasmus Wriedt Larsen
994db060c7 Python: Use CWE-091 for XSLT
As indicated here https://www.zaproxy.org/docs/alerts/90017/
2020-06-25 11:53:12 +02:00
Calum Grant
4642bb2767 Merge pull request #3774 from hvitved/csharp/tripleticks
C#: Enable syntax highlighting in QLDoc snippets
2020-06-25 10:31:50 +01:00
Rasmus Wriedt Larsen
b36c23ef63 Merge pull request #3500 from yoff/UnmatchableDollar
Python: Regexp: Handle repetions {n} (with no ,)
2020-06-25 11:26:52 +02:00
Rasmus Wriedt Larsen
0b36cd44b8 Merge pull request #3522 from porcupineyhairs/pythonXpath
Python : Add Xpath injection query
2020-06-25 11:21:45 +02:00
Calum Grant
6e3609696a C#: Address review comments. 2020-06-25 09:59:59 +01:00
Taus Brock-Nannestad
9f06e13313 Python: Fix incomplete renaming in Thrift.qll. 2020-06-25 10:48:26 +02:00
Rasmus Lerchedahl Petersen
415e0c4aac Python: add suggestion for test cases 2020-06-25 10:46:33 +02:00
Erik Krogh Kristensen
2d7feb794f Refactor Promises.qll to use PreCallGraphStep 2020-06-25 10:41:08 +02:00
Rasmus Lerchedahl Petersen
5973fe8411 Python: scaffold for testing data flow coverage 2020-06-25 10:32:10 +02:00
Tom Hvitved
b8ae4b7f64 C#: Move async data-flow tests from local to global 2020-06-25 10:04:18 +02:00
Tom Hvitved
3f91aa3b55 C#: More data-flow collection tests 2020-06-25 09:48:52 +02:00
Dave Bartolomeo
06a5242d76 Merge pull request #3793 from rdmarsh2/rdmarsh/cpp/ir-range-analysis-experimental
C++: move IR range analysis to experimental
2020-06-24 20:51:07 -04:00
Dave Bartolomeo
2685aa4b8b C++: Use fewer words 2020-06-24 20:42:02 -04:00
Dave Bartolomeo
8b02f121d6 C++: QLDoc for all of Instruction.qll
I think I've now documented every class and public predicate in `Instruction.qll` I've tried to include detailed semantics of each instruction where appropriate.
2020-06-24 20:29:31 -04:00
Robert Marsh
362fbd12dc C++: QLDoc for PrintAST.qll 2020-06-24 16:45:20 -07:00
Robert Marsh
39aaccc1ac C++: Add QLDoc for AST range analysis libraries 2020-06-24 16:29:20 -07:00
Robert Marsh
3e6a19843d Merge pull request #3727 from jbj/tainted-format-string-high
C++: Raise cpp/tainted-format-string* precisions to high
2020-06-24 15:06:13 -07:00
Calum Grant
d32199cccc C#: QLdoc for CIL instructions. 2020-06-24 22:01:33 +01:00
Calum Grant
262a20cea0 C#: Add qldocs for Concurrency.qll, Documentation.qll, cil.qll and dotnet.qll. 2020-06-24 22:01:33 +01:00
Taus Brock-Nannestad
02363d76c1 Python: Document Comment.qll.
I didn't do the `toString` methods in this commit. I'm thinking
they're better to do in a separate commit. (There are 48 undocumented
instances!)
2020-06-24 22:43:59 +02:00
Taus Brock-Nannestad
fe78e68fd0 Python: Document a bunch of hasLocationInfo methods.
If only we had been _somewhat consistent in how we named the
parameters for these...
2020-06-24 22:38:03 +02:00
Rasmus Wriedt Larsen
155bbbdec9 Python: Add annotated call-graph tests
See the added README for in-depth details
2020-06-24 22:15:39 +02:00
Taus Brock-Nannestad
682e1b6040 Python: Document Comparisons.qll. 2020-06-24 22:13:46 +02:00
Asger F
090a685d86 Merge pull request #3751 from toufik-airane/master
[javascript] CWE-347: JWT Missing Secret Or Public Key Verification
2020-06-24 21:09:41 +01:00
Taus Brock-Nannestad
b8e744eade Python: Document Class.qll. 2020-06-24 22:07:47 +02:00
Taus Brock-Nannestad
25122c9fb5 Python: Document (parts of) ExternalArtifact.qll.
I don't think there's any need to document the parts specific to
metrics or defects, as I don't believe these are used anywhere.
2020-06-24 21:53:37 +02:00
Robert Marsh
fb6e578618 C++: move IR range analysis to experimental 2020-06-24 12:50:14 -07:00
Mathias Vorreiter Pedersen
8c6753a3cc C++: Accept consistency tests. 2020-06-24 21:13:38 +02:00
Geoffrey White
d259e8e8df C++: Correct StrCpy.hasTaintFlow. 2020-06-24 18:34:02 +01:00
Geoffrey White
c3d275d0e7 C++: Clean up SprintfBW and comment Sprintf. 2020-06-24 18:34:02 +01:00
Geoffrey White
c681e6999d C++: Refine the strcat and strcpy models, have BufferWrite depend on them so that information isn't duplicated. 2020-06-24 18:34:02 +01:00
ubuntu
d9a0dc0982 Remove check for console().getAMethodCall 2020-06-24 19:31:23 +02:00
Robert Marsh
38067b5b34 Merge pull request #3777 from rdmarsh2/rdmarsh/csharp/autobuilder-lang-name
C#/C++: Use CODEQL_EXTRACTOR_<LANG>_* in autobuilder
2020-06-24 10:18:26 -07:00
ubuntu
65eba0272d Merge remote-tracking branch 'upstream/master' into loginjection 2020-06-24 19:15:27 +02:00
Mathias Vorreiter Pedersen
5190c26635 C++: Accept tests. 2020-06-24 18:28:41 +02:00
Mathias Vorreiter Pedersen
7530dc2132 C++: Hide operand nodes from path explanations to make the review diff smaller. 2020-06-24 18:28:23 +02:00
Mathias Vorreiter Pedersen
5aa1b13136 C++: Make the pre update node for ExplicitFieldStoreQualifierNode an operand node. This fixes the IR dataflow consistency errors. 2020-06-24 18:27:53 +02:00
Mathias Vorreiter Pedersen
470ee0059d C++: Alternate dataflow between operands and instructions 2020-06-24 18:27:12 +02:00
Mathias Vorreiter Pedersen
d7a9d3d8bc C++: Introduce operand dataflow node 2020-06-24 18:26:17 +02:00
luchua-bc
0779aab28f Clean up the QL code 2020-06-24 15:02:16 +00:00
Anders Schack-Mulligen
791f31fa65 Merge pull request #3595 from luchua-bc/j2ee-server-directory-listing
Java: Add check for J2EE server directory listing
2020-06-24 16:45:34 +02:00
semmle-qlci
daeb13d9fd Merge pull request #3779 from asger-semmle/js/metric-queries
Approved by esbena
2020-06-24 15:37:03 +01:00
Asger Feldthaus
42f32bf76c JS: Recognize calls to .item and .namedItem 2020-06-24 15:11:18 +01:00
Geoffrey White
ff0a9bfc48 C++: QLDoc Stmt.qll, Block.qll. 2020-06-24 13:57:29 +01:00
Geoffrey White
ed32250636 C++: Deprecate Member.qll. 2020-06-24 13:57:28 +01:00
Geoffrey White
f1aac04bdf C++: Deprecate overly specific parts of Type.qll. 2020-06-24 13:57:28 +01:00
Geoffrey White
e43ddd3f78 C++: QLDoc Type.qll. 2020-06-24 13:57:28 +01:00
Geoffrey White
6bcc1a0220 C++: QLDoc NameQualifiers.qll, Namespace.qll, NestedFields.qll. 2020-06-24 13:57:27 +01:00
semmle-qlci
696d19cb14 Merge pull request #3773 from erik-krogh/guardedCrypto
Approved by asgerf
2020-06-24 13:04:04 +01:00
Jonas Jensen
3982da5c47 Merge pull request #3771 from hvitved/qldoc-style-tripleticks
Suggest using target language syntax highlighting in QLDoc
2020-06-24 11:36:39 +02:00
Asger Feldthaus
e2a300e811 JS: Add change note 2020-06-24 10:33:45 +01:00
Rasmus Lerchedahl Petersen
f6c59abcd9 Merge branch 'master' of github.com:github/codeql into UnmatchableDollar
to make CodeScan happy
2020-06-24 11:04:07 +02:00
Rasmus Lerchedahl Petersen
6e9c48bba7 Python: test zero iterations 2020-06-24 11:01:27 +02:00
Rasmus Lerchedahl Petersen
226c295b4c Python: format 2020-06-24 10:48:51 +02:00
Anders Schack-Mulligen
941177ee25 Merge pull request #3762 from hvitved/dataflow/clear-contents
Data flow: Model field clearing
2020-06-24 10:19:50 +02:00
Anders Schack-Mulligen
3b62bd254c Merge pull request #3723 from JLLeitschuh/fix/JLL/gitignore_vs_code_generated_files
Add .gitignore for VS Code Generated maven project files
2020-06-24 09:35:01 +02:00
Erik Krogh Kristensen
76ed03f75b update change-note
Co-authored-by: Asger F <asgerf@github.com>
2020-06-24 09:30:43 +02:00
semmle-qlci
a723ac0d8e Merge pull request #3767 from esbena/js/console-member-calls
Approved by erik-krogh
2020-06-24 08:03:49 +01:00
Asger Feldthaus
d15c98d18c JS: Add more metrics 2020-06-24 08:03:24 +01:00
Geoffrey White
afcc6ac712 Merge pull request #3766 from rdmarsh2/rdmarsh/cpp/add-qldoc-3
C++: Add QLDocs for Initializer.qll-Macro.qll and model classes
2020-06-24 07:31:48 +01:00
Robert Marsh
e24566e313 C#/C++: Use CODEQL_EXTRACTOR_CPP_ROOT in autobuild
Left this out earlier because I thought it needed to point to the C#
extractor root even in C++ mode, but it looks like it isn't yet used in
C++ mode.
2020-06-23 15:53:25 -07:00
Robert Marsh
c37c282861 C#/C++: Fix tests with new environment variables 2020-06-23 15:35:22 -07:00
Robert Marsh
da9aa546de C#/C++: Use CODEQL_EXTRACTOR_CPP_* in autobuilder 2020-06-23 14:47:07 -07:00
Mathias Vorreiter Pedersen
30d9c6b9e4 Merge pull request #3776 from geoffw0/qldoc
C++: QLDoc ObjectiveC.qll, BufferWrite.qll, FileWrite.qll, OutputWrite.qll
2020-06-23 22:23:03 +02:00
Robert Marsh
b402352321 Merge pull request #3775 from hvitved/dataflow/tripleticks
Data flow: Enable syntax highlighting in QLDoc snippets
2020-06-23 09:53:10 -07:00
Robert Marsh
edaa43ab0b C++: respond to PR comments on qldoc 2020-06-23 09:23:08 -07:00
Asger Feldthaus
63d48bfe5c JS: Move IgnoredFile to MetaMetrics 2020-06-23 17:08:09 +01:00
Asger Feldthaus
35bdb4127e JS: Add TypedExprs metric 2020-06-23 17:05:58 +01:00
Geoffrey White
fbaf398e7a C++: QLDoc FileWrite and OutputWrite. 2020-06-23 16:57:22 +01:00
Geoffrey White
e01f050db8 C++: QLDoc BufferWrite.qll. 2020-06-23 16:29:00 +01:00
Geoffrey White
dea9a13e44 C++: QLDoc ObjectiveC.qll (deprecated). 2020-06-23 16:28:51 +01:00
Rasmus Lerchedahl Petersen
c70cf6d780 Python: better (if imperfect) handling of phi node 2020-06-23 17:25:33 +02:00
Tom Hvitved
652de80fa5 C#: Enable syntax highlighting in QLDoc snippets 2020-06-23 16:56:56 +02:00
Tom Hvitved
a3e7fd60f2 Data flow: Enable syntax highlighting in QLDoc snippets 2020-06-23 16:54:34 +02:00
Bt2018
fffc88ea5b Metadata update 2020-06-23 10:34:28 -04:00
Taus
a2677f8df0 Merge pull request #3758 from RasmusWL/python-methods-overrides-as-recommendation
Python: Changing signature in overriden method is not an error
2020-06-23 16:16:44 +02:00
Erik Krogh Kristensen
79599b6cc0 add change-note 2020-06-23 15:57:55 +02:00
Erik Krogh Kristensen
3f8881a334 don't report insecure randomness when the insecure random is just a fallback 2020-06-23 15:53:19 +02:00
luchua-bc
f8c494716f Fix ending line error 2020-06-23 12:48:07 +00:00
Tom Hvitved
8d5077ae83 Suggest using target language syntax highlighting in QLDoc 2020-06-23 14:48:04 +02:00
luchua-bc
89260d6f8a Fix ending line error 2020-06-23 12:36:07 +00:00
Taus Brock-Nannestad
1e4ec5c987 Python: Make QLDoc for TObject.qll visible. 2020-06-23 14:31:30 +02:00
Taus Brock-Nannestad
ccf63e03bb Python: Document FileOpen.qll. 2020-06-23 14:31:06 +02:00
Taus Brock-Nannestad
f86011fb51 Python: Document RedundantComparison.qll. 2020-06-23 14:30:42 +02:00
Taus Brock-Nannestad
2f93b1458e Python: Document IsComparisons.qll. 2020-06-23 14:30:17 +02:00
Taus Brock-Nannestad
d6e5a5cb01 Python: Document AdvancedFormatting.qll. 2020-06-23 14:29:34 +02:00
Taus Brock-Nannestad
513ead66d3 Python: Document CallArgs.qll. 2020-06-23 14:28:40 +02:00
luchua-bc
deabfe6e5c Adjust id tag and fix ending line error 2020-06-23 12:24:03 +00:00
luchua-bc
7642b43990 Adjust id tag and fix ending line error 2020-06-23 12:10:07 +00:00
semmle-qlci
0d61443915 Merge pull request #3753 from asger-semmle/js/xss-dom-exception-rephrasing
Approved by erik-krogh
2020-06-23 13:01:41 +01:00
Asger F
552b7ad3ca Merge pull request #3765 from asger-semmle/js-team-sprint-merge2
JS: Merge js-team-sprint
2020-06-23 12:58:27 +01:00
semmle-qlci
a5a3573a3e Merge pull request #3757 from asger-semmle/js/unused-npm-dependencies
Approved by erik-krogh
2020-06-23 12:56:45 +01:00
Asger Feldthaus
4f67cc269b JS: Reduce ExpansiveTypes test 2020-06-23 11:44:07 +01:00
Asger Feldthaus
234f968294 JS: Deprecate property lookup on types 2020-06-23 11:42:28 +01:00
Toufik Airane
27f91b36b0 Update javascript/ql/src/experimental/Security/CWE-347/JWTMissingSecretOrPublicKeyVerification.ql
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-06-23 12:28:21 +02:00
toufik-airane
37f44d98ce fix minor issues 2020-06-23 12:28:03 +02:00
Rasmus Lerchedahl Petersen
b759b71ac8 Python: explain the regression test 2020-06-23 11:02:33 +02:00
Tom Hvitved
ff751ac0f8 Data flow: Sync files 2020-06-23 10:55:12 +02:00
Tom Hvitved
98ed2a18ac Data flow: Move field-clearing checks from flowCandFwf0 into flowCandFwd 2020-06-23 10:55:12 +02:00
Tom Hvitved
13b4dfa972 Data flow: Rename BigStepBarrierNode to FlowCheckNode 2020-06-23 10:55:12 +02:00
Tom Hvitved
3faca03de6 C#: Introduce ObjectInitializerNode 2020-06-23 10:55:12 +02:00
Tom Hvitved
83050d96f8 C++: Stub implementations for clearsContent() 2020-06-23 10:55:12 +02:00
Tom Hvitved
c01f570d9e Java: Implement clearsContent() 2020-06-23 10:55:12 +02:00
Tom Hvitved
c057e82efa Data flow: Sync files 2020-06-23 10:55:11 +02:00
Tom Hvitved
e578827626 Java: Add more field-flow tests 2020-06-23 10:55:11 +02:00
Tom Hvitved
a1d5591634 C#: Model field-clearing in data-flow 2020-06-23 10:55:11 +02:00
Tom Hvitved
b5bc15a097 C#: Add more field-flow tests 2020-06-23 10:55:11 +02:00
James Fletcher
843c5c6c1e Merge pull request #3742 from jf205/sd-110
CodeQL docs: Expand QLDoc style guide
2020-06-23 09:47:25 +01:00
Esben Sparre Andreasen
2d32ee7448 JS: support member calls of console 2020-06-23 10:46:01 +02:00
james
7e7d7e752e docs: further improvements 2020-06-23 09:42:56 +01:00
Jonas Jensen
3747bd98f3 Merge pull request #3694 from geoffw0/models
C++: Extend the GetsFunction and SystemFunction models.
2020-06-23 10:15:32 +02:00
Shati Patel
95870977ca Merge pull request #3763 from adityasharad/java/training-example-brace
Fix training example syntax
2020-06-23 08:34:09 +01:00
James Fletcher
c7cfd59651 Apply suggestions from code review
Co-authored-by: Shati Patel <42641846+shati-patel@users.noreply.github.com>
2020-06-23 08:31:48 +01:00
Mathias Vorreiter Pedersen
55ce5ce47a Merge pull request #3754 from jbj/revert-flat-structs
C++: Revert #3419 to fix OpenJDK performance
2020-06-23 08:58:08 +02:00
Rasmus Lerchedahl Petersen
a55b4660d4 Python: support for with-definitions 2020-06-23 07:45:30 +02:00
Robert Marsh
c1eb712841 C++: QLDoc for data and taint models 2020-06-22 17:25:55 -07:00
Asger Feldthaus
b4f75ef414 Merge branch 'master' into js-team-sprint-merge2 2020-06-23 00:18:09 +01:00
Asger F
2edeb4aa8d Merge pull request #3735 from esbena/js/insecure-http-options
JS: polish js/disabling-certificate-validation
2020-06-23 00:16:45 +01:00
Asger F
ca06f6dfb4 Merge branch 'js-team-sprint' into js/insecure-http-options 2020-06-23 00:16:02 +01:00
semmle-qlci
69b44def7b Merge pull request #3759 from asger-semmle/js/sprint-suite
Approved by erik-krogh
2020-06-22 23:27:43 +01:00
toufik-airane
f7cbc8a8d4 Enhance query ouput
- add valuable text to assess the query results
- add an example of the output
2020-06-22 22:34:06 +02:00
toufik-airane
0f8879716f rewrite description 2020-06-22 21:57:58 +02:00
Aditya Sharad
915148f82c C++: Fix placeholder syntax in training example 2020-06-22 12:26:26 -07:00
Aditya Sharad
95f8ba433e Java: Fix training example 2020-06-22 12:21:15 -07:00
Robert Marsh
231b85cb11 C++: File-level QLDoc for publicly imported models 2020-06-22 11:43:43 -07:00
Alessio Della Libera
a759905a5c Update javascript/ql/src/experimental/Security/CWE-117/LogInjection.qll
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-06-22 20:37:38 +02:00
toufik-airane
364f0ca734 rewrite description 2020-06-22 20:11:58 +02:00
toufik-airane
ac8991b192 remove JWTMissingSecretOrPublicKeyVerification.qll 2020-06-22 20:09:48 +02:00
toufik-airane
d9ecb7d762 rewrite help 2020-06-22 20:06:17 +02:00
toufik-airane
d65b7be32b rewrite help 2020-06-22 20:00:52 +02:00
Toufik Airane
bb7ba50e23 Apply suggestions from code review
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-06-22 19:27:36 +02:00
james
3fa49a9771 address review comment about sentence style 2020-06-22 17:07:10 +01:00
James Fletcher
676d486635 Apply suggestions from code review
Co-authored-by: Jonas Jensen <jbj@github.com>
2020-06-22 17:03:31 +01:00
Asger Feldthaus
1efd71a681 JS: Sort security suite 2020-06-22 16:40:55 +01:00
Asger Feldthaus
8cc41a0c84 JS: Add new queries to security suite 2020-06-22 16:40:19 +01:00
Asger F
a067cd35aa Merge pull request #3756 from esbena/js/delay-slow-query-merge
JS: delay merging two slow queries
2020-06-22 16:35:15 +01:00
Asger F
7d54b02fb9 Merge branch 'js-team-sprint' into js/delay-slow-query-merge 2020-06-22 16:34:49 +01:00
Asger F
4a459c8a7d Merge pull request #3755 from esbena/js/polish-imcs
JS: polish js/incomplete-html-attribute-sanitization
2020-06-22 16:32:16 +01:00
Jonas Jensen
39137510ba Merge pull request #3736 from rneatherway/exclude-cs-vulnerable-package
Exclude dependency-based query from C# Code Scanning
2020-06-22 17:27:23 +02:00
Geoffrey White
466f36c7e1 C++: Autoformat. 2020-06-22 16:04:32 +01:00
Rasmus Wriedt Larsen
d5895c16c8 Python: Changing signature in overriden method is not an error
Rather, fulfiling the Liskov substitution principle is an opinionated
recommendation. Looking at `py/inheritance/incorrect-overridden-signature` and
`py/mixed-tuple-returns`, it seems very appropriate that this should have
`@severity recommendation`, and `@sub-severity high`.
2020-06-22 16:58:52 +02:00
Rasmus Lerchedahl Petersen
e8289d6fa1 Python: add regression tests and organise tests 2020-06-22 16:36:19 +02:00
Asger Feldthaus
5cd2c7cdb2 JS: Reduce precision of js/unused-npm-dependency 2020-06-22 15:25:24 +01:00
Rasmus Lerchedahl Petersen
aa04a2a476 Python: sync dataflow files 2020-06-22 14:56:11 +02:00
Esben Sparre Andreasen
d4ad9a8bb2 Update change-notes/1.25/analysis-javascript.md
Co-authored-by: Asger F <asgerf@github.com>
2020-06-22 14:55:27 +02:00
Rasmus Lerchedahl Petersen
656c76558a Merge branch 'master' of github.com:github/codeql into SharedDataflow
To sync dataflow files
2020-06-22 14:55:04 +02:00
Esben Sparre Andreasen
9a0bbb31f4 Revert "Merge pull request #3702 from esbena/js/memory-exhaustion"
This reverts commit eca5e2df8a, reversing
changes made to 1548eca994.
2020-06-22 14:46:51 +02:00
Esben Sparre Andreasen
0a8d15ccc4 Revert "Merge pull request #3672 from esbena/js/server-crashing-route-handler"
This reverts commit 243e3ad9e3, reversing
changes made to df79f2adc5.
2020-06-22 14:45:35 +02:00
Esben Sparre Andreasen
3be094ea5b JS: polish js/incomplete-html-attribute-sanitization 2020-06-22 14:35:00 +02:00
Rasmus Lerchedahl Petersen
13bb971b05 Python: sort out some enclosing callable confusion 2020-06-22 14:26:25 +02:00
Jonas Jensen
5a5df4de26 Revert "Merge pull request #3419 from MathiasVP/flat-structs"
There was unfortunately a semantic merge conflict between #3419 and
 #3587 that caused a performance regression on (at least) OpenJDK.

This reverts commit 982fb38807, reversing
changes made to b841cacb83.
2020-06-22 14:09:06 +02:00
semmle-qlci
7a5aae7432 Merge pull request #3630 from erik-krogh/DevServer
Approved by asgerf
2020-06-22 12:59:13 +01:00
Asger F
56124b68a3 Update javascript/ql/src/Security/CWE-079/ExceptionXss.ql
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-06-22 12:54:19 +01:00
Rasmus Wriedt Larsen
daa1b6fc79 Python: Fix grammar in QLDoc
Co-authored-by: Taus <tausbn@gmail.com>
2020-06-22 13:41:03 +02:00
Rasmus Wriedt Larsen
287bc40264 Merge pull request #3743 from tausbn/python-fix-deprecated-terms
Python: Fix a bunch of deprecated terms.
2020-06-22 13:36:06 +02:00
semmle-qlci
7f29465f35 Merge pull request #3752 from erik-krogh/limitStr
Approved by asgerf
2020-06-22 12:31:49 +01:00
toufik-airane
4853b8a281 Try to finish the PR
- Add help documentation
- Empty qll file
- rename examples
2020-06-22 13:26:13 +02:00
semmle-qlci
e06a54c33d Merge pull request #3494 from hvitved/dataflow/partial-flow-access-path-limit
Approved by aschackmull
2020-06-22 12:09:00 +01:00
James Fletcher
5ebaa1d303 Apply suggestions from code review
Co-authored-by: Shati Patel <42641846+shati-patel@users.noreply.github.com>
2020-06-22 12:07:42 +01:00
Rasmus Lerchedahl Petersen
8d564e06d7 Python: sync data flow files 2020-06-22 12:16:11 +02:00
Geoffrey White
104298e09a Merge branch 'master' into models5 2020-06-22 10:59:15 +01:00
Asger Feldthaus
1edb2a1892 JS: Rephrase XSS queries that use exception/dom text as source 2020-06-22 10:44:46 +01:00
Calum Grant
f2f020fa51 Merge pull request #3610 from hvitved/csharp/dataflow/call-sensitivity
C#: Add call-sensitivity to data-flow call resolution
2020-06-22 10:36:45 +01:00
Rasmus Lerchedahl Petersen
94a828aca2 Merge branch 'master' of github.com:github/codeql into SharedDataflow
To avoid CodeScan check failing
2020-06-22 11:29:00 +02:00
Rasmus Lerchedahl Petersen
b65e6fba9e Python: attempt at capturing maximal flows
(this is what used to be "all flows")
2020-06-22 11:28:28 +02:00
Esben Sparre Andreasen
0654823b97 Merge branch 'js-team-sprint' into js/insecure-http-options 2020-06-22 11:25:25 +02:00
Esben Sparre Andreasen
f1dad0d6e0 Update DisablingCertificateValidation.qhelp 2020-06-22 11:24:33 +02:00
Esben Sparre Andreasen
3e898487e8 Apply suggestions from code review
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2020-06-22 11:23:40 +02:00
Rasmus Lerchedahl Petersen
cc8367bff2 Python: update readme with lessons learned 2020-06-22 11:22:32 +02:00
Anders Schack-Mulligen
71665a02fa Merge pull request #3737 from Marcono1234/patch-1
Simplify NoAssignInBooleanExprs.ql
2020-06-22 10:46:00 +02:00
Erik Krogh Kristensen
8d1b080d78 limit size of getStringValue 2020-06-22 10:29:53 +02:00
Tom Hvitved
72e6c9c2b1 Data flow: Use accessPathLimit() in partial flow as well 2020-06-22 10:08:51 +02:00
Rasmus Lerchedahl Petersen
47819bbcda Python: obtain remaining expected flows
- implement encosing callable for more nodes
 - implement extra flow for ESSA global variables
2020-06-22 07:36:09 +02:00
Porcupiney Hairs
a519132407 add support for libxml2 2020-06-22 02:01:07 +05:30
toufik-airane
7166d5422e add test file for CWE-347
Add a test file for CWE-347.
The HS256 algorithm is safe, but the none algorithm is unsafe.
2020-06-20 17:10:35 +02:00
toufik-airane
8a2a33459a Merge branch 'master' of github.com:toufik-airane/codeql 2020-06-20 16:56:27 +02:00
toufik-airane
b0aaca0e1c JWT Missing Secret Or Public Key Verification
Add an experimental CodeQL query.
2020-06-20 16:54:41 +02:00
Taus Brock-Nannestad
5d5f1b487b Merge branch 'master' into python-fix-deprecated-terms 2020-06-19 21:59:17 +02:00
Asger F
eca5e2df8a Merge pull request #3702 from esbena/js/memory-exhaustion
JS: add query js/memory-exhaustion
2020-06-19 20:35:57 +01:00
Jonas Jensen
ac89559b20 Merge pull request #3744 from github/p0-patch-1
Fix typo in cpp-security-extended.qls
2020-06-19 21:19:20 +02:00
Pavel Avgustinov
00f1e57d0c Update cpp-security-extended.qls 2020-06-19 20:16:24 +01:00
Jonas Jensen
81d8dc15cd Merge pull request #3693 from geoffw0/stringtest
C++: Add tests of char* -> std::string -> char* conversions.
2020-06-19 21:12:33 +02:00
Taus Brock-Nannestad
410f4781b3 Python: Fix one last reference.
This one got lost in the big renaming somehow.
2020-06-19 20:15:01 +02:00
semmle-qlci
1548eca994 Merge pull request #3689 from erik-krogh/https-fix
Approved by mchammer01
2020-06-19 17:00:11 +01:00
Tom Hvitved
573d55a160 Merge pull request #3740 from github/codeql-analysis-yml
Enable code scanning
2020-06-19 17:57:52 +02:00
Taus Brock-Nannestad
48e3e9c0b4 Python: Do all the renames. 2020-06-19 17:02:47 +02:00
james
f02b54fcd2 docs: add more detailed qldoc style guide 2020-06-19 15:59:22 +01:00
Taus Brock-Nannestad
06d6913a20 Python: Change "sanity" to "consistency". 2020-06-19 16:55:59 +02:00
Taus Brock-Nannestad
01fb1e3786 Python: Get rid of deprecated terms in code and .qhelp. 2020-06-19 16:51:09 +02:00
Taus
2081d0cecc Merge pull request #3575 from RasmusWL/python-add-qldoc-FunctionValue.getQualifiedName
Python: Add QLDoc for FunctionValue.getQualifiedName
2020-06-19 16:32:23 +02:00
Tom Hvitved
56670f3a5f Disable analysis for JS and Python 2020-06-19 16:25:23 +02:00
Jonas Jensen
09d7ed092b Merge pull request #3612 from dbartol/github/codeql-c-analysis-team/69_union
C++: Share `TInstruction` across IR stages
2020-06-19 16:03:11 +02:00
Geoffrey White
c18e0aa21a C++: Add a TODO comment. 2020-06-19 14:30:56 +01:00
Erik Krogh Kristensen
0f5ef2c02a Merge branch 'js-team-sprint' into https-fix 2020-06-19 14:57:44 +02:00
semmle-qlci
e13353f26a Merge pull request #3732 from erik-krogh/priv-file-polish
Approved by mchammer01
2020-06-19 13:56:57 +01:00
Tom Hvitved
4b47483263 Add codeql-config.yml 2020-06-19 12:28:52 +00:00
Erik Krogh Kristensen
e46bd709c4 add change note 2020-06-19 14:15:50 +02:00
Erik Krogh Kristensen
0ee3f4977c add test of webpack-dev-server and monorepo import 2020-06-19 14:15:46 +02:00
Erik Krogh Kristensen
c860151e8d recognize instances of express from webpack-dev-server 2020-06-19 14:15:25 +02:00
Erik Krogh Kristensen
11cc97d286 add basic support for importing from neighbouring packages 2020-06-19 14:15:10 +02:00
Erik Krogh Kristensen
a17d152ca4 Merge branch 'js-team-sprint' into priv-file-polish 2020-06-19 13:19:10 +02:00
semmle-qlci
bfb2e9d6ea Merge pull request #3724 from erik-krogh/bad-random-polish
Approved by mchammer01
2020-06-19 12:18:25 +01:00
Tom Hvitved
ffe3f500d7 Restrict languages in codeql-analysis.yml 2020-06-19 13:01:28 +02:00
Esben Sparre Andreasen
457588e893 JS: mention MITM 2020-06-19 11:59:12 +02:00
Geoffrey White
ab8d1ea723 C++: Model ConversionConstructor instead of all Constructors. 2020-06-19 10:55:10 +01:00
Anders Schack-Mulligen
8107fbadc2 Merge pull request #3456 from hvitved/dataflow/precise-field-types
Data flow: Track precise types during field flow
2020-06-19 11:50:10 +02:00
Esben Sparre Andreasen
4126d5b59e Merge pull request #3646 from dellalibera/master
[javascript] CodeQL query to detect missing origin validation in cross-origin communication via postMessage
2020-06-19 11:43:57 +02:00
Rasmus Lerchedahl Petersen
426b1da552 Python: update sources and sinks 2020-06-19 11:38:15 +02:00
Tom Hvitved
a285f6460c Create codeql-analysis.yml 2020-06-19 11:34:31 +02:00
Geoffrey White
3f4ebd285f C++: Move models into models dir. 2020-06-19 10:26:07 +01:00
Rasmus Lerchedahl Petersen
9e078da963 Python: Better definition of all flows
does not become too big, when we filter out 0-step flows
2020-06-19 11:25:34 +02:00
Geoffrey White
e0651b2c19 Merge remote-tracking branch 'upstream/master' into models5 2020-06-19 10:15:25 +01:00
Geoffrey White
eebaf0f330 C++: Modify the tests so that ConversionConstructors are tested; we don't want the general case for Constructors any more. 2020-06-19 10:15:01 +01:00
Tom Hvitved
ca86bb8603 Address review comments 2020-06-19 10:34:11 +02:00
Esben Sparre Andreasen
0463c427a5 Update javascript/ql/src/Security/CWE-770/ResourceExhaustion.qhelp
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2020-06-19 09:47:59 +02:00
Esben Sparre Andreasen
b8229ca362 Update javascript/ql/src/Security/CWE-770/ResourceExhaustion.qhelp
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2020-06-19 09:47:48 +02:00
Esben Sparre Andreasen
e73beccc0b Update javascript/ql/src/Security/CWE-770/ResourceExhaustion.qhelp
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2020-06-19 09:47:26 +02:00
Esben Sparre Andreasen
2846666f32 Update javascript/ql/src/Security/CWE-770/ResourceExhaustion.qhelp
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2020-06-19 09:47:13 +02:00
Esben Sparre Andreasen
4557af3c30 Update javascript/ql/src/Security/CWE-770/ResourceExhaustion.qhelp
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2020-06-19 09:46:58 +02:00
Esben Sparre Andreasen
baaa31665a Update javascript/ql/src/experimental/Security/CWE-020/PostMessageNoOriginCheck.qhelp 2020-06-19 09:05:13 +02:00
Rasmus Lerchedahl Petersen
5ca6391f15 Python: update call graph test
we also have flow into functions!
2020-06-19 07:49:47 +02:00
Rasmus Lerchedahl Petersen
5a864aab87 Python: override genEnclosingCallable
achieved flow out of functions!
2020-06-19 07:29:46 +02:00
Alessio Della Libera
eba64dba7c Update javascript/ql/src/experimental/Security/CWE-020/PostMessageNoOriginCheck.ql
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-06-18 19:44:46 +02:00
Alessio Della Libera
c0271b1627 Update javascript/ql/src/experimental/Security/CWE-020/PostMessageNoOriginCheck.qhelp
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-06-18 19:44:38 +02:00
Alessio Della Libera
ffc9a449ab Update javascript/ql/src/experimental/Security/CWE-020/PostMessageNoOriginCheck.qhelp
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-06-18 19:43:45 +02:00
Alessio Della Libera
e84339d5bf Update javascript/ql/src/experimental/Security/CWE-020/PostMessageNoOriginCheck.qhelp
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-06-18 19:43:36 +02:00
ubuntu
71a7ec593c Use StringOps to identify functions used for verifing the origin 2020-06-18 19:41:07 +02:00
Alessio Della Libera
cc91026873 Update javascript/ql/src/experimental/Security/CWE-117/LogInjection.qll
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2020-06-18 19:31:11 +02:00
Alessio Della Libera
b4f255176a Update javascript/ql/src/experimental/Security/CWE-117/LogInjection.help
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
2020-06-18 19:29:34 +02:00
Erik Krogh Kristensen
7d6dac479c Merge branch 'js-team-sprint' into https-fix 2020-06-18 16:53:01 +02:00
Erik Krogh Kristensen
dcf617b235 Merge branch 'js-team-sprint' into bad-random-polish 2020-06-18 16:52:32 +02:00
Erik Krogh Kristensen
6b0adf18d1 rewrite sentence in private-file-exposure qhelp 2020-06-18 16:51:15 +02:00
Erik Krogh Kristensen
1556b62007 Merge branch 'js-team-sprint' into priv-file-polish 2020-06-18 16:40:53 +02:00
Erik Krogh Kristensen
9ba2c98ec0 Apply suggestions from doc review
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2020-06-18 16:38:52 +02:00
semmle-qlci
20e96799e2 Merge pull request #3661 from erik-krogh/build-leaks
Approved by asgerf, mchammer01
2020-06-18 15:32:45 +01:00
Taus
44637e29ee Merge pull request #3716 from RasmusWL/python-fix-re-escape-fp
Python: Fix FP in treating re.escape as regex
2020-06-18 16:05:50 +02:00
Marcono1234
161ba92123 Simplify NoAssignInBooleanExprs.ql 2020-06-18 15:16:09 +02:00
Rasmus Lerchedahl Petersen
9669a6a4dc Python: test for getASuccessor
also align test names
2020-06-18 15:10:45 +02:00
Rasmus Lerchedahl Petersen
03b26f7ebe Python: Remove excessive type pruning 2020-06-18 13:58:47 +02:00
Esben Sparre Andreasen
ab01dda559 JS: another qhelp fixup 2020-06-18 13:01:02 +02:00
Esben Sparre Andreasen
c9f60d4c97 JS: add lodash sinks for js/resource-exhaustion 2020-06-18 13:01:02 +02:00
Esben Sparre Andreasen
96160a6334 JS: fixup qhelp 2020-06-18 13:01:02 +02:00
Esben Sparre Andreasen
3f67e90374 JS: rename query, support timeouts, add documentation, add to suite 2020-06-18 13:01:02 +02:00
Esben Sparre Andreasen
d9d8eb4805 JS: avoid type inference in the taint steps (just a nice to have) 2020-06-18 13:00:45 +02:00
Esben Sparre Andreasen
fa4e8914e6 JS: fixups 2020-06-18 13:00:45 +02:00
Esben Sparre Andreasen
7b97fd07a8 JS: add query js/memory-exhaustion 2020-06-18 13:00:45 +02:00
Robin Neatherway
17d36cf363 Exclude dependency-based query from C# Code Scanning
This query overlaps with tools such as dependabot.
2020-06-18 11:29:15 +01:00
Esben Sparre Andreasen
44aa182d0d Update change-notes/1.25/analysis-javascript.md
Co-authored-by: Asger F <asgerf@github.com>
2020-06-18 10:14:16 +02:00
Esben Sparre Andreasen
5e31f3a34e JS: polish js/disabling-certificate-validation 2020-06-18 09:07:08 +02:00
Rasmus Lerchedahl Petersen
1562f5c69a Python: General comment on dataflow
between SSA variables and control flow nodes
2020-06-18 07:52:29 +02:00
Rasmus Lerchedahl Petersen
d283919b92 Python: implemented ParameterNode, updated test 2020-06-18 07:45:16 +02:00
ubuntu
41c029567f Add CodeQL query to detect Log Injection in JS code 2020-06-17 21:16:24 +02:00
Erik Krogh Kristensen
27a20b263e Merge branch 'https-fix' of github.com:erik-krogh/ql into https-fix 2020-06-17 21:06:21 +02:00
Erik Krogh Kristensen
7a1c161e9e Merge branch 'js-team-sprint' into https-fix 2020-06-17 21:04:44 +02:00
Erik Krogh Kristensen
218338b4f1 Merge branch 'js-team-sprint' into bad-random-polish 2020-06-17 21:04:00 +02:00
Erik Krogh Kristensen
73f26956a6 Merge branch 'js-team-sprint' into priv-file-polish 2020-06-17 21:03:09 +02:00
Rasmus Lerchedahl Petersen
c20219c2b9 Python: more local flow and more tests 2020-06-17 20:48:06 +02:00
Geoffrey White
35487ff109 Merge branch 'master' into stringtest 2020-06-17 19:00:26 +01:00
Erik Krogh Kristensen
bdda587247 Merge branch 'js-team-sprint' into build-leaks 2020-06-17 19:51:30 +02:00
ubuntu
c490cfdfa5 Create another branch 2020-06-17 19:51:14 +02:00
Erik Krogh Kristensen
6d6f29eb85 Merge pull request #3726 from erik-krogh/bad-code-polish
JS: Bad code polish
2020-06-17 19:45:37 +02:00
ubuntu
4ccfdef71d Add CodeQL query to detect Log Injection in JS code 2020-06-17 19:44:58 +02:00
Geoffrey White
174fdadbf5 Merge branch 'master' into stringtest 2020-06-17 18:24:30 +01:00
Rasmus Lerchedahl Petersen
ce57a28c8f Python: Use CallableValue and improve tests 2020-06-17 19:12:10 +02:00
Geoffrey White
03c6d7a7e5 Merge pull request #3654 from jbj/controlsBlock-perf
C++: Speed up IRGuardCondition::controlsBlock
2020-06-17 17:53:10 +01:00
Rasmus Lerchedahl Petersen
f24dc69e1d Python: add flow from ArgumentNodes 2020-06-17 18:36:50 +02:00
Rasmus Lerchedahl Petersen
a45b5a7d3c Python: Implemented return node
but I think they receive no flow
2020-06-17 17:41:43 +02:00
Tom Hvitved
ad56f17246 Merge pull request #2 from aschackmull/dataflow/content-type-tracking
Dataflow: Record content types
2020-06-17 17:26:04 +02:00
Erik Krogh Kristensen
a465fef7aa shorten sentence in qhelp 2020-06-17 17:24:18 +02:00
Anders Schack-Mulligen
74eab3cbc0 Dataflow: Fix qltest. 2020-06-17 17:23:35 +02:00
Erik Krogh Kristensen
7aa911b9f4 add reference to cwe-116 in change-note 2020-06-17 17:20:46 +02:00
Erik Krogh Kristensen
abd9aab109 code-injection -> code injection 2020-06-17 17:20:46 +02:00
Erik Krogh Kristensen
45e2b94eb5 Apply suggestions from doc review
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2020-06-17 17:19:44 +02:00
Erik Krogh Kristensen
69888f90c6 add dot after bullet-point 2020-06-17 17:15:39 +02:00
Anders Schack-Mulligen
cedfaf6aaf Dataflow: autoformat 2020-06-17 17:09:55 +02:00
Anders Schack-Mulligen
543ab71dfe Dataflow: minor review fixes. 2020-06-17 17:03:22 +02:00
Rasmus Lerchedahl Petersen
25d624d64b Python: Implement parameter nodes 2020-06-17 16:59:19 +02:00
Geoffrey White
33fab08975 C++: Autoformat. 2020-06-17 15:53:05 +01:00
Dave Bartolomeo
687d6d2643 C++: Replace TRawInstruction() calls
Replace most direct calls to `TRawInstruction()` with calls to `getInstructionTranslatedElement()` and `getInstructionTag()`, matching existing practice. One tiny RA diff in an inconsequential join order in `getInstructionVariable`.
2020-06-17 10:52:32 -04:00
Geoffrey White
833f5b0cf3 C++: Add flow through assignment operators. 2020-06-17 15:47:37 +01:00
Geoffrey White
b9a65581ce C++: Some constructors should have dataflow instead of taint. 2020-06-17 15:47:37 +01:00
Geoffrey White
031c9b98f1 C++: General taint flow through constructors. 2020-06-17 15:47:37 +01:00
Geoffrey White
30151c99d7 C++: Remove the std::string Constructor model. 2020-06-17 15:43:58 +01:00
Rasmus Lerchedahl Petersen
8e51b2fed8 Python: refactor test for global flow 2020-06-17 16:43:11 +02:00
Geoffrey White
d565cfc58e C++: Add a test of default constructors etc. 2020-06-17 15:41:36 +01:00
Geoffrey White
c196ea24b2 C++: Add taint tests of class constructors and assignment. 2020-06-17 15:41:00 +01:00
Geoffrey White
ea9e9a7a26 C++: Add taint tests of std::string constructors and assignment. 2020-06-17 15:41:00 +01:00
Dave Bartolomeo
c1016743a5 C++: Remove instructionOrigin()
This noopt predicate is no longer necessary. It's equivalent to `instruction = TRawInstruction(element, tag)`, which is already materialized and has a more favorable column order anyway.
2020-06-17 10:25:59 -04:00
Rasmus Lerchedahl Petersen
71f364eef3 Python: Implement OutNode
Also, fix test for local flow
2020-06-17 16:24:44 +02:00
Dave Bartolomeo
e85cc0b0c6 C++: Stop caching raw IR construction predicates
These predicates are only used within the new single IR stage, so there's no need to cache them beyond that. RA diffs are trivial. Where previously many of the predicate on `Instruction` were inline wrappers around cached predicates from `IRConstruction`, now the predicates from `IRConstruction` get inlined into the `Instruction` predicates, and the `Instruction` predicates get materialized. The net amount of work is the same, but now it's not getting cached unnecessarily.
2020-06-17 09:47:48 -04:00
Anders Schack-Mulligen
d28b5ace63 Dataflow: Sync. 2020-06-17 15:40:48 +02:00
Anders Schack-Mulligen
10b64fc47a Dataflow: Record content type for stores. 2020-06-17 15:40:42 +02:00
Mathias Vorreiter Pedersen
01abaf373a Merge pull request #3728 from geoffw0/memberfunctions
C++: Split MemberFunction.qll from Function.qll.
2020-06-17 14:54:33 +02:00
Jonas Jensen
a87ff80ac0 Merge pull request #3587 from rdmarsh2/ir-this-parameter-2
C++: IR return indirections for `this`
2020-06-17 13:27:35 +02:00
Geoffrey White
7edaade175 C++: Improve QLDoc. 2020-06-17 12:11:42 +01:00
Erik Krogh Kristensen
cd111fe350 Merge pull request #3721 from asger-semmle/js/non-linear-pattern-msg
JS: Improve alert message in js/non-linear-pattern
2020-06-17 13:10:56 +02:00
Geoffrey White
0a9ec70c31 C++: Autoformat. 2020-06-17 11:54:50 +01:00
Erik Krogh Kristensen
b0be0eb805 fix qhelp links 2020-06-17 11:50:44 +02:00
Erik Krogh Kristensen
fa0a8c3423 add documentation examples as tests 2020-06-17 11:37:32 +02:00
Erik Krogh Kristensen
b42824640d add qhelp for js/exposure-of-private-files 2020-06-17 11:29:24 +02:00
Geoffrey White
f3e24963cb C++: Update QLDoc. 2020-06-17 10:27:34 +01:00
ubuntu
22cb45beab Merge remote-tracking branch 'upstream/master' 2020-06-17 11:13:13 +02:00
Erik Krogh Kristensen
345283fe34 add change note 2020-06-17 10:48:27 +02:00
Erik Krogh Kristensen
639907967f add home/rootdir as leaking folders 2020-06-17 10:46:42 +02:00
Erik Krogh Kristensen
6675ddae12 add more libraries that serve static files to js/exposure-of-private-files 2020-06-17 10:00:59 +02:00
Jonas Jensen
e0ba23d2c7 C++: @precision high for tainted-format-string*
I think these queries have excellent results on lgtm.com. Many of the
results come from projects that use `sprintf` like it's a templating
engine, trusting that values from `argv` or `getenv` contain the correct
number of `%s`. I think we want to flag that.

The structure of the change note is modeled after 91af51cf46.
2020-06-17 09:03:13 +02:00
Rasmus Lerchedahl Petersen
52898f16f5 Python: update paths after move 2020-06-17 08:34:45 +02:00
Rasmus Lerchedahl Petersen
47f5b04e87 Python: fix identical-files.json after move
also more grouping
2020-06-17 07:08:46 +02:00
Rasmus Lerchedahl Petersen
e192b66116 Python: move shared dataflow to experimental 2020-06-17 06:46:46 +02:00
luchua-bc
f40e27a3c5 Hardcoded AWS credentials 2020-06-17 02:46:02 +00:00
Erik Krogh Kristensen
fb5e13b456 Apply suggestions from doc review
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2020-06-16 23:45:45 +02:00
Erik Krogh Kristensen
d811518a2e fixed from doc review, and add fixed example for js/biased-cryptographic-random using a secure library 2020-06-16 23:26:54 +02:00
Dave Bartolomeo
8e977dc6bf C++/C#: Move overrides of IRType::getByteSize() into leaf classes
See https://github.com/github/codeql/pull/2272. I've added code comments in all of the places that future me will be tempted to hoist these overrides.
2020-06-16 16:48:42 -04:00
Dave Bartolomeo
24c3110989 Merge from master 2020-06-16 16:37:38 -04:00
Erik Krogh Kristensen
210e71cd93 update expected output 2020-06-16 21:52:59 +02:00
Robert Marsh
ef940e815f C++: Add comment for false positives in swap tests 2020-06-16 11:46:14 -07:00
Robert Marsh
0c99b3644c C++: remove false negative comments in swap tests 2020-06-16 11:33:26 -07:00
Robert Marsh
1c9b6f0a48 Merge branch 'master' into ir-this-parameter-2
Accept test changes - dataflow changes are all positive
2020-06-16 11:28:49 -07:00
Geoffrey White
3d75d287a9 C++: Split MemberFunction.qll from Function.qll. 2020-06-16 17:40:46 +01:00
ubuntu
3104f8a37b Remove Fields in PostMessageEvent 2020-06-16 18:30:00 +02:00
Alessio Della Libera
68b2a6c848 Update javascript/ql/src/experimental/Security/CWE-020/PostMessageNoOriginCheck.ql
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-06-16 18:27:21 +02:00
Alessio Della Libera
8843522d14 Update javascript/ql/src/experimental/Security/CWE-020/PostMessageNoOriginCheck.ql
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-06-16 18:26:42 +02:00
Alessio Della Libera
72dc6510b2 Update javascript/ql/src/experimental/Security/CWE-020/PostMessageNoOriginCheck.ql
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-06-16 18:22:55 +02:00
Robert Marsh
ab327b989d Merge pull request #3713 from MathiasVP/flow-diff-test
C++: Add test for differences between AST and IR field flow
2020-06-16 09:09:46 -07:00
Erik Krogh Kristensen
ac1a0d9925 Merge pull request #3725 from erik-krogh/yargs-changenote
JS: add changenote for yargs
2020-06-16 16:28:43 +02:00
Erik Krogh Kristensen
02c825351c add change note for js/bad-code-sanitization 2020-06-16 16:25:30 +02:00
Erik Krogh Kristensen
5ce17bea60 add qhelp for js/bad-code-sanitization 2020-06-16 16:23:41 +02:00
Jonas Jensen
e5e373cff2 Merge pull request #3673 from MathiasVP/assign-op-using-swap
C++: Add tests for taint through swap
2020-06-16 15:43:52 +02:00
Rasmus Lerchedahl Petersen
0f77403f0e Python: small start on global flow
need to actually have `OutNode`s
2020-06-16 15:36:03 +02:00
Erik Krogh Kristensen
a0951f76b6 add additional taint steps when type-tracking RemoteFlowSource 2020-06-16 14:55:07 +02:00
semmle-qlci
07bff646d8 Merge pull request #3641 from asger-semmle/js/pre-call-graph-steps
Approved by erik-krogh
2020-06-16 13:41:55 +01:00
Erik Krogh Kristensen
cb5b946546 add changenote for yargs 2020-06-16 14:37:53 +02:00
Jonas Jensen
17737cd872 C++: Account for unreachable blocks in guards
This restores the code I removed in 4642037dc.
2020-06-16 14:33:12 +02:00
Rasmus Lerchedahl Petersen
f3e879a5ab Python: small test of local flow 2020-06-16 14:31:22 +02:00
Erik Krogh Kristensen
696879653a add qhelp to js/biased-cryptographic-random 2020-06-16 11:10:09 +02:00
lcartey@github.com
2978af34cd Java: Add RestTemplate as flow source. 2020-06-16 09:50:37 +01:00
lcartey@github.com
f2edc53144 Java: Add Spring RestTemplate return values to untrusted data types
- Also improve unwrapping of lists/arrays/maps etc.
2020-06-16 09:50:37 +01:00
lcartey@github.com
9625e82afd Java: Model Spring WebClients/RestTemplates. 2020-06-16 09:50:37 +01:00
lcartey@github.com
cd6339f5cd Java: Add Spring flow out of HttpEntity and HttpHeader 2020-06-16 09:50:36 +01:00
lcartey@github.com
93c28d4c03 Java: Add taint step to flow through Spring tainted user data class
getters.
2020-06-16 09:50:36 +01:00
lcartey@github.com
8678d5fc6f Java: Model untrusted user data types
Model the datatypes that may be populated on demand from request
parameters.
2020-06-16 09:50:36 +01:00
lcartey@github.com
8bd5f748b4 Java: SpringController - handle non-string literal produces values. 2020-06-16 09:50:36 +01:00
lcartey@github.com
0db7cead31 Java: Model taint flow through ResponseEntity. 2020-06-16 09:50:35 +01:00
lcartey@github.com
f6b2accabd Java: Model ResponseEntity.BodyBuilder 2020-06-16 09:50:35 +01:00
lcartey@github.com
e2cec582be Java: XSS - ignore Spring sinks when content-type is safe.
Methods annotated with a produces field which indicates a safe
content-type should not be considered XSS sinks. For example:

@RequestMapping(..., produces = "application/json")
2020-06-16 09:50:35 +01:00
lcartey@github.com
f6a99cb42e Java: Model produces parameter to RequestMapping attribute. 2020-06-16 09:50:34 +01:00
lcartey@github.com
8057dff368 Java: Add Spring XSS sinks
Look for Spring request methods which return a String value which may be
coerced into a text/html output.
2020-06-16 09:50:34 +01:00
lcartey@github.com
c59042f9c3 Java: Taint tracking through String.replace(all)? 2020-06-16 09:50:34 +01:00
lcartey@github.com
7d555a7467 Java: Track flow through HttpEntity and ResponseEntity
- Only track if the body is a String type, as that is the only type at
   risk of XSS.
2020-06-16 09:50:33 +01:00
lcartey@github.com
1d1234093f Java: Model Spring @ResponseBody methods. 2020-06-16 09:50:33 +01:00
lcartey@github.com
fd2cd6025d Java: Modelling of the Spring HTTP classes. 2020-06-16 09:50:33 +01:00
lcartey@github.com
bfcc06dd0b Java: Improve Spring controller modelling
- Identify ModelMaps correctly
 - Add extra not tainted param types (Pageable)
 - Identify ModelAttributes
2020-06-16 09:50:33 +01:00
lcartey@github.com
7c4251deac Java: Add flow out of Map and List 2020-06-16 09:50:32 +01:00
lcartey@github.com
6de2b93f3a Java: Add SpringWebRequest to RemoteTaintedMethod 2020-06-16 09:50:32 +01:00
lcartey@github.com
4300bc8088 Java: Update RemoteFlowSource to use improve Spring request parameter
mapping.
2020-06-16 09:50:31 +01:00
lcartey@github.com
f5dc0337ed Java: Improve modelling of Spring request methods
- Recognise @<httpverb>Mapping as well as @RequestMapping.
 - Identify tainted/not tainted parameters of RequestMapping methods.
2020-06-16 09:50:31 +01:00
Mathias Vorreiter Pedersen
c30d1a618e C++: Add charpred to partial definition node classes in qltest 2020-06-16 09:55:37 +02:00
Jonas Jensen
d80a033bed Merge pull request #3719 from dbartol/github/codeql-c-analysis-team/69-consistency
C++/C#: Fix a couple new consistency failures, and improve consistency messages
2020-06-16 08:48:35 +02:00
Rasmus Lerchedahl Petersen
0abba238cc Python: bit more local flow and fix ql docs 2020-06-16 08:21:32 +02:00
Rasmus Lerchedahl Petersen
ad04ec554a Python: group related predicates
also restore accidentally removed comment
2020-06-16 07:30:44 +02:00
Jonathan Leitschuh
c2052ed152 Add .gitignore for VS Code Generated maven project files
When VS Code detects a Maven project, it automatically generates
a bunch of Eclipse files to describe the project.

These are now ignored in order to not pollute the repository
2020-06-15 22:29:30 -04:00
Erik Krogh Kristensen
5e060fa6a8 Apply suggestions from code review
Co-authored-by: Asger F <asgerf@github.com>
2020-06-15 23:47:40 +02:00
Erik Krogh Kristensen
315faaffee small corrections in documentation
Co-authored-by: Asger F <asgerf@github.com>
2020-06-15 23:40:27 +02:00
Asger Feldthaus
23d28967a7 JS: Autoformat 2020-06-15 20:40:17 +01:00
Asger Feldthaus
3242f5ed94 JS: Include qhelp example in test suite 2020-06-15 17:37:26 +01:00
Asger Feldthaus
824054ba62 JS: Change note and updated help 2020-06-15 17:34:36 +01:00
Asger Feldthaus
7091a9f704 JS: Special-case alert message for type annotations 2020-06-15 17:17:47 +01:00
Asger Feldthaus
c8ab69af11 JS: Avoid duplicate alerts 2020-06-15 16:57:54 +01:00
Asger Feldthaus
f380898126 JS: Add test showing duplicate alerts 2020-06-15 16:40:37 +01:00
Aditya Sharad
d7d00bddf6 Merge pull request #3718 from adityasharad/cpp/formatting-function-doc
C++: Fix QLDoc on `FormattingFunction` library
2020-06-15 08:39:16 -07:00
Asger Feldthaus
51d143d6f1 JS: Add test with destructuring pattern that looks like type annotations 2020-06-15 16:35:36 +01:00
Dave Bartolomeo
881b3c8e33 C#: Fix IR consistency errors
We were creating a `TranslatedFunction` even for functions that were not from source code, but then telling the IR package that those functions didn't have IR. This resulted in having prologue/epilogue instructions (e.g. `EnterFunction`, `ExitFunction`) with no enclosing `IRFunction`.
2020-06-15 11:33:00 -04:00
Owen Mansel-Chan
f9db197e17 Merge pull request #3683 from owen-mc/improve-ast-class-reference-for-java
Improve ast class reference for java
2020-06-15 16:25:25 +01:00
Erik Krogh Kristensen
23223fc5fb change-note 2020-06-15 17:22:11 +02:00
Erik Krogh Kristensen
3ef5dc74a1 add backtracking to find division that end up being rounded 2020-06-15 17:10:10 +02:00
Erik Krogh Kristensen
e8db624e74 add .jar and .war to the list of sensitive files for js/insecure-download 2020-06-15 16:48:07 +02:00
Dave Bartolomeo
fecffab8e7 C++: Fix consistency error
`TTranslatedAllocationSideEffects` wasn't limiting itself to functions that actually have IR, so it was getting used even in template definitions.
2020-06-15 10:47:00 -04:00
Dave Bartolomeo
8cbc7e8654 C++/C#: Improve consistency failure result messages
Some of our IR consistency failure query predicates already produced results in the schema as an `@kind problem` query, including `$@` replacements for the enclosing `IRFunction` to make it easier to figure out which function to dump when debugging. This change moves the rest of the query predicates in `IRConsistency.qll` to do the same. In addition, it wraps each call to `getEnclosingIRFunction()` to return an `OptionalIRFunction`, which can be either a real `IRFunction` or a placeholder in case `getEnclosingIRFunction()` returned no results. This exposes a couple new consistency failures in `syntax-zoo`, which will be fixed in a subsequent commit.

This change also deals with consistency failures when the enclosing `IRFunction` has more than one `Function` or `Location`. For multiple `Function`s, we concatenate the function names. For multiple `Location`s, we pick the first one in lexicographical order. This changes the number of results produced in the existing tests, but does't change the actual number of problems.
2020-06-15 10:46:46 -04:00
semmle-qlci
3728e1afd3 Merge pull request #3715 from asger-semmle/js/returned-functions
Approved by erik-krogh, esbena
2020-06-15 15:32:54 +01:00
Aditya Sharad
1033d22d1b C++: Fix QLDoc on FormattingFunction library
Copy-paste typo from `DataFlowFunction`.
2020-06-15 07:32:53 -07:00
Shati Patel
3520f2c737 Merge pull request #3714 from shati-patel/name-res-114
QL handbook: Update process for module resolution
2020-06-15 15:29:56 +01:00
Rasmus Lerchedahl Petersen
f8eb5839cd Python: start on local flow 2020-06-15 16:25:41 +02:00
Shati Patel
947ccb06c7 Update docs/language/ql-handbook/name-resolution.rst
Co-authored-by: Henning Makholm <hmakholm@github.com>
2020-06-15 15:15:44 +01:00
Shati Patel
e69c946f31 Mention libraryPathDependencies 2020-06-15 14:56:57 +01:00
Erik Krogh Kristensen
d2716c532c qhelp 2020-06-15 14:59:48 +02:00
Asger Feldthaus
17010e25a1 JS: Update another test 2020-06-15 13:55:46 +01:00
Erik Krogh Kristensen
dc09a68eb4 add change-note 2020-06-15 14:30:34 +02:00
semmle-qlci
57c8dd85a4 Merge pull request #2801 from esbena/js/bulky-route-handler-registration
Approved by asgerf
2020-06-15 13:06:22 +01:00
Erik Krogh Kristensen
8682918779 add change note 2020-06-15 13:47:43 +02:00
Erik Krogh Kristensen
fe9aa241a1 add qhelp 2020-06-15 13:47:39 +02:00
Erik Krogh Kristensen
4d1920eec1 add .js and .py files to js/insecure-download 2020-06-15 12:48:50 +02:00
Asger Feldthaus
4b3faabcc8 JS: Autoformat 2020-06-15 11:16:55 +01:00
Asger Feldthaus
c4179eb81d JS: Update test 2020-06-15 11:13:20 +01:00
Rasmus Wriedt Larsen
c0043eb9db Python: Don't treat re.escape(...) as a regex
Fixes https://github.com/github/codeql/issues/3712
2020-06-15 11:54:14 +02:00
Rasmus Lerchedahl Petersen
6dfb3a5df8 Python: Address QL docs 2020-06-15 11:50:07 +02:00
Rasmus Wriedt Larsen
7601bd497e Python: Add tests for re.escape FP 2020-06-15 11:34:42 +02:00
semmle-qlci
b6b838774e Merge pull request #3704 from asger-semmle/js/cve-serve
Approved by esbena
2020-06-15 09:54:17 +01:00
Asger Feldthaus
c7f74e47e2 JS: Autoformat 2020-06-15 09:51:42 +01:00
Calum Grant
0d1fb0f248 Merge pull request #3509 from hvitved/csharp/html-raw
C#: Recognize more calls to `IHtmlHelper.Raw`
2020-06-15 09:31:58 +01:00
Shati Patel
3dd529035d QL reference: Update process for name resolution 2020-06-15 08:45:30 +01:00
Mathias Vorreiter Pedersen
6748f3887e C++: Add test demonstrating differences between AST and IR field flow. Also refactored the partial definitions test 2020-06-15 09:39:15 +02:00
Rasmus Lerchedahl Petersen
1af2e56894 Summary of recent meeting.
Perhaps a not-python-specific version of this
could go into the shared implementation.
2020-06-15 08:01:02 +02:00
Dave Bartolomeo
89a1fd4b4a C++/C#: Fix formatting 2020-06-13 08:22:04 -04:00
Dave Bartolomeo
eac3b06c57 C#: Fix up C# IR construction to latest interface 2020-06-12 17:40:27 -04:00
Dave Bartolomeo
73d2e09a8d C++:/C# Remove opcode from TRawInstruction 2020-06-12 17:36:01 -04:00
Dave Bartolomeo
978275cbd4 C++/C#: Move irFunc out of various TInstruction branches 2020-06-12 17:26:45 -04:00
Dave Bartolomeo
07c1520b4d C++/C#: Move ast out of TRawInstruction 2020-06-12 17:03:02 -04:00
Dave Bartolomeo
2aabe431f6 C++/C#: Stop caching getOldInstruction() 2020-06-12 16:22:58 -04:00
Dave Bartolomeo
ac169931b3 C++/C#: More efficient evaluation of SSA::hasInstruction() 2020-06-12 16:09:50 -04:00
Asger Feldthaus
315f3389d1 JS: Autoformat test 2020-06-12 19:58:05 +01:00
Asger F
d844e0025a Merge pull request #3651 from esbena/js/bad-multicharacter-sanitization
JS: initial version of IncompleteMultiCharacterSanitization.ql
2020-06-12 16:25:22 +01:00
Asger Feldthaus
b9cd157c0f JS: Autoformat 2020-06-12 15:36:02 +01:00
Dave Bartolomeo
4331b9b54e C++: Simplify logic to an implication 2020-06-12 09:31:19 -04:00
Esben Sparre Andreasen
678bb7c128 JS: simplify loop detection 2020-06-12 14:56:08 +02:00
Asger Feldthaus
eaf6be5fea JS: Fix lazy qldoc 2020-06-12 13:29:35 +01:00
Asger Feldthaus
91d98c0d00 JS: Change note 2020-06-12 13:12:55 +01:00
Asger Feldthaus
5548606f21 JS: Add test 2020-06-12 13:02:33 +01:00
Erik Krogh Kristensen
01c51eea89 Merge pull request #3680 from erik-krogh/bad-code-sanitizer
JS: Add query to detect bad code sanitizers
2020-06-12 14:00:21 +02:00
Asger Feldthaus
4795b87daa JS: Add model of Micro 2020-06-12 12:45:11 +01:00
Asger Feldthaus
230f78afb6 JS: Step through path.{format, parse} 2020-06-12 12:26:45 +01:00
semmle-qlci
2342d3dba3 Merge pull request #3662 from asger-semmle/js/package-export-fixes
Approved by esbena
2020-06-12 12:18:23 +01:00
Max Schaefer
cafbe14dc8 Merge pull request #3703 from shati-patel/mergeback
Merge rc/1.24 into master
2020-06-12 11:37:47 +01:00
Shati Patel
07d5ee6126 Merge branch 'rc/1.24' into mergeback 2020-06-12 11:30:47 +01:00
Rasmus Lerchedahl Petersen
375da38765 Python: Minimal compilation of shared dataflow 2020-06-12 11:48:41 +02:00
Erik Krogh Kristensen
f0ec2eb37b add missing qldoc 2020-06-12 11:47:53 +02:00
Erik Krogh Kristensen
c9fc1a378d Merge pull request #3663 from erik-krogh/bad-crypto
JS: Introduce query to detect biased random number generators
2020-06-12 11:32:12 +02:00
Erik Krogh Kristensen
1751fb6c47 add missing qldoc 2020-06-12 11:30:22 +02:00
Erik Krogh Kristensen
adabd2daca add qldoc and customizations module 2020-06-12 11:26:49 +02:00
Asger Feldthaus
4c536dde20 JS: Propagate locally returned functions out of calls 2020-06-12 10:07:37 +01:00
Erik Krogh Kristensen
908edb39b9 unsecure -> insecure 2020-06-12 11:02:26 +02:00
Erik Krogh Kristensen
86b23b239e Merge pull request #3656 from erik-krogh/destruct-yargs
JS: support rest-patterns inside property patterns
2020-06-12 10:57:24 +02:00
Asger Feldthaus
6531db3cca JS: Add test 2020-06-12 09:56:38 +01:00
Erik Krogh Kristensen
57d2226080 typo 2020-06-12 10:55:29 +02:00
Erik Krogh Kristensen
9780fcf8fe fix ftp protocol regexp 2020-06-12 10:54:56 +02:00
Erik Krogh Kristensen
3f957103ed improve alert message - and autoformat 2020-06-12 10:53:19 +02:00
Erik Krogh Kristensen
056a7e87ff refactor into customizations module - and move curl download to a ClientRequest 2020-06-12 10:51:09 +02:00
Erik Krogh Kristensen
8225adcaea move TODOs 2020-06-12 10:28:06 +02:00
Erik Krogh Kristensen
02c4a0477d add tests for js/build-artifact-leak 2020-06-12 10:21:37 +02:00
Anders Schack-Mulligen
041af38934 Merge pull request #3697 from intrigus-lgtm/patch-1
Fix typo
2020-06-12 10:04:40 +02:00
semmle-qlci
6f40fc2eae Merge pull request #3678 from Marcono1234/patch-1
Approved by shati-patel
2020-06-12 08:49:53 +01:00
Anders Schack-Mulligen
421a548e42 Update java/ql/src/semmle/code/java/Expr.qll 2020-06-12 09:24:37 +02:00
Jonas Jensen
abd05bcff1 Merge pull request #3596 from robertbrignull/more-suites
Add more code-scanning suites
2020-06-12 09:08:20 +02:00
semmle-qlci
035d8ea24c Merge pull request #3690 from asger-semmle/js/fix-lgtm-filters-comment
Approved by max-schaefer
2020-06-12 07:40:58 +01:00
Esben Sparre Andreasen
1bdae109c5 Merge pull request #3686 from esbena/js/insecure-http-options
JS: add query js/disabling-certificate-validation
2020-06-12 08:40:12 +02:00
semmle-qlci
5c2f1169d0 Merge pull request #3679 from asger-semmle/js/dom-value-ref-restriction
Approved by erik-krogh, esbena
2020-06-12 07:39:26 +01:00
Esben Sparre Andreasen
243e3ad9e3 Merge pull request #3672 from esbena/js/server-crashing-route-handler
JS: add initial version of ServerCrash.ql
2020-06-12 08:38:37 +02:00
Robert Marsh
65f4ef712e C++: accept false positive tests after merge
The IR false positives are due to the same path length limit as the AST
false positives on the same line.
2020-06-11 15:27:13 -07:00
Erik Krogh Kristensen
5b491313ad add simple query for detecting sensitive files downloaded over unsecure connection 2020-06-11 23:19:28 +02:00
Erik Krogh Kristensen
065cb04202 make PropNode private again 2020-06-11 23:19:03 +02:00
Erik Krogh Kristensen
ef72c03ca9 use simpler taint-step for DestructingPattern 2020-06-11 23:16:46 +02:00
Marcono1234
7cd6dd27a6 Add link to Java regex Pattern documentation to language.rst
Co-authored-by: Shati Patel <42641846+shati-patel@users.noreply.github.com>
2020-06-11 23:02:59 +02:00
intrigus-lgtm
422b059aec Fix typo 2020-06-11 22:54:13 +02:00
Robert Marsh
a7efa0d602 Merge branch 'master' into ir-this-parameter-2 2020-06-11 13:21:52 -07:00
Mathias Vorreiter Pedersen
b78c06559e Merge pull request #3691 from geoffw0/reftest
C++: Add a test case for CWE-114 involving pointers and references.
2020-06-11 22:02:45 +02:00
Geoffrey White
fdd7ad2300 C++: Add a SideEffectFunction model to 'system'. 2020-06-11 18:59:17 +01:00
Geoffrey White
e8b34e07f8 C++: Add an AliasFunction model to 'system'. 2020-06-11 18:44:41 +01:00
Geoffrey White
7fee2c239d C++: Add an ArrayFunction model to 'system'. 2020-06-11 18:44:09 +01:00
Geoffrey White
b38a7a9ffc C++: Fill out ArrayFunction model for 'fgets'. 2020-06-11 18:20:24 +01:00
Robert Marsh
ae46a8d8a1 Merge pull request #3692 from igfoo/blockstmt
C++: Fix reference to `Block`
2020-06-11 09:49:19 -07:00
Geoffrey White
40c20f2731 C++: Add the test for DefaultTaintTracking as well. 2020-06-11 17:37:05 +01:00
Geoffrey White
2f192f6a0c C++: Add a test of char* -> std::string -> char* taint. 2020-06-11 17:37:05 +01:00
Dave Bartolomeo
41df7000c5 Merge from master, including fixing up merge conflicts 2020-06-11 12:20:46 -04:00
Ian Lynagh
fd88289e46 C++: Fix reference to Block
We don't call it `BlockStmt`.
2020-06-11 16:50:23 +01:00
Asger Feldthaus
475c631ff9 JS: Fix a misleading javadoc comment 2020-06-11 16:16:51 +01:00
Dave Bartolomeo
b116a3e8ea C#: Rename IR module references to point to experimental 2020-06-11 10:24:01 -04:00
Anders Schack-Mulligen
c961a31789 Java: Add Expr.getAnEnclosingStmt. 2020-06-11 13:46:12 +02:00
semmle-qlci
c2de54f5ca Merge pull request #3685 from shati-patel/ast-go-edits
Approved by felicitymay, owen-mc
2020-06-11 12:43:20 +01:00
Esben Sparre Andreasen
169c8909df formatting 2020-06-11 13:28:26 +02:00
Esben Sparre Andreasen
bc7f02156b JS: replace class with two predicates (and improve alert message) 2020-06-11 13:20:46 +02:00
Erik Krogh Kristensen
7c7af8d841 less heuristics when flagging division that is rounded 2020-06-11 12:55:13 +02:00
Erik Krogh Kristensen
f1b24ba901 use type inference to detect string concatenations 2020-06-11 12:34:58 +02:00
Esben Sparre Andreasen
2e059376fd JS: add query js/disabling-certificate-validation 2020-06-11 12:32:01 +02:00
Erik Krogh Kristensen
f634c62af5 remove redundant check 2020-06-11 12:18:41 +02:00
Shati Patel
2874050503 CodeQL for Go: Edit AST reference 2020-06-11 10:49:19 +01:00
Rasmus Wriedt Larsen
a24974b194 Python: Add missing <p> to qhelp 2020-06-11 11:45:38 +02:00
Anders Schack-Mulligen
f23eb0432e Java: Improve qldoc for JavadocTag. 2020-06-11 11:44:50 +02:00
Rasmus Wriedt Larsen
33a9fb6034 Python: Reorder XSLT qhelp to be valid 2020-06-11 11:30:54 +02:00
Tom Hvitved
ca531cbb9a C#: Rename a class 2020-06-11 11:26:25 +02:00
Tom Hvitved
8395980fb1 C#: Recognize more calls to IHtmlHelper.Raw
Generalize logic by recognizing not only calls to
`Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper.Raw()`, but calls to all `Raw()`
methods that implement `Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper.Raw()`.
2020-06-11 11:26:25 +02:00
Erik Krogh Kristensen
c375a0c611 fix compilation and update expected output 2020-06-11 11:16:38 +02:00
Owen Mansel-Chan
ab52010674 Give general syntax instead of examples for exprs 2020-06-11 10:06:46 +01:00
Owen Mansel-Chan
3ca5d34d9b Add more links to java AST class reference
Using the explicit hyperlink target feature of rst to keep the text in
the tables short and put all the URLs at the end of the document
2020-06-11 10:06:46 +01:00
Owen Mansel-Chan
84a4630eaf Move explicit hyperlink targets to the bottom 2020-06-11 10:06:42 +01:00
Erik Krogh Kristensen
1124816f73 fixing FPs in js/biased-cryptographic-random 2020-06-11 11:06:02 +02:00
Calum Grant
5e021c24c1 Merge pull request #3652 from hvitved/csharp/dataflow/impl-layer
C#: Refactor data-flow predicates defined by dispatch
2020-06-11 10:01:50 +01:00
Asger Feldthaus
4bb2e8b637 JS: Update test externs and include array indices 2020-06-11 09:53:55 +01:00
Pavel Avgustinov
60df00c7e3 Merge pull request #3669 from github/sj-patch-contributing-SLA
Update CONTRIBUTING.md to clarify that CLAs are no longer required
2020-06-11 09:17:11 +01:00
Shati Patel
d9d0903084 Merge pull request #3681 from github/rc/1.24
Merge rc/1.24 into master
2020-06-11 09:00:57 +01:00
Max Schaefer
cee248520e Merge pull request #3675 from owen-mc/ast-class-reference-for-go
AST class reference for go
2020-06-11 08:05:41 +01:00
Rasmus Lerchedahl Petersen
b5703cd3f6 Python: link to FP report in test file 2020-06-11 07:14:48 +02:00
Robert Marsh
982fb38807 Merge pull request #3419 from MathiasVP/flat-structs
C++: Add reverse reads to IR field flow
2020-06-10 14:31:00 -07:00
ubuntu
e8b05b70c4 Added support for detecting unsafe methods used for origin verification 2020-06-10 23:11:03 +02:00
ubuntu
cf3142e083 Updated qhelp with a third example 2020-06-10 23:09:35 +02:00
ubuntu
92f9f320f9 Added new example of an unsafe event.origin verification 2020-06-10 23:07:05 +02:00
Erik Krogh Kristensen
aa3482cbae improve detection of duplicate results with js/code-injection 2020-06-10 22:58:02 +02:00
Erik Krogh Kristensen
5142670138 don't import AdditionalSinks, refactor sink out in new HeuristicSinks instead 2020-06-10 22:30:45 +02:00
Mathias Vorreiter Pedersen
a38839b446 C++: Include copy of IntWrapper class with two data members 2020-06-10 22:27:40 +02:00
Mathias Vorreiter Pedersen
ca20f17703 C++: Implement move constructor in terms of swap. I'm haven't found anything online on whether this is good or bad, and the only reason for not doing it might be performance. 2020-06-10 22:16:58 +02:00
Esben Sparre Andreasen
d6ae905eac JS: remove speculative property access sink from js/server-crash 2020-06-10 21:40:12 +02:00
semmle-qlci
b841cacb83 Merge pull request #3676 from max-schaefer/js/global-access-paths-minor-fixes
Approved by erik-krogh
2020-06-10 20:02:55 +01:00
Calum Grant
cd914deeff Merge pull request #3666 from hvitved/csharp/ir-experimental
C#: Move IR code into 'experimental' folder
2020-06-10 19:50:37 +01:00
Erik Krogh Kristensen
373a437d71 add query to detect improperly sanitized code 2020-06-10 19:50:12 +02:00
Owen Mansel-Chan
d8900448ec Add references to the AST class reference for go 2020-06-10 17:32:41 +01:00
Owen Mansel-Chan
48ff00832c Add a reference to the AST class reference for go 2020-06-10 17:24:40 +01:00
semmle-qlci
4cdb3c13df Merge pull request #3658 from RasmusWL/python-3.8-dict-ismapping
Approved by tausbn
2020-06-10 17:19:49 +01:00
semmle-qlci
f7c6b1364b Merge pull request #3640 from RasmusWL/python-handle-3.8-enum-convert
Approved by tausbn
2020-06-10 17:19:22 +01:00
Erik Krogh Kristensen
5c31b94761 autoformat and update expected output 2020-06-10 18:00:56 +02:00
Marcono1234
5d2b911596 Fix incorrect java.util.regex.Pattern name in specification 2020-06-10 17:56:57 +02:00
Max Schaefer
0f2186c844 JavaScript: Fix a few typos. 2020-06-10 16:44:24 +01:00
Owen Mansel-Chan
5b2c0fbb04 AST class reference for go
The master copy of this file is in the codeql-go repository
2020-06-10 16:42:03 +01:00
Mathias Vorreiter Pedersen
1a95095505 C++: Add default move constructor. Also removed debug comment I forgot to remove earlier. Luckily, that meant that no line numbers changed in .expected files. 2020-06-10 17:13:04 +02:00
Rasmus Wriedt Larsen
ce1f0a39ac Python: Minor fixup of qhelp for XPath injection 2020-06-10 16:59:40 +02:00
Mathias Vorreiter Pedersen
5abab25c28 Update cpp/ql/test/library-tests/dataflow/taint-tests/taint.cpp
Co-authored-by: Jonas Jensen <jbj@github.com>
2020-06-10 16:51:21 +02:00
Rasmus Wriedt Larsen
48b2d2cc5c Python: Make isSequence() and isMapping() tests version specific
Since unicode/bytes difference, output can't match between Python 2 and Python 3.
2020-06-10 16:43:56 +02:00
Asger Feldthaus
f23c6030aa JS: Restrict domValueRef to known DOM property names 2020-06-10 15:14:23 +01:00
Asger Feldthaus
bb2b7fb6fb JS: Add test with class stored in global variable 2020-06-10 15:14:23 +01:00
Rasmus Wriedt Larsen
721713b9e1 Python: Minor fixes from code review
Co-authored-by: Taus <tausbn@gmail.com>
2020-06-10 16:14:21 +02:00
Taus
5b0d92d72b Merge pull request #3464 from yoff/UnicodeEscape
Python: Handle more escapes in regexes
2020-06-10 15:47:09 +02:00
Taus
da6736df37 Merge pull request #3668 from RasmusWL/python-random-modernisations
Python: Two small modernisations
2020-06-10 15:45:07 +02:00
Geoffrey White
91b9b78c48 C++: Add a test case for CWE-114 involving pointers and references. 2020-06-10 14:09:46 +01:00
Asger Feldthaus
36c4803694 JS: Add test 2020-06-10 14:08:33 +01:00
Mathias Vorreiter Pedersen
88dabffd2b C++: Add tests that demonstrate flow through custom swap functions 2020-06-10 15:06:57 +02:00
Asger Feldthaus
07e90ff65f JS: Autoformat 2020-06-10 14:03:01 +01:00
semmle-qlci
df79f2adc5 Merge pull request #3655 from asger-semmle/js/string-ops-regexp-test-fix
Approved by esbena
2020-06-10 13:35:22 +01:00
Esben Sparre Andreasen
1d396524a3 JS: add initial version of ServerCrash.ql 2020-06-10 14:25:56 +02:00
semmle-qlci
1b8f3c4b84 Merge pull request #3657 from hvitved/dataflow/hidden-nodes
Approved by aschackmull, jbj
2020-06-10 13:22:09 +01:00
Erik Krogh Kristensen
c4f61134f1 include the source of cryptographically random number in alert message 2020-06-10 13:32:46 +02:00
semmle-qlci
22d50f009e Merge pull request #3667 from aschackmull/java/compiletimeconstant-cast-eval
Approved by aibaars
2020-06-10 12:05:42 +01:00
Bas van Schaik
bf19489501 Update CONTRIBUTING.md 2020-06-10 12:02:24 +01:00
Bas van Schaik
be48daf0d0 Update CONTRIBUTING.md 2020-06-10 11:58:38 +01:00
Erik Krogh Kristensen
7e8fd80327 use steps from InsecureRandomness, and use small-steps 2020-06-10 12:27:50 +02:00
Rasmus Wriedt Larsen
f73876e6ce Python: Modernise ShouldBeContextManager 2020-06-10 11:53:11 +02:00
Rasmus Wriedt Larsen
37cfb5400d Python: Modernise RatioOfDefinitions 2020-06-10 11:51:41 +02:00
Anders Schack-Mulligen
4b3ca13f25 Merge pull request #3491 from luchua-bc/java-insecure-smtp-ssl
Java: CWE-297 insecure JavaMail SSL configuration
2020-06-10 11:02:50 +02:00
Robert Brignull
ded5eec76a rename slow-queries.yml to exclude-slow-queries.yml 2020-06-10 09:59:31 +01:00
Anders Schack-Mulligen
c334d72f11 Java: Fix CompileTimeConstantExpr qldoc and add char cast case. 2020-06-10 10:59:10 +02:00
Erik Krogh Kristensen
9029dbacf5 refactor isAdditionalTaintStep to a utility predicate in InsecureRandomness 2020-06-10 10:55:30 +02:00
Erik Krogh Kristensen
9189f23403 add support for secure-random 2020-06-10 10:39:02 +02:00
Erik Krogh Kristensen
16ec405724 add explanations about modulo by power of 2 2020-06-10 10:38:47 +02:00
Erik Krogh Kristensen
111f6d406c introduce query to detect biased random number generators 2020-06-10 10:00:10 +02:00
Tom Hvitved
70c3ff36f8 C#: Adjust IR imports 2020-06-10 09:54:56 +02:00
Tom Hvitved
d5b8c9728c Update identifal-files.json 2020-06-10 09:40:44 +02:00
Tom Hvitved
3c8735f43f C#: Move IR code into 'experimental' folder 2020-06-10 09:37:30 +02:00
Erik Krogh Kristensen
733e04c1eb Move rest-pattern inside property-pattern step to a taint-step 2020-06-10 09:02:22 +02:00
Erik Krogh Kristensen
2f9124f754 add missing qldoc 2020-06-09 23:32:58 +02:00
luchua-bc
1fd9c7fdec Add all dependent class stubs 2020-06-09 20:12:05 +00:00
Jonas Jensen
ad401e9f21 C++: Copy and adjust Java's correctness argumnt
Instead of a vague reference to a code comment for another language, the
`controlsBlock` predicate now has the whole comment in it directly.

I've adjusted the wording so it should be reasonably correct for C/C++.
As with the other comments in this file, I don't distinguish between the
condition and its block. I think that makes the explanation clearer
without losing any detail we care about.

To make the code fit the wording of the comment, I changed the
`hasBranchEdge/2` predicate into `getBranchSuccessor/1`.
2020-06-09 20:53:56 +02:00
Erik Krogh Kristensen
eb00da5b31 improve readability
Co-authored-by: Asger F <asgerf@github.com>
2020-06-09 20:02:46 +02:00
Asger Feldthaus
a923a404ab JS: Explicitly handle export declarations in PackageExports 2020-06-09 18:28:15 +01:00
Asger Feldthaus
806c9a372e JS: Resolve package.json main module differently 2020-06-09 18:28:15 +01:00
Erik Krogh Kristensen
b8a9ac39f4 add lValueFlowStep for rest-pattern nested inside a property-pattern (and removed old incorrect approach) 2020-06-09 18:16:00 +02:00
Erik Krogh Kristensen
b6e0e6645f Merge pull request #3645 from erik-krogh/infExposure
JS: add query to detect accidential leak of private files
2020-06-09 17:38:31 +02:00
Erik Krogh Kristensen
a7f6f045d2 add taint-steps for copying properties of an object 2020-06-09 17:16:13 +02:00
Erik Krogh Kristensen
7050d9d7bb remove dead FlowLabel 2020-06-09 17:15:55 +02:00
Erik Krogh Kristensen
2af8739bb6 simplify web.DefinePlugin sink 2020-06-09 17:15:35 +02:00
Erik Krogh Kristensen
90596167b1 add taint-step for Array.reduce 2020-06-09 17:15:00 +02:00
Mathias Vorreiter Pedersen
06066f0c5b Merge pull request #3659 from jbj/getFieldSizeOfClass-perf
C++: Performance tweak for 1-field struct loads
2020-06-09 15:53:19 +02:00
Erik Krogh Kristensen
be71ddf7bb introduce basic BuildArtifactLeak query 2020-06-09 15:27:55 +02:00
Erik Krogh Kristensen
896a9b05f6 refactor CleartextLogging to allow for reuse 2020-06-09 15:03:07 +02:00
Jonas Jensen
a341912da9 C++: Performance tweak for 1-field struct loads
On kamailio/kamailio the `DataFlowUtil::simpleInstructionLocalFlowStep`
predicate was slow because of the case for single-field structs, where
there was a large tuple-count bulge when joining with
`getFieldSizeOfClass`:

    3552902   ~2%       {2} r1 = SCAN Instruction::CopyInstruction::getSourceValueOperand_dispred#3#ff AS I OUTPUT I.<1>, I.<0>
    2065347   ~2%       {2} r35 = JOIN r1 WITH Operand::NonPhiMemoryOperand::getAnyDef_dispred#3#ff AS R ON FIRST 1 OUTPUT r1.<1>, R.<1>
    2065827   ~2%       {3} r36 = JOIN r35 WITH Instruction::Instruction::getResultType_dispred#3#ff AS R ON FIRST 1 OUTPUT R.<1>, r35.<1>, r35.<0>
    2065825   ~3%       {3} r37 = JOIN r36 WITH Type::Type::getSize_dispred#ff AS R ON FIRST 1 OUTPUT r36.<1>, r36.<2>, R.<1>
    2068334   ~2%       {4} r38 = JOIN r37 WITH Instruction::Instruction::getResultType_dispred#3#ff AS R ON FIRST 1 OUTPUT R.<1>, r37.<2>, r37.<0>, r37.<1>
    314603817 ~0%       {3} r39 = JOIN r38 WITH DataFlowUtil::getFieldSizeOfClass#fff_120#join_rhs AS R ON FIRST 2 OUTPUT r38.<3>, R.<2>, r38.<2>
    8         ~0%       {2} r40 = JOIN r39 WITH Instruction::Instruction::getResultType_dispred#3#ff AS R ON FIRST 2 OUTPUT r39.<2>, r39.<0>

That's 314M tuples.

Strangely, there is no such bulge on more well-behaved snapshots like
mysql/mysql-server.

With this commit the explosion is gone:

    ...
    2065825  ~0%       {4} r37 = JOIN r36 WITH Type::Type::getSize_dispred#ff AS R ON FIRST 1 OUTPUT r36.<0>, R.<1>, r36.<1>, r36.<2>
    1521     ~1%       {3} r38 = JOIN r37 WITH DataFlowUtil::getFieldSizeOfClass#fff_021#join_rhs AS R ON FIRST 2 OUTPUT r37.<2>, R.<2>, r37.<3>
    8        ~0%       {2} r39 = JOIN r38 WITH Instruction::Instruction::getResultType_dispred#3#ff AS R ON FIRST 2 OUTPUT r38.<0>, r38.<2>
2020-06-09 14:50:02 +02:00
Rasmus Wriedt Larsen
bacd491875 Python: Fix isSequence() and isMapping() 2020-06-09 14:21:02 +02:00
Anders Schack-Mulligen
f77f486c6b Merge pull request #3438 from artem-smotrakov/unsafe-tls
Java: Added a query for unsafe TLS versions
2020-06-09 14:07:17 +02:00
Rasmus Wriedt Larsen
846101d295 Python: Extend isSequence/isMapping test with custom classes 2020-06-09 14:04:14 +02:00
Tom Hvitved
a371205db1 Data flow: Sync files 2020-06-09 13:55:12 +02:00
Tom Hvitved
8c9f85d04f Data flow: Allow nodes to be hidden from path explanations 2020-06-09 13:53:19 +02:00
Erik Krogh Kristensen
b510e470b1 support rest-patterns inside property patterns 2020-06-09 13:28:56 +02:00
Erik Krogh Kristensen
c580ada527 Merge pull request #3643 from erik-krogh/yargs
JS: extend support for yargs for js/indirect-command-line-injection
2020-06-09 13:17:28 +02:00
Jonas Jensen
4642037dce C++: Speed up IRGuardCondition::controlsBlock
The `controlsBlock` predicate had some dramatic bulges in its tuple
counts. To make matters worse, those bulges were in materialized
intermediate predicates like `#shared` and `#antijoin_rhs`, not just in
the middle of a pipeline.

The problem was particularly evident on kamailio/kamailio, where
`controlsBlock` was the slowest predicate in the IR libraries:

    IRGuards::IRGuardCondition::controlsBlock_dispred#fff#shared#4 ........ 58.8s
    IRGuards::IRGuardCondition::controlsBlock_dispred#fff#antijoin_rhs .... 33.4s
    IRGuards::IRGuardCondition::controlsBlock_dispred#fff#antijoin_rhs#1 .. 26.7s

The first of the above relations had 201M rows, and the others
had intermediate bulges of similar size.

The bulges could be observed even on small projects although they did
not cause measurable performance issues there. The
`controlsBlock_dispred#fff#shared#4` relation had 3M rows on git/git,
which is a lot for a project with only 1.5M IR instructions.

This commit borrows an efficient implementation from Java's
`Guards.qll`, tweaking it slightly to fit into `IRGuards`. Performance
is now much better:

    IRGuards::IRGuardCondition::controlsBlock_dispred#fff ................... 6.1s
    IRGuards::IRGuardCondition::hasDominatingEdgeTo_dispred#ff .............. 616ms
    IRGuards::IRGuardCondition::hasDominatingEdgeTo_dispred#ff#antijoin_rhs . 540ms

After this commit, the biggest bulge in `controlsBlock` is the size of
`IRBlock::dominates`. On kamailio/kamailio this is an intermediate tuple
count of 18M rows in the calculation of `controlsBlock`, which in the
end produces 11M rows.
2020-06-09 12:15:45 +02:00
Rasmus Wriedt Larsen
65ce6d27ff Python: Update isSequence() and isMapping() for Python 3.8 2020-06-09 11:57:00 +02:00
Rasmus Wriedt Larsen
958763edc2 Python: Add test for ClassValue.isSequence() and isMapping()
For Python 3.6
2020-06-09 11:55:22 +02:00
Tom Hvitved
8006866370 C#: Refactor data-flow predicates defined by dispatch 2020-06-09 11:25:07 +02:00
Erik Krogh Kristensen
b04d7015ae fix test 2020-06-09 11:23:46 +02:00
Asger Feldthaus
0345036420 JS: Fix 'match' call in StringOps::RegExpTest 2020-06-09 10:07:36 +01:00
Jonas Jensen
cade3a3e23 C++: Use the hasBranchEdge helper predicate
This tidies up the code, removing unnecessary repetition.
2020-06-09 10:33:03 +02:00
Erik Krogh Kristensen
c2fbcea96f base the chaining on yargs on the methods that are NOT chained 2020-06-09 10:22:25 +02:00
Esben Sparre Andreasen
2d2468463b JS: initial version of IncompleteMultiCharacterSanitization.ql 2020-06-09 08:59:59 +02:00
Erik Krogh Kristensen
167239e745 add query to detect accidential leak of private files 2020-06-08 23:41:14 +02:00
Dave Bartolomeo
3fc02ce24e C++: Fix join order in virtual dispatch with unique
The optimizer picked a terrible join order in `VirtualDispatch::DataSensitiveCall::flowsFrom()`. Telling it that `getAnOutNode()` has a unique result convinces it to join first on the `Callable`, rather than on the `ReturnKind`.
2020-06-08 17:15:43 -04:00
Robert Marsh
2a96856ca5 C++/C#: Document IRPositionalParameter 2020-06-08 12:41:26 -07:00
Dave Bartolomeo
c511cc3444 C++: Better caching for getPrimaryInstructionForSideEffect() 2020-06-08 15:37:36 -04:00
ubuntu
ab65ec40c0 Add Codeql to detect missing 'Message.origin' validation when using postMessage API 2020-06-08 20:18:34 +02:00
luchua-bc
5acfc52087 Add dependent stub classes for the test case 2020-06-08 16:17:40 +00:00
luchua-bc
1e4addb20d Add dependent stub classes for the test case 2020-06-08 16:17:01 +00:00
Dave Bartolomeo
0ae98e78a2 Merge remote-tracking branch 'github/master' into github/codeql-c-analysis-team/69_union 2020-06-08 11:20:14 -04:00
Dave Bartolomeo
398678a28b Merge pull request #3637 from jbj/dispatch-global-perf
C++: Fix data-flow dispatch perf with globals
2020-06-08 11:19:37 -04:00
semmle-qlci
1a7570ebbe Merge pull request #3563 from RasmusWL/python-fabric-execute
Approved by tausbn
2020-06-08 16:00:49 +01:00
Erik Krogh Kristensen
0f06f04e32 extend support for yargs for js/indirect-command-line-injection 2020-06-08 16:45:09 +02:00
Asger Feldthaus
53280a6b11 JS: Add test demonstrating new flow 2020-06-08 14:25:21 +01:00
Rasmus Wriedt Larsen
baa415fec8 Python: Add points-to regression for metaclass 2020-06-08 15:03:46 +02:00
Rasmus Wriedt Larsen
7c037cd2ab Python: Handle Enum._convert in Python 3.8 2020-06-08 14:49:58 +02:00
Asger Feldthaus
2d9b9fa584 JS: Use PreCallGraphStep in select array steps 2020-06-08 13:45:28 +01:00
Asger Feldthaus
3d2bbbd3db JS: Add PreCallGraphStep extension point 2020-06-08 13:45:28 +01:00
Asger Feldthaus
1f2ab605bd JS: Add store/load steps to AdditionalTypeTrackingStep 2020-06-08 13:45:28 +01:00
Henning Makholm
5daf1db5e5 Merge pull request #3615 from github/fix-root-defintion
QL Specification: Fix mistake in dispatch computation
2020-06-08 14:34:58 +02:00
Bt2018
99aa559ef2 Fix auto-formatting issue 2020-06-08 06:43:00 -04:00
Mathias Vorreiter Pedersen
b48168fc03 C++: Accept tests 2020-06-08 12:26:25 +02:00
Jonas Jensen
c62220e0dc C++: Fix data-flow dispatch perf with globals
There wasn't a good join order for the "store to global var" case in the
virtual dispatch library. When a global variable had millions of
accesses but few stores to it, the `flowsFrom` predicate would join to
see all those millions of accesses before filtering down to stores only.
The solution is to pull out a `storeIntoGlobal` helper predicate that
pre-computes which accesses are stores.

To make the code clearer, I've also pulled out a repeated chunk of code
into a new `addressOfGlobal` helper predicate.

For the kamailio/kamailio project, these are the tuple counts before:

    Starting to evaluate predicate DataFlowDispatch::VirtualDispatch::DataSensitiveCall::flowsFrom#fff#cur_delta/3[3]@21a1df (iteration 3)
    Tuple counts for DataFlowDispatch::VirtualDispatch::DataSensitiveCall::flowsFrom#fff#cur_delta:
    ...
    59002      ~0%     {3} r17 = SCAN DataFlowDispatch::VirtualDispatch::DataSensitiveCall::flowsFrom#fff#prev_delta AS I OUTPUT I.<1>, true, I.<0>
    58260      ~1%     {3} r31 = JOIN r17 WITH DataFlowUtil::Node::asVariable_dispred#fb AS R ON FIRST 1 OUTPUT R.<1>, true, r17.<2>
    2536187389 ~6%     {3} r32 = JOIN r31 WITH Instruction::VariableInstruction::getASTVariable_dispred#fb_10#join_rhs AS R ON FIRST 1 OUTPUT R.<1>, true, r31.<2>
    2536187389 ~6%     {3} r33 = JOIN r32 WITH project#Instruction::VariableAddressInstruction#class#3#ff AS R ON FIRST 1 OUTPUT r32.<0>, true, r32.<2>
    58208      ~0%     {3} r34 = JOIN r33 WITH Instruction::StoreInstruction::getDestinationAddress_dispred#ff_10#join_rhs AS R ON FIRST 1 OUTPUT R.<1>, true, r33.<2>

Tuple counts after:

    Starting to evaluate predicate DataFlowDispatch::VirtualDispatch::DataSensitiveCall::flowsFrom#fff#cur_delta/3[3]@6073c5 (iteration 3)
    Tuple counts for DataFlowDispatch::VirtualDispatch::DataSensitiveCall::flowsFrom#fff#cur_delta:
    ...
    59002    ~0%     {3} r17 = SCAN DataFlowDispatch::VirtualDispatch::DataSensitiveCall::flowsFrom#fff#prev_delta AS I OUTPUT I.<1>, true, I.<0>
    58260    ~1%     {3} r23 = JOIN r17 WITH DataFlowUtil::Node::asVariable_dispred#ff AS R ON FIRST 1 OUTPUT R.<1>, true, r17.<2>
    58208    ~0%     {3} r24 = JOIN r23 WITH DataFlowDispatch::VirtualDispatch::storeIntoGlobal#ff_10#join_rhs AS R ON FIRST 1 OUTPUT R.<1>, true, r23.<2>
    58208    ~0%     {3} r25 = JOIN r24 WITH DataFlowUtil::InstructionNode#ff_10#join_rhs AS R ON FIRST 1 OUTPUT true, r24.<2>, R.<1>

Notice that the final tuple count, 58208, is the same before and after.

The kamailio/kamailio project seems to have been affected by this issue
because it has global variables to do with logging policy, and these
variables are loaded from in every place where their logging macro is
used.
2020-06-08 11:48:40 +02:00
Anders Schack-Mulligen
8513c6981c Merge pull request #3329 from artem-smotrakov/mvel-injection
Java: Add a query for MVEL injections
2020-06-08 11:48:00 +02:00
Mathias Vorreiter Pedersen
431cc5c926 C++: Fix inconsistent class name 2020-06-08 11:27:09 +02:00
Calum Grant
00078d14b9 Merge pull request #3601 from hvitved/csharp/overlapping-configs
C#: Avoid multiple taint-tracking configurations
2020-06-08 10:21:40 +01:00
Mathias Vorreiter Pedersen
01f3793159 C++: Add ReadSideEffect as a possible end instruction for load chains 2020-06-08 11:05:30 +02:00
Mathias Vorreiter Pedersen
a4388e9258 C++: Add example demonstrating missing flow 2020-06-08 11:03:36 +02:00
Esben Sparre Andreasen
872ee13ba6 JS: formatting 2020-06-08 10:04:37 +02:00
Anders Schack-Mulligen
ad8647f345 Merge pull request #3547 from pwntester/issue_3139
add support for java.io.StringWriter
2020-06-08 10:02:23 +02:00
Pavel Avgustinov
7c0b8f5587 Merge pull request #3622 from aschackmull/mergeback-124
Mergeback rc/1.24 -> master
2020-06-08 08:38:12 +01:00
Anders Schack-Mulligen
e444bcc923 Merge pull request #3634 from Marcono1234/MagicConstants-code-style
Fix Java code style of MagicConstants examples
2020-06-08 09:34:48 +02:00
Anders Schack-Mulligen
be862280b2 Update java/ql/src/semmle/code/java/dataflow/internal/TaintTrackingUtil.qll
Fix trailing whitespace
2020-06-08 09:18:39 +02:00
Esben Sparre Andreasen
fa35a6a694 JS: formatting 2020-06-08 08:13:58 +02:00
porcupineyhairs
6dd9106301 Update XSLT.qll 2020-06-08 03:12:23 +05:30
Porcupiney Hairs
424e88d318 include sugestions from review 2020-06-08 02:52:11 +05:30
Marcono1234
ad1146a23a Fix Java code style of MagicConstants examples
- Use recommended ordering of modifiers
- Use recommended variable naming scheme
2020-06-07 01:00:27 +02:00
Porcupiney Hairs
1ceb963d4c Python : Add support for detecting XSLT Injection
This PR adds support for detecting XSLT injection in Python.
I have included the ql files as well as the tests with this.
2020-06-07 03:05:50 +05:30
luchua-bc
cba81eeb97 Fix string/type match and add a test case 2020-06-06 03:56:12 +00:00
Robert Marsh
cce99f92a1 C++: exclude conversions in IR field flow tests 2020-06-05 16:19:02 -07:00
Robert Marsh
53a87fa378 C++: accept field flow test changes after merge 2020-06-05 15:41:10 -07:00
Dave Bartolomeo
94c2bba584 C++/C#: Fix formatting 2020-06-05 17:14:14 -04:00
Robert Marsh
0d2f8f3825 Merge branch 'master' into ir-this-parameter-2 2020-06-05 13:52:56 -07:00
Dave Bartolomeo
d4e1ee8aa7 Merge pull request #3629 from MathiasVP/remove-initialize-this-from-value-numbering
C++: Remove TInitializeThisValueNumber from IR value numbering
2020-06-05 15:55:20 -04:00
Dave Bartolomeo
1c32e4cc68 C++/C#: Do filtering of instructions in cached predicates
The four cached predicates used to access common properties of instructions took a `TStageInstruction` as a parameter. This requires the calling code, in `Instruction.qll`, to then join the results with `hasInstruction()` to filter out results for `TRawInstruction`s that were discarded as unreachable. By simply switching the parameter types to `Instruction`, we can force that join to happen in the cached predicate itself. This makes the various accessor predicates on `Instruction` trivially inlinable to the cached predicate, instead of being joins of two huge relations that might have to be recomputed in later stages.
2020-06-05 15:41:21 -04:00
Dave Bartolomeo
e62b884b48 C++/C#: Cache Instruction.getResultIRType()
Most of the predicates on `Instruction` are thin wrappers around cached predicates in the `IRConstruction` or `SSAConstruction` modules. However, `getResultIRType()` has to join `Construction::getInstructionResultType()` with `LanguageType::getIRType()`. `getResultIRType()` is called frequently both within the IR code and by IR consumers, and that's a big join to have to repeat in multiple stages.

I looked at most of the other predicates in `Instruction.qll`, and didn't see any other predicates that met all of the criteria of "large, commonly called, and not already inline".
2020-06-05 15:17:28 -04:00
Dave Bartolomeo
c708ed1fe9 C++: Remove some usage of Instruction.getResultType()
There were a few places in the IR itself where we use `Instruction.getResultType()`, which returns the C++ `Type` of the result, instead of `Instruction.getResultIRType()`, which returns the language-neutral `IRType` of the result. By removing this usage, we can avoid evaluating `getResultType()` at all.

There are still other uses of `Instruction.getResultType()` in other libraries. We should switch those as well.
2020-06-05 14:08:01 -04:00
Dave Bartolomeo
11818489f5 C++/C#: Use cached to ensure that IR is evaluated in a single stage
Before this change, evaluation of the IR was spread out across about 5 stages. This resulted in a lot of redundant evaluation, especially tuple numbering of large IPA types like `TInstruction`. This change makes two small changes that, when combined, ensure that the IR is evaluated all in one stage:

First, we mark `TInstruction` as `cached`. This collapses all of the work to create instructions, across all three IR phases, into a single phase.

Second, we make the `SSA` module in `SSAConstruction.qll` just contain aliases to `cached` predicates defined in the `Cached` module. This ensures that all of the `Operand`-related SSA computation happens in the same stage as all of the `Instruction`-related SSA computation.
2020-06-05 14:05:25 -04:00
Robert Marsh
4c44c84ec0 C++: Add QLdoc in Initializer.qll-Macro.qll 2020-06-05 10:47:25 -07:00
Henning Makholm
d2d235d7a4 Merge pull request #3476 from hmakholm/pr/module-res-update
QL language specification: bring library path documentation up to date
2020-06-05 18:12:35 +02:00
Henning Makholm
c2c70d7627 QL specification: typo fix
Co-authored-by: Shati Patel <42641846+shati-patel@users.noreply.github.com>
2020-06-05 18:01:21 +02:00
Artem Smotrakov
b7c3dd666c Java: Clean up MVEL injection query 2020-06-05 17:22:45 +03:00
Artem Smotrakov
2842aeee72 Java: Simplified MvelInjectionLib 2020-06-05 17:17:43 +03:00
Artem Smotrakov
4a83fb8cc1 Java: Simplified MvelInjection test 2020-06-05 17:17:43 +03:00
Artem Smotrakov
df9d10f2ac Java: Added MVELRuntime.execute() sink for MVEL injections 2020-06-05 17:17:43 +03:00
Artem Smotrakov
fa717b2d86 Java: Added template sinks for MVEL injections 2020-06-05 17:17:43 +03:00
Artem Smotrakov
8fd72659ec Java: Added JSR 223 sinks for MVEL injections
- Updated MvelInjectionLib.qll
- Added tests and stubs for JSR 223 API
2020-06-05 17:17:43 +03:00
Artem Smotrakov
6a6c805048 Java: Added Accessor sink for MVEL injections 2020-06-05 17:13:24 +03:00
Artem Smotrakov
12e0234d40 Java: Added CompiledAccExpression sink for MVEL injections 2020-06-05 17:13:24 +03:00
Artem Smotrakov
32ff5ad496 Java: Added CompiledExpression sink for MVEL injections 2020-06-05 17:13:24 +03:00
Artem Smotrakov
c6c4c2c99b Java: Add a query for MVEL injections
- Added experimental/Security/CWE/CWE-094/MvelInjection.ql
- Added experimental/Security/CWE/CWE-094/MvelInjectionLib.qll
- Added a qhelp file with an example of vulnerable code
- Added tests and stubs for mvel2-2.4.7
2020-06-05 17:13:24 +03:00
yoff
e5480e471a Merge pull request #3591 from RasmusWL/python-taintkind-fixup
Python: Fix some problems in TaintKind useage
2020-06-05 16:03:18 +02:00
Anders Schack-Mulligen
e4e51b5027 Merge pull request #3291 from artem-smotrakov/spel-injection
Java: Add a query for SpEL injections
2020-06-05 15:51:38 +02:00
Mathias Vorreiter Pedersen
7642680ab9 C++: Also remove TInitializeThisValueNumber from the AST wrapper 2020-06-05 15:26:09 +02:00
Mathias Vorreiter Pedersen
1a33a3b7e1 Merge branch 'master' into remove-initialize-this-from-value-numbering 2020-06-05 15:03:54 +02:00
Mathias Vorreiter Pedersen
d49c0f7b67 C++: Sync identical files 2020-06-05 15:01:18 +02:00
Mathias Vorreiter Pedersen
15fa7be09a C++: Remove TInitializeThisValueNumber case from IR value numbering 2020-06-05 15:01:11 +02:00
semmle-qlci
ff6936caa7 Merge pull request #3625 from erik-krogh/CVE714
Approved by asgerf
2020-06-05 12:21:10 +01:00
semmle-qlci
69a1e11c06 Merge pull request #3609 from erik-krogh/CredFN
Approved by asgerf, esbena
2020-06-05 10:49:01 +01:00
Erik Krogh Kristensen
82cf53897f TypeOfCheck -> TypeOfUndefinedSanitizer
Co-authored-by: Asger F <asgerf@github.com>
2020-06-05 11:35:39 +02:00
Erik Krogh Kristensen
f70453c544 autoformat 2020-06-05 10:10:57 +02:00
Erik Krogh Kristensen
05d7be8e23 autoformat 2020-06-05 09:59:45 +02:00
Erik Krogh Kristensen
96ca4cf7eb add missing quote 2020-06-04 19:45:24 +00:00
Erik Krogh Kristensen
815671f5d0 add sanitizer guard for typeof undefined 2020-06-04 21:32:26 +02:00
Henning Makholm
269fa3a140 comments from alexet
Put 'the query directory of the current file` back in the description.
2020-06-04 20:41:54 +02:00
Jonas Jensen
ad2d1d531b Merge pull request #3616 from dbartol/dbartol/sync-missing
Allow missing files in `sync-files --latest`
2020-06-04 16:52:44 +02:00
Rasmus Wriedt Larsen
1ff369f62d Python: Update test results for fabric.api.execute 2020-06-04 16:30:03 +02:00
Erik Krogh Kristensen
58f4f7129e change-note 2020-06-04 16:25:26 +02:00
Erik Krogh Kristensen
5ce2987cb2 adjust comments to reflect that tainted-path have no array-steps 2020-06-04 16:15:37 +02:00
Erik Krogh Kristensen
ed4e1bbbdf don't have a MembershipTestBarrierGuard in Configuration.qll 2020-06-04 16:13:49 +02:00
Erik Krogh Kristensen
b7a3c4a3d6 autoformat 2020-06-04 16:07:28 +02:00
semmle-qlci
22a651cb5c Merge pull request #3621 from max-schaefer/js/qltest-experimental
Approved by asgerf, erik-krogh
2020-06-04 14:19:17 +01:00
Dave Bartolomeo
0666a2e587 Remove usage of f-string 2020-06-04 08:48:14 -04:00
Esben Sparre Andreasen
f618d430e7 JS: simplify HTTP::ContainerCollection, and improve expressivity(!) 2020-06-04 14:34:52 +02:00
Esben Sparre Andreasen
44ebf84f4c JS: more express tests 2020-06-04 14:33:03 +02:00
Dave Bartolomeo
e2afad91dd Merge pull request #3620 from MathiasVP/fix-missing-case-in-getkind
C++: Fix missing case in ValueNumber::getKind
2020-06-04 07:27:30 -04:00
Max Schaefer
9549b01e3c JavaScript: Turn on experimental language features for two tests.
All other tests already pass with experimental features turned on, so once this is merged we can do so by default.
2020-06-04 11:27:31 +01:00
Mathias Vorreiter Pedersen
7328429ef1 C++: Sync identical files 2020-06-04 11:31:32 +02:00
Mathias Vorreiter Pedersen
36cfe3624b C++: Add TConstantValueNumber case to ValueNumber::getKind 2020-06-04 11:31:02 +02:00
Erik Krogh Kristensen
e47770281a update change-note
Co-authored-by: Asger F <asgerf@github.com>
2020-06-04 11:14:25 +02:00
semmle-qlci
c806e229aa Merge pull request #3618 from aschackmull/java/typeflow-test
Approved by aibaars
2020-06-04 10:09:44 +01:00
Mathias Vorreiter Pedersen
4b16067af2 C++: Fix testcases after merge from master 2020-06-04 11:02:03 +02:00
Erik Krogh Kristensen
60320a9d78 update TaintedPath to use new consistency checking 2020-06-04 11:00:40 +02:00
Erik Krogh Kristensen
68ca8e23c0 introduce consistency-checking utility predicates 2020-06-04 11:00:01 +02:00
Erik Krogh Kristensen
c7c46ea3d6 update test comments to be consistent 2020-06-04 10:55:09 +02:00
Mathias Vorreiter Pedersen
2cf9bcef86 Merge branch 'master' into flat-structs 2020-06-04 10:52:25 +02:00
Erik Krogh Kristensen
550c578c3c use MemberShipTest in TaintedPath 2020-06-04 10:51:08 +02:00
Erik Krogh Kristensen
d513e6c5b5 update comments in TaintedPath tests 2020-06-04 10:40:14 +02:00
Anders Schack-Mulligen
64225c31a6 Java: Add test case. 2020-06-04 10:31:08 +02:00
semmle-qlci
70131e6ac8 Merge pull request #3598 from asger-semmle/js/regexp-test
Approved by esbena
2020-06-04 09:05:21 +01:00
Mathias Vorreiter Pedersen
b48fe6ac32 Merge pull request #3123 from jbj/dataflow-indirect-args
C++: Wire up param/arg indirections in data flow
2020-06-04 09:38:57 +02:00
Dave Bartolomeo
cb2370cc7d C++/C#: Fix formatting 2020-06-04 02:36:51 -04:00
Jonas Jensen
df96f8e4e8 Merge remote-tracking branch 'upstream/master' into dataflow-indirect-args 2020-06-04 08:20:00 +02:00
Dave Bartolomeo
a409b9d451 Merge remote-tracking branch 'github/master' into github/codeql-c-analysis-team/69_union 2020-06-03 16:10:22 -04:00
Dave Bartolomeo
15f41c0107 C++/C#: Remove dead QL code 2020-06-03 15:42:30 -04:00
yo-h
5cdc29e49a Merge pull request #3607 from aschackmull/java/array-instanceof-typeflow
Java: Add instanceof type bounds for ArrayAccess.
2020-06-03 15:29:37 -04:00
Dave Bartolomeo
a18eba2c4c Allow missing files in sync-files --latest
When running `sync-files` (or `sync-identical-files`) with the `--latest` switch, if one or more of the files in a group does not exist, the script will crash. This happens all the time when I add a new group, or add a new file path in an existing group. This has bothered me for a long time, so I finally fixed it when I ran into it again today.

I've changed the script as follows:
- If _none_ of the paths in the group exist, print an error message listing the paths in the group. This happens with or without `--latest`.
- If `--latest` is specified, copy the master file to the paths of the missing files.
2020-06-03 14:53:31 -04:00
Tom Hvitved
9e7ca25732 C#: Add call-sensitivity to data-flow call resolution 2020-06-03 20:43:49 +02:00
Dave Bartolomeo
bbadf4b4bb C#: Port TInstruction-sharing support from C++
This updates C#'s IR to share `TInstruction` across stages the same way C++ does. The only interesting part is that, since we have not yet ported full alias analysis to C#, I stubbed out the required parts of the aliased SSA interface in `AliasedSSAStub.qll`.
2020-06-03 13:52:19 -04:00
Dave Bartolomeo
e65a5c921e C++: Add missing QLDoc 2020-06-03 13:49:14 -04:00
Alexander Eyers-Taylor
5dd1b1d1a9 QL Specification: Fix mistake in dispatch computation 2020-06-03 18:38:00 +01:00
Dave Bartolomeo
f93c2e4e64 C++: Remove resultType from the IPA constructors for TInstruction
Making these part of the IPA object identity changes the failure mode for cases where we assign multiple result types to an instruction. Previously, we would just have one instruction with two result types, but now we'd have two instructions, which breaks things worse. This change goes back to how things were before, to avoid any new surprises on real-world code with invalid ASTs or IR.
2020-06-03 10:11:27 -04:00
Jonas Jensen
e292eee3d1 C++: Autoformat fixup 2020-06-03 15:48:50 +02:00
Erik Krogh Kristensen
a90c8769ee update expected output 2020-06-03 15:24:04 +02:00
Erik Krogh Kristensen
7c26efbc12 case insensitive authorization header 2020-06-03 15:23:51 +02:00
Erik Krogh Kristensen
b508ad41c8 don't have a separate fetch module 2020-06-03 15:20:06 +02:00
Erik Krogh Kristensen
46cd0143d8 Update javascript/ql/src/semmle/javascript/frameworks/ClientRequests.qll
Co-authored-by: Asger F <asgerf@github.com>
2020-06-03 15:18:10 +02:00
Mathias Vorreiter Pedersen
d295e2139a C++: Accept tests after merge from master 2020-06-03 15:13:44 +02:00
Mathias Vorreiter Pedersen
43a0d4c97d Merge branch 'master' into flat-structs 2020-06-03 15:11:14 +02:00
Esben Sparre Andreasen
8316121a44 JS: formatting 2020-06-03 15:02:36 +02:00
Jonas Jensen
ad292d8fb6 C++: Accept one more test change from last commit 2020-06-03 14:51:05 +02:00
Tom Hvitved
86dd86848f C#: Update call-sensitivity data-flow tests 2020-06-03 14:21:23 +02:00
Erik Krogh Kristensen
baee47f3c6 remove mention of fetch from change-note 2020-06-03 13:56:32 +02:00
Erik Krogh Kristensen
28a1900612 treat all writes to Authorization as a CredentialsExpr 2020-06-03 13:55:49 +02:00
Erik Krogh Kristensen
6466ab19a0 Update javascript/ql/src/semmle/javascript/frameworks/ClientRequests.qll
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-06-03 13:51:04 +02:00
Erik Krogh Kristensen
f8caec76ab move the Fetch module to ClientRequests 2020-06-03 13:37:34 +02:00
Erik Krogh Kristensen
aa463d8298 mention fetch instead of node-fetch 2020-06-03 13:33:43 +02:00
Erik Krogh Kristensen
c80baf981a simplify change-note
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-06-03 13:33:31 +02:00
Erik Krogh Kristensen
1b53cd4bd9 update docstring of FetchAuthorization
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-06-03 13:31:16 +02:00
Jonas Jensen
8f702d4b49 C++: Override toString on argument indirections
Without this override, end users would see the string
`BufferReadSideEffect` in path explanations.
2020-06-03 13:04:10 +02:00
Erik Krogh Kristensen
19dd472ee5 change note 2020-06-03 12:19:48 +02:00
Erik Krogh Kristensen
a1940979ba support credentials in a Buffer 2020-06-03 12:02:00 +02:00
Erik Krogh Kristensen
ba44ebe8a8 better support for browser based fetch API 2020-06-03 11:51:24 +02:00
Erik Krogh Kristensen
3622fb8716 support more variants of the Headers API 2020-06-03 11:50:10 +02:00
Anders Schack-Mulligen
a969dbc6ca Java: Fix missing CFG edge for switch expressions. 2020-06-03 10:49:08 +02:00
Anders Schack-Mulligen
8d6e39eb18 Java: Add instanceof type bounds for ArrayAccess. 2020-06-03 09:42:37 +02:00
Mathias Vorreiter Pedersen
b890b162f4 C++: Restrict the side effect of StoreChainEndInstructionSideEffect to be WriteSideEffectInstructions 2020-06-03 09:28:06 +02:00
Esben Sparre Andreasen
afee864295 JS: make use of the colletions type tracking steps 2020-06-03 08:19:34 +02:00
Esben Sparre Andreasen
36b7574ac1 JS: add additional route handler registration tests 2020-06-03 08:18:11 +02:00
Esben Sparre Andreasen
117f009d17 JS: use HTTP::RouteHandlerCandidateContainer in Express 2020-06-03 08:18:11 +02:00
Esben Sparre Andreasen
9964902c10 JS: introduce HTTP::RouteHandlerCandidateContainer 2020-06-03 08:16:58 +02:00
Esben Sparre Andreasen
606f8274c7 JS: add tests for various route handler registration patterns 2020-06-03 08:16:58 +02:00
Robert Marsh
f7752b0a01 C++/C#: add IRParameter subclass of IRVariable 2020-06-02 17:22:10 -07:00
Erik Krogh Kristensen
3c802007a3 add support for string concatenations and base64-encoding of hardcoded credentials 2020-06-02 23:15:13 +02:00
Erik Krogh Kristensen
b6dc94fccb add fetch.Headers.Authorization as a CredentialsExpr 2020-06-02 23:02:16 +02:00
Erik Krogh Kristensen
14f0d1687a factor fetch import into NodeJSLib 2020-06-02 22:45:47 +02:00
Asger Feldthaus
8342981799 JS: Make isCoercedToBoolean private 2020-06-02 17:16:55 +01:00
Jonas Jensen
10dfa497a5 Merge remote-tracking branch 'upstream/master' into dataflow-indirect-args
Fixed a semantic merge conflict by accepting test changes in
`cpp/ql/test/library-tests/dataflow/fields/ir-path-flow.expected`.
2020-06-02 18:03:34 +02:00
Jonas Jensen
9c50acc0f9 Merge pull request #3602 from MathiasVP/path-problem-for-dataflow-tests
C++: Make path-problem versions of ir-flow.ql and flow.ql
2020-06-02 17:59:26 +02:00
Asger Feldthaus
8a38633639 JS: Handle exec() == undefined 2020-06-02 16:52:07 +01:00
Asger Feldthaus
7d5384b723 JS: Autoformat 2020-06-02 16:38:40 +01:00
Asger Feldthaus
945db4d86c JS: Fix test output 2020-06-02 16:38:21 +01:00
Philip Ginsbach
8b3dd6dec4 Merge pull request #3572 from ginsbach/typeunions
introduce type unions in the handbook
2020-06-02 16:31:36 +01:00
Mathias Vorreiter Pedersen
2a1ba6d592 C++: Share configurations in testcases 2020-06-02 16:50:57 +02:00
Mathias Vorreiter Pedersen
b9af1123d9 C++: Make path-problem versions of ir-flow.ql and flow.ql 2020-06-02 16:28:01 +02:00
Jonas Jensen
771fd0b1cc C++: Fixup wording 2020-06-02 15:46:34 +02:00
Jonas Jensen
5f0d283212 Merge remote-tracking branch 'upstream/master' into dataflow-indirect-args
The conflicts came from how `this` is now a parameter but not a
`Parameter` on `master`.

Conflicts:
	cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll
	cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/defaulttainttracking.cpp
	cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/tainted.expected
	cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/test_diff.expected
	cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-ir-consistency.expected
	cpp/ql/test/library-tests/dataflow/fields/ir-flow.expected
	cpp/ql/test/library-tests/syntax-zoo/dataflow-ir-consistency.expected
2020-06-02 15:35:02 +02:00
Tom Hvitved
1e8b7ed367 C#: Avoid multiple taint-tracking configurations
The taint-tracking configuration in `ExposureOfPrivateInformation.ql`
overlaps with the XSS taint-tracking configuration, as witnessed by this import chain:

```
semmle.code.csharp.security.dataflow.ExposureOfPrivateInformation.qll imports
semmle.code.csharp.security.dataflow.flowsinks.ExternalLocationSink imports
semmle.code.csharp.security.dataflow.flowsinks.Remote imports
semmle.code.csharp.security.dataflow.XSS
```

(The same for `CleartextStorage.qll` and `LogForging.ql`.)

The fix is to use `TaintTracking2` for the XSS configuration.
2020-06-02 14:42:35 +02:00
Mathias Vorreiter Pedersen
ce34d91a07 C++: Add more QLDoc to StoreNode and LoadNode classes, and related predicates. I also simplified the code a bit by moving common implementations of predicates into shared super classes. Finally, I added a getLocation predicate to StoreNode to match the structure of the LoadNode class. 2020-06-02 13:50:00 +02:00
semmle-qlci
e7800d4695 Merge pull request #3415 from esbena/js/membershiptest
Approved by asgerf
2020-06-02 11:36:51 +01:00
Calum Grant
b099f13f55 Merge pull request #3514 from hvitved/csharp/remove-more-deprecated
C#: Remove more deprecated classes and predicates
2020-06-02 10:35:14 +01:00
Mathias Vorreiter Pedersen
e17b486195 Merge pull request #3593 from rdmarsh2/rdmarsh/cpp/add-qldoc-2
C++: Add QLDoc for AST classes up to Include.qll
2020-06-02 10:23:23 +02:00
Robert
a0ee41306a Update cpp/ql/src/codeql-suites/slow-queries.yml
Co-authored-by: Robert Marsh <rdmarsh2@gmail.com>
2020-06-02 09:22:23 +01:00
Esben Sparre Andreasen
f9ed64fc45 Merge branch 'master' into js/membershiptest 2020-06-02 08:54:44 +02:00
Robert Marsh
3460b9d550 C++: autoformat 2020-06-01 15:38:06 -07:00
Dave Bartolomeo
53d4a8e3b2 C++: Refactor IR construction interface
Now that `TInstruction` is shared between IR stages, several of the per-stage IR construction predicates can now be moved into the `Raw` interface exposed only by the initial construction of IR from the ASTs. This also removed a couple predicates that were not used previously at all.
2020-06-01 11:15:29 -04:00
Dave Bartolomeo
1e863ac40b C++: Share TInstruction across IR stages
Each stage of the IR reuses the majority of the instructions from previous stages. Previously, we've been wrapping each reused old instruction in a branch of the `TInstruction` type for the next stage. This causes use to create roughly three times as many `TInstruction` objects as we actually need.

Now that IPA union types are supported in the compiler, we can share a single `TInstruction` IPA type across stages. We create a single `TInstruction` IPA type, with individual branches of this type for instructions created directly from the AST (`TRawInstruction`) and for instructions added by each stage of SSA construction (`T*PhiInstruction`, `T*ChiInstruction`, `T*UnreachedInstruction`). Each stage then defines a `TStageInstruction` type that is a union of all of the branches that can appear in that particular stage. The public `Instruction` class for each phase extends the `TStageInstruction` type for that stage.

The interface that each stage exposes to the pyrameterized modules in the IR is now split into three pieces:
- The `Raw` module, exposed only by the original IR construction stage. This module identifies which functions have IR, which `TRawInstruction`s exist, and which `IRVariable`s exist.
- The `SSA` module, exposed only by the two SSA construction stages. This identifiers which `Phi`, `Chi`, and `Unreached` instructions exist.
- The global module, exposed by all three stages. This module has all of the predicates whose implementation is different for each stage, like gathering definitions of `MemoryOperand`s.

Similarly, there is now a single `TIRFunction` IPA type that is shared across all three stages. There is a single `IRFunctionBase` class that exposes the stage-indepdendent predicates; the `IRFunction` class for each stage extends `IRFunctionBase`.

Most of the other changes are largely mechanical.
2020-06-01 11:15:29 -04:00
Philip Ginsbach
c97055faa9 whitespace in example for type unions fixed
Co-authored-by: Shati Patel <42641846+shati-patel@users.noreply.github.com>
2020-06-01 14:27:34 +01:00
semmle-qlci
7265e94028 Merge pull request #3578 from erik-krogh/HtmlGuard
Approved by asgerf
2020-06-01 13:25:02 +01:00
Asger F
712c53afe9 Merge pull request #3579 from erik-krogh/fix-change-note-merge
JS: remove duplicates from change-note
2020-06-01 13:22:23 +01:00
Philip Ginsbach
faf4c16865 Mark the QL code as invalid more explicitly 2020-06-01 12:24:06 +01:00
Asger Feldthaus
707b0f33a0 JS: Use in ContainsHTMLGuard 2020-06-01 12:06:40 +01:00
Robert Brignull
6e0552c074 add more code-scanning suites 2020-06-01 11:45:46 +01:00
Asger Feldthaus
fa1a6eefa7 JS: Add StringOps::RegExpTest 2020-06-01 11:43:50 +01:00
Artem Smotrakov
df3adeec36 Java: Add a query for SpEL injections
- Added experimental/Security/CWE/CWE-094/SpelInjection.ql
  and a couple of libraries
- Added a qhelp file with a few examples
- Added tests and stubs for Spring
2020-05-31 20:52:45 +03:00
semmle-qlci
14be4fedf7 Merge pull request #3594 from erik-krogh/CachedExprStringValue
Approved by asgerf
2020-05-30 16:56:40 +01:00
Erik Krogh Kristensen
dfd35aee61 autoformat 2020-05-30 14:50:13 +02:00
Mathias Vorreiter Pedersen
cd574e8569 Merge pull request #3589 from rdmarsh2/ir-placement-new-consistency
C++: fix IR control flow for cast in placement new
2020-05-30 13:27:34 +02:00
luchua-bc
3d4a5a337d Add check for J2EE server directory listing 2020-05-30 10:58:16 +00:00
Erik Krogh Kristensen
3b4e57ab8d autoformat 2020-05-30 12:45:51 +02:00
Robert Marsh
e17adf14dc C++: autoformat 2020-05-29 16:13:40 -07:00
Robert Marsh
f8b6e07391 C++: Added QLDoc for Element.qll-Include.qll 2020-05-29 16:09:19 -07:00
Robert Marsh
1c20714c62 C++: file QLDoc for AutogeneratedFile-Diagnostics 2020-05-29 14:58:01 -07:00
Robert Marsh
45e555cff0 C++: accept inconsistency with unreachable exit block 2020-05-29 14:43:48 -07:00
Robert Marsh
5ee37bcd5a Merge branch 'master' into ir-this-parameter-2
Bring in fix for duplicate virtual variables for parameter indirections
2020-05-29 14:40:45 -07:00
Jonas Jensen
91da0d5567 Merge pull request #3592 from geoffw0/strlen
CPP: Don't taint the return value of strlen
2020-05-29 19:23:47 +02:00
Robert Marsh
f8cfcef9c9 C++/C#: document isThisIndirection and sync files 2020-05-29 09:52:03 -07:00
Robert Marsh
6c9051ae6f C++: accept consistency fixes 2020-05-29 09:49:28 -07:00
Geoffrey White
9ee75aaca1 C++: Change note. 2020-05-29 16:22:42 +01:00
Mathias Vorreiter Pedersen
3adc10fdb4 C++: Accept tests 2020-05-29 15:33:55 +02:00
Geoffrey White
f534f09784 C++: Autoformat. 2020-05-29 14:05:08 +01:00
Geoffrey White
19c33ab41c C++: Refine StrLenFunction, including removal of taint flow. 2020-05-29 14:04:27 +01:00
Geoffrey White
705529cdf7 C++: Split StrLenFunction from PureStrFunction (without changes). 2020-05-29 14:04:27 +01:00
Geoffrey White
59cb5f9b1e C++: Remove a special case for strlen in DefaultTaintTracking. 2020-05-29 14:04:26 +01:00
Geoffrey White
408e38a4d4 C++: Clarify which taint tracking libraries should be used somewhat. 2020-05-29 14:04:26 +01:00
Geoffrey White
d77092c931 C++: Add taint tests for strlen. 2020-05-29 13:39:40 +01:00
Rasmus Wriedt Larsen
551420401a Python: Fix typo
Co-authored-by: Taus <tausbn@gmail.com>
2020-05-29 14:27:07 +02:00
semmle-qlci
f291749243 Merge pull request #3585 from asger-semmle/js/use-newer-yarn
Approved by erik-krogh
2020-05-29 13:02:20 +01:00
Mathias Vorreiter Pedersen
a0603692cb C++: Add LoadChain and StoreChain nodes to handle reverse reads in dataflow 2020-05-29 13:53:53 +02:00
Rasmus Wriedt Larsen
59548a523e Python: Add change-note about UntrustedStringKind imports 2020-05-29 13:45:10 +02:00
Philip Ginsbach
2d47537f11 Slightly modified version of Henning's suggestion 2020-05-29 12:41:58 +01:00
Erik Krogh Kristensen
f7ad210331 use SSA instead of internal AccessPath API 2020-05-29 13:08:19 +02:00
Erik Krogh Kristensen
05bfba4f99 use getImmediatePredecessor instead of getALocalSource() 2020-05-29 13:01:09 +02:00
Jonas Jensen
453de6bf4e Merge pull request #3583 from MathiasVP/qldoc-for-unix-constants
C++: QLDoc for Constants
2020-05-29 12:27:59 +02:00
Mathias Vorreiter Pedersen
335baaef73 C++: Add testcases for partial definitions with long access paths 2020-05-29 12:15:39 +02:00
Rasmus Wriedt Larsen
48be57c8fd Python: Improve QLDoc for ExternalStringDictKind 2020-05-29 12:06:57 +02:00
Rasmus Wriedt Larsen
b083c01520 Python: Deprecate StringDictKind
This QL

```codeql
import python
import semmle.python.dataflow.TaintTracking
import semmle.python.security.strings.Untrusted

from CollectionKind ck
where
    ck.(DictKind).getMember() instanceof StringKind
    or
    ck.getMember().(DictKind).getMember() instanceof StringKind
select ck, ck.getAQlClass(), ck.getMember().getAQlClass()
```

generates these 6 results.

```
1	{externally controlled string}          ExternalStringDictKind	UntrustedStringKind
2	{externally controlled string}	        StringDictKind	        UntrustedStringKind
3	[{externally controlled string}]	SequenceKind	        ExternalStringDictKind
4	[{externally controlled string}]	SequenceKind	        StringDictKind
5	{{externally controlled string}}	DictKind	        ExternalStringDictKind
6	{{externally controlled string}}	DictKind	        StringDictKind
```

StringDictKind was only used in *one* place in our library code. As illustrated
above, it pollutes our set of TaintKinds. Effectively, every time we make a
flow-step for dictionaries with tainted strings as values, we do it TWICE --
once for ExternalStringDictKind, and once for StringDictKind... that is just a
waste.
2020-05-29 12:06:57 +02:00
Rasmus Wriedt Larsen
87bc8ae28d Python: Don't use UntrustedStringKind in web lib
If I wanted to use my own TaintKind and not have any interaction with
`UntrustedStringKind` that wouldn't be possible today since these standard http
libraries import it directly. (also, I wouldn't get any sources of my custom
TaintKind from turbogears or bottle). I changed them to use the same pattern of
`ExternalStringKind` as everything else does.
2020-05-29 12:06:57 +02:00
Mathias Vorreiter Pedersen
ae4f6edc6a Merge pull request #3204 from jbj/Expr-location-workaround
C++: Move Expr location workaround to Expr.qll
2020-05-29 11:58:50 +02:00
Philip Ginsbach
bb9e800241 remove "experimental syntax" box for type unions 2020-05-29 10:24:42 +01:00
Philip Ginsbach
299d87aa8e better explanation of the purpose of type unions
Co-authored-by: Pavel Avgustinov <54942558+p0@users.noreply.github.com>
2020-05-29 10:22:57 +01:00
Philip Ginsbach
0562b4a2dd restricted _subsets_ of algebraic datatypes
Co-authored-by: Pavel Avgustinov <54942558+p0@users.noreply.github.com>
2020-05-29 10:21:58 +01:00
Asger Feldthaus
f3a08375b4 JS: Use newer yarn.lock format 2020-05-29 09:45:50 +01:00
Jonas Jensen
7d4d435f25 Merge remote-tracking branch 'upstream/master' into Expr-location-workaround
Conflicts:
	cpp/ql/test/library-tests/dataflow/fields/dataflow-ir-consistency.expected
2020-05-29 10:04:12 +02:00
Mathias Vorreiter Pedersen
a305d39111 Merge pull request #3577 from dbartol/github/codeql-c-analysis-team/69
C++: Fix `MemoryLocation` with multiple `VirtualVariables`
2020-05-29 09:40:58 +02:00
Mathias Vorreiter Pedersen
0467995f4f C++: Make explicit that O_CREAT and O_EXCL are Linux-specific 2020-05-29 09:36:08 +02:00
Jonas Jensen
9813258a3e Merge remote-tracking branch 'upstream/master' into Expr-location-workaround
Conflicts and semantic conflicts in `library-tests/dataflow/fields` and
`library-tests/ir/ir`.
2020-05-29 08:44:37 +02:00
Jonas Jensen
87ad519541 Merge pull request #3569 from geoffw0/strftime
C++: Taint flow consistency change for strftime
2020-05-29 08:05:25 +02:00
yo-h
1fea545160 Merge pull request #3573 from aschackmull/java/private-interface-methods
Java: Fix for private interface methods.
2020-05-28 20:31:55 -04:00
yo-h
c2de08ca51 Merge pull request #3499 from aschackmull/java/instanceof-pattern-cfg
Java: Add CFG edges for Java 14 pattern-matching instanceof.
2020-05-28 20:24:39 -04:00
Robert Marsh
a638a08bc5 C++: autoformat 2020-05-28 17:06:14 -07:00
Robert Marsh
f82c97b84a C++: fix IR control flow for cast in placement new 2020-05-28 16:53:21 -07:00
Robert Marsh
56d0762380 C++: add test for placement new with cast 2020-05-28 16:36:26 -07:00
Robert Marsh
732da9cc4c Merge pull request #3586 from MathiasVP/qldoc-for-remaining-controlflow
C++: QLDoc for the remaining elements in the controlflow directory
2020-05-28 15:59:19 -07:00
Robert Marsh
a897caec76 C++: outbound dataflow via this indirections 2020-05-28 15:30:41 -07:00
Robert Marsh
7dc30e3fdc C++: add output indirections for this 2020-05-28 15:30:41 -07:00
Dave Bartolomeo
476f27e427 Merge from master 2020-05-28 17:27:08 -04:00
Dave Bartolomeo
01ef8795bf C++: Updated fixed test expectation 2020-05-28 17:24:38 -04:00
Robert Marsh
0d8472bd9e Merge pull request #3571 from rdmarsh2/ir-this-parameter
Treat `this` as a parameter in IR generation
2020-05-28 14:16:12 -07:00
Calum Grant
2b90b50587 Merge pull request #3528 from hvitved/csharp/cfg/cs6-initializers
C#: Fix CFG for C# 6 initializers
2020-05-28 21:40:52 +01:00
Calum Grant
499e349bff Merge pull request #3529 from hvitved/csharp/cs6-nested-initializer-type
C#: Fix extracted type for nested object initializers
2020-05-28 21:25:57 +01:00
Jonas Jensen
8b8c00de75 Merge pull request #3584 from jbj/devcontainer
Codespaces: initial configuration
2020-05-28 19:06:02 +02:00
Robert Marsh
d8b5d3bce8 C++: accept test fixes 2020-05-28 08:45:01 -07:00
Robert Marsh
693789c2cc Merge branch 'master' into ir-this-parameter
Bring in new tests so their output can be fixed
2020-05-28 08:32:10 -07:00
Mathias Vorreiter Pedersen
7b2c9c5aed C++: Add quotes to improve readability. 2020-05-28 16:48:48 +02:00
Mathias Vorreiter Pedersen
5fb79cde9a C++: Sync identical files 2020-05-28 16:45:52 +02:00
Mathias Vorreiter Pedersen
0671586aac C++: QLDoc for the remaining elements in the controlflow directory 2020-05-28 16:35:46 +02:00
Geoffrey White
6fcfd0310f C++: Autoformat. 2020-05-28 15:23:48 +01:00
Geoffrey White
c9e1ccf320 Merge branch 'master' into strftime 2020-05-28 15:22:16 +01:00
Jonas Jensen
19d4011b8a Codespaces: initial configuration
This was adapted from https://github.com/github/vscode-codeql-starter.
2020-05-28 14:01:36 +02:00
Jonas Jensen
688f540843 Merge pull request #3582 from MathiasVP/qldoc-for-controlflow
C++: QLDoc for BasicBlock, ControlFlowGraph and Dataflow
2020-05-28 13:52:43 +02:00
Philip Ginsbach
63a6422dbf incorporated Henning's example for type unions into the handbook 2020-05-28 12:32:31 +01:00
Erik Krogh Kristensen
5bb308dc8f sanitize variables used in an HTML escaping switch-case 2020-05-28 12:37:41 +02:00
Mathias Vorreiter Pedersen
1ef0643b60 C++: QLDoc for Constants 2020-05-28 12:24:23 +02:00
Calum Grant
725a8f55ca Merge pull request #3574 from hvitved/csharp/unification-performance
C#: Fix performance issue in unification library
2020-05-28 10:39:02 +01:00
Mathias Vorreiter Pedersen
52da5755b3 C++: Respond to review comments. 2020-05-28 11:20:13 +02:00
Jonas Jensen
1b23f3ec90 C++: Accept two more changed tests 2020-05-28 11:18:14 +02:00
Erik Krogh Kristensen
1a2db10a90 recognize barrier guard where the result is stored in a variable 2020-05-28 10:24:42 +02:00
Erik Krogh Kristensen
562a38cdd5 add ContainsHTMLGuard 2020-05-28 10:24:42 +02:00
Mathias Vorreiter Pedersen
3d27b6bbde C++: QLDoc for BasicBlock, ControlFlowGraph and Dataflow 2020-05-28 10:10:26 +02:00
Jonas Jensen
9153f568be C++: Accept test results with location fixes 2020-05-28 09:42:49 +02:00
Jonas Jensen
6eaf64c896 Merge remote-tracking branch 'upstream/master' into Expr-location-workaround 2020-05-28 09:37:15 +02:00
luchua-bc
104f1c3197 Add validation query for SSL Engine/Socket and com.rabbitmq.client.ConnectionFactory 2020-05-28 03:34:29 +00:00
Robert Marsh
54ed5d647a C++:autoformat 2020-05-27 19:30:02 -07:00
Robert Marsh
58673c449a C++: switch to TranslatedThisParameter 2020-05-27 19:29:29 -07:00
Porcupiney Hairs
8c5a97170d Python : Add Xpath injection query
This PR adds support for detecting XPATH injection in Python.
I have included the ql files as well as the tests with this.
2020-05-28 03:15:12 +05:30
Robert Marsh
593d4c0f32 Merge pull request #3567 from MathiasVP/ir-partial-definition
Implement `asPartialDefinition` for IR dataflow nodes
2020-05-27 13:51:41 -07:00
semmle-qlci
083b8ef8e5 Merge pull request #3568 from asger-semmle/js/avoid-accidental-string-coercion
Approved by erik-krogh
2020-05-27 20:46:54 +01:00
Robert Marsh
be74616b2b C++: accept consistency test fixes 2020-05-27 12:39:54 -07:00
Jonas Jensen
c7fa11229c Merge pull request #3532 from MathiasVP/remove-field-conflation-from-ir-fieldflow
C++: Remove field conflation caused by IR field flow
2020-05-27 21:17:32 +02:00
Erik Krogh Kristensen
df3fb842c5 remove duplicates from change-note 2020-05-27 20:36:23 +02:00
Dave Bartolomeo
533eeff7e8 C++: Fix MemoryLocation with multiple VirtualVariables
While investigating a bug with `TInstruction` sharing, I discovered that we had a case where alias analysis could create two `VirtualVariable`s for the same `Allocation`. For an indirect parameter allocation, we were using the type of the pointer variable as the type of the indirect allocation, instead of just `Unknown`. If the `IRType` of the pointer variable was the same type as the type of at least one access to the indirect allocation, we'd create both an `EntireAllocationVirtualVariable` and a `VariableVirtualVariable` for the allocation.

I added a new consistency test to guard against this in the future. This also turned out to be the root cause of the one existing known consistency failure in the IR tests.
2020-05-27 14:06:59 -04:00
Mathias Vorreiter Pedersen
bd97fe627c Merge branch 'master' into remove-field-conflation-from-ir-fieldflow 2020-05-27 17:08:19 +02:00
Rasmus Wriedt Larsen
21d531f81e Python: Add QLDoc for FunctionValue.getQualifiedName
Matching the one for Function.getQualifiedName
2020-05-27 16:59:18 +02:00
semmle-qlci
674c184a97 Merge pull request #3566 from erik-krogh/XssAttributeSanitizer
Approved by asgerf
2020-05-27 15:45:41 +01:00
Tom Hvitved
1c5da67cd8 C#: Fix performance issue in unification library 2020-05-27 15:26:03 +02:00
Erik Krogh Kristensen
33da82d884 Merge branch 'master' of https://github.com/github/codeql into pr/erik-krogh/3566 2020-05-27 12:21:14 +00:00
semmle-qlci
3cfc1e553c Merge pull request #3560 from erik-krogh/OptionalSanitizer
Approved by asgerf
2020-05-27 13:15:41 +01:00
Erik Krogh Kristensen
d05a61c745 Merge branch 'master' of https://github.com/github/codeql into pr/erik-krogh/3566 2020-05-27 12:12:08 +00:00
Philip Ginsbach
748d01f888 Merge pull request #1 from shati-patel/typeunions-edits
Editorial suggestions for "type unions"
2020-05-27 12:01:28 +01:00
Shati Patel
6c9c803d94 update wording 2020-05-27 12:00:17 +01:00
Shati Patel
5cf2e3ed8c Editorial suggestions for "type unions" 2020-05-27 11:33:39 +01:00
semmle-qlci
fd05314b2c Merge pull request #3531 from asger-semmle/js/node-version-check-notimeout
Approved by esbena
2020-05-27 11:13:22 +01:00
Erik Krogh Kristensen
3ae4e90902 change note 2020-05-27 09:45:49 +00:00
Philip Ginsbach
460b64cfd9 noted that type unions are enabled from 2.2.0 2020-05-27 10:13:00 +01:00
Anders Schack-Mulligen
a858a8cd42 Java: Fix for private interface methods. 2020-05-27 11:05:41 +02:00
Anders Schack-Mulligen
796eac108f Java: Autoformat 2020-05-27 09:19:59 +02:00
Mathias Vorreiter Pedersen
db557a45e7 Merge pull request #3570 from geoffw0/mysprintftest
C++: Fix mysprintf in taint test
2020-05-27 09:19:54 +02:00
Mathias Vorreiter Pedersen
97edd97778 C++: Add getLocation to TNode IPA type in testcase 2020-05-27 08:28:18 +02:00
Robert Marsh
b45473ec4c C++: more specific type in IndirectParameterAlloc 2020-05-26 14:07:26 -07:00
Robert Marsh
70f62538af C++: autoformat 2020-05-26 14:06:22 -07:00
Robert Marsh
fb46002332 C++: Fix ThisParameterNode after IR changes 2020-05-26 13:35:08 -07:00
Erik Krogh Kristensen
dbc25ca3fb cache Expr::getStringValue 2020-05-26 22:17:00 +02:00
Philip Ginsbach
c8ed08f14c introduce type unions in the handbook 2020-05-26 19:46:58 +01:00
Robert Marsh
7ad45d50c0 C++: add test case from issue 2020-05-26 11:38:14 -07:00
yo-h
f952293ba0 Merge pull request #3526 from aschackmull/java/qltest-fps-nullness-rangeanalyis
Java: Add a few qltest cases for nullness and range analysis FPs.
2020-05-26 14:09:27 -04:00
Geoffrey White
95537ed26f C++: Fix mysprintf in test. 2020-05-26 18:06:14 +01:00
Geoffrey White
d96bf797ef C++: Test layout. 2020-05-26 18:06:06 +01:00
Erik Krogh Kristensen
319363f56c update expected output 2020-05-26 18:47:37 +02:00
Robert Marsh
43520b8f9b C++/C#: Fix copy/pasted qldoc 2020-05-26 09:47:30 -07:00
Geoffrey White
1baf14461d C++: Add a definition of taint to the models library. 2020-05-26 17:44:17 +01:00
Robert Marsh
2429e22709 Merge pull request #3548 from dbartol/github/codeql-c-analysis-team/69
C++: Fix duplicate result types
2020-05-26 09:44:12 -07:00
Geoffrey White
965d4829b5 C++: Consistency. 2020-05-26 17:43:40 +01:00
Erik Krogh Kristensen
63a14d1b96 use HtmlConcatenationLeaf 2020-05-26 18:33:29 +02:00
Rasmus Wriedt Larsen
6cba2fe4f8 Python: Model Django response sinks that are not vuln to XSS
Since HttpResponse is not *only* used for XSS, it is still valuable to know the
content is send as part of the response.

The *proper* solution to this problem of not all HttpResponses being vulnerable
to XSS is probably to define a new abstract class in Http.qll called
HttpResponseXSSVulnerableSink (or similar). I would like to model a few more
libraries/frameworks before fully comitting to an approach though.
2020-05-26 16:45:46 +02:00
Geoffrey White
dea7be0884 Merge pull request #3557 from jbj/qldoc-external
C++: QLDoc for legacy libraries in `external` dir
2020-05-26 15:01:03 +01:00
Erik Krogh Kristensen
9b047f6f03 use the DOTALL flag 2020-05-26 14:53:33 +02:00
Erik Krogh Kristensen
fd561d1ce2 remove temporary comment
Co-authored-by: Asger F <asgerf@github.com>
2020-05-26 14:37:02 +02:00
Erik Krogh Kristensen
0c00331527 less -> fewer
Co-authored-by: Asger F <asgerf@github.com>
2020-05-26 14:30:29 +02:00
Mathias Vorreiter Pedersen
08fa3141cd C++: Fix accidential removal of private annotations 2020-05-26 14:15:46 +02:00
Erik Krogh Kristensen
124c4cb15e Merge branch 'master' of github.com:github/codeql into OptionalSanitizer 2020-05-26 13:59:57 +02:00
Erik Krogh Kristensen
e5afdc53be use HtmlSanitizerCall to recognize sanitizers 2020-05-26 13:34:49 +02:00
Erik Krogh Kristensen
3e3372be4b recognize DOMPurify.sanitize as a HTML sanitizer 2020-05-26 13:34:33 +02:00
Jonas Jensen
5deeda0337 Merge pull request #3387 from geoffw0/tostringperf
C++: Eliminate recursion from toString().
2020-05-26 13:24:43 +02:00
Calum Grant
f0499451d3 Merge pull request #3513 from hvitved/csharp/deprecate-override
C#: Remove two deprecated predicates
2020-05-26 12:22:41 +01:00
Mathias Vorreiter Pedersen
251240376b C++: Fix asPartialDefinition for IR dataflow nodes and accept testcases 2020-05-26 13:14:38 +02:00
Mathias Vorreiter Pedersen
c5c3ffaef0 C++: Add asPartialDefinition testcases 2020-05-26 13:14:11 +02:00
semmle-qlci
be5b343a0c Merge pull request #3564 from max-schaefer/js/reflective-argument-access
Approved by asgerf
2020-05-26 12:09:13 +01:00
Asger Feldthaus
75fee22f1e JS: Avoid string coercion in JSXName.getValue 2020-05-26 12:03:02 +01:00
Erik Krogh Kristensen
ad40c4b0f2 add a sanitizer guard for safe attribute string concatenations 2020-05-26 12:36:47 +02:00
Erik Krogh Kristensen
a9bea63019 recognize more HTML attribute concatenations 2020-05-26 12:36:24 +02:00
semmle-qlci
4b0354c4bc Merge pull request #3555 from max-schaefer/js/require-flow
Approved by asgerf
2020-05-26 10:54:21 +01:00
Max Schaefer
5b0a3b9673 JavaScript: Change "Less results" to "Fewer results" in change notes. 2020-05-26 10:49:30 +01:00
Max Schaefer
abfcc42133 JavaScript: Re-alphabetise change notes. 2020-05-26 10:49:30 +01:00
Max Schaefer
215682f67c JavaScript: Add change note. 2020-05-26 10:49:30 +01:00
Max Schaefer
7ddf5ced23 JavaScript: Update expected output for unrelated tests. 2020-05-26 10:49:30 +01:00
semmle-qlci
4b56229ca0 Merge pull request #3527 from esbena/js/fastify
Approved by asgerf
2020-05-26 10:44:59 +01:00
Rasmus Lerchedahl Petersen
6b168de7fc Python: re, handle \Z 2020-05-26 11:42:21 +02:00
semmle-qlci
df205b617e Merge pull request #3539 from asger-semmle/js/capture-level-flow
Approved by erik-krogh
2020-05-26 10:42:14 +01:00
Mathias Vorreiter Pedersen
b205d36933 C++: Remove chi -> load rule from simpleLocalFlowStep and accept tests 2020-05-26 11:40:26 +02:00
Rasmus Wriedt Larsen
c78ca2616c Merge branch 'master' into python-keyword-only-args 2020-05-26 11:20:04 +02:00
Rasmus Wriedt Larsen
5a18b08d13 Python: Add comment explaining kw-only default index upgrade 2020-05-26 11:15:00 +02:00
Rasmus Wriedt Larsen
a616704a56 Python: Fix typo
Co-authored-by: Taus <tausbn@gmail.com>
2020-05-26 11:07:49 +02:00
Max Schaefer
9d3a9d71f1 JavaScript: Add basic support for reasoning about reflective parameter accesses.
Currently, only `arguments[c]` for a constant value `c` is supported.

This allows us to detect the prototype-pollution vulnerabilities in (old versions of) `extend`, `jquery`, and `node.extend`.
2020-05-26 09:59:29 +01:00
Max Schaefer
a39e8b4802 JavaScript: Add test for FlowSteps::argumentPassing predicate. 2020-05-26 09:51:06 +01:00
Rasmus Wriedt Larsen
9c75a39b81 Python: Extend command-injection to handle fabric.api.execute 2020-05-26 10:22:27 +02:00
Rasmus Wriedt Larsen
e04d1ffcd2 Python: Add test for fabric.api.execute 2020-05-26 10:20:22 +02:00
Anders Schack-Mulligen
6bc9624a4c Merge pull request #3236 from luchua-bc/java-improper-url-validation
Java: Improper url validation
2020-05-26 09:48:44 +02:00
Mathias Vorreiter Pedersen
5fb76df44f Merge pull request #3556 from jbj/qldoc-CodeDuplication
C++/JavaScript: Improve CodeDuplication.qll QLDoc
2020-05-26 09:17:28 +02:00
semmle-qlci
64aefc612f Merge pull request #3554 from jbj/too-few-arguments-ambiguous
Approved by dbartol
2020-05-26 07:26:53 +01:00
Rasmus Lerchedahl Petersen
f1efdee194 Python: re test with \Z 2020-05-26 08:07:13 +02:00
Erik Krogh Kristensen
3f66c04e12 change note 2020-05-26 00:09:11 +02:00
Erik Krogh Kristensen
9254df1f78 sanitize optionally sanitized values 2020-05-26 00:09:11 +02:00
Erik Krogh Kristensen
8fac3a1403 add IsEmptyGuard to TaintTracking 2020-05-26 00:09:08 +02:00
Dave Bartolomeo
5c20d56134 Merge pull request #3558 from jbj/qldoc-default-objc
C++: Properly deprecate objc.qll and default.qll
2020-05-25 14:31:25 -04:00
Dave Bartolomeo
12688f80ce Merge pull request #3559 from jbj/vcs-remove
C++: Remove VCS.qll and all queries using it
2020-05-25 14:30:31 -04:00
Jonas Jensen
e28ed848a4 C++: Remove VCS.qll and all queries using it
All these queries have been deprecated since 2018. There is
unfortunately no way to deprecate a library, but it's been years since
we populated any databases using the VCS library, so nobody should be
using it.
2020-05-25 19:28:06 +02:00
Jonas Jensen
85df60ea65 C++: Replace import default with import cpp
Some tests still used the old name for the top-level library.
2020-05-25 19:07:28 +02:00
Jonas Jensen
5fc2a3de92 C++: QLDoc for default.qll and objc.qll
These are both deprecated.
2020-05-25 19:05:41 +02:00
Jonas Jensen
357e14b2d2 C++: QLDoc for legacy libraries in external dir
These docs were taken from the corresponding files in JavaScript, and
parameter names were changed to match.
2020-05-25 19:03:14 +02:00
Jonas Jensen
6fc9e1d84c C++/JavaScript: Improve CodeDuplication.qll QLDoc
I took most of the docs from the corresponding predicates in
JavaScript's `CodeDuplication.qll`. Where JavaScript had a corresponding
predicate but didn't have QLDoc, I added new QLDoc to both.
2020-05-25 18:59:48 +02:00
Taus
7716cff3d8 Merge pull request #3551 from RasmusWL/python-fix-upcoming-deprecation
Python: Fix (upcoming) deprecation compiler-warnings
2020-05-25 16:17:57 +02:00
semmle-qlci
8146073c74 Merge pull request #3553 from RasmusWL/python-fix-tainttracking-import
Approved by tausbn
2020-05-25 14:18:54 +01:00
semmle-qlci
6f1f926e0c Merge pull request #3552 from RasmusWL/python-fix-filename-example
Approved by tausbn
2020-05-25 14:17:05 +01:00
Jonas Jensen
bc09720704 Merge pull request #3479 from geoffw0/fp2762
C++: Allow equality to block taint (security taint tracking)
2020-05-25 15:11:10 +02:00
Jonas Jensen
3d58e6f7af Merge pull request #3515 from hvitved/dataflow/remove-deprecated
Data flow: Remove deprecated predicates
2020-05-25 15:08:28 +02:00
Jonas Jensen
b4c32a00d8 C++: Fix up QLDoc in TooFewArguments.qll 2020-05-25 14:49:02 +02:00
Jonas Jensen
b1edc1d255 C++: Only give alert when no def fits arg count
The `cpp/too-few-arguments` query produced alerts for ambiguous
databases where a function had multiple possible declarations, with some
declarations having the right number of parameters and some having too
many. With this change, the query errs on the side of caution in those
cases and does not produce an alert.

This fixes false positives on racket/racket.

The new `hasDefiniteNumberOfParameters` is exactly the negation of the
old `hasZeroParamDecl`.
2020-05-25 14:48:57 +02:00
Bt2018
2a654af983 Correct the select statement in the query 2020-05-25 08:24:38 -04:00
Rasmus Wriedt Larsen
f602f3e1c7 Python: Use proper import for semmle.python.dataflow.TaintTracking
It was moved in 637677d515, but imports were not
updated.
2020-05-25 13:45:49 +02:00
Rasmus Wriedt Larsen
74167923bc Python: Fix filename example
I got my eyes on this one since it was using a deprecated method, BUT it was
also doing the thing, since File.getName() is the same as
File.getAbsolutePath(), and that doesn't match the description :\
2020-05-25 13:17:32 +02:00
Rasmus Wriedt Larsen
6ce1b9f7fa Python: Fix use of StrConst.strValue() 2020-05-25 13:12:56 +02:00
Anders Schack-Mulligen
0d75c6a5f1 Merge pull request #3506 from ggolawski/spring-actuators-fix
Fixes FPs in SpringBootActuators query
2020-05-25 13:09:56 +02:00
semmle-qlci
ac1a338390 Merge pull request #3407 from RasmusWL/python-add-BoundMethodValue-v2
Approved by tausbn
2020-05-25 12:00:45 +01:00
Rasmus Wriedt Larsen
32c8dd0491 Python: Fix (upcoming) deprecation compiler-warnings
In a near-future release overriding a deprecated predicate without making as
deprecated would give a compiler warning.

Not fixing the XML one. [I can see that this shouldn't be reported
anymore](https://github.com/github/codeql/pull/3520#issuecomment-631552943), and
it's not safe to remove since it was only marked as deprecated in
e6425bb4cf.
2020-05-25 11:05:30 +02:00
Taus
a2308771a3 Merge pull request #3489 from yoff/DeprecateObject
Python: Modernise `py/missing-equals`.
2020-05-25 10:56:16 +02:00
Rasmus Wriedt Larsen
49d7e12acd Python: Remove unnecessary restriction from getNamedArgumentForCall
As agreed in https://github.com/github/codeql/pull/3407
2020-05-25 10:17:37 +02:00
Rasmus Wriedt Larsen
4fc3cae646 Python: Add test for how arguments to *args and **kwargs are handled 2020-05-25 10:16:10 +02:00
Rasmus Wriedt Larsen
87ee6ae101 Python: Add a bit of docs to CallableObjectInternal
As requested :)
2020-05-25 09:53:28 +02:00
Rasmus Wriedt Larsen
9e0d57c610 Python: Fix grammar in QLDoc
Co-authored-by: Taus <tausbn@gmail.com>
2020-05-25 09:47:01 +02:00
Rasmus Lerchedahl Petersen
3e712be431 Python: Modernise 2020-05-25 09:00:34 +02:00
Rasmus Lerchedahl Petersen
712513916c Python: Address review 2020-05-25 07:44:00 +02:00
Max Schaefer
573fdaa424 JavaScript: Track require through local data flow. 2020-05-24 20:00:10 +01:00
luchua-bc
6d1ba3f899 Java: CWE-273 Unsafe certificate trust 2020-05-24 16:43:15 +00:00
Robert Marsh
1fa1bd5e36 C#: fix compilation error in IR 2020-05-22 16:08:11 -07:00
Robert Marsh
b4a947ddf1 C++: add getIRVariable for this temp variables 2020-05-22 15:43:34 -07:00
Robert Marsh
8a53dc882d C++: treat this as a parameter in IR 2020-05-22 15:35:34 -07:00
Dave Bartolomeo
df834ac031 C++: Fix duplicate result types
In a couple of cases, we use `glval<unknown>` as the result type of an instruction because we can't come up with anything better. Two examples are the result of `VariableAddress[#ellipsis]`, and the address of the temp variable that holds the lvalue result of the conditional operator in `(a ? b : c) = y`. In both cases, we call `getTypeForGLValue(any(UnknownType t))`, but that would have multiple results because `result.hasType(any(UnknownType t), true)` also holds for `CppFunctionGLValueType`. I tightened the result type to ensure we get the right one.
2020-05-22 16:20:33 -04:00
Alvaro Muñoz
0b20785cce add support for java.io.StringWriter 2020-05-22 18:13:28 +02:00
semmle-qlci
b9ecf1a304 Merge pull request #3447 from erik-krogh/LibCmdInjection
Approved by asgerf, mchammer01
2020-05-22 17:10:57 +01:00
Esben Sparre Andreasen
e172d55ecb Update javascript/ql/test/query-tests/Security/CWE-020/IncompleteUrlSchemeCheck.js
Co-authored-by: Asger F <asgerf@github.com>
2020-05-22 13:33:34 +02:00
Asger Feldthaus
823ed3bbdf JS: Wrap node --version call in retry loop 2020-05-22 10:40:16 +01:00
Asger Feldthaus
6f0356b229 Revert "JS: Remove timeout for node --version check"
This reverts commit ec7c9489dc.
2020-05-22 10:40:07 +01:00
James Fletcher
9259dca40d Merge pull request #3540 from github/jf205-patch-2
Link README.md to CodeQL for Go repo
2020-05-22 10:29:55 +01:00
Shati Patel
8c1e4d49ca Merge pull request #3537 from syang-ng/master
fix an error in the code snippet of the documentation about global-data-flow-java
2020-05-21 19:43:51 +01:00
James Fletcher
49d4c76f2f Update README.md 2020-05-21 16:37:44 +01:00
Asger Feldthaus
75be3b7ecb JS: Add test case for missed captured flow 2020-05-21 16:14:13 +01:00
syang-ng
184209d1eb fix an error in the code snippet of the documentation about global-data-flow-java 2020-05-21 22:00:15 +08:00
Geoffrey White
0f4723aee4 Merge pull request #3520 from dbartol/github/codeql-c-analysis-team/79
C++: Mark deprecated overrides as deprecated
2020-05-21 14:55:39 +01:00
Erik Krogh Kristensen
b79b25ef87 correct cwe-78 to cwe-078 2020-05-21 12:38:44 +00:00
Erik Krogh Kristensen
b297837969 Apply suggestions from doc review
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
2020-05-21 14:32:02 +02:00
Esben Sparre Andreasen
b31f83a5af JS: fixup expected output 2020-05-21 13:47:16 +02:00
Esben Sparre Andreasen
e588e59f9b JS: fixup 2020-05-21 13:42:28 +02:00
Esben Sparre Andreasen
c400b45cd6 JS: make the Fastify model support isUserControlledObject 2020-05-21 13:42:28 +02:00
Esben Sparre Andreasen
894033df8a JS: de-boilerplate the fastify model: address expr/dataflow comments 2020-05-21 13:42:28 +02:00
Esben Sparre Andreasen
74fc33e2a8 JS: make the qldoc check happy 2020-05-21 13:42:27 +02:00
Esben Sparre Andreasen
a76c70d2d7 JS: model fastify 2020-05-21 13:42:27 +02:00
Mathias Vorreiter Pedersen
617ef32464 C++: Remove [FALSE POSITIVE] annotations 2020-05-21 02:22:57 +02:00
Dave Bartolomeo
5641b2c140 C++: Remove deprecated predicate from File 2020-05-20 14:14:49 -04:00
Dave Bartolomeo
ff1e70efce C++: Undo changes to shared XML.qll 2020-05-20 14:14:31 -04:00
Mathias Vorreiter Pedersen
3c167125e5 C++: Accept test output 2020-05-20 18:18:34 +02:00
Mathias Vorreiter Pedersen
218a3cf93d C++: Remove field conflation 2020-05-20 18:18:26 +02:00
Asger Feldthaus
ec7c9489dc JS: Remove timeout for node --version check 2020-05-20 17:12:24 +01:00
semmle-qlci
8df7b7c42a Merge pull request #3525 from erik-krogh/ZipTaint
Approved by asgerf
2020-05-20 16:45:02 +01:00
Bt2018
74ab6981eb Fix HTML tag issue 2020-05-20 10:23:40 -04:00
semmle-qlci
079021a3e9 Merge pull request #3453 from RasmusWL/python-flask-routed-params
Approved by tausbn
2020-05-20 14:47:53 +01:00
Erik Krogh Kristensen
a23cde1354 autoformat 2020-05-20 15:36:46 +02:00
Tom Hvitved
011a95dcfa C#: Fix extracted type for nested object initializers 2020-05-20 14:20:41 +02:00
Tom Hvitved
70d47b76b1 C#: Add test for the type of an object initializer 2020-05-20 14:18:16 +02:00
Geoffrey White
9babd5dc10 C++: Another positive effect of the change. 2020-05-20 12:49:01 +01:00
Erik Krogh Kristensen
5a3eec87c0 rename isTaintedPathStep to isPosixPathStep 2020-05-20 13:44:14 +02:00
Erik Krogh Kristensen
97c199e10d update docstring
Co-authored-by: Asger F <asgerf@github.com>
2020-05-20 13:40:12 +02:00
Geoffrey White
f2436ff713 C++: Autoformat. 2020-05-20 12:39:54 +01:00
Rasmus Wriedt Larsen
712d4bd150 Python: Fix typo in docs
Co-authored-by: Taus <tausbn@gmail.com>
2020-05-20 13:06:24 +02:00
semmle-qlci
c15d22d9f8 Merge pull request #3516 from asger-semmle/js/typescript-3.9.2
Approved by erik-krogh
2020-05-20 11:31:57 +01:00
semmle-qlci
2bbc1c2af0 Merge pull request #3478 from erik-krogh/PromiseAll
Approved by asgerf, esbena
2020-05-20 11:03:05 +01:00
Tom Hvitved
7a54a90e61 C#: Fix CFG for C# 6 initializers 2020-05-20 12:01:22 +02:00
semmle-qlci
29b8a0db92 Merge pull request #3508 from asger-semmle/js/shared-data-flow-node
Approved by esbena
2020-05-20 10:58:09 +01:00
Anders Schack-Mulligen
8cbc01d49b Java: Add a few qltest cases for nullness and range analysis FPs. 2020-05-20 10:44:15 +02:00
Erik Krogh Kristensen
33e0f25f3c use NodeJSLib::Path instead of DataFlow::moduleMember 2020-05-20 10:30:23 +02:00
Erik Krogh Kristensen
7c51dff0f7 share implementation between TaintedPath and ZipSlip 2020-05-20 10:10:04 +02:00
Tom Hvitved
36e29e0f75 C#: Add CFG tests for C# 6 initializers 2020-05-20 09:33:51 +02:00
Tom Hvitved
e9839198f4 Merge pull request #3484 from calumgrant/cs/index-initializers
C#: Extract indexed initializers correctly
2020-05-20 09:22:47 +02:00
Tom Hvitved
97080731ad Merge pull request #3486 from h3ku/master
CSHARP: Add experimental query for tainted WebClient
2020-05-20 08:17:05 +02:00
Rasmus Lerchedahl Petersen
4d6ad32f04 Python: Update test expectations.
As ar as I can tell, all these are improvements
2020-05-20 08:11:03 +02:00
Robert Marsh
28c2acabe5 Merge pull request #3505 from dbartol/github/codeql-c-analysis-team/69
C++/C#: Remove `UnmodeledDefinition` instruction
2020-05-19 17:17:53 -07:00
Dave Bartolomeo
3832d4cae6 C++: Mark deprecated overrides as deprecated
The QL compiler is about to be changed to emit a warning when overriding a deprecated predicate. This PR marks the existing overrides of deprecated predicates as `deprecated` themselves, which avoids the warning.

The `Print.qll` models seem to preserve the `isWideCharDefault()` predicate for backwards compatibility, so we can't remove them and must continue overriding them.

The `XML.qll` override is necessary because both superclasses declare the `getName()` predicate. One is `deprecated`, and the other is `abstract`, so we have to have an override.
2020-05-19 16:33:33 -04:00
semmle-qlci
0a8b3adc25 Merge pull request #3518 from felicitymay/merge-124-master
Approved by shati-patel
2020-05-19 19:30:47 +01:00
Felicity Chapman
99d7a21425 Merge branch 'rc/1.24' into merge-124-master 2020-05-19 19:04:44 +01:00
Tom Hvitved
f0f833b58f Merge pull request #3512 from jbj/mergeback-2020-05-19
Mergeback rc/1.24 -> master
2020-05-19 19:51:36 +02:00
Erik Krogh Kristensen
5b569a4d6d add a sanitizer for chained replace-calls 2020-05-19 19:16:58 +02:00
Geoffrey White
fdf4e83c25 C++: Solve tuple count bulge that may affect performance. 2020-05-19 16:59:37 +01:00
Jonas Jensen
d38700a87c Merge remote-tracking branch 'upstream/master' into mergeback-2020-05-19
Conflicts:
	cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/tainted.expected
	cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/test_diff.expected
2020-05-19 17:44:15 +02:00
Asger Feldthaus
9d006327df JS: Update qldoc for ValueNode 2020-05-19 15:57:07 +01:00
semmle-qlci
26dfca80f6 Merge pull request #3510 from max-schaefer/cull-boring-queries
Approved by asgerf, esbena
2020-05-19 15:41:53 +01:00
Asger Feldthaus
b39e0ec091 JS: Update output due to whitelisting change 2020-05-19 15:30:36 +01:00
Hector Cuesta
66d77a43bd Fix typo in comment and TaintTrackingConfiguration name 2020-05-19 15:15:03 +01:00
Hector Cuesta
e18d8c5234 Remove duplicated CWE in security tag 2020-05-19 15:12:43 +01:00
Hector Cuesta
7d1ef92fbf Remove unnecessary CWE reference. 2020-05-19 15:09:17 +01:00
Mathias Vorreiter Pedersen
f0f7e531d7 Merge pull request #3511 from jbj/simplify-field-conflation-test
C++: Simplify field conflation test
2020-05-19 16:04:45 +02:00
yo-h
bfeaeccf60 Merge pull request #3507 from aschackmull/java/cleanup-deprecated-overrides
Java: Clean up deprecated overrides.
2020-05-19 09:47:57 -04:00
Tom Hvitved
431403f5db Data flow: Remove deprecated predicates 2020-05-19 15:42:59 +02:00
Tom Hvitved
2519e8a5f1 C#: Remove more deprecated classes and predicates 2020-05-19 15:39:17 +02:00
Tom Hvitved
9db8b993a9 C#: Remove two deprecated predicates 2020-05-19 15:32:29 +02:00
Bt2018
19d2a404c9 Add AndroidRString RefType to clarify the Android query 2020-05-19 08:44:26 -04:00
Max Schaefer
a803120414 Lower precision for a number of queries.
These queries are currently run by default, but don't have their results displayed.

Looking through results on LGTM.com, they are either false positives (e.g., `BitwiseSignCheck` which flags many perfectly harmless operations and `CompareIdenticalValues` which mostly flags NaN checks) or harmless results that developers are unlikely to care about (e.g., `EmptyArrayInit` or `MisspelledIdentifier`).

With this PR, the only queries that are still run but not displayed are security queries, where different considerations may apply.
2020-05-19 13:43:17 +01:00
Jonas Jensen
5318d42c4f Merge remote-tracking branch 'upstream/rc/1.24' into mergeback-2020-05-19 2020-05-19 14:42:58 +02:00
Jonas Jensen
486f06ab18 C++: Simplify field conflation test
It turned out the `memcpy` step was not even necessary.
2020-05-19 14:12:11 +02:00
Erik Krogh Kristensen
b71919299b Apply suggestions from code review
Co-authored-by: Asger F <asgerf@github.com>
2020-05-19 14:03:03 +02:00
Esben Sparre Andreasen
76bce40a8b JS: test fixups 2020-05-19 13:12:34 +02:00
Asger F
875c3706e3 Update javascript/ql/src/semmle/javascript/CFG.qll
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-05-19 12:08:51 +01:00
Asger Feldthaus
3f30564d93 JS: Autoformat 2020-05-19 12:05:32 +01:00
Geoffrey White
7d630c458e Merge branch 'master' into fp2762 2020-05-19 11:43:50 +01:00
Asger Feldthaus
0db0ddf476 JS: Add a change note 2020-05-19 11:07:35 +01:00
Asger Feldthaus
525b9871e0 JS: Update benign test output changes 2020-05-19 11:07:08 +01:00
Asger Feldthaus
b5b93f33bc JS: Bump to TypeScript 3.9.2 2020-05-19 11:07:08 +01:00
Anders Schack-Mulligen
6f03a0bc39 Merge pull request #3487 from luchua-bc/java-sensitive-jboss-logging
Add JBoss logging
2020-05-19 11:04:18 +02:00
Anders Schack-Mulligen
c36e6213f1 Merge pull request #3288 from ggolawski/jndi-injection
CodeQL query to detect JNDI injections
2020-05-19 11:03:29 +02:00
Asger Feldthaus
f49b36aec7 JS: Change note 2020-05-19 09:52:26 +01:00
Anders Schack-Mulligen
9d7329de30 Java: Clean up deprecated overrides. 2020-05-19 10:41:41 +02:00
Erik Krogh Kristensen
0275ea955b update expected output 2020-05-19 10:29:07 +02:00
Erik Krogh Kristensen
a4450c36f6 autoformat 2020-05-19 10:26:36 +02:00
Erik Krogh Kristensen
5a5192b890 add testing for complex path sanitizer in ZipSlip 2020-05-19 10:17:15 +02:00
semmle-qlci
0c081a8e87 Merge pull request #3497 from esbena/js/yield-and-local-objects
Approved by asgerf, erik-krogh
2020-05-19 09:02:22 +01:00
semmle-qlci
0d762066f5 Merge pull request #3504 from erik-krogh/unique
Approved by esbena
2020-05-19 08:35:08 +01:00
Dave Bartolomeo
d6ef94a4c7 C++: Remove dead comment 2020-05-18 23:05:19 -04:00
Dave Bartolomeo
3758f3c48d C++: Fix syntax-zoo test output 2020-05-18 18:07:52 -04:00
Dave Bartolomeo
01c2f0ce01 C++/C#: Fix formatting 2020-05-18 18:02:00 -04:00
Asger Feldthaus
91b9e95010 JS: Fix join ordering in analysis of add expressions 2020-05-18 22:45:59 +01:00
Asger Feldthaus
6a37e4b7a3 JS: Cache clobberedProp 2020-05-18 22:45:59 +01:00
Asger Feldthaus
5213c511b9 JS: Improve perf of GlobalVarUse.isIncomplete 2020-05-18 22:45:59 +01:00
Asger Feldthaus
7d9923038e JS: Fix perf issue from overriding isIncomplete 2020-05-18 22:45:59 +01:00
Asger Feldthaus
e58683769d JS: Fix bad join order in exploratoryBoundInvokeStep 2020-05-18 22:45:59 +01:00
Asger Feldthaus
9581bb52cb JS: Update test output 2020-05-18 22:45:59 +01:00
Asger Feldthaus
430bf2da8a JS: Fix whitelisting in UselessConditional 2020-05-18 22:45:56 +01:00
Asger Feldthaus
1d994b017f JS: Update type inference 2020-05-18 22:42:12 +01:00
Asger Feldthaus
d5d08da545 JS: Update getEnclosingExpr 2020-05-18 22:42:12 +01:00
Asger Feldthaus
12cc228946 JS: Update getFallbackTypeAnnotation 2020-05-18 22:42:12 +01:00
Asger Feldthaus
b06cd6db30 JS: Update Node.isIncomplete 2020-05-18 22:42:12 +01:00
Grzegorz Golawski
73e736b47a Enhanced comments according to the review comment 2020-05-18 23:37:48 +02:00
Asger Feldthaus
5568f0e182 JS: Pass local arguments to parameter value node, not SSA node 2020-05-18 22:34:42 +01:00
Asger Feldthaus
dc2d6a5fd9 JS: Make ValueNode the ParameterNode with a step to the SSA node 2020-05-18 22:34:42 +01:00
Asger Feldthaus
37ddccfa15 JS: Merge DestructuringPatternNode into ValueNode 2020-05-18 22:29:33 +01:00
Asger Feldthaus
b3161b1c41 JS: Factor TNode into a separate file 2020-05-18 22:29:33 +01:00
Asger Feldthaus
d9123833af JS: Avoid misoptimization in mayReturnImplicitValue 2020-05-18 22:29:33 +01:00
Asger Feldthaus
eddbdffe62 JS: Add more tests for implicit returns 2020-05-18 22:29:33 +01:00
Asger Feldthaus
6a63f5b677 JS: Avoid bad join order in ImplicitProcessImport 2020-05-18 22:29:32 +01:00
Asger Feldthaus
c869812563 JS: Add UselessConditional test 2020-05-18 22:29:32 +01:00
Grzegorz Goławski
0075d35346 Update java/ql/src/experimental/Security/CWE/CWE-074/JndiInjectionLib.qll
Co-authored-by: Anders Schack-Mulligen <aschackmull@users.noreply.github.com>
2020-05-18 23:18:16 +02:00
Erik Krogh Kristensen
aa396a39d3 Merge branch 'master' of https://github.com/github/codeql into pr/erik-krogh/3478 2020-05-18 20:57:51 +00:00
Grzegorz Golawski
ac329e81f8 Fixes FPs in SpringBootActuators query
No evidence that Spring Actuators are being used, e.g. `http.authorizeRequests().anyRequest().permitAll()`
Only safe Actuators are enabled, e.g. `EndpointRequest.to("health", "info")`
2020-05-18 22:55:33 +02:00
Erik Krogh Kristensen
fc7e9eb8c8 add test for non-tracked aliasing 2020-05-18 22:40:41 +02:00
Dave Bartolomeo
42c659b8f2 C++/C#: Remove UnmodeledDefinition instruction 2020-05-18 15:08:50 -04:00
Erik Krogh Kristensen
b8ba31aaa0 autoformat 2020-05-18 21:06:19 +02:00
Erik Krogh Kristensen
0758413cc7 revert change to import 2020-05-18 21:06:19 +02:00
Erik Krogh Kristensen
742abf8751 refactor package export into a library, and add tests for the library 2020-05-18 21:06:14 +02:00
Erik Krogh Kristensen
d7b852f408 use count aggregate to count 2020-05-18 21:03:26 +02:00
semmle-qlci
192bf918c3 Merge pull request #3488 from asger-semmle/js/sql-type-tracking
Approved by erik-krogh
2020-05-18 19:57:32 +01:00
Erik Krogh Kristensen
202b8a56b7 apply the unique aggregate where trivially applicable 2020-05-18 20:37:38 +02:00
Rasmus Wriedt Larsen
3774310985 Python: Reduce FPs in Django due to bad XSS taint-sinks
Fixes https://github.com/github/codeql-python-team/issues/38
2020-05-18 19:14:43 +02:00
Rasmus Wriedt Larsen
fa08676a1d Python: Proper redirect taint sinks for Django
Also a major restructuring of the code. A bit controversial since it
renames/moves classes that are already public.

Fixes https://github.com/github/codeql/issues/3466
2020-05-18 19:14:29 +02:00
Asger F
96d6115452 Merge branch 'master' into js/sql-type-tracking 2020-05-18 15:58:42 +01:00
Rasmus Wriedt Larsen
72ea4ff0dc Python: Add more tests of django responses
They clearly shouldn't all be XSS sinks
2020-05-18 16:56:47 +02:00
Dave Bartolomeo
35868d4e5b C++/C#: Change dump of unmodeled use to m?
This is kind of inconsequential on its own, but will make the test diffs easier to understand once the next commit removes `UnmodeledDefinition`.
2020-05-18 10:47:43 -04:00
Erik Krogh Kristensen
70a28f60e3 Merge branch 'master' of https://github.com/github/codeql into pr/erik-krogh/3478 2020-05-18 14:05:37 +00:00
Bt2018
69f2525e62 Remove the ending blank lines for auto-format check 2020-05-18 10:02:37 -04:00
Bt2018
08ab7b0eb2 Remove the ending blank line for auto-format check 2020-05-18 10:00:12 -04:00
semmle-qlci
0da1e68462 Merge pull request #3498 from max-schaefer/js/remote-exec
Approved by esbena
2020-05-18 14:17:20 +01:00
Rasmus Wriedt Larsen
8fc803fb9f Merge branch 'master' into python-keyword-only-args 2020-05-18 14:44:31 +02:00
Rasmus Lerchedahl Petersen
b56545b236 Python: Regexp: Handle repetions {n} (with no ,) 2020-05-18 14:44:11 +02:00
Asger F
a9983fdb49 Update javascript/ql/src/semmle/javascript/frameworks/SQL.qll
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-18 13:23:22 +01:00
Bt2018
7a9381f1fb Add declaring type to the res.getString(R.string.key) call 2020-05-18 07:59:38 -04:00
Anders Schack-Mulligen
37c8917813 Java: Add test. 2020-05-18 13:19:19 +02:00
Max Schaefer
bdd778f989 JavaScript: Add change note. 2020-05-18 12:08:36 +01:00
Max Schaefer
6797fec1a3 JavaScript: Add more models of packages that execute commands over SSH. 2020-05-18 12:08:14 +01:00
Esben Sparre Andreasen
a9ba6ac659 JS: make LocalObjects::isEscape aware of yield 2020-05-18 12:43:46 +02:00
Erik Krogh Kristensen
0f82370f4e rename getHighLight() -> getAlertLocation() 2020-05-18 12:28:28 +02:00
Erik Krogh Kristensen
2b1724291b adjust qhelp to focus on user-controlled data 2020-05-18 12:27:20 +02:00
Erik Krogh Kristensen
d18808698a adjust qhelp to focus on the execFile API 2020-05-18 12:22:46 +02:00
Esben Sparre Andreasen
aa87008775 JS: typo fixups 2020-05-18 12:19:46 +02:00
Erik Krogh Kristensen
9c294513c7 Apply suggestions from code review
Co-authored-by: Asger F <asgerf@github.com>
2020-05-18 12:18:20 +02:00
semmle-qlci
14664be467 Merge pull request #3468 from p0/imp/nodejs-vm-sinks
Approved by esbena
2020-05-18 11:10:13 +01:00
Esben Sparre Andreasen
b3691cd0e9 JS: change MembershipTest to MembershipCandidate 2020-05-18 11:51:00 +02:00
Erik Krogh Kristensen
c6276ddd1c update expected output after restricting precise array tracking to Promise.all 2020-05-18 11:49:07 +02:00
Asger Feldthaus
a18e0b37cf JS: simplify sequelize model 2020-05-18 09:34:17 +01:00
Asger F
f52c827966 Apply suggestions from code review
Base type of EscapingSanitizer

Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-18 09:31:09 +01:00
Asger F
ffb22c061a Apply suggestions from code review
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-18 09:28:22 +01:00
Erik Krogh Kristensen
bd3c4d4077 Merge branch 'master' of https://github.com/github/codeql into pr/erik-krogh/3478 2020-05-18 07:51:19 +00:00
Esben Sparre Andreasen
ddb545c182 JS: introduce MembershipTests.qll and use in two locations 2020-05-18 09:50:00 +02:00
Anders Schack-Mulligen
bd114db862 Java: Add cfg edges for instanceof-pattern. 2020-05-18 09:49:32 +02:00
semmle-qlci
6041d52936 Merge pull request #3424 from asger-semmle/js/express-param-handler
Approved by esbena
2020-05-18 08:48:24 +01:00
semmle-qlci
135eae9895 Merge pull request #3483 from esbena/js/fix-qhelp-FNs
Approved by asgerf
2020-05-18 08:47:05 +01:00
semmle-qlci
0230b79efc Merge pull request #3391 from erik-krogh/SplitFPs
Approved by esbena
2020-05-18 08:46:26 +01:00
Erik Krogh Kristensen
8717f7bd0d restrict precise array elements to Promise.all() 2020-05-17 15:58:59 +02:00
Erik Krogh Kristensen
2d6e3a5784 support outdir in tsconfig.json 2020-05-17 10:32:27 +02:00
Erik Krogh Kristensen
dfdecf1450 add change note 2020-05-17 10:32:27 +02:00
Erik Krogh Kristensen
c8cf958c8a add test cases for js/shell-command-constructed-from-input 2020-05-17 10:32:27 +02:00
Erik Krogh Kristensen
59001bbdf4 add qhelp for js/shell-command-constructed-from-input 2020-05-17 10:32:27 +02:00
Erik Krogh Kristensen
5e647da0de add js/shell-command-constructed-from-input query 2020-05-17 10:32:15 +02:00
luchua-bc
6c24f36068 Java: CWE-297 insecure JavaMail SSL configuration 2020-05-17 02:43:26 +00:00
Erik Krogh Kristensen
a1a6826278 support non-SourceNode in IndirectCommandArgument#argumentList 2020-05-16 23:15:37 +02:00
Erik Krogh Kristensen
a6cd91bb49 add support for mz/fs and mz/child_process 2020-05-16 23:15:33 +02:00
Erik Krogh Kristensen
bb8905b46e add "valid" to the AdHocWhitelistCheckSanitizer 2020-05-16 22:43:36 +02:00
semmle-qlci
8d41ce1630 Merge pull request #3480 from erik-krogh/moreSlip
Approved by esbena
2020-05-16 21:17:27 +01:00
Mathias Vorreiter Pedersen
a42d80aa14 Merge pull request #3481 from dbartol/github/codeql-c-analysis-team/69
C++/C#: Allow memory operands to lack a definition
2020-05-16 11:53:00 +02:00
Asger Feldthaus
897a3e39c9 JS: Autoformat 2020-05-16 09:37:16 +01:00
Asger Feldthaus
0171c9e10c JS: Autoformat 2020-05-16 09:25:18 +01:00
Asger Feldthaus
d279845a43 JS: Minor fixes 2020-05-16 09:24:53 +01:00
yo-h
4f00e40257 Merge pull request #3474 from aschackmull/java/string-formatted
Java: Add taint steps for String.formatted.
2020-05-15 22:04:36 -04:00
yo-h
69ab158910 Merge pull request #3473 from aschackmull/java/switchexpr
Java: Extend library support for switch expressions.
2020-05-15 20:46:37 -04:00
Dave Bartolomeo
96c87b309b C++/C#: Use unique to get a better join order
The previous changes made the optimizer choose a bad join order for the RHS of the antijoin in `addressOperandAllocationAndOffset`. Once again, `unique` to the rescue.
2020-05-15 17:36:43 -04:00
Erik Krogh Kristensen
e2cd7e6230 more precise taint-tracking for Promise.all 2020-05-15 22:02:41 +02:00
Hector Cuesta
16e39414bc Reword of help file 2020-05-15 18:14:52 +01:00
Asger Feldthaus
435f9ea09f JS: Change note 2020-05-15 17:27:30 +01:00
Asger Feldthaus
5249e84359 JS: Type track spanner model 2020-05-15 17:27:30 +01:00
Asger Feldthaus
d225715828 JS: Type track mssql model 2020-05-15 17:27:30 +01:00
Asger Feldthaus
6dcee5a0ef JS: Type track sqlite model 2020-05-15 17:27:30 +01:00
Asger Feldthaus
84cd02cf01 JS: Type track pg model 2020-05-15 17:27:27 +01:00
Asger Feldthaus
f7771f17d1 JS: Type track mysql model 2020-05-15 17:27:27 +01:00
Asger Feldthaus
3e9849b7c4 JS: Type track sequelize model 2020-05-15 17:27:24 +01:00
Hector Cuesta
ef53e443b7 Fix typo in comment 2020-05-15 17:17:42 +01:00
luchua-bc
4117cd73a7 Add JBoss logging 2020-05-15 16:14:41 +00:00
Geoffrey White
edd09f09cd C++: Add test cases where several specific values are permitted. 2020-05-15 17:01:23 +01:00
Hector Cuesta
a022086498 Add experimental query for Tainted WebClient 2020-05-15 16:30:10 +01:00
Calum Grant
da6c37d7dc C#: Update test output. 2020-05-15 15:40:49 +01:00
Henning Makholm
a57b060a0c docs/language/ql-handbook/language.rst: apply suggestion from review
Co-authored-by: Shati Patel <42641846+shati-patel@users.noreply.github.com>
2020-05-15 15:55:16 +02:00
Jonas Jensen
b08de6c051 Merge pull request #3482 from MathiasVP/getlim-taint-source
C++: Add GetDelim as taint step
2020-05-15 15:54:29 +02:00
Tom Hvitved
cd9538d0d9 Merge remote-tracking branch 'upstream/master' into dataflow/precise-field-types 2020-05-15 15:24:05 +02:00
Calum Grant
5787871734 Merge pull request #3351 from hvitved/csharp/unification-nested-types
C#: Teach unification library about nested types
2020-05-15 14:11:00 +01:00
Calum Grant
cc844648ff Merge pull request #3365 from hvitved/csharp/format-queries-path-problem
C#: Convert `string.format()` queries to path queries
2020-05-15 14:08:54 +01:00
Rasmus Wriedt Larsen
061f318576 Merge pull request #3460 from yoff/boolDefault
Python: __bool__ does not raise TypeError by default
2020-05-15 15:07:45 +02:00
Dave Bartolomeo
89ec60c948 C++/C#: Add missing QLDoc 2020-05-15 09:01:16 -04:00
Dave Bartolomeo
bcddaf4c29 C++/C#: Fix formatting 2020-05-15 08:56:32 -04:00
Mathias Vorreiter Pedersen
7502c6f821 Set mustWrite to false in response to PR feedback
Co-authored-by: Jonas Jensen <jbj@github.com>
2020-05-15 14:32:46 +02:00
Asger Feldthaus
e311cc7689 JS: Change note 2020-05-15 13:06:37 +01:00
Calum Grant
53ca3ccf53 C#: Update changenotes 2020-05-15 13:06:17 +01:00
Rasmus Lerchedahl Petersen
60d5ba23b3 Python: Move test into appropriate class.
Also update test expectations with changed line numbers.
2020-05-15 13:51:51 +02:00
Calum Grant
84bce9f742 C#: Extract indexed initializers correctly. 2020-05-15 12:50:53 +01:00
Rasmus Lerchedahl Petersen
1b0687e2f2 Python: update expectations correctly 2020-05-15 13:25:20 +02:00
Esben Sparre Andreasen
1c5bffc095 JS: fix some FNs in the qhelp examples 2020-05-15 12:40:38 +02:00
Jonas Jensen
8a0af0bcac Merge pull request #3465 from MathiasVP/remove-abstract-from-access-and-cast
C++: Remove abstract keyword from `Access` and `Cast` classes
2020-05-15 12:25:34 +02:00
Erik Krogh Kristensen
3138918f1d add test for promise inside Promise.all 2020-05-15 11:49:29 +02:00
Mathias Vorreiter Pedersen
866b1361ec C++: Accept tests 2020-05-15 11:12:47 +02:00
Mathias Vorreiter Pedersen
e70f22c753 C++: Model getdelim and friends 2020-05-15 11:05:57 +02:00
Mathias Vorreiter Pedersen
90d473d886 C++: Demonstrate lack of taint through getdelim 2020-05-15 11:01:27 +02:00
Asger Feldthaus
d84f1b47c2 JS: Refactor RequestInputAccess to use source nodes 2020-05-15 09:59:28 +01:00
Asger Feldthaus
da974f1527 JS: Add test with dynamic access to req.query 2020-05-15 09:59:28 +01:00
Asger Feldthaus
659e2ff709 JS: Tweak evaluation of route handler params 2020-05-15 09:59:27 +01:00
Asger F
b9995b784d Update javascript/ql/src/semmle/javascript/frameworks/ConnectExpressShared.qll
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-05-15 09:59:27 +01:00
Asger Feldthaus
a982cdc39c JS: Autoformat 2020-05-15 09:59:27 +01:00
Asger Feldthaus
bfbe70a7a9 JS: Fixes 2020-05-15 09:59:27 +01:00
Asger Feldthaus
82d3a7eb23 JS: Go back to disjunction 😭 2020-05-15 09:59:27 +01:00
Asger Feldthaus
c45d84f8f3 JS: Update getRouteHandlerParameter and router tracking 2020-05-15 09:59:27 +01:00
Asger Feldthaus
9cacfab7c6 JS: Recognize Express param value callback as RemoteFlowSource 2020-05-15 09:59:26 +01:00
Geoffrey White
48f3db3fbe Merge branch 'master' into fp2762 2020-05-15 09:55:30 +01:00
Erik Krogh Kristensen
6d79bab7e4 rename Fs to FS 2020-05-15 10:54:08 +02:00
Erik Krogh Kristensen
dd3342ba6f restrict the number of stored array elements 2020-05-15 10:01:27 +02:00
Erik Krogh Kristensen
4eb96848a6 add change note for bluebird and "Promise" 2020-05-15 09:58:33 +02:00
Erik Krogh Kristensen
cb96ee8def remove redundant instanceof check
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-05-15 09:58:18 +02:00
Erik Krogh Kristensen
7df35a6bab update change note 2020-05-15 09:52:59 +02:00
semmle-qlci
a536069059 Merge pull request #3408 from esbena/js/unsafe-html-expansion
Approved by asgerf, mchammer01
2020-05-15 08:24:12 +01:00
Tom Hvitved
01102b309b C#: Rename predicates 2020-05-15 09:06:12 +02:00
Dave Bartolomeo
4614372873 C++/C#: Add QLDoc 2020-05-14 17:49:23 -04:00
Dave Bartolomeo
6c12b59f0f C++/C#: Allow non-Phi memory operands to have no definition 2020-05-14 17:22:23 -04:00
Henning Makholm
43e8a0f716 Apply suggestions from code review
Co-authored-by: Shati Patel <42641846+shati-patel@users.noreply.github.com>
2020-05-14 23:13:50 +02:00
Erik Krogh Kristensen
6775294ac1 update expected output 2020-05-14 22:26:44 +02:00
Rasmus Lerchedahl Petersen
81a5692935 Python: handle \uxxxx and refactor 2020-05-14 21:22:21 +02:00
Erik Krogh Kristensen
e7d1b12ac8 add test 2020-05-14 20:31:23 +02:00
Erik Krogh Kristensen
6d2bffef72 add fs.open/openSync as ZipSlip sinks 2020-05-14 20:31:13 +02:00
Erik Krogh Kristensen
2d675262b2 use the generalized fs module in more places 2020-05-14 20:31:00 +02:00
Geoffrey White
6579c71866 C++: Change note. 2020-05-14 18:44:06 +01:00
Geoffrey White
df5e16c45d C++: Add a 1.25 change note file (didn't we used to have templates for these?). 2020-05-14 18:41:14 +01:00
Geoffrey White
4a6021fb61 C++: Allow equality checking to block taint flow. 2020-05-14 18:32:38 +01:00
Erik Krogh Kristensen
5132e61ce7 add tests 2020-05-14 18:55:49 +02:00
Erik Krogh Kristensen
e98f794dab implement precise data-flow steps for Promise.all 2020-05-14 18:55:44 +02:00
Henning Makholm
69ba22a3c2 QL handbook: bring library path documentation up to date 2020-05-14 18:41:22 +02:00
semmle-qlci
c06680a496 Merge pull request #3470 from asger-semmle/js/cache-module-import
Approved by esbena
2020-05-14 17:20:04 +01:00
Mathias Vorreiter Pedersen
fe682556bf Merge pull request #3475 from jbj/field-conflation-memcpy
C++: Test field conflation with array in struct
2020-05-14 17:53:32 +02:00
Dave Bartolomeo
efa133f0db Merge pull request #3463 from MathiasVP/fix-field-flow-annotation
C++: Annotate field flow tests
2020-05-14 10:49:27 -04:00
Jonas Jensen
49ebb3197a Merge pull request #3472 from geoffw0/paramstring
C++: Improve getParameterString().
2020-05-14 16:48:07 +02:00
Jonas Jensen
a380dc113f C++: Test field conflation with array in struct 2020-05-14 16:29:39 +02:00
Dave Bartolomeo
9de597db25 C++: Refactor Operand to prepare for cross-phase IPA sharing 2020-05-14 10:29:08 -04:00
Geoffrey White
754d7f0be8 C++: More test cases for TaintedAllocationSize. 2020-05-14 15:23:31 +01:00
Anders Schack-Mulligen
1838a7455a Java: Add taint steps for String.formatted. 2020-05-14 16:17:03 +02:00
Rasmus Lerchedahl Petersen
21d1ea5d96 Merge branch 'boolDefault' of github.com:yoff/codeql into boolDefault 2020-05-14 16:06:58 +02:00
Tom Hvitved
2c243ad1cd C#: Add data-flow test 2020-05-14 15:58:50 +02:00
Tom Hvitved
2d7470fc3a C++: Follow-up changes 2020-05-14 15:58:50 +02:00
Tom Hvitved
e608c53c3f Java: Follow-up changes 2020-05-14 15:58:50 +02:00
Tom Hvitved
aa83cc1472 Data flow: Sync files 2020-05-14 15:58:50 +02:00
Tom Hvitved
a0d100485b Data flow: Rename Content variables from f to c 2020-05-14 15:58:50 +02:00
Tom Hvitved
f1cd53507d Data flow: Track precise types during field flow 2020-05-14 15:58:50 +02:00
Jonas Jensen
3cd377e299 C++: Fixup forgotten test annotation
This should have been removed in 038bea2f52.
2020-05-14 15:57:47 +02:00
Rasmus Lerchedahl Petersen
1817d2af2b Make test for wrong bool type pass 2020-05-14 15:56:57 +02:00
Rasmus Lerchedahl Petersen
7b004c3746 Python: Add test for wrong exception type 2020-05-14 15:42:52 +02:00
Anders Schack-Mulligen
0aad24e6db Java: Extend library support for switch expressions. 2020-05-14 15:40:26 +02:00
Mathias Vorreiter Pedersen
1c2b8563ae C++: Remove 'flow' value from testcases 2020-05-14 15:33:02 +02:00
Geoffrey White
6583012e6d C++: Use concat in getParameterString(). 2020-05-14 14:21:46 +01:00
Geoffrey White
da83f826b9 C++: Solve duplication in getParameterString(). 2020-05-14 14:21:06 +01:00
Geoffrey White
ca0d23fd72 C++: Add a test case. 2020-05-14 14:20:02 +01:00
Mathias Vorreiter Pedersen
5f9b96cde9 C++: Fix off-by-one in test annotation 2020-05-14 15:12:00 +02:00
semmle-qlci
23532ae49a Merge pull request #3467 from erik-krogh/tarSlip
Approved by esbena
2020-05-14 14:06:42 +01:00
semmle-qlci
57f44c5a81 Merge pull request #2886 from asger-semmle/js/call-graph-exploration
Approved by erik-krogh, esbena
2020-05-14 14:01:23 +01:00
semmle-qlci
384df88df1 Merge pull request #3359 from erik-krogh/MayHavePropName
Approved by esbena
2020-05-14 13:52:45 +01:00
Asger Feldthaus
e491431f4e JS: Autoformat 2020-05-14 13:29:33 +01:00
Bt2018
819a599e2c Correct the name tag and change the placeholders in the query 2020-05-14 08:13:21 -04:00
Geoffrey White
78f098f37a C++: Test Function.getParameterString(). 2020-05-14 13:05:39 +01:00
Mathias Vorreiter Pedersen
f414b277ba C++: Modify complex.cpp test to account for longer access paths in the dataflow library 2020-05-14 13:58:04 +02:00
Pavel Avgustinov
3cc13db3a0 NodeJSLib: Restore backwards-compatibility. 2020-05-14 12:51:09 +01:00
Geoffrey White
53a53fb633 C++: Modernize the Functions test. 2020-05-14 12:50:57 +01:00
Bt2018
9a7ab4ee32 Correct comment of the HostVerificationMethodAccess method access 2020-05-14 07:43:17 -04:00
Asger Feldthaus
1cdb51741f JS: Dont use deprecated API in test case 2020-05-14 11:08:31 +01:00
Anders Schack-Mulligen
5c9fb2312e Merge pull request #3090 from luchua-bc/java-insert-sensitive-info-into-log
Java: CWE-532 sensitive info logging
2020-05-14 11:43:47 +02:00
Mathias Vorreiter Pedersen
f5f3405ec3 C++: Modify IR field flow tests to use InlineExpectationsTest.qll 2020-05-14 11:11:21 +02:00
Pavel Avgustinov
ab2d059ed4 JavaScript: Model extra sinks in vm module 2020-05-14 10:01:40 +01:00
Erik Krogh Kristensen
b12e21edcc add test for new zipslip sanitizer 2020-05-14 10:11:37 +02:00
Erik Krogh Kristensen
422ade16db Apply suggestions from code review
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-05-14 10:05:59 +02:00
Erik Krogh Kristensen
ce5356f592 change note 2020-05-14 09:48:50 +02:00
Erik Krogh Kristensen
4175d36269 add test case 2020-05-14 09:46:54 +02:00
Erik Krogh Kristensen
b727fa81a0 add a path sanitizer to zipslip 2020-05-14 09:46:50 +02:00
Erik Krogh Kristensen
71e7083dcb add "linkname" as a file-name-property for zip-slip 2020-05-14 09:06:23 +02:00
Erik Krogh Kristensen
a19718a10f add fs.link and fs.linkSync as writing file system calls 2020-05-14 09:00:50 +02:00
Mathias Vorreiter Pedersen
671242ce5e C++: Add upgrade script 2020-05-14 08:49:34 +02:00
Mathias Vorreiter Pedersen
dbba2269ad C++: Add stats 2020-05-14 08:47:16 +02:00
yoff
e5eadf9126 Update python/ql/test/query-tests/Functions/general/protocols.py
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
2020-05-14 07:34:53 +02:00
Rasmus Lerchedahl Petersen
c7ddd2c20c Python: make test for unicode names pass 2020-05-14 07:31:03 +02:00
Rasmus Lerchedahl Petersen
de50aabd60 Python: test for unicode names 2020-05-14 07:30:29 +02:00
Rasmus Lerchedahl Petersen
4c7cf2ac2d Python: Make test pass
Also checked that the OP's snapshot no longer has alerts from
`duplicate_char_in_class`
2020-05-14 07:06:59 +02:00
Robert Marsh
396ccda81f Merge pull request #3422 from Cornelius-Riemenschneider/inbounds-ptr
C++: Add InBoundsPointerDeref.qll to experimental
2020-05-13 16:55:42 -07:00
Mathias Vorreiter Pedersen
8f3ba75534 C++: Remove abstract keyword from Access and Cast and create .dbscheme unions 2020-05-13 23:15:11 +02:00
Dave Bartolomeo
ea2081ca40 Merge pull request #3459 from dbartol/github/codeql-c-analysis-team/69
C++/C#: Remove `UnmodeledUse` instruction
2020-05-13 13:13:40 -04:00
Rasmus Lerchedahl Petersen
f9f52b0105 Python: test for unicode in raw strings 2020-05-13 18:47:36 +02:00
Asger Feldthaus
2ef7719b06 JS: PathExprInModule deprecation notice 2020-05-13 16:35:24 +01:00
Asger Feldthaus
3846f534a8 JS: Factor out overridden part of PathExpr.getSearchRoot 2020-05-13 16:34:43 +01:00
Asger Feldthaus
5f510878f3 JS: Remove PathExprBase and PathExprInModule 2020-05-13 16:34:28 +01:00
Asger Feldthaus
2d88385ffb JS: Cache moduleImport 2020-05-13 15:07:13 +01:00
Mathias Vorreiter Pedersen
34314d0cb6 C++: Annotation field flow tests with [IR] and [AST] 2020-05-13 15:16:02 +02:00
Calum Grant
f5daeea618 Merge pull request #3421 from hvitved/csharp/dataflow/change-note
C#/Java/C++: Add change note for #3110
2020-05-13 13:53:01 +01:00
semmle-qlci
2a341d973d Merge pull request #3458 from esbena/js/NoSQLCodeInjection
Approved by erik-krogh
2020-05-13 13:33:28 +01:00
Bt2018
7b88988981 Convert to path-problem query 2020-05-13 08:09:22 -04:00
Dave Bartolomeo
b0f7e9c6a7 C++: Accept test output 2020-05-13 08:02:17 -04:00
Bt2018
632cb8b666 Simplify CredentialExpr as the AddExpr step is included by TaintTracking::localTaintStep(node1, node2) 2020-05-13 07:55:32 -04:00
Bt2018
d9cc3c6f8d Add a comment for reasoning in why debug and trace are included and other variations are excluded 2020-05-13 07:46:44 -04:00
Esben Sparre Andreasen
c6fa88af28 JS: change notes 2020-05-13 12:56:33 +02:00
Esben Sparre Andreasen
9552352d6a JS: address qhelp feedback 2020-05-13 12:53:59 +02:00
Rasmus Lerchedahl Petersen
d9d86e1f56 Make test pass 2020-05-13 12:16:11 +02:00
Jonas Jensen
1018eaff09 Merge remote-tracking branch 'upstream/master' into dataflow-indirect-args
Conflicts:
	cpp/ql/test/library-tests/dataflow/fields/ir-flow.expected
2020-05-13 12:05:58 +02:00
Esben Sparre Andreasen
7305a873b1 JS: formatting 2020-05-13 11:28:48 +02:00
Esben Sparre Andreasen
fedd32fc2b JS: address review comment 2020-05-13 09:57:02 +02:00
Esben Sparre Andreasen
91f43a7dae JS: address review comments 2020-05-13 09:52:01 +02:00
Jonas Jensen
038bea2f52 C++: Add type check to prevent field conflation 2020-05-13 09:25:24 +02:00
Jonas Jensen
250e12a323 C++: Demonstrate new field conflation 2020-05-13 09:24:36 +02:00
Esben Sparre Andreasen
7722d77c86 JS: add the NoSQL $where as a sink for js/code-injection 2020-05-13 08:30:22 +02:00
Esben Sparre Andreasen
20cf04442c JS: model marsdb and minimongo 2020-05-13 08:28:59 +02:00
Anders Schack-Mulligen
f5e491caf0 Merge pull request #3448 from yo-h/java-qldoc-add
Java: improve QLDoc completeness
2020-05-13 08:26:02 +02:00
Dave Bartolomeo
5d3f25211d C++/C#: Remove UnmodeledUse instruction 2020-05-13 01:06:40 -04:00
Dave Bartolomeo
7f2c6dd9f9 C++/C#: Remove UnmodeledUseOperand 2020-05-13 01:05:27 -04:00
Bt2018
ffd442a17a Fine tuning criteria
1. Change the regex pattern from variable contains "url" to variable starts with "url"
2. Add the logging trace method to sink
2020-05-12 23:24:55 -04:00
Bt2018
491b67e658 Change string concatenation in the source to TaintTracking::Configuration 2020-05-12 22:57:07 -04:00
Bt2018
106c181ab1 Formatting with auto-format 2020-05-12 15:53:29 -04:00
yo-h
a884538238 Update java/ql/src/semmle/code/java/frameworks/javaee/ejb/EJBRestrictions.qll
Co-authored-by: Anders Schack-Mulligen <aschackmull@users.noreply.github.com>
2020-05-12 14:14:26 -04:00
yo-h
facd429d0a Update java/ql/src/semmle/code/java/frameworks/javaee/ejb/EJBJarXML.qll
Co-authored-by: Anders Schack-Mulligen <aschackmull@users.noreply.github.com>
2020-05-12 14:14:14 -04:00
Bt2018
d75841d6a7 Add sample usage and remove unused imports 2020-05-12 13:42:17 -04:00
jcreedcmu
3c233c762c Merge pull request #3431 from jcreedcmu/jcreed/jump-to-def-langs
Java, Javascript, Csharp: Add jump-to-definition queries
2020-05-12 10:54:11 -04:00
Tom Hvitved
d0c607c83f Address review comments 2020-05-12 16:13:02 +02:00
semmle-qlci
6fb047aef6 Merge pull request #3451 from erik-krogh/fstreamWrite
Approved by esbena
2020-05-12 14:58:02 +01:00
semmle-qlci
ee848328ab Merge pull request #3442 from erik-krogh/SmallPerfs
Approved by esbena
2020-05-12 14:36:34 +01:00
Rasmus Lerchedahl Petersen
6a35c6b4d4 Test: __bool__ does not raise TypeError by default 2020-05-12 15:28:12 +02:00
Rasmus Wriedt Larsen
8150c78ae0 Python: In flask, taint routed prameters for variable rules
Fixes https://github.com/github/codeql-python-team/issues/79
2020-05-12 15:02:32 +02:00
Jason Reed
569083d6d1 Csharp: Make Use class public, since definitions query needs it 2020-05-12 08:52:02 -04:00
Erik Krogh Kristensen
83d34b939c change note 2020-05-12 14:24:04 +02:00
Erik Krogh Kristensen
d46148c045 add test case 2020-05-12 14:23:28 +02:00
Rasmus Wriedt Larsen
7d5e35a7aa Python: Expand flask tests to use "variable rules"
which is what flask calls them. wildcard rules in bottle, django doesn't even
give them a proper term :(
2020-05-12 14:23:24 +02:00
Erik Krogh Kristensen
3707792cfd recognize reading/wrinting calls to fstream methods 2020-05-12 14:18:07 +02:00
Jonas Jensen
451ae7b762 Merge pull request #3444 from dbartol/codeql-c-analysis-team/68
Rename `sanity` -> `consistency`
2020-05-12 12:33:08 +02:00
Erik Krogh Kristensen
bd768cbd7e autoformat 2020-05-12 12:28:02 +02:00
Erik Krogh Kristensen
2fbdeceae7 add getContainedNode constraint to charpred of IndirectInclusionTest, and refactor two getEnclosingExpr() 2020-05-12 10:19:06 +02:00
semmle-qlci
8ce9c9d57e Merge pull request #3441 from erik-krogh/BabelDirectives
Approved by esbena
2020-05-12 08:57:20 +01:00
Mathias Vorreiter Pedersen
73882c9f90 Merge pull request #3439 from jbj/passesByReference-qualifier
C++: Call qualifiers are passed by reference
2020-05-12 08:31:57 +02:00
Mathias Vorreiter Pedersen
df6abdc074 Merge pull request #3389 from jbj/dataflow-defbyref-to-field
C++: Post-update flow through &, *, +, ...
2020-05-12 08:30:33 +02:00
yo-h
1d55dffb98 Java: add missing QLDoc for J2ObjC.qll 2020-05-11 20:01:48 -04:00
yo-h
c55d01318c Java: add missing QLDoc for JavaServerFaces.qll and JSFAnnotations.qll 2020-05-11 20:01:48 -04:00
yo-h
53ccbeed6d Java: add missing QLDoc for JavadocCommon.qll 2020-05-11 20:01:47 -04:00
yo-h
e33ebdc803 Java: add missing QLDoc for NamingConventionsCommon.qll 2020-05-11 20:01:47 -04:00
yo-h
0e1ca44dfd Java: add missing QLDoc for UnusedMavenDependencies.qll 2020-05-11 20:01:46 -04:00
yo-h
1c9c87241f Java: add missing QLDoc for JdkInternals*.qll 2020-05-11 20:01:46 -04:00
yo-h
20a8438109 Java: add missing QLDoc for default.qll 2020-05-11 20:01:46 -04:00
yo-h
6c8a016ca6 Java: add missing QLDoc for JacksonSerializability.qll 2020-05-11 20:01:45 -04:00
yo-h
45b502a82f Java: add missing QLDoc for GWT.qll, GwtUiBinder.qll, GwtXml.qll 2020-05-11 20:01:45 -04:00
yo-h
0d8d5773b7 Java: add missing QLDoc for Clover.qll 2020-05-11 20:01:44 -04:00
yo-h
6e64f3dd05 Java: add missing QLDoc for JavaxAnnotations.qll 2020-05-11 20:01:44 -04:00
yo-h
537c657b19 Java: add missing QLDoc for EJBRestrictions.qll 2020-05-11 20:01:44 -04:00
yo-h
4594b51dfc Java: add missing QLDoc for EJB.qll 2020-05-11 20:01:43 -04:00
yo-h
3a82090087 Java: add missing QLDoc for EJBJarXML.qll 2020-05-11 20:01:42 -04:00
yo-h
8fe093c854 Java: add missing QLDoc for PersistenceXML.qll 2020-05-11 20:01:42 -04:00
yo-h
5b962c1add Java: add missing QLDoc for Persistence.qll 2020-05-11 20:01:42 -04:00
Robert Marsh
090977447b Merge pull request #3445 from geoffw0/rangerounding
C++: Round result of >> in SimpleRangeAnalysis
2020-05-11 13:07:18 -07:00
Felicity Chapman
0366c5d035 Merge pull request #3446 from hmakholm/rc/1.24
Merge rc/1.24 back into master
2020-05-11 20:15:34 +01:00
Jason Reed
66da91fe59 Java, Javascript, Csharp: Restrict definitions predicates
Only expose definition-use relation itself, and getEncodedFile.
2020-05-11 15:14:16 -04:00
Dave Bartolomeo
e5bd66809a C++/C#: Add QLDoc for renamed queries 2020-05-11 14:16:21 -04:00
Geoffrey White
a4fa4c859a C++: Fix rounding for >>. 2020-05-11 18:55:01 +01:00
Geoffrey White
b1c32deabc C++: Add some tests with 64-bit values. 2020-05-11 18:54:50 +01:00
Dave Bartolomeo
3987267f26 Rename sanity -> consistency 2020-05-11 13:46:26 -04:00
Dave Bartolomeo
06783938d3 JavaScript: Rename sanity -> consistency 2020-05-11 13:46:12 -04:00
Dave Bartolomeo
b39d4bc4bd Java: Rename sanity -> consistency 2020-05-11 13:37:01 -04:00
Dave Bartolomeo
09d1da2f7a C++/C#: Rename sanity -> consistency
I did both of these languages together because they share some of the changed code via `identical-files.json`.
2020-05-11 13:29:52 -04:00
Asger F
86a774d912 Merge pull request #3394 from monkey-junkie/master
JS SSTI CWE-094
2020-05-11 15:06:17 +01:00
Jonas Jensen
cec73e689e Merge pull request #3393 from dbartol/codeql-c-analysis-team/40/1
C++: A few IR QLDoc comments
2020-05-11 15:56:43 +02:00
Erik Krogh Kristensen
970ddcac7b autoformat 2020-05-11 15:38:45 +02:00
Jonas Jensen
48d2bd6102 C++: Improve suppression of duplicate sources
This fixes a cosmetic bug in `.../CWE-134/.../examples.c` in the
internal repo.
2020-05-11 14:44:53 +02:00
Jonas Jensen
3a89f43cd6 Merge remote-tracking branch 'upstream/master' into dataflow-indirect-args
Conflicts:
	cpp/ql/src/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll
	cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll
	cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/defaulttainttracking.cpp
	cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/tainted.expected
	cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/test_diff.expected
	cpp/ql/test/library-tests/dataflow/dataflow-tests/test_ir.expected
2020-05-11 14:44:17 +02:00
Jonas Jensen
3369453bb1 Merge pull request #3427 from MathiasVP/remove-abstract-from-builtin-op
C++: Remove abstract keyword from `BuiltInOperation`
2020-05-11 14:16:46 +02:00
Erik Krogh Kristensen
8b3e86c4f8 change note 2020-05-11 13:40:59 +02:00
Erik Krogh Kristensen
3ce60733cc add test case 2020-05-11 13:11:24 +02:00
Erik Krogh Kristensen
acb0f2e54f exclude "@babel/helpers - .." from js/unknown-directive 2020-05-11 12:42:18 +02:00
Jonas Jensen
4f5b8f7306 Merge pull request #3430 from MathiasVP/comments-about-comments
C++: Add QLDoc to CaptionedComments.qll and CommentedOutCode.qll
2020-05-11 12:36:54 +02:00
Tom Hvitved
c837ab7d1a Apply suggestions from code review
Co-authored-by: Jonas Jensen <jbj@github.com>
2020-05-11 11:42:50 +02:00
Mathias Vorreiter Pedersen
715fa9e446 Simplify comment
Co-authored-by: Jonas Jensen <jbj@github.com>
2020-05-11 11:32:10 +02:00
Mathias Vorreiter Pedersen
104545f3a7 Replace 'Returns' with 'Gets'
Co-authored-by: Jonas Jensen <jbj@github.com>
2020-05-11 11:31:51 +02:00
Calum Grant
91229f8d52 Merge pull request #3398 from hvitved/csharp/missing-x-frame-option
C#: More results for `cs/web/missing-x-frame-options`
2020-05-11 10:28:26 +01:00
Mathias Vorreiter Pedersen
411e52a231 C++: Replace @buildin_op with @builtin_op 2020-05-11 11:12:48 +02:00
Jonas Jensen
b3498bd0ad Merge pull request #3425 from MathiasVP/remove-more-abstract-classes
C++: Remove abstract keyword from a couple of AST classes
2020-05-11 10:55:35 +02:00
Jonas Jensen
bebd5ae36b C++: Call qualifiers are passed by reference
After #3382 changed the escape analysis to model qualifiers as escaping,
there was an imbalance in the SSA library, where `addressTakenVariable`
excludes variables from SSA analysis if they have their address taken
but are _not_ passed by reference. This showed up as a missing result in
`TOCTOUFilesystemRace.ql`, demonstrated with a test case in #3432.

This commit changes the definition of "pass by reference" to include
call qualifiers, which allows SSA modeling of variables that have member
function calls on them.
2020-05-11 09:39:48 +02:00
Jonas Jensen
8ff045b6a2 Merge pull request #3432 from geoffw0/toctou
C++: Add a test of TOCTOUFilesystemRace.ql
2020-05-11 09:18:51 +02:00
Tom Hvitved
c2c4142271 Merge pull request #3306 from calumgrant/cs/extraction-nullability
C#: Enable nullability in Semmle.Extraction project
2020-05-11 08:40:31 +02:00
Jonas Jensen
71c21e6eca C++: Accept test changes forgotten in 32e04b403
Adding a new test case leads to changes in all `.expected` files in its
directory.

The new results show that the `DefinitionsAndUses` library does not
model `std::addressof` correctly, but that library is not intended to be
used for new code.
2020-05-11 08:17:13 +02:00
Erik Krogh Kristensen
f8de69156e inline basicFlowStep into flowStep 2020-05-10 22:15:37 +02:00
Erik Krogh Kristensen
87167900d1 deduplicate - and slightly optimize IndirectInclusionTest 2020-05-10 22:15:37 +02:00
Erik Krogh Kristensen
6d05b40d23 eliminate recursion from GuardControlFlowNode::dominates 2020-05-10 22:15:34 +02:00
Cornelius Riemenschneider
3596ff7c51 Address review. 2020-05-10 19:34:16 +02:00
Artem Smotrakov
bab6f3788e Java: Added a query for unsafe TLS versions
- Added experimental/Security/CWE/CWE-327/UnsafeTlsVersion.ql
- Added SslLib.qll
- Added a qhelp file with examples
- Added tests in java/ql/test/experimental/Security/CWE/CWE-327
2020-05-10 19:14:52 +02:00
Mathias Vorreiter Pedersen
b34db333a5 C++: Add upgrade script 2020-05-09 13:41:39 +02:00
Grzegorz Golawski
a16295ebc0 Fix typos 2020-05-08 20:13:50 +02:00
yo-h
c54f8d8128 Merge pull request #3383 from aschackmull/java/printast
Java: Library for pretty-printing AST in linear time.
2020-05-08 13:01:39 -04:00
Jason Reed
beccdce108 C#: Refactor definitions query, add queries for ide search
This enables jump-to-definition and find-references in the VS Code
extension, for C# source archives.
2020-05-08 07:31:50 -04:00
jcreedcmu
c9788a7928 Merge pull request #3308 from jcreedcmu/jcreed/jump-to-def
Add queries for VS Code jump-to-definition
2020-05-08 07:29:02 -04:00
Mathias Vorreiter Pedersen
86f283dff2 C++: Add new stats file from Jenkins job 2020-05-08 09:15:58 +02:00
Grzegorz Golawski
afea9330b7 Fix the case where user-controlled input is passed as URL to env Hashtable 2020-05-08 00:44:22 +02:00
Grzegorz Golawski
df9921f870 Update according to the review comments 2020-05-07 23:19:13 +02:00
Geoffrey White
bff97d9fe5 C++: Effect of #3382. 2020-05-07 19:06:05 +01:00
Geoffrey White
6499197087 C++: Add a test of TOCTOUFilesystemRace.ql. 2020-05-07 19:03:32 +01:00
Robert Marsh
761e3186f5 Merge pull request #3426 from MathiasVP/test-3110
C++: Add testcase for #3110
2020-05-07 10:40:12 -07:00
Jason Reed
01eeebc068 Java: Refactor definitions query, add queries for ide search
This enables jump-to-definition and find-references in the VS Code
extension, for Java source archives.
2020-05-07 12:44:36 -04:00
Jason Reed
48e4079c64 JS: Refactor definitions query, add queries for ide search
This enables jump-to-definition and find-references in the VS Code
extension, for javascript source archives.
2020-05-07 12:44:36 -04:00
Mathias Vorreiter Pedersen
8df25c3025 C++: Add QLDoc 2020-05-07 18:34:26 +02:00
Jonas Jensen
4b9a3f1482 Merge remote-tracking branch 'upstream/master' into dataflow-defbyref-to-field 2020-05-07 16:48:41 +02:00
Jonas Jensen
88eeca39fb Merge commit '52d8acc1a198c5ea29c1dddceda1d6c0fb75de14' into dataflow-defbyref-to-field
This is a partial merge from master. In particular, it takes in #3382
and #3385.
2020-05-07 16:46:11 +02:00
Jonas Jensen
5e8bd0a724 C++: Fix variable name in comment 2020-05-07 16:38:15 +02:00
Jonas Jensen
32e04b4033 C++: Support std::addressof
I didn't add this support in `AddressConstantExpression.qll` since I
think it would require extra work and testing to get the constexprness
right. My long-term plan for `AddressConstantExpression.qll` is to move
its functionality to the extractor.
2020-05-07 16:30:44 +02:00
Tom Hvitved
948c2f7f7e C++: Add change note 2020-05-07 16:01:55 +02:00
Tom Hvitved
0b85f3fed4 Address review comments 2020-05-07 15:58:46 +02:00
Taus
2502d1c3ed Merge pull request #3410 from RasmusWL/python-fix-3397
Python: More safe methods for py/modification-of-default-value
2020-05-07 15:28:24 +02:00
Anders Schack-Mulligen
2561ba82db Merge pull request #3215 from aibaars/validating-object-input
Java: teach UnsafeDeserialization about ValidatingObjectInputStream
2020-05-07 14:57:50 +02:00
Cornelius Riemenschneider
1aa7a827af Add QLDoc. 2020-05-07 14:53:41 +02:00
Mathias Vorreiter Pedersen
594f3b1807 C++: Add testcase for #3110 2020-05-07 14:39:53 +02:00
Dave Bartolomeo
e435484740 C++/C#: Fix formatting 2020-05-07 08:39:01 -04:00
Mathias Vorreiter Pedersen
43ffcfe730 C++: Remove abstract keyword from BuiltInOperation 2020-05-07 13:18:12 +02:00
Taus
964b8478dc Merge pull request #3405 from jcreedcmu/jcreed/jump-to-def-python
Python: Refactor definitions query, add queries for ide search
2020-05-07 12:51:35 +02:00
Mathias Vorreiter Pedersen
dd0ca34038 C++: Remove abstract keyword from a couple of AST classes 2020-05-07 12:01:07 +02:00
Calum Grant
313c9ac6ec C#: Address review comments. 2020-05-07 10:35:29 +01:00
Rasmus Wriedt Larsen
f099e0fdc6 Merge branch 'master' into python-keyword-only-args 2020-05-07 11:27:11 +02:00
Erik Krogh Kristensen
945fe45b6f all split()[0] are safe for url-redirect 2020-05-07 10:55:17 +02:00
Erik Krogh Kristensen
a3fb13882b Merge branch 'master' into SplitFPs 2020-05-07 10:51:11 +02:00
Dave Bartolomeo
f0e86a9191 C++: Add missing module comment 2020-05-06 17:30:20 -04:00
Dave Bartolomeo
df4fdaf6ff C++: Fix PR feedback
Note that the various predicates to access the singleton instances of the `EdgeKind` classes have been moved into a module named `EdgeKind`.
2020-05-06 17:06:48 -04:00
Geoffrey White
c8524522c8 C++: Add test cases. 2020-05-06 18:51:50 +01:00
monkey-junkie
4594aa470d Update javascript/ql/src/experimental/Security/CWE-94/ServerSideTemplateInjection.ql
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-06 18:18:06 +03:00
Cornelius Riemenschneider
e397e5d325 Add new testcase to arraylengthanalysis library. 2020-05-06 16:36:48 +02:00
Cornelius Riemenschneider
1c9fa4eb1d This library proves that a subset of pointer dereferences in a program are safe, i.e. in-bounds.
It does so by first defining what a pointer dereference is (on the IR
`Instruction` level), and then using the array length analysis and the range
analysis together to prove that some of these pointer dereferences are safe.
2020-05-06 16:36:48 +02:00
Tom Hvitved
f19b1045d6 Java: Add change note 2020-05-06 15:52:49 +02:00
semmle-qlci
b2f1008a00 Merge pull request #3420 from max-schaefer/js/fix-missing-triple-backtick
Approved by asgerf
2020-05-06 13:52:18 +01:00
Jason Reed
5934345fe3 Python: Fix formatting. 2020-05-06 08:48:45 -04:00
Esben Sparre Andreasen
7cc3a5a242 JS: qhelp fixups 2020-05-06 14:46:34 +02:00
Tom Hvitved
ddd62a56cc C#: Add change note for #3110 2020-05-06 14:28:47 +02:00
Anders Schack-Mulligen
f7410739d9 Java: Fix bug in qldoc. 2020-05-06 14:06:49 +02:00
Anders Schack-Mulligen
8c5e89c160 Java: Add PrintAst. 2020-05-06 14:06:40 +02:00
Esben Sparre Andreasen
69191577d6 JS: qhelp for js/unsafe-html-expansion 2020-05-06 14:03:27 +02:00
monkey-junkie
5ce9e0d0a2 Update javascript/ql/src/experimental/Security/CWE-94/ServerSideTemplateInjection.ql
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-06 14:32:55 +03:00
Asger F
5725814774 Merge pull request #3403 from asger-semmle/js/getcontainer
JS: Move getContainer to single rootdef (+fixes)
2020-05-06 12:06:44 +01:00
Max Schaefer
9335a6cb79 JavaScript: Fix missing triple backtick in qldoc comment. 2020-05-06 11:40:00 +01:00
Arthur Baars
39e652b26b Java: teach UnsafeDeserialization about ValidatingObjectInputStream
The class org.apache.commons.io.serialization.ValidatingObjectInputStream
is an implementation of ObjectInputStream that validates the deserialized
classes against a white list. Therefore, this class should not be considered an
unsafe deserialization sink.
2020-05-06 12:15:30 +02:00
Arthur Baars
797721cd31 Test 2020-05-06 12:15:27 +02:00
monkey-junkie
122354a81a Update javascript/ql/src/experimental/Security/CWE-94/ServerSideTemplateInjection.ql
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-06 12:54:50 +03:00
Esben Sparre Andreasen
344f0c36b0 JS: update expected output 2020-05-06 11:18:14 +02:00
monkey-junkie
3314dd0614 Update javascript/ql/src/experimental/Security/CWE-94/ServerSideTemplateInjection.ql
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-05-06 11:17:41 +03:00
Rasmus Wriedt Larsen
f1630983d3 Python: Cleanup default-indexing upgrade script 2020-05-06 09:57:07 +02:00
Rasmus Wriedt Larsen
010d5fb769 Python: Fix indexes of keyword-only defaults in upgrade script
Works like a charm ;)
2020-05-06 09:57:07 +02:00
Rasmus Wriedt Larsen
a15833d194 Python: DB upgrade script for default-indexing change
Follow this excellent guide:
https://github.com/github/codeql-c-extractor-team/blob/master/docs/db-upgrade.md
2020-05-06 09:56:53 +02:00
Tom Hvitved
0466e36985 C#: Teach Implements.qll about nested types 2020-05-06 09:25:40 +02:00
Tom Hvitved
f9ece0aefb C#: Add implements test for nested types 2020-05-06 09:25:40 +02:00
Tom Hvitved
4c1a9b25c1 C#: Teach unification library about nested types 2020-05-06 09:25:40 +02:00
Tom Hvitved
851fc98b01 C#: Add type unification tests for nested types 2020-05-06 09:25:40 +02:00
Anders Schack-Mulligen
3b3ca6d41e Merge pull request #3214 from aibaars/base64
Java: Add org.apache.commons.codec.(De|En)coder to TaintTrackingUtil
2020-05-06 09:21:18 +02:00
Jonas Jensen
63f04afa8d Merge pull request #3312 from hvitved/dataflow/impl-no-postupdate
Data flow: Support stores into nodes that are not `PostUpdateNode`s
2020-05-06 09:09:31 +02:00
semmle-qlci
9210660ea0 Merge pull request #3401 from erik-krogh/jsonLike
Approved by esbena
2020-05-06 08:00:44 +01:00
Asger F
b2da4fe491 Update javascript/ql/src/semmle/javascript/internal/StmtContainers.qll
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-06 07:59:04 +01:00
Asger Feldthaus
926e79d272 JS: Autoformat 2020-05-06 07:59:04 +01:00
Asger Feldthaus
f51e846439 JS: Fix ClosureModule implementation 2020-05-06 07:59:04 +01:00
Asger Feldthaus
0f870a4992 JS: Use TCapturedVariableNode as starting point of callInputStep 2020-05-06 07:59:04 +01:00
Asger Feldthaus
4d6da19173 JS: Improve performance of getExceptionTarget 2020-05-06 07:59:04 +01:00
Asger Feldthaus
639f04386c JS: Avoid bad join ordering in ClosureModule 2020-05-06 07:59:04 +01:00
Asger Feldthaus
e52e1b26c6 JS: Upgrade script 2020-05-06 07:59:04 +01:00
Asger Feldthaus
5f710bc881 JS: Move definition of getContainer() to a single rootdef 2020-05-06 07:59:04 +01:00
semmle-qlci
86c5b38d62 Merge pull request #3341 from hvitved/csharp/generics-nested-types
Approved by calumgrant
2020-05-06 07:16:37 +01:00
Erik Krogh Kristensen
52392f2a6d autoformat 2020-05-05 22:33:53 +02:00
Robert Marsh
78d2ac1ff4 Merge pull request #3368 from Cornelius-Riemenschneider/local-ala
C++: Add experimental Array Length Tracking library
2020-05-05 13:05:52 -07:00
Felicity Chapman
0e0d0499bb Merge pull request #3413 from felicitymay/update-docs-reviews
Update requirements for docs review
2020-05-05 19:05:57 +01:00
Mathias Vorreiter Pedersen
114310700a Merge pull request #3414 from geoffw0/issue3356
C++: Fix error in QLDoc.
2020-05-05 18:07:49 +02:00
Geoffrey White
3e2e69c06a C++: Autoformat. 2020-05-05 16:55:15 +01:00
Jason Reed
c759e891d0 Python: Exclude additional tag from LGTM suites 2020-05-05 09:43:40 -04:00
jcreedcmu
6cf30ef87a Update python/ql/src/analysis/DefinitionTracking.qll
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
2020-05-05 09:40:54 -04:00
Anders Schack-Mulligen
11ffcc4378 Merge pull request #2912 from Mithrilwoodrat/master
Add check for disabled HTTPOnly setting in Tomcat
2020-05-05 14:39:32 +02:00
Geoffrey White
27490a35ae C++: Fix error in QLDoc. 2020-05-05 13:37:14 +01:00
monkey-junkie
560674b670 Update javascript/ql/src/experimental/Security/CWE-94/ServerSideTemplateInjection.ql
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-05 15:36:11 +03:00
monkey-junkie
758e85dd3e Update javascript/ql/src/experimental/Security/CWE-94/ServerSideTemplateInjection.ql
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-05 15:34:57 +03:00
Tom Hvitved
e8e27e0e00 C#: Address review comments 2020-05-05 14:28:13 +02:00
Tom Hvitved
3d37a49ccd C#: Add change note 2020-05-05 14:28:13 +02:00
Tom Hvitved
19c3e6a58d C#: Add DB upgrade script 2020-05-05 14:28:13 +02:00
Tom Hvitved
c324c388d0 C#: Refine UnboundGeneric and ConstructedGeneric 2020-05-05 14:28:13 +02:00
Tom Hvitved
8a01023dee C#: Add more generics tests 2020-05-05 14:28:13 +02:00
Tom Hvitved
4f7743058a C#: Restructure existing generics tests 2020-05-05 14:28:13 +02:00
Felicity Chapman
c0ebf12ab0 Update requirements for docs review 2020-05-05 13:25:19 +01:00
monkey-junkie
a8019705b5 Update javascript/ql/src/experimental/Security/CWE-94/ServerSideTemplateInjection.qhelp
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-05 15:24:24 +03:00
monkey-junkie
0aaa8af3bd Update javascript/ql/src/experimental/Security/CWE-94/ServerSideTemplateInjection.qhelp
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-05 15:24:10 +03:00
Geoffrey White
2940f4794e C++: Fix isfromtemplateinstantiation test. 2020-05-05 13:12:44 +01:00
Esben Sparre Andreasen
99e5db407f JS: address review comments 2020-05-05 14:04:05 +02:00
Erik Krogh Kristensen
a4eee7e88e more -> additional
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-05-05 14:01:39 +02:00
Tom Hvitved
e95cc24b3f Data flow: Support stores into nodes that are not PostUpdateNodes 2020-05-05 14:01:04 +02:00
Geoffrey White
0b381b9ba7 C++: Autoformat. 2020-05-05 12:58:54 +01:00
Erik Krogh Kristensen
bffb12725b add test and change-note to prototype-polution 2020-05-05 13:49:11 +02:00
Erik Krogh Kristensen
38db731e0b add change note and new test for js/incomplete-url-scheme-check 2020-05-05 13:38:27 +02:00
Erik Krogh Kristensen
f56915d99f add change note for js/xss 2020-05-05 13:36:50 +02:00
Erik Krogh Kristensen
3568439769 change getAnElementRead to getASubstringRead 2020-05-05 13:33:21 +02:00
Erik Krogh Kristensen
8711a8744c update expected output 2020-05-05 13:27:32 +02:00
Erik Krogh Kristensen
fe02137d0b change naming of StringSplitCall methods 2020-05-05 13:27:14 +02:00
Anders Schack-Mulligen
b7458091a9 Merge pull request #3110 from hvitved/dataflow/no-more-summaries
Data flow: No more flow summaries
2020-05-05 13:27:07 +02:00
Erik Krogh Kristensen
4a26c293c1 fix number of arguments for String.prototype.split 2020-05-05 13:22:35 +02:00
Erik Krogh Kristensen
f586639703 change getSplitAt to getSeparator
Co-authored-by: Esben Sparre Andreasen <esbena@github.com>
2020-05-05 13:22:21 +02:00
Matthew Gretton-Dann
52d8acc1a1 Merge pull request #3404 from nickrolfe/field_attrs
C++: add test for attributes on fields
2020-05-05 12:12:28 +01:00
Rasmus Wriedt Larsen
6488714758 Python: Autoformat 2020-05-05 11:38:17 +02:00
Rasmus Wriedt Larsen
07ae40206f Python: Don't allow getParameter(-1) for BoundMethodValue
As per discussion in the PR
2020-05-05 11:37:10 +02:00
Rasmus Wriedt Larsen
5d5d412b78 Python: Add test of safe methods for py/modification-of-default-value 2020-05-05 11:14:37 +02:00
Rasmus Wriedt Larsen
4da5222255 Python: More safe methods for py/modification-of-default-value
Fixes https://github.com/github/codeql/issues/3397
2020-05-05 11:09:05 +02:00
Geoffrey White
31a7e2c34e C++: Make getAnonymousParameterDescription private. 2020-05-05 10:05:18 +01:00
monkey-junkie
056566ecc1 Update javascript/ql/src/experimental/Security/CWE-94/ServerSideTemplateInjection.ql
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-05 12:05:01 +03:00
monkey-junkie
3a4ea82ae2 Update javascript/ql/src/experimental/Security/CWE-94/ServerSideTemplateInjection.ql
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-05 12:02:46 +03:00
monkey-junkie
8310c96b97 Update javascript/ql/src/experimental/Security/CWE-94/ServerSideTemplateInjection.qhelp
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-05 11:59:06 +03:00
monkey-junkie
25df6e1664 Update javascript/ql/src/experimental/Security/CWE-94/ServerSideTemplateInjection.qhelp
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-05 11:58:49 +03:00
monkey-junkie
700a070a15 Update javascript/ql/src/experimental/Security/CWE-94/examples/ServerSideTemplateInjection.js
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-05 11:58:40 +03:00
monkey-junkie
d8fb552097 Update javascript/ql/src/experimental/Security/CWE-94/examples/ServerSideTemplateInjectionSafe.js
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-05 11:58:28 +03:00
Esben Sparre Andreasen
304b013f88 JS: query and tests for unsafe HTML expansion 2020-05-05 10:32:16 +02:00
Rasmus Wriedt Larsen
affca1a728 Python: Add test-cases using keyword arguments for builtin function 2020-05-05 10:26:25 +02:00
Geoffrey White
a70f534458 Sync identical files. 2020-05-05 09:18:05 +01:00
Rasmus Wriedt Larsen
dfe7c8270b Python: Clean up trailing whitespace 2020-05-05 09:55:09 +02:00
Rasmus Wriedt Larsen
87d7738b6e Python: Expand QLDoc for get[Named]ArgumentForCall 2020-05-05 09:54:54 +02:00
Erik Krogh Kristensen
4b8b0cb379 update expected output 2020-05-05 09:13:21 +02:00
Erik Krogh Kristensen
7af19559d4 add test case for location.split("?")[0] for DomBasedXss 2020-05-05 09:13:21 +02:00
Erik Krogh Kristensen
4dcf944ccd use StringSplitCall in TaintedPath 2020-05-05 09:13:21 +02:00
Erik Krogh Kristensen
22ec12b130 use split("?")[0] sanitizer is both DomBasedXSS and ClientSideUrlRedirect 2020-05-05 09:13:21 +02:00
Erik Krogh Kristensen
89f45372d1 introduce StringSplitCall and use it 2020-05-05 09:13:15 +02:00
Rasmus Wriedt Larsen
061bbb82f5 Python: Restructure getNamedArgumentForCall
So it matches the structure of getArgumentForCall -- call.getArgByName first!
2020-05-05 09:00:55 +02:00
Cornelius Riemenschneider
264763080e Autoformat, address review. 2020-05-05 08:52:52 +02:00
John Doe
337be9c2e0 ssti query and help updated 2020-05-05 03:58:29 +03:00
John Doe
09922e5bb4 Merge branch 'master' of github.com:monkey-junkie/codeql 2020-05-05 03:44:23 +03:00
John Doe
895aa622bf ssti updated 2020-05-05 03:37:43 +03:00
monkey-junkie
cd18842aa5 Update javascript/ql/src/experimental/Security/CWE-94/ServerSideTemplateInjection.qhelp
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-05 02:15:58 +03:00
monkey-junkie
a60660617f Update javascript/ql/src/experimental/Security/CWE-94/ServerSideTemplateInjection.qhelp
Co-authored-by: Erik Krogh Kristensen <erik-krogh@github.com>
2020-05-05 02:15:00 +03:00
Rasmus Wriedt Larsen
838106d49c Python: Refactor get[Named]ArgumentForCall
Also fixed a bug for BoundMethodValue, as highlighted in the expected diff 👍
2020-05-04 20:51:23 +02:00
Rasmus Wriedt Larsen
bc92c26e12 Python: Add BoundMethodValue 2020-05-04 20:51:12 +02:00
Rasmus Wriedt Larsen
96fdb7a5b6 Python: Add tests for getParameter[byName]
These already have results for BoundMethodValue, although

1) it's a bit strange that `getParameter(-1)` has results
2) why does `Method(Function C.n, class C)` exists? this would only be relevant
if `n` was a classmethod, but it isn't. It's not a problem that it exsits per
se, but curious.
2020-05-04 20:51:04 +02:00
Rasmus Wriedt Larsen
e9859ad96d Python: Fix getArgumentForCall when using keyword arguments
Yikes :|
2020-05-04 20:50:56 +02:00
Rasmus Wriedt Larsen
acb506db21 Python: Add test for getNamedArgumentForCall
and rename the one for getArgumentForCall
2020-05-04 20:50:32 +02:00
Rasmus Wriedt Larsen
9ec32ee1c1 Python: Add test-cases using keyword arguments 2020-05-04 20:50:19 +02:00
Rasmus Wriedt Larsen
fc0b0221f0 Python: Add test-cases for BuiltinFunction and BuiltinMethod 2020-05-04 20:50:14 +02:00
Rasmus Wriedt Larsen
f624754390 Python: Use Value in GetACAll test
That was not possible when using the old Object-API, but in Value-API getACall
is defined on all Values.
2020-05-04 20:50:06 +02:00
Rasmus Wriedt Larsen
06b67e0d32 Python: Modernise test/library-tests/PointsTo/calls/* 2020-05-04 20:49:57 +02:00
Rasmus Wriedt Larsen
a5289bd708 Python: Use Object in CallRefersTo test
Since other things than FunctionObject can be called ;)
2020-05-04 20:49:47 +02:00
Rasmus Wriedt Larsen
7b8b4af6d2 Python: Add test for call.getFunction().refersTo
Showing that
`call.getFunction().refersTo(func)` gives different results from
`call = func.getACall()`
2020-05-04 20:49:19 +02:00
Geoffrey White
511d7c9199 C++: Improve solution for UsingDeclarationEntry. 2020-05-04 18:01:29 +01:00
Geoffrey White
3d431607e7 C++: Combine the usings tests and add detail about classes. 2020-05-04 17:48:42 +01:00
Geoffrey White
9fc37d174e C++: Update the 'usings' tests. 2020-05-04 17:46:26 +01:00
Erik Krogh Kristensen
eb7e0d6a62 still flag single-expression files that contain a function 2020-05-04 18:37:26 +02:00
Jason Reed
c34fa840a2 Python: Use NiceLocationExpr::hasLocationInfo for ide jump-to-def 2020-05-04 11:36:54 -04:00
Jason Reed
b0f72ebb56 Python: Refactor definitions query, add queries for ide search
This enables jump-to-definition and find-references in the VS Code
extension, for python source archives.
2020-05-04 11:27:30 -04:00
Nick Rolfe
ae913fbf56 C++: update expected output to include field attribute 2020-05-04 16:17:59 +01:00
Calum Grant
a01ef83312 Merge pull request #3270 from hvitved/csharp/dataflow/library-field-flow
C#: Field-sensitive summaries for library code
2020-05-04 16:11:18 +01:00
Mathias Vorreiter Pedersen
a98135093f Merge pull request #3400 from jbj/fieldFlow-join-order
C++: Fix fieldFlow join order
2020-05-04 17:07:55 +02:00
Nick Rolfe
124ea86d65 C++: add test for attributes on fields 2020-05-04 15:12:49 +01:00
Tom Hvitved
c7763e69e5 C#: Add comments to LibraryCodeNode::get{Predecessor|Successor}() 2020-05-04 13:46:52 +02:00
Bt2018
3b1dad84b3 The query help builder will interpret and automatically add the reference so this isn't needed here. And one typo is corrected. 2020-05-04 07:39:45 -04:00
Bt2018
5c803b70c5 The query help builder will interpret and automatically add this reference so this isn't needed here. 2020-05-04 07:05:15 -04:00
Bt2018
a6c9c5117f Update java/ql/src/experimental/CWE-532/SensitiveInfoLog.ql
Co-authored-by: Felicity Chapman <felicitymay@github.com>
2020-05-04 06:58:34 -04:00
Bt2018
a2560656d5 Update java/ql/src/experimental/CWE-532/SensitiveInfoLog.qhelp
Co-authored-by: Felicity Chapman <felicitymay@github.com>
2020-05-04 06:57:42 -04:00
Jonas Jensen
50b0d426ee C++: Fix fieldFlow join order
The `fieldFlow` predicate contained a fragile join that has become
ordered wrong recently, either as result of an unrelated change in the
data-flow library or as part of the stats change for the last dbscheme
change.

The minimal fix is to use `getEnclosingCallable` instead of
`getFunction` since the former uses `unique` to ensure good join
ordering in its callers. A longer-term fix should be applied to the AST
base libraries, but this will be invasive and require independent
testing.

Tuple counts on Wireshark before (cancelled after a few minutes):

    (747s) Starting to evaluate predicate DataFlowUtil::localFlowStep#ff/2@bdba82
    (848s) Tuple counts for DataFlowUtil::localFlowStep#ff:
    1766640980 ~1%        {2} r1 = JOIN DataFlowUtil::Node::getFunction_dispred#ff_10#join_rhs AS L WITH DataFlowUtil::Node::getFunction_dispred#ff_10#join_rhs AS R ON FIRST 1 OUTPUT L.<1>, R.<1>
    1327       ~0%        {2} r2 = JOIN r1 WITH project#DataFlowImplLocal::Configuration::hasFlow#fbb AS R ON FIRST 2 OUTPUT r1.<0>, r1.<1>
    9691232    ~0%        {2} r3 = DataFlowUtil::simpleLocalFlowStep#ff@staged_ext \/ r2
                          return r3

After:

    (0s) Starting to evaluate predicate DataFlowUtil::localFlowStep#ff/2@a852a0
    (0s) Tuple counts for DataFlowUtil::localFlowStep#ff:
    49017    ~4%     {3} r1 = JOIN project#DataFlowImplLocal::Configuration::hasFlow#fff AS L WITH DataFlowUtil::Node::getEnclosingCallable_dispred#ff AS R ON FIRST 1 OUTPUT L.<1>, R.<1>, R.<0>
    42359    ~0%     {2} r2 = JOIN r1 WITH DataFlowUtil::Node::getEnclosingCallable_dispred#ff AS R ON FIRST 2 OUTPUT r1.<2>, r1.<0>
    9732264  ~0%     {2} r3 = DataFlowUtil::simpleLocalFlowStep#ff@staged_ext \/ r2
                     return r3
2020-05-04 12:14:07 +02:00
Rasmus Wriedt Larsen
16e9d76e22 Merge branch 'master' into python-keyword-only-args 2020-05-04 11:49:00 +02:00
Mithrilwoodrat
a7960c3385 Update java/ql/src/experimental/Security/CWE/CWE-1004/InsecureTomcatConfig.qhelp
Co-authored-by: Anders Schack-Mulligen <aschackmull@users.noreply.github.com>
2020-05-04 17:48:41 +08:00
Jonas Jensen
2b0ad2df6f Merge pull request #3185 from github/geoffw0-patch-1
Add details about query tagging to supported-queries.md
2020-05-04 11:41:35 +02:00
semmle-qlci
a805a63443 Merge pull request #3357 from erik-krogh/YetAnotherPerformancePatch
Approved by asgerf, esbena
2020-05-04 10:05:34 +01:00
semmle-qlci
a0800cecc4 Merge pull request #3386 from erik-krogh/lessJQueryChaining
Approved by asgerf
2020-05-04 09:16:17 +01:00
Erik Krogh Kristensen
9a7f8d97d2 change note 2020-05-04 09:49:20 +02:00
Erik Krogh Kristensen
659d40e08d add test to make sure sanitizer is not too broad 2020-05-04 09:49:14 +02:00
Erik Krogh Kristensen
c56063f857 recognize more split("?") sanitizers 2020-05-04 09:48:50 +02:00
Erik Krogh Kristensen
291134be66 add failing test 2020-05-04 09:48:29 +02:00
Tom Hvitved
a4d933d1d6 C#: More results for cs/web/missing-x-frame-options
Report an alert in _any_ `Web.config` file, as long as it does not have an
`X-Frame-Options` entry (as opposed to only reporting alerts when _all_
`Web.config` files lack the entry).
2020-05-04 09:17:08 +02:00
Erik Krogh Kristensen
ffdbe31a30 change-note 2020-05-04 09:08:46 +02:00
Erik Krogh Kristensen
cee986fa76 skip expressions that are alone in a file for js/useless-expression 2020-05-04 09:08:41 +02:00
Tom Hvitved
32b419229d C#: Address review comments 2020-05-04 09:01:49 +02:00
mithrilwoodrat
1053aa4c44 add query to found Tomcat config disables 'HttpOnly' flag 2020-05-04 12:26:03 +08:00
Grzegorz Golawski
f893954ea3 Add Spring LDAP and JMXServiceURL related sinks 2020-05-03 20:51:50 +02:00
Dave Bartolomeo
8e9e3c8919 Merge pull request #3395 from jbj/IRBlock-unique
C++: Use `unique` aggregate in IRBlock computation
2020-05-03 07:54:51 -04:00
Jonas Jensen
0a59045dc3 C++: Use unique aggregate in IRBlock computation
This gives a slight speedup, and I think it makes the code shorter and
clearer.

On Wireshark, the time from the beginning of the `IRBlock` stage until
just before evaluation of `getInstruction` drops from 44s to 34s.
2020-05-03 10:07:09 +02:00
John Doe
68b57502f9 JS SSTI CWE-094 2020-05-03 02:42:45 +03:00
Dave Bartolomeo
d8f32e3db5 Merge pull request #3392 from rdmarsh2/rdmarsh/cpp/qldoc-get-ConvertedResultExpression
C++/C#: improve qldoc on IR get*ResultExpression
2020-05-02 15:59:08 -04:00
semmle-qlci
c66ec3c981 Merge pull request #3380 from asger-semmle/js/cache-amd
Approved by erik-krogh
2020-05-02 20:18:22 +01:00
Cornelius Riemenschneider
bab893d2d1 Address review. 2020-05-02 15:27:56 +02:00
Dave Bartolomeo
a166a4d143 C++: A few IR QLDoc comments 2020-05-01 18:17:20 -04:00
Robert Marsh
83e222e5bd C++/C#: sync files 2020-05-01 14:17:43 -07:00
Robert Marsh
537db53a8d C++/C#: improve qldoc on IR get*ResultExpression 2020-05-01 14:12:44 -07:00
Nick Rolfe
4ce896b856 Merge pull request #3378 from matt-gretton-dann/codeql-c-extractor/49-consteval
Add support for C++20's consteval specifier
2020-05-01 17:56:56 +01:00
Erik Krogh Kristensen
efbd74a4a4 remove more spurious jQuery objects by using externs 2020-05-01 18:54:32 +02:00
Geoffrey White
c8292e4b8e Merge pull request #3148 from jbj/minmax-to-unique
C++: Replace "min = max" with "unique"
2020-05-01 17:43:32 +01:00
Erik Krogh Kristensen
2a1095abcc autoformat, and apply naming suggestion 2020-05-01 18:35:34 +02:00
Jonas Jensen
4ec0ae6698 Merge pull request #3388 from geoffw0/cleanupstuff
C++: Small tidy up
2020-05-01 17:29:12 +02:00
Jonas Jensen
62c7387a76 Merge pull request #3373 from sj/patch-4
Update CODEOWNERS to use GitHub team identifiers after repo move
2020-05-01 17:11:12 +02:00
Mathias Vorreiter Pedersen
2e3463740d Merge pull request #3382 from jbj/escape-qualifier
C++: Addresses may escape through call qualifiers
2020-05-01 16:23:46 +02:00
Mathias Vorreiter Pedersen
37f30d3bd2 Merge pull request #3385 from jbj/dataflow-remove-from-post
C++: Remove an unneeded local-flow case
2020-05-01 16:19:04 +02:00
Jonas Jensen
1b1095ee75 C++: Post-update flow through &, *, +, ...
Flow from a definition by reference of a field into its object was
working inconsistently and in a very syntax-dependent way. For a
function `f` receiving a reference, `f(a->x)` could propagate data back
to `a` via the _reverse read_ mechanism in the shared data-flow library,
but for a function `g` receiving a pointer, `g(&a->x)` would not work.
And `f((*a).x)` would not work either.

In all cases, the issue was that the shared data-flow library propagates
data backwards between `PostUpdateNode`s only, but there is no
`PostUpdateNode` for `a->x` in `g(&a->x)`. This pull request inserts
such post-update nodes where appropriate and links them to their
neighbors. In this exapmle, flow back from the output parameter of `g`
passes first to the `PostUpdateNode` of `&`, then to the (new)
`PostUpdateNode` of `a->x`, and finally, as a _reverse read_ with the
appropriate field projection, to `a`.
2020-05-01 15:40:19 +02:00
Geoffrey White
9b4884dfaf C++: Backticks. 2020-05-01 14:26:34 +01:00
Geoffrey White
200d7ed360 C++: Remove if-else. 2020-05-01 14:26:34 +01:00
Geoffrey White
4907677351 C++: Try to improve QLDoc on deconstructSizeExpr. 2020-05-01 14:26:33 +01:00
Jonas Jensen
9b9f5248af C++: Accept test changes
Lambda invocations are apparently const. This was exposed by the fix in
the previous commit.
2020-05-01 15:23:00 +02:00
Erik Krogh Kristensen
87365357ba remove spurious jQuery objects 2020-05-01 15:19:54 +02:00
Geoffrey White
46332d4849 C++: Eliminate recursion from toString(). 2020-05-01 14:12:52 +01:00
Jonas Jensen
36bdcfa42d C++: Remove an unneeded local-flow case
This case was added in dccc0f4db. The surrounding code has changed a lot
since then, and the case no longer seems to have an effect except to
create some dead ends and possibly cycles in the local flow graph.
2020-05-01 15:08:15 +02:00
Jonas Jensen
5f74c24d4d C++: Test definitions through &, *, ... 2020-05-01 11:04:49 +02:00
Jonas Jensen
4ddf12119d C++: Don't suppress consistency checks for calls
See https://github.com/github/codeql/pull/3162#discussion_r400849713.
2020-05-01 11:04:42 +02:00
Taus
33f4503ac3 Merge pull request #3213 from RasmusWL/python-iter-str-seq-with-tests
Python: supress non-useful results (w/ tests) for iter str/seq query
2020-05-01 11:04:05 +02:00
Taus
40def2af05 Merge pull request #3311 from RasmusWL/python-parse_qs
Python: Propagate taint through parse_qs
2020-05-01 10:40:31 +02:00
Erik Krogh Kristensen
16823143dd refactor getAPropertyUsedInLoadStore 2020-05-01 09:58:11 +02:00
Erik Krogh Kristensen
1a42c9fd80 make predicates private
Co-authored-by: Asger F <asgerf@github.com>
2020-05-01 09:42:09 +02:00
Jonas Jensen
9fc27e9130 C++: Fix "is constant" check
The check was supposed to check for constant type, not constant value.
This fixes a false negative that appeared in
`LargeParameter/test.cpp:106`.
2020-05-01 09:04:31 +02:00
Rasmus Wriedt Larsen
e569d7ae41 Merge branch 'master' into python-parse_qs 2020-04-30 17:05:17 +02:00
Cornelius Riemenschneider
c856552b64 Add preOffset to the bindingset for simpleArrayLengthStep. 2020-04-30 15:00:12 +02:00
semmle-qlci
606a1145eb Merge pull request #3331 from RasmusWL/python-improve-file-taint
Approved by tausbn
2020-04-30 13:58:03 +01:00
Jonas Jensen
8ffa124bf9 C++: Addresses may escape through call qualifiers
Also clarify the docs on `Call` to decrease the likelyhood of such an
omission happening again.

The updated test reflects that `f1.operator()` lets the address of `f1`
escape from the caller.
2020-04-30 14:27:40 +02:00
Rasmus Wriedt Larsen
e0b4518a3e Merge branch 'master' into python-improve-file-taint 2020-04-30 11:24:29 +02:00
Tom Hvitved
b03e87f623 Merge pull request #3379 from calumgrant/cs/nullability-warning
C#: Remove nullability warnings
2020-04-30 08:38:28 +02:00
Cornelius Riemenschneider
b838426421 Move ArrayLengthAnalysis library to the correct location. 2020-04-29 21:07:44 +02:00
Jason Reed
62c128f9a4 C++: Add QLDoc. 2020-04-29 11:06:06 -04:00
semmle-qlci
2b055de4d6 Merge pull request #3154 from erik-krogh/ImplicitConv
Approved by asgerf
2020-04-29 16:05:19 +01:00
Calum Grant
25d5c81896 C#: Enable nullability for Semmle.Extraction project. Some refactoring required. 2020-04-29 15:59:46 +01:00
Calum Grant
6b8a5606d6 C#: Enable nullability for Autobuild tests project. 2020-04-29 15:27:35 +01:00
Calum Grant
86d032e2ea C#: Remove nullability warning by lifting local function. Warning seems to be caused by a compiler bug. 2020-04-29 15:21:43 +01:00
Jason Reed
e73833eda6 C++: Factor out file encoding predicate 2020-04-29 10:15:26 -04:00
Jason Reed
0500715bc1 C++: Fix docstring in localReferences.ql 2020-04-29 10:15:26 -04:00
Jason Reed
f0a7ff0d9d Exclude ide queries from lgtm suite. 2020-04-29 10:15:26 -04:00
Jason Reed
b341f768de C++: Fix formatting 2020-04-29 10:15:26 -04:00
Jason Reed
3b7fecab93 C++: Fix duplicate query ids 2020-04-29 10:15:26 -04:00
Jason Reed
5390f4b255 C++: Scope tags meant for ide contextual queries 2020-04-29 10:15:26 -04:00
Jason Reed
aa7a0e6879 CPP: Add tags for VS Code jump-to-defition 2020-04-29 10:15:26 -04:00
alexet
6a41028d3a CPP:Add preliminary local jump to def queries 2020-04-29 10:15:26 -04:00
Matthew Gretton-Dann
7d605095a5 C++: Update expected test results 2020-04-29 14:31:35 +01:00
Matthew Gretton-Dann
5b29a49c73 C++: Add library support for consteval 2020-04-29 14:31:35 +01:00
Cornelius Riemenschneider
f83c3452a1 Switch allocation size expression analysis to unconverted result expression. 2020-04-29 15:13:00 +02:00
Anders Schack-Mulligen
29a5ea121a Merge pull request #2901 from ggolawski/java-spring-boot-actuators
CodeQL query to detect open Spring Boot actuator endpoints
2020-04-29 15:10:54 +02:00
Cornelius Riemenschneider
64cf0906b5 Address review.
Most important fix is that VNLength is now restricted to the subset
of value numbers that are Bounds in the RangeAnalysis.
2020-04-29 15:10:30 +02:00
Erik Krogh Kristensen
2ef13ef6e8 cousing -> sibling 2020-04-29 14:30:03 +02:00
Nick Rolfe
55301b4b2f Merge pull request #3074 from matt-gretton-dann/codeql-c-extractor/50-char8_t
Add support for C++20's char8_t type.
2020-04-29 12:15:25 +01:00
Cornelius Riemenschneider
9d2533c8ab Fix bug in handling of subtractions. 2020-04-29 13:07:15 +02:00
Mathias Vorreiter Pedersen
8a1d96b313 Merge pull request #3374 from jbj/PartialDefinition-refactor
C++: Refactor `PartialDefinition` charpred
2020-04-29 13:03:40 +02:00
Cornelius Riemenschneider
e6d193294a Experimental library that tracks the length of memory.
For each pointer, we start tracking (starting from the allocation or an array declaration)
1) how long is the chunk of memory allocated
2) where the current pointer is in this chunk of memory.
This information might not always exist, but when it does, it is reliable.
Currently only works intraprocedurally.
2020-04-29 12:55:54 +02:00
Cornelius Riemenschneider
55cd0fac5c Move useful helper predicate and types from RangeAnalysis to RangeUtils. 2020-04-29 12:55:54 +02:00
Jonas Jensen
de3fa8e68b Merge pull request #3337 from Cornelius-Riemenschneider/alloc-type
C++: Allocation.qll: Provide getAllocatedElementType predicate for AllocationExprs.
2020-04-29 11:55:02 +02:00
Anders Schack-Mulligen
b6a7ab8bf4 Merge pull request #3372 from aibaars/spring-multipart
Java: add `org.springframework.web.multipart.MultipartFile::getX` as RemoteFlowSource
2020-04-29 11:35:04 +02:00
Matthew Gretton-Dann
a6947e0296 C++: Complete support for char8_t 2020-04-29 10:18:13 +01:00
Matthew Gretton-Dann
c0d0f7862b C++: Add DB Upgrade script 2020-04-29 10:18:13 +01:00
Matthew Gretton-Dann
52670dd956 C++: Update expected test output. 2020-04-29 10:18:13 +01:00
Matthew Gretton-Dann
2d898af2fe C++: Add library support for char8_t type. 2020-04-29 10:18:13 +01:00
Matthew Gretton-Dann
79b3a995e9 C++: Add DB support for C++20's char8_t 2020-04-29 10:18:13 +01:00
semmle-qlci
62b7cbfdb4 Merge pull request #3377 from shati-patel/mergeback
Approved by jf205
2020-04-29 09:15:04 +01:00
Erik Krogh Kristensen
8af08756b9 split store-steps into backwards and forwards, and prune even more. 2020-04-29 09:16:22 +02:00
Erik Krogh Kristensen
7aa421fd8a prune clearly infeasible store steps 2020-04-29 09:15:32 +02:00
Erik Krogh Kristensen
8cf71e59ce prune infeasible load steps 2020-04-29 09:13:49 +02:00
Erik Krogh Kristensen
435b5cf42d refactor how exploratoryFlowStep is used 2020-04-29 09:11:26 +02:00
Shati Patel
5c80cd5032 Merge branch 'rc/1.24' into mergeback 2020-04-29 08:05:53 +01:00
Jonas Jensen
796041af72 C++: Refactor PartialDefinition charpred
This class used `newtype` for seemingly no reason. The new code is
shorter and should be faster as well.
2020-04-28 17:10:25 +02:00
Bas van Schaik
5940fa5799 Update CODEOWNERS with GitHub team identifiers after move 2020-04-28 16:02:05 +01:00
Arthur Baars
d7774788b3 Java: add Spring MultipartFile as RemoteFlowSource 2020-04-28 16:57:03 +02:00
Arthur Baars
ae2bab7e9c Add test case 2020-04-28 16:57:03 +02:00
Anders Schack-Mulligen
bc7163aa68 Merge pull request #3216 from aibaars/message-digest
Java: teach Encryption.qll about MessageDigest.getInstance
2020-04-28 11:41:53 +02:00
Arthur Baars
31e284a707 Add test case 2020-04-28 11:26:43 +02:00
Arthur Baars
9742d3892d Java: Add org.apache.commons.codec.(De|En)coder to TainTrackingUtil
The commons codec library contains many encoder and decoder methods
and is fairly commonly used.
2020-04-28 11:26:43 +02:00
Tom Hvitved
7cbf37c6ba C#: Convert string.format() queries to path queries 2020-04-28 09:59:19 +02:00
Asger Feldthaus
9b014c36df JS: Avoid lots of unhelpful magic 2020-04-28 08:56:27 +01:00
Asger Feldthaus
a8283593a9 JS: Make PropWrite not depend on SourceNode 2020-04-28 08:56:27 +01:00
Asger Feldthaus
e3440c1410 JS: Cache AMD modules 2020-04-28 08:56:27 +01:00
Asger Feldthaus
aa2a49d189 JS: Rewrite mayHaveStringValue to avoid misoptimization 2020-04-28 08:56:27 +01:00
Grzegorz Golawski
31a2972eca Remove qlpack.yml as these are not needed 2020-04-27 23:32:48 +02:00
Grzegorz Golawski
0c75330e42 Remove qlpack.yml as these are not needed 2020-04-27 23:31:10 +02:00
Grzegorz Golawski
639aa826ea Remove qlpack.yml as these are not needed 2020-04-27 23:26:59 +02:00
yo-h
97f4cb64ef Merge pull request #3349 from aschackmull/java/qldoc1
Java: Improve qldoc coverage.
2020-04-27 12:49:23 -04:00
Jonas Jensen
36221fe69a Merge pull request #3334 from MathiasVP/get-an-assigned-value-join-order
C++: Fix join order in getAnAssignedValue
2020-04-27 17:50:12 +02:00
Rasmus Wriedt Larsen
c5e14f5c0d Python: Handle defaults and annotations for keyword-only arguments
This commit is based on a change to the extractor
2020-04-27 17:24:10 +02:00
Rasmus Wriedt Larsen
1fcbb6e9f4 Python: Better test for Argument.getDefault(i)
Default values for positional arugments follow a rule, so if an argument has a
default value, later positional arguments must also have default values.

The database only stores the actual default values, and nothing about the
arguments that doesn't have default values.

This turns out to be a major problem for Argument.getKwDefault(i), since default
values for keyword-only arguments doesn't have the same rule. So if you know
there is one default value, you can't tell if it is associated with `foo` or
`bar`, as in the examples below:

```
def a(*, foo=None, bar):
    pass

def b(*, foo, bar=None):
    pass
```
2020-04-27 17:22:56 +02:00
Rasmus Wriedt Larsen
5f6058363f Python: Improve QLdoc for Parameter.getPosition 2020-04-27 17:22:56 +02:00
Rasmus Wriedt Larsen
8c1cfe52f6 Python: Use getAKeywordOnlyArg instead of getAKwonlyarg
The result is the same, but `getAKeywordOnlyArg` is the method used everywhere
else in the code.
2020-04-27 17:22:56 +02:00
Rasmus Wriedt Larsen
c508e89a00 Python: Handle keyword-only arguments properly 2020-04-27 17:22:56 +02:00
Rasmus Wriedt Larsen
4185edc087 Python: Expand parameters/functions test
I want to ensure we handle when only _some_ parameters have default/annotations
2020-04-27 17:22:56 +02:00
Rasmus Wriedt Larsen
0cc8d49112 Python: Add tests for full Python 3 parameters syntax
Currently keyword-only parameters are not handled properly :(
2020-04-27 17:22:56 +02:00
Rasmus Wriedt Larsen
96b36a7f0f Python: Clean up some QLdocs 2020-04-27 17:22:56 +02:00
Rasmus Wriedt Larsen
ce2d7fe04c Python: Improve QLDoc for Arguments 2020-04-27 17:22:56 +02:00
Rasmus Wriedt Larsen
64c013ef4d Merge branch 'master' into python-iter-str-seq-with-tests 2020-04-27 17:20:06 +02:00
Rasmus Wriedt Larsen
4e80abbfa9 Python: Fixup wording in comment
where you place a not is not without significance :D
2020-04-27 17:03:01 +02:00
jcreedcmu
12f264ca63 Merge pull request #3354 from dbartol/dbartol/Recommendation
Recommend the CodeQL for VSCode extension
2020-04-27 10:26:02 -04:00
Esben Sparre Andreasen
04b5a794f1 Merge pull request #3313 from esbena/js/typical-bad-sanitizer
New query: Incomplete HTML attribute sanitization
2020-04-27 14:31:13 +02:00
Mathias Vorreiter Pedersen
b1a94d8809 Merge branch 'master' into get-an-assigned-value-join-order 2020-04-27 14:11:30 +02:00
Tom Hvitved
d28c4fb0f5 Merge pull request #3202 from jbj/pathStep-join-unique
Java/C++/C#: Use `unique` to improve join order fix
2020-04-27 13:06:27 +02:00
Cornelius Riemenschneider
3f7d68178c Use stripTopLevelSpecifiers() to get the allocated element type for malloc(). 2020-04-27 12:46:14 +02:00
Cornelius Riemenschneider
92e8604fa1 Provide getAllocatedElementType predicate for AllocationExprs.
This predicate tries to determine the type of the allocated elements of an allocation expression.
2020-04-27 12:41:19 +02:00
Cornelius Riemenschneider
203315ae33 Assign malloc results in test to variables. 2020-04-27 12:40:35 +02:00
Esben Sparre Andreasen
c0250894de Apply suggestions from code review
Co-Authored-By: mc <42146119+mchammer01@users.noreply.github.com>
2020-04-27 12:37:39 +02:00
Geoffrey White
230e5a3a9a Merge pull request #3326 from Cornelius-Riemenschneider/alloc-size-mul
C++: Allocation.qll: Analyze common pattern of malloc() invocations to provide more accurate getSizeMult()
2020-04-27 11:18:54 +01:00
Erik Krogh Kristensen
1ad64bc619 introduce PropRef#mayHavePropertyName 2020-04-27 11:47:51 +02:00
Jonas Jensen
20c956e0a9 Merge pull request #3320 from Semmle/rdmarsh/cpp/taint-tracking-util-port
C++: move logic from DefaultTaintTracking into TaintTrackingUtil
2020-04-27 11:34:03 +02:00
Taus
de08433bd3 Merge pull request #3212 from RasmusWL/python-fix-tests-filter
Python: Fix (some) shortcomings of tests filter
2020-04-27 11:26:35 +02:00
Cornelius Riemenschneider
a50d5b7c6a Accept changed test output. 2020-04-27 09:17:16 +02:00
Esben Sparre Andreasen
0a8e371b0e Update javascript/ql/src/Security/CWE-116/IncompleteHtmlAttributeSanitization.qhelp
Co-Authored-By: Asger F <asgerf@github.com>
2020-04-27 09:09:26 +02:00
semmle-qlci
cbe417f5eb Merge pull request #3336 from erik-krogh/MoarJQuery
Approved by esbena
2020-04-25 15:17:55 +01:00
Arthur Baars
59869ace63 Java: teach Encryption.qll about MessageDigest.getInstance
We already modelled usage of the protected `MessageDigest(String algo)`
constructor as a crypto algorithm specification. For some reason we did
not model the more commonly used public `MessageDigest.getInstance` method.
2020-04-25 00:41:10 +02:00
Robert Marsh
4eea62cbde Merge pull request #3345 from Cornelius-Riemenschneider/openssl-allocators
C++: Allocation.qll: Add support for openssl allocation/deallocation functions.
2020-04-24 14:48:05 -07:00
Dave Bartolomeo
5e09d6d02d Tell GitHub to allow JSON files with comments 2020-04-24 14:04:05 -04:00
Dave Bartolomeo
5180b44e1e Recommend the CodeQL for VSCode extension
I've added a `.vscode/extensions.json` file that will automatically recommend the CodeQL for Visual Studio Code extension to anyone who opens the repo in VS Code (without the extension already installed).
2020-04-24 13:46:35 -04:00
Jonas Jensen
5917ce60b7 Merge pull request #3342 from dbartol/dbartol/SyncTask
Add a VS Code task to run `sync-files.py`
2020-04-24 16:42:44 +02:00
Dave Bartolomeo
c539e84071 Update README.md with VSCode info 2020-04-24 10:36:16 -04:00
Taus
bcb980b3d5 Merge pull request #3302 from RasmusWL/python-str-taint-add-methods
Python: Add taint for string methods
2020-04-24 16:29:11 +02:00
Rasmus Wriedt Larsen
b2b0296120 Merge pull request #3242 from BekaValentine/python-objectapi-to-valueapi-incorrectlyoverridenmethod
Python: ObjectAPI to ValueAPI: IncorrectlyOverriddenMethod
2020-04-24 16:28:11 +02:00
semmle-qlci
4c7a5007d8 Merge pull request #3314 from RasmusWL/python-model-stdlib-http.server
Approved by tausbn
2020-04-24 15:27:21 +01:00
Dave Bartolomeo
97565fd90f Add Sync Identical Files tasks to build group 2020-04-24 10:24:17 -04:00
Dave Bartolomeo
8ed8d3ccc5 Merge pull request #3343 from sauyon/sync-files
sync-files.py: cast line to string before concat
2020-04-24 10:12:52 -04:00
Mathias Vorreiter Pedersen
98c2fd8401 Merge branch 'master' into get-an-assigned-value-join-order 2020-04-24 15:03:59 +02:00
Taus
266de2efa2 Merge pull request #3348 from RasmusWL/python-random-modernisation
Python: random modernisations
2020-04-24 14:18:10 +02:00
Anders Schack-Mulligen
beab320557 Java: Add more qldoc. 2020-04-24 14:17:47 +02:00
Rasmus Wriedt Larsen
2b3025265b Python: Clean up QLdoc
Co-Authored-By: Taus <tausbn@gmail.com>
2020-04-24 14:05:02 +02:00
Calum Grant
fcc2b66d1a Merge pull request #3347 from hvitved/csharp/vsvars-test
C#: Update expected test output
2020-04-24 12:12:31 +01:00
Rasmus Wriedt Larsen
367ee3e8c4 Python: Modernise security/injection/Path.qll
And we're making things a bit more clean since it's not *any* argument of `open()` that is a taint-sink.
2020-04-24 12:03:42 +02:00
Rasmus Wriedt Larsen
67837887c8 Python: Modernise security/injection/Exec.qll 2020-04-24 11:59:05 +02:00
Calum Grant
1f1ac72de8 Merge pull request #3309 from hvitved/csharp/cfg/catch-finally-bug
C#: Add missing CFG edge from generic `catch` block to `finally` block
2020-04-24 10:12:53 +01:00
Esben Sparre Andreasen
58b5bd5cfd JS: fixup documentation 2020-04-24 10:56:53 +02:00
semmle-qlci
28cfe548d5 Merge pull request #3325 from erik-krogh/MoreEventClasses
Approved by asgerf
2020-04-24 09:02:27 +01:00
semmle-qlci
671e7c6637 Merge pull request #3335 from asger-semmle/js/cached-chained-methods
Approved by esbena
2020-04-24 08:28:05 +01:00
Tom Hvitved
6911937ab8 C#: Update expected test output 2020-04-24 09:26:50 +02:00
Esben Sparre Andreasen
f0a05f6a6c JS: change notes 2020-04-24 09:18:16 +02:00
Esben Sparre Andreasen
6d6ec89ba8 JS: add qhelp 2020-04-24 09:18:09 +02:00
Esben Sparre Andreasen
708fd3d73f JS: add query to query suite 2020-04-24 09:17:46 +02:00
Esben Sparre Andreasen
89613dbd23 JS: add query for incomplete HTML attribute sanitization 2020-04-24 09:17:46 +02:00
Jonas Jensen
d98e956c2b Merge pull request #3322 from felicitymay/merge-124-master
Merge rc/1.24 into master
2020-04-24 08:48:54 +02:00
Rasmus Wriedt Larsen
8878884724 Python: Rewrite web/stdlib/Request.qll QLDoc to be more clear 2020-04-24 08:07:23 +02:00
Rasmus Wriedt Larsen
23f3736b67 Python: Simplify CgiFieldStorageFieldKind.getTaintOfAttribute 2020-04-24 08:04:55 +02:00
Cornelius Riemenschneider
c25eb19b18 Add support for openssl allocation/deallocation functions. 2020-04-24 01:57:14 +02:00
Sauyon Lee
972551edd7 sync-files.py: cast line to string before concat 2020-04-23 15:32:28 -07:00
Dave
95b55f86ba Add a VS Code task to run sync-files.py
If you're developing one of the libraries that has muiltiple copies auto-generated by `sync-files.py`, you can now run `sync-files.py --latest` by going to the `Terminal | Run Task...` menu in VS Code and selecting the `Sync Identical Files` task. You can set a keyboard binding to run this task for quicker access.
2020-04-23 16:58:34 -04:00
Erik Krogh Kristensen
19c6092998 autoformat 2020-04-23 20:59:34 +02:00
Erik Krogh Kristensen
ea1628ef54 fix typo in jQuery.qll
Co-Authored-By: Esben Sparre Andreasen <esbena@github.com>
2020-04-23 20:58:49 +02:00
Erik Krogh Kristensen
a71567da54 autoformat 2020-04-23 18:58:33 +02:00
Taus
1d6b6a48ae Merge pull request #2924 from BekaValentine/python-objectapi-to-valueapi-wrongnumberargumentsincall
Python: ObjectAPI to ValueAPI: WrongNumberArgumentsInCall
2020-04-23 17:56:39 +02:00
Erik Krogh Kristensen
ee43db1b58 slightly expand the $().each model 2020-04-23 16:49:47 +02:00
Erik Krogh Kristensen
448ed150df allow the empty string to flow to a JQuery XSS sink 2020-04-23 16:45:37 +02:00
Cornelius Riemenschneider
0ea7fedeb0 Address review and fix bug in deconstructSizeExpr/3.
Logic is hard, and I made a mistake inverting the formula for the second case, so the
predicate never held for a sizeExpr like sizeof(int)*sizeof(void).
Now, this case is correctly handled by the fallback.
2020-04-23 16:39:29 +02:00
Cornelius Riemenschneider
492f1f446a Remove pragma[inline] from deconstructSizeExpr/3. 2020-04-23 15:53:11 +02:00
Erik Krogh Kristensen
96896fd7f5 second round of UnsafeJQueryPlugin reuse 2020-04-23 15:12:32 +02:00
Erik Krogh Kristensen
ea569dba78 update doc for JQuery plugin predicate
Co-Authored-By: Esben Sparre Andreasen <esbena@github.com>
2020-04-23 15:03:39 +02:00
Asger Feldthaus
cafdcfa4de JS: Preserve reflective calls in getAMethodCall 2020-04-23 13:57:14 +01:00
Erik Krogh Kristensen
1954a60b6e reuse existing predicate from UnsafeJqueryPlugin 2020-04-23 14:25:34 +02:00
Erik Krogh Kristensen
09b6727e6d refactor $.each model 2020-04-23 14:24:56 +02:00
Erik Krogh Kristensen
ce106981b3 add tests 2020-04-23 14:24:33 +02:00
Mathias Vorreiter Pedersen
deff2820c2 C++: Modernize getAnAssignedValue following PR comments 2020-04-23 14:14:35 +02:00
Rasmus Wriedt Larsen
fe50811bbf Python: In taint test, list comprehension => for loop
Apparently they're not the same thing :(
2020-04-23 14:13:00 +02:00
Rasmus Wriedt Larsen
06edd076b6 Python: Enable taint when iterating over ExternalFileObject 2020-04-23 14:11:50 +02:00
Erik Krogh Kristensen
e7d8cd8e8c Merge remote-tracking branch 'upstream/master' into MoarJQuery 2020-04-23 14:10:53 +02:00
semmle-qlci
36b28386f8 Merge pull request #3332 from erik-krogh/JGrowl
Approved by esbena
2020-04-23 13:06:00 +01:00
Erik Krogh Kristensen
67443718c0 change note 2020-04-23 13:55:37 +02:00
Erik Krogh Kristensen
6897dda614 model that this in $().each(callback) is a DOM-node 2020-04-23 13:51:17 +02:00
Erik Krogh Kristensen
8de86967aa model that this in a jQuery plugin is a jQuery object 2020-04-23 13:48:54 +02:00
semmle-qlci
801ce89c67 Merge pull request #3099 from esbena/js/introduce-poi-utility
Approved by erik-krogh
2020-04-23 12:14:00 +01:00
Jonas Jensen
37e3bc4b3e C++: invoke unique without | |
Based on PR feedback. This will avoid a syntactic wart and make the
invocation do the right thing both with and without
`language[monotonicAggregates]`.
2020-04-23 13:10:05 +02:00
Jonas Jensen
312e6229fb Merge pull request #3330 from MathiasVP/libc-assert
C++: Generalize charpred of LibcAssert
2020-04-23 13:06:41 +02:00
Rasmus Wriedt Larsen
1fe0040086 Python: Don't use six in urllib.parse string related tests
Since this test inheriently has `--max-import-depth=1`, by using six, we would
never look at the actual source-code of urllib.parse/urlparse and therefore the
test would never show if we understood the library code good enough that we
could propagate taint out-of-the-box.

All tests moved by one line... that is why the diff is so big
2020-04-23 13:00:45 +02:00
Erik Krogh Kristensen
d8c498bd15 add NOT OK comment
Co-Authored-By: Esben Sparre Andreasen <esbena@github.com>
2020-04-23 12:17:25 +02:00
Cornelius Riemenschneider
a33b7f8c99 Make getSizeMult() functional. 2020-04-23 12:15:31 +02:00
Rasmus Wriedt Larsen
94ae2febe5 Python: Propagate taint through parse_qsl 2020-04-23 12:14:22 +02:00
Erik Krogh Kristensen
e1423b0fa5 add test for jGrowl 2020-04-23 11:58:06 +02:00
Erik Krogh Kristensen
5382976195 change note 2020-04-23 11:52:16 +02:00
Taus
54d1991a9d Merge pull request #3300 from RasmusWL/python-pointsto-regression-open
Python: Add points-to regression for uncalled function
2020-04-23 11:50:30 +02:00
Pavel Avgustinov
adf12ba2b4 Merge pull request #3333 from sj/patch-3
Update CODE_OF_CONDUCT.md to be based on Contributor Covenant template
2020-04-23 10:46:41 +01:00
Bas van Schaik
0c8786f941 Update code of conduct in line with GH
Updates CODE_OF_CONDUCT.md to use the Contributor Covenant Code of Conduct that is widely used for other open source projects at GitHub.
2020-04-23 10:19:13 +01:00
Jonas Jensen
d6f77c0f98 Merge pull request #3328 from MathiasVP/literal-comment
C++: Remove unnecessary part of comment
2020-04-23 11:10:16 +02:00
Mathias Vorreiter Pedersen
0fb534c79e C++: Fix join order in getAnAssignedValue 2020-04-23 11:04:40 +02:00
Erik Krogh Kristensen
90652eeb25 add $.jGrowl as an XSS sink 2020-04-23 10:44:41 +02:00
Rasmus Wriedt Larsen
86630f1d6c Python: Handle readline, readlines for ExternalFileObject 2020-04-23 10:40:16 +02:00
Rasmus Wriedt Larsen
7385ea5024 Python: Add tests for ExternalFileObject 2020-04-23 10:36:51 +02:00
Rasmus Wriedt Larsen
c479a77d55 Python: Refactor ExternalFileObject to use field
Instead of string matching. This brings it in line with what CollectionKind,
SequenceKind, and DictKind does.
2020-04-23 10:28:29 +02:00
semmle-qlci
da3292606c Merge pull request #3191 from erik-krogh/XssDom
Approved by esbena, mchammer01
2020-04-23 09:17:07 +01:00
Jonas Jensen
f696594d35 Merge pull request #3295 from MathiasVP/field-flow-single-struct
C++: Add PostUpdateNode for updates to structs with no chi instructions
2020-04-23 10:02:10 +02:00
Jonas Jensen
cbed175931 Merge pull request #3273 from Semmle/rdmarsh/cpp/RemoteFlowSource-model
C++: Add remote flow sources via models
2020-04-23 09:54:40 +02:00
Mathias Vorreiter Pedersen
1016a0c0db C++: Generalize charpred of LibcAssert 2020-04-23 09:48:30 +02:00
Esben Sparre Andreasen
a66b4b55fe Update javascript/ql/src/experimental/poi/PoI.qll
Co-Authored-By: Erik Krogh Kristensen <erik-krogh@github.com>
2020-04-23 09:47:21 +02:00
semmle-qlci
1312fcccae Merge pull request #3324 from erik-krogh/BoundSocketIO
Approved by asgerf
2020-04-23 08:42:45 +01:00
Tom Hvitved
5b5f9adfc6 C#: Add missing CFG edge from generic catch block to finally block 2020-04-23 08:45:11 +02:00
Tom Hvitved
bd075a7de0 C#: Add CFG test 2020-04-23 08:45:11 +02:00
Esben Sparre Andreasen
161c05dced Apply suggestions from code review
Co-Authored-By: Erik Krogh Kristensen <erik-krogh@github.com>
2020-04-23 08:41:54 +02:00
Mathias Vorreiter Pedersen
7b51d0c8a5 C++: Remove unnecessary part of comment 2020-04-23 08:35:44 +02:00
Cornelius Riemenschneider
293e6466d4 AllocationExpr.getSizeMult() now analyzes the size expression of function calls.
This yields more precise size information in a lot of the common cases of C allocation code,
as the common pattern malloc(count * sizeof(type)) is now understood.
2020-04-23 02:05:31 +02:00
Cornelius Riemenschneider
247fc42ec5 Add tests that show AllocationExpr.getSizeMult() behaviour. 2020-04-23 02:02:57 +02:00
Robert Marsh
0dc797d288 C++: autoformat ModelUtil.qll 2020-04-22 16:14:58 -07:00
Robert Marsh
ac22e7950c C++: autoformat FlowSources.qll 2020-04-22 16:11:33 -07:00
Robert Marsh
471f536326 Merge pull request #3307 from dbartol/dbartol/BinaryConditional
C++: IR translation for binary conditional operator
2020-04-22 15:01:16 -07:00
Erik Krogh Kristensen
6ada588dd1 add support for util.inherits 2020-04-22 22:55:12 +02:00
Erik Krogh Kristensen
957e4073b0 use getABoundCallbackParameter in SocketIO 2020-04-22 21:56:34 +02:00
Erik Krogh Kristensen
40822e10b4 add SocketIO test case 2020-04-22 21:55:20 +02:00
Tom Hvitved
5a2dcc591c Merge pull request #3317 from Semmle/revert-2814-cs/unqualify-trap-ids
Revert "C#: Improve db consistency by removing assembly id"
2020-04-22 20:46:35 +02:00
Felicity Chapman
89bf35cd43 Merge branch 'rc/1.24' into merge-124-master
Conflicts:
	change-notes/1.24/analysis-javascript.md
    Resolved in favor of the rc/1.24 branch
2020-04-22 19:01:47 +01:00
Rebecca Valentine
89752f4b55 Merge branch 'master' into python-objectapi-to-valueapi-wrongnumberargumentsincall 2020-04-22 09:52:33 -07:00
Rebecca Valentine
9cd2171fb8 Merge branch 'master' into python-objectapi-to-valueapi-incorrectlyoverridenmethod 2020-04-22 09:40:33 -07:00
Rebecca Valentine
d5c44d8513 Merge pull request #3315 from tausbn/python-finalise-1.24-change-notes
Python: Finalise change notes for 1.24.
2020-04-22 09:15:54 -07:00
Dave Bartolomeo
163ecd97de Merge pull request #3277 from geoffw0/rangeshift
C++: Support for & and >> in SimpleRangeAnalysis
2020-04-22 11:36:36 -04:00
Rasmus Wriedt Larsen
22096c36b9 Python: Add standard HttpSources tests for BaseHTTPRequestHandler 2020-04-22 17:28:49 +02:00
Rasmus Wriedt Larsen
51a9094064 Python: Add sinks for http.server.BaseHTTPRequestHandler 2020-04-22 17:28:27 +02:00
Felicity Chapman
e29468135d Editorial suggestions
We don't hyphenate "QL-library" and there were a few typos. Feel free to further revise this if I've changed the meaning too much.

As discussed separately, I was unable to raise this as a PR in GitHub.com and had to resort to a direct commit.
2020-04-22 15:48:01 +01:00
Tom Hvitved
8c0c283811 Revert "C#: Improve db consistency by removing assembly id" 2020-04-22 16:32:13 +02:00
Rasmus Wriedt Larsen
a27431e197 Python: Add module level QLDoc in web/stdlib/Request.qll 2020-04-22 16:22:03 +02:00
Taus
44b570f7b6 Apply suggestions from code review
Co-Authored-By: Felicity Chapman <felicitymay@github.com>
2020-04-22 16:03:20 +02:00
Taus Brock-Nannestad
e97d88c158 Python: Finalise change notes for 1.24. 2020-04-22 14:31:04 +02:00
Esben Sparre Andreasen
a0e6562208 JS: address review feedback 2020-04-22 14:24:35 +02:00
Esben Sparre Andreasen
2747e2a0c7 JS: formatting 2020-04-22 14:24:35 +02:00
Esben Sparre Andreasen
2186ca7efc JS: address non-semantic review feedback 2020-04-22 14:24:35 +02:00
Esben Sparre Andreasen
27e5fce0ed JS: make the default PoIConfiguration/enabled inclusive 2020-04-22 14:24:34 +02:00
Esben Sparre Andreasen
3b45bcd285 JS: remove the standard PoI configurations 2020-04-22 14:24:34 +02:00
Esben Sparre Andreasen
dd6378f1d0 JS: address PoI review comments 2020-04-22 14:24:34 +02:00
Esben Sparre Andreasen
b2ca3d2bdc JS: improve PoI::alertQuery docstring 2020-04-22 14:24:34 +02:00
Esben Sparre Andreasen
a386d2dcee JS: add missing expected output 2020-04-22 14:24:34 +02:00
Esben Sparre Andreasen
607d46e2f9 JS: improve PoI tests 2020-04-22 14:24:34 +02:00
Esben Sparre Andreasen
c407cc072e JS: autoformat 2020-04-22 14:24:34 +02:00
Esben Sparre Andreasen
e4ea089a0b JS: add experimental PoI module 2020-04-22 14:24:34 +02:00
Esben Sparre Andreasen
ec73c97422 JS: refactor ClassifyFiles.qll from ClassifyFiles.ql 2020-04-22 14:24:34 +02:00
Erik Krogh Kristensen
ac26741816 reuse existing SanitizerGuard from UnsafeJQueryPlugin 2020-04-22 14:16:15 +02:00
Dave Bartolomeo
66381e89ef C++: Add comment from PR feedback 2020-04-22 08:11:43 -04:00
Erik Krogh Kristensen
0a29d132d0 reuse existing logic in DomBasedXss 2020-04-22 13:50:43 +02:00
Rasmus Wriedt Larsen
6b84137a92 Python: Model cgi.FieldStorage (parsing of submitted forms) 2020-04-22 11:37:47 +02:00
Rasmus Wriedt Larsen
1ecfa2eb55 Merge pull request #3278 from tausbn/python-fix-warnings
Python: Fix remaining deprecation warnings.
2020-04-22 11:33:16 +02:00
Rasmus Wriedt Larsen
6eb24011eb Python: Add docs to web/stdlib/Request.qll 2020-04-22 11:26:50 +02:00
Erik Krogh Kristensen
ac44cb425e Merge branch 'master' into js/call-graph-exploration 2020-04-22 10:49:26 +02:00
Robert Marsh
9e0d6e8aa0 C++: move taint step cases to TaintTrackingUtil 2020-04-22 01:38:00 -07:00
Taus Brock-Nannestad
2fad5e8e32 Python: Remove deprecated TaintFlow and additionalFlowStepVar. 2020-04-22 10:34:00 +02:00
Erik Krogh Kristensen
a5bbfa30d1 add change note 2020-04-22 10:23:07 +02:00
Erik Krogh Kristensen
7bfea946fd update links in xss-through-dom qhelp 2020-04-22 10:23:03 +02:00
Erik Krogh Kristensen
8811455d49 Merge remote-tracking branch 'upstream/master' into XssDom 2020-04-22 10:20:40 +02:00
Calum Grant
1b88c97688 Merge pull request #3199 from hvitved/csharp/vsvars-unset-platform
C#: Unset `Platform` env variable when invoking `vcvarsall.bat`
2020-04-22 09:18:20 +01:00
Geoffrey White
2e392516c2 Apply suggestions from code review
Co-Authored-By: Dave Bartolomeo <dbartol@github.com>
2020-04-22 09:09:16 +01:00
Erik Krogh Kristensen
76503d3536 user controlled -> user-controlled 2020-04-22 10:08:01 +02:00
Erik Krogh Kristensen
947e9828da Update javascript/ql/src/Security/CWE-079/XssThroughDom.qhelp
Co-Authored-By: mc <42146119+mchammer01@users.noreply.github.com>
2020-04-22 10:07:50 +02:00
Rasmus Wriedt Larsen
26ed911bb2 Python: Add modeling of http.server.BaseHTTPRequestHandler 2020-04-22 09:52:10 +02:00
Rasmus Wriedt Larsen
30e2592701 Python: Propagate taint through parse_qs 2020-04-22 08:55:35 +02:00
Robert Marsh
52b1fb703d C++: use models in TaintTrackingUtil 2020-04-21 17:18:14 -07:00
Robert Marsh
11683fa9cb C++: add mapping between models and instructions 2020-04-21 17:10:45 -07:00
Taus
5af351eacd Merge pull request #3275 from RasmusWL/python-fix-points-to-deprecations
Python: Remove deprecated annotation for old PointsTo::points_to
2020-04-21 18:18:07 +02:00
Dave Bartolomeo
4b44afef90 C++: Accept syntax-zoo test output 2020-04-21 09:42:24 -04:00
Dave Bartolomeo
fee557001e C++: Update SignAnalysis test results 2020-04-21 09:34:44 -04:00
Mathias Vorreiter Pedersen
a49d22e6e4 C++: Fix join ordering 2020-04-21 13:25:06 +02:00
semmle-qlci
2fb711e460 Merge pull request #3169 from erik-krogh/Maps
Approved by asgerf, esbena
2020-04-21 12:12:06 +01:00
Erik Krogh Kristensen
59b94b3d1b revert back to having 2 separate cases in JQuery::MethodCall 2020-04-21 13:08:06 +02:00
Asger Feldthaus
18188b659c JS: Add 1.25 change note 2020-04-21 10:53:37 +01:00
Asger Feldthaus
c04ba91a90 JS: Autoformat 2020-04-21 10:51:42 +01:00
Asger Feldthaus
39920c1b08 JS: Add forwarding libraries in old locations 2020-04-21 10:51:42 +01:00
Asger Feldthaus
9e4709148b JS: Move Forward/Backward exploration to explore folder 2020-04-21 10:51:41 +01:00
Asger Feldthaus
647a3d3a60 JS: Add note and debugging and exploration 2020-04-21 10:51:41 +01:00
Asger Feldthaus
ffeda7f45a JS: Expand on doc a bit 2020-04-21 10:51:41 +01:00
Asger Feldthaus
066549f682 JS: Fix typo in qldoc 2020-04-21 10:51:41 +01:00
Asger F
291ebccfef Update javascript/ql/src/semmle/javascript/explore/CallGraph.qll
Co-Authored-By: Max Schaefer <54907921+max-schaefer@users.noreply.github.com>
2020-04-21 10:51:41 +01:00
Asger F
4c9ef8c570 Update javascript/ql/src/semmle/javascript/explore/CallGraph.qll
Co-Authored-By: Max Schaefer <54907921+max-schaefer@users.noreply.github.com>
2020-04-21 10:51:41 +01:00
Asger Feldthaus
759e1dfe45 JS: Add helper library for call graph exploration 2020-04-21 10:51:40 +01:00
Rasmus Wriedt Larsen
32a97266cf Python: Fix deprecation warnings in test output 2020-04-21 11:39:44 +02:00
semmle-qlci
53abf83229 Merge pull request #3304 from asger-semmle/js/typescript-unary-type-expr
Approved by erik-krogh
2020-04-21 10:38:59 +01:00
Asger Feldthaus
1703ffe6a1 JS: Cache some SourceNode getter methods differently 2020-04-21 10:33:07 +01:00
semmle-qlci
2ecef33c9d Merge pull request #3299 from asger-semmle/js/flows-to-redundant-check
Approved by esbena
2020-04-21 10:00:34 +01:00
semmle-qlci
80c20cb66e Merge pull request #3297 from asger-semmle/js/isambient-refactor
Approved by esbena
2020-04-21 09:36:14 +01:00
semmle-qlci
d75d520f35 Merge pull request #3232 from RasmusWL/python-more-deprecated-annotations
Approved by BekaValentine
2020-04-21 09:30:27 +01:00
Tom Hvitved
29e690e159 Merge remote-tracking branch 'upstream/master' into csharp/vsvars-unset-platform 2020-04-21 09:00:26 +02:00
Tom Hvitved
7d86cce658 Merge pull request #2814 from calumgrant/cs/unqualify-trap-ids
C#: Improve db consistency by removing assembly id
2020-04-21 08:58:34 +02:00
Dave Bartolomeo
1428811f75 C++: IR translation for binary conditional operator
IR generation was not handling the special two-operand flavor of the `?:` operator that GCC supports as an extension. The extractor doesn't quite give us enough information to do this correctly (see github/codeql-c-extractor-team#67), but we can get pretty close.

About half of the code could be shared between the two-operand and three-operand flavors. The main differences for the two-operand flavor are:
1. The "then" operand isn't a child of the `ConditionalExpr`. Instead, we just reuse the original value of the "condition" operand, skipping any implicit cast to `bool` (see comment for rationale).
2. For the three-operand flavor, we generate the condition as control flow rather than the computation of a `bool` value, to avoid creating unnecessarily complicated branching. For the two-operand version, we just compute the value, since we have to reuse that value in the "then" branch anyway.

I've added IR tests for these new cases. I've also updated the expectations for `SignAnalysis.ql` based on the fix. @rdmarsh2, can you please double-check that these diffs look correct? I believe they do, but you're the range/sign analysis expert.
2020-04-21 02:05:21 -04:00
Robert Marsh
d0bb5ad4e2 C++: rename and add description to hasFlowSource 2020-04-20 13:25:31 -07:00
Robert Marsh
e6630a8fba Apply suggestions from code review
Co-Authored-By: Jonas Jensen <jbj@github.com>
2020-04-20 10:14:13 -07:00
Asger Feldthaus
883846dfb6 JS: Fix extraction of negative number literal types 2020-04-20 16:17:15 +01:00
Jonas Jensen
875daae84b Merge pull request #3151 from dbartol/dbartol/floats
C++: Better support for complex numbers in IR and AST
2020-04-20 16:27:20 +02:00
Rasmus Wriedt Larsen
43bc7c6619 Python: Autoformat
I'm not particularly happy about this one, but I don't care to fight about it today.
2020-04-20 16:08:53 +02:00
Rasmus Wriedt Larsen
b7145af447 Python: Handle all methods in StringKind.getTaintOfMethodResult 2020-04-20 16:07:30 +02:00
Calum Grant
41d8d32764 C#: Address review comment: Make dictionary type more specific. 2020-04-20 15:06:42 +01:00
Asger Feldthaus
ca60e8264e JS: Autoformat 2020-04-20 14:42:41 +01:00
Rasmus Wriedt Larsen
a5d3966cb3 Python: Refactor StringKind.getTaintOfMethodResult
no need to match on ControlFlowNodes manually anymore 🎉
2020-04-20 15:01:40 +02:00
Rasmus Wriedt Larsen
10b36bb7a8 Python: Taint of string method reference isn't handled 2020-04-20 15:01:40 +02:00
Rasmus Wriedt Larsen
1631787336 Python: Fix points-to regressions Test.ql
Only being able to debug missing pointsTo for NameNode was quite limiting ...
2020-04-20 14:41:55 +02:00
Rasmus Wriedt Larsen
8746876377 Python: Add points-to regression for uncalled function 2020-04-20 14:41:45 +02:00
Mathias Vorreiter Pedersen
8be1bfe8d0 C++: Add comments and accept expected dataflow sanity failures 2020-04-20 14:13:12 +02:00
Erik Krogh Kristensen
9fc29ee0f8 update qhelp 2020-04-20 13:29:00 +02:00
Erik Krogh Kristensen
73b0aa4004 add more attributes potentially vulnerable to xss-through-dom 2020-04-20 13:29:00 +02:00
Erik Krogh Kristensen
12f4ce8111 merge two cases of jQuery method calls 2020-04-20 13:28:55 +02:00
Erik Krogh Kristensen
aee7cc117d add change-note 2020-04-20 13:08:51 +02:00
Erik Krogh Kristensen
8b254f7b49 Merge remote-tracking branch 'upstream/master' into Maps 2020-04-20 13:00:39 +02:00
semmle-qlci
e965e5c73e Merge pull request #3094 from erik-krogh/Mispelled
Approved by esbena
2020-04-20 11:41:23 +01:00
Calum Grant
eb1474acee Merge pull request #3276 from hvitved/csharp/dataflow/array-tests
C#: Add data-flow test for collections
2020-04-20 11:36:17 +01:00
Calum Grant
ead916702a C#: Take nullability into account when creating symbol entities. Otherwise, an entity with the wrong (cached) nullability could be created. 2020-04-20 11:29:31 +01:00
Asger Feldthaus
bccc27f1e7 JS: Rephrase flowsTo to avoid redundant SourceNode::Range check 2020-04-20 10:57:52 +01:00
Erik Krogh Kristensen
2d3e42e6d6 update qhelp for xss-through-dom
Co-Authored-By: Asger F <asgerf@github.com>
2020-04-20 11:50:46 +02:00
Mathias Vorreiter Pedersen
e0cd595d54 C++: Reduce intermediate tuple counts 2020-04-20 11:46:10 +02:00
Erik Krogh Kristensen
c713ba7bfe fix typo 2020-04-20 10:51:42 +02:00
Tom Hvitved
e186c9ddd1 C#: Update data-flow collection test method names 2020-04-20 09:29:51 +02:00
Tom Hvitved
161093bd57 C#: Rename arrays data-flow test to collections 2020-04-20 09:20:42 +02:00
Mathias Vorreiter Pedersen
a6e619ce5b C++: Add field flow through single-field structs and accept tests 2020-04-20 08:52:46 +02:00
Mathias Vorreiter Pedersen
6fca23bc8b C++: Demonstrate lack of flow through single-field structs 2020-04-20 08:50:31 +02:00
Asger Feldthaus
bb9fea5a27 JS: Refactor isAmbient computation 2020-04-19 22:45:19 +01:00
Grzegorz Golawski
40fcd4cbe5 Fix references 2020-04-19 20:49:07 +02:00
Grzegorz Golawski
457e2eaf59 CodeQL query to detect OGNL injections 2020-04-19 20:31:57 +02:00
Erik Krogh Kristensen
2632699397 Merge branch 'master' of git.semmle.com:Semmle/ql into Mispelled 2020-04-18 17:58:57 +02:00
Dave Bartolomeo
8041b74f1c C++: Fix formatting 2020-04-18 09:56:38 -04:00
Dave Bartolomeo
de5abdb29a C++/C#: Add missing QLDoc 2020-04-18 09:55:35 -04:00
semmle-qlci
243dea706e Merge pull request #3269 from erik-krogh/Promisify
Approved by esbena
2020-04-18 13:02:42 +01:00
Grzegorz Golawski
af48bc3e57 CodeQL query to detect JNDI injections 2020-04-17 21:45:42 +02:00
Robert Marsh
9008084b74 Merge pull request #3272 from dbartol/dbartol/DumpFixes
C++: A couple of fixes for IR dumps
2020-04-17 11:49:52 -07:00
Geoffrey White
a7c22db989 C++: Autoformat. 2020-04-17 18:50:41 +01:00
Geoffrey White
de751b0b75 C++: Correct UnsignedBitwiseAndExpr. 2020-04-17 17:10:59 +01:00
Geoffrey White
01d3257d72 C++: Add test cases involving casts. 2020-04-17 17:01:58 +01:00
Jonas Jensen
8ca6c57eef Merge pull request #3118 from MathiasVP/ir-flow-fields
C++: IR field flow
2020-04-17 15:49:19 +02:00
Erik Krogh Kristensen
cffa911661 retarget change note for 1.25 2020-04-17 14:22:57 +02:00
Erik Krogh Kristensen
a2ddf7bf8f retarget change-note for 1.25 2020-04-17 14:19:17 +02:00
Erik Krogh Kristensen
88f600fa34 more -> additional
Co-Authored-By: Esben Sparre Andreasen <esbena@github.com>
2020-04-17 14:14:08 +02:00
Mathias Vorreiter Pedersen
ba0429cf01 Merge branch 'master' into ir-flow-fields 2020-04-17 13:57:12 +02:00
Erik Krogh Kristensen
225dc4b017 change-note 2020-04-17 13:54:48 +02:00
Tom Hvitved
f91af7daf3 C#: Add more data-flow tests 2020-04-17 13:49:08 +02:00
Tom Hvitved
05ec75558d Java: Update test 2020-04-17 13:49:08 +02:00
Tom Hvitved
1b6e978a62 Data flow: Sync files 2020-04-17 13:49:06 +02:00
Tom Hvitved
de41e668b0 Data flow: No more flow summaries 2020-04-17 13:48:20 +02:00
Chris Gavin
e974006122 Merge pull request #3283 from jbj/mergeback-2020-04-17
Mergeback rc/1.24 -> master
2020-04-17 12:11:22 +01:00
Erik Krogh Kristensen
e72eed1db5 more -> additional
Co-Authored-By: Esben Sparre Andreasen <esbena@github.com>
2020-04-17 13:10:06 +02:00
Mathias Vorreiter Pedersen
8c03423f3e C++: Accept test output 2020-04-17 12:03:16 +02:00
Erik Krogh Kristensen
4a93b91d59 make maybePromisified private 2020-04-17 11:47:03 +02:00
Erik Krogh Kristensen
3b230648d2 change-note 2020-04-17 11:45:08 +02:00
Erik Krogh Kristensen
4f32157a78 rename func to callback
Co-Authored-By: Esben Sparre Andreasen <esbena@github.com>
2020-04-17 11:36:48 +02:00
Erik Krogh Kristensen
427c32f211 report a local variable as the misspelling if there any many occourances of the global 2020-04-17 11:25:23 +02:00
Tom Hvitved
c36142f129 C#: Add data-flow test for collections 2020-04-17 11:22:01 +02:00
Erik Krogh Kristensen
1b80f46f30 add QHelp for js/xss-through-dom query 2020-04-17 10:54:21 +02:00
Erik Krogh Kristensen
14b551f887 Xss through DOM 2020-04-17 10:54:14 +02:00
Jonas Jensen
c970e8a52e Merge remote-tracking branch 'upstream/rc/1.24' into mergeback-2020-04-17 2020-04-17 10:42:27 +02:00
Erik Krogh Kristensen
55edfed1ee support jQuery().get() returning a DOM node 2020-04-17 10:32:53 +02:00
Erik Krogh Kristensen
dd9aec056c handle basic dynamic method dispatch for jQuery methods 2020-04-17 10:32:52 +02:00
Erik Krogh Kristensen
eca98b42d2 basic support for util.promisify for NodeJSFileSystemAccess 2020-04-17 09:54:37 +02:00
Erik Krogh Kristensen
ea0f6a367d refactor into maybePromisified predicate 2020-04-17 09:50:08 +02:00
Dave Bartolomeo
c705797a2d C++: IR construction for _Imaginary types
Includes a fairly exhaustive test case for arithmetic operations involving `_Complex` and/or `_Imaginary` types. Thanks to these new tests, I discovered that the extractor treats certain arithmetic operations on `_Imaginary` types as separate expression kinds, so I added support for those kinds in IR construction.
2020-04-16 11:58:09 -04:00
Mathias Vorreiter Pedersen
62e2ffe623 C++: Make PartialDefinitionNode private and add/update comments based on review comments 2020-04-16 17:19:12 +02:00
Tom Hvitved
1959480b78 C#: Field-flow summaries for library code 2020-04-16 15:20:47 +02:00
Dave Bartolomeo
3dd3b5304e Merge remote-tracking branch 'upstream/master' into dbartol/floats 2020-04-16 08:44:41 -04:00
Taus
964a619450 Merge pull request #3211 from RasmusWL/python-unused-import-small-fix
Python: Fix FN in unused import
2020-04-16 14:22:50 +02:00
Taus
a92d926b56 Merge pull request #3218 from RasmusWL/python-add-missing-override
Python: Add missing override to ClassValue.hasAttribute
2020-04-16 14:06:23 +02:00
Taus Brock-Nannestad
2d8770d17c Python: Fix remaining deprecation warnings. 2020-04-16 14:03:21 +02:00
Geoffrey White
24d7446976 C++: Basic model of '&' and '>>' in SimpleRangeAnalysis. 2020-04-16 11:17:29 +01:00
Geoffrey White
2acbdecfdb C++: Add test cases. 2020-04-16 11:11:58 +01:00
Tom Hvitved
922e52f061 Merge pull request #3257 from hvitved/csharp/dataflow/tests
C#: Update data flow tests
2020-04-16 11:47:45 +02:00
Rasmus Wriedt Larsen
ab120ed7af Python: Remove deprecated annotation for old PointsTo::points_to
We should only deprecate it when we're ready to deprecate the old refersTo and
all the old Object classes
2020-04-16 09:47:45 +02:00
Robert Marsh
d0e047186a C++: add remote flow models for fread and gets 2020-04-15 18:01:04 -07:00
Robert Marsh
a006bd3117 C++: add model-based RemoteFlowSource 2020-04-15 17:46:00 -07:00
Dave Bartolomeo
2264ec714f C++: Better type preservation in getVariableType()
`getVariableType()` is used to compute the actual semantic type of a variable from its declared type. That's where we handle pointer and function decay for parameters, and it's also where we handle arrays of unknown bound initialized with an initializer of known bound.

Previously, even if neither of the above situations applied, the type that we returned was the `getUnspecifiedType()` of the variable. This meant that, for example, `const char* p` would be treated as `char *`. This is inconsistent with how we handle types elsewhere in IR construction, where we preserve typedefs and cv-qualifiers when creating the `CppType` of an `IRVariable`, `Instruction`, or `Operand`.

The only visible effect this fix has is to fix the inferred result type for `Phi` instructions for variables affect by this change in `getVariableType()` behavior. Previously, we would see the variable accessed as both `const char*` and as `char*`, so we'd fall back to the canonical pointer type, which is `decltype(nullptr)`. Now, we see the same type for all accesses to the variable, so we use that type as the type of the SSA memory location and as the result type of the `Phi` instruction.
2020-04-15 18:41:24 -04:00
Dave Bartolomeo
90dc14c56e C++/C#: Fix phantom Chi definitions in PrintSSA
When `PrintSSA.qll` is imported, IR dumps will be annotated with the alias analysis information used during SSA construction. When printing this information, we incorrectly treated instructions at offset -1, which should only be `Phi` instructions, as `Chi` instructions for the instruction at offset 0. This produced phantom annotations, but did not affect the correctness of the actual IR.
2020-04-15 18:24:11 -04:00
Mathias Vorreiter Pedersen
86ba03bea8 Merge pull request #3256 from Semmle/rdmarsh/cpp/add-qldoc-1
C++: Add QLdoc to some AST methods (Class.qll-Diagnostics.qll)
2020-04-15 21:46:36 +02:00
Erik Krogh Kristensen
69a16af152 Merge branch 'master' into Maps 2020-04-15 20:41:22 +02:00
Erik Krogh Kristensen
fd51142200 change succ in storeStep to be a SourceNode 2020-04-15 20:40:58 +02:00
Erik Krogh Kristensen
e8dc77d508 add support for util.promisify with child_process calls 2020-04-15 19:16:30 +02:00
Rasmus Wriedt Larsen
b179a0bdc2 Python: Add deprecated comment for FinalCustomPointsToFact 2020-04-15 16:59:07 +02:00
Rasmus Wriedt Larsen
5a51d2cc4c Merge pull request #3245 from BekaValentine/python-objectapi-to-valueapi-wrongnameforargumentinclassinstantiation
Python: ObjectAPI to ValueAPI: WrongNameForArgumentInClassInstantiation
2020-04-15 16:48:26 +02:00
Rasmus Wriedt Larsen
390959713a Merge pull request #3246 from BekaValentine/python-objectapi-to-valueapi-uselessclass
Python: ObjectAPI to ValueAPI: UselessClass
2020-04-15 16:45:02 +02:00
Jonas Jensen
aa8f30cd83 Merge pull request #3268 from MathiasVP/ql-doc-negativitiy
C++: Add QLDoc to public predicates in Negativity.qll
2020-04-15 15:12:07 +02:00
Mathias Vorreiter Pedersen
3d0ac53266 Apply suggestions from code review
Co-Authored-By: Jonas Jensen <jbj@github.com>
2020-04-15 14:01:49 +02:00
Geoffrey White
b8acd702d6 C++: Rename the test for consistency. 2020-04-15 12:49:07 +01:00
semmle-qlci
bfd80b42a7 Merge pull request #3260 from asger-semmle/js/location-tweaks
Approved by erik-krogh
2020-04-15 10:47:35 +01:00
Asger F
34d40b5035 Merge pull request #3237 from asger-semmle/js/sparse-capture
JS: Add CapturedVariableNode to avoid N^2 edges
2020-04-15 10:42:48 +01:00
Mathias Vorreiter Pedersen
f02feac33a C++: Add flow from #3220 2020-04-15 11:34:19 +02:00
Mathias Vorreiter Pedersen
209e084820 Merge branch 'master' into ir-flow-fields 2020-04-15 10:51:45 +02:00
Mathias Vorreiter Pedersen
a2fbe9e9da C++: Add QLDoc to public predicates in Negativity 2020-04-15 08:18:03 +02:00
Jonas Jensen
b603a3da64 Merge pull request #3259 from MathiasVP/ql-doc-fileclosed-loopbounds-memoryfreed
C++: QLDoc for FileClosed, LoopBounds and MemoryFreed
2020-04-15 08:08:04 +02:00
Jonas Jensen
6eac35c753 Merge pull request #3264 from Semmle/merge-rc/1.24
Merge rc/1.24 into master.
2020-04-15 07:56:58 +02:00
Jonas Jensen
ae11e7b72c Merge pull request #3265 from Semmle/rdmarsh/cpp/deprecate-isDefined
C++: deprecate Declaration::isDefined()
2020-04-15 07:53:19 +02:00
Chris Gavin
4e981d8e70 Merge rc/1.24 into master. 2020-04-14 21:30:29 +01:00
Robert Marsh
146bfca2ad Merge pull request #3254 from dbartol/dbartol/ImplicitReturnValue2
C++: Treat implicit end of body of non`-void` function as `Unreached`
2020-04-14 12:18:50 -07:00
Asger Feldthaus
1107e7c6a6 JS: Rename other uses of getURL 2020-04-14 19:45:09 +01:00
Dave Bartolomeo
279467654e C++: Make test functions return void 2020-04-14 14:17:56 -04:00
Dave Bartolomeo
812087968f C++: Fix test output
Mostly noise, but a couple of the missing operand errors are actual fixes.
2020-04-14 14:17:20 -04:00
Robert Marsh
b5c0a0f77d C++: remove all uses of Declaration::isDefined 2020-04-14 10:54:06 -07:00
Robert Marsh
5ee60762fe C++: deprecate Declaration::isDefined() 2020-04-14 10:49:52 -07:00
Robert Marsh
7f5b3de665 C++: autoformat 2020-04-14 10:36:53 -07:00
Robert Marsh
be81a1a8b3 Merge pull request #3255 from dbartol/dbartol/UnmodeledDefinition
C++: Connect `InitializeIndirection` to `UnmodeledDefinition`
2020-04-14 10:34:30 -07:00
Taus
8402e6a2e1 Merge pull request #3243 from BekaValentine/python-objectapi-to-valueapi-incorrectlyspecifiedoverriddenmethod
Python: ObjectAPI to ValueAPI: IncorrectlySpecifiedOverriddenMethod
2020-04-14 18:55:42 +02:00
Mathias Vorreiter Pedersen
092145d571 Update cpp/ql/src/Critical/FileClosed.qll
Co-Authored-By: Jonas Jensen <jbj@github.com>
2020-04-14 18:38:33 +02:00
Dave Bartolomeo
125a09ce6e C++: Fix IR generation of return of void expression 2020-04-14 11:40:33 -04:00
Dave Bartolomeo
95a6dd01c6 C#: Accept test output 2020-04-14 11:11:36 -04:00
Dave Bartolomeo
83cd78c6cf C++: Fix test output 2020-04-14 10:54:00 -04:00
Asger F
c178eecd43 Update javascript/ql/src/semmle/javascript/Variables.qll
Co-Authored-By: Erik Krogh Kristensen <erik-krogh@github.com>
2020-04-14 14:40:21 +01:00
Taus
3e46604fa5 Merge pull request #3223 from BekaValentine/python-objectapi-to-valueapi-iterreturnsnoniterator
Python: ObjectAPI to ValueAPI: IterReturnsNonIterator
2020-04-14 12:55:21 +02:00
Taus
d9a2429de8 Merge pull request #3244 from BekaValentine/python-objectapi-to-valueapi-wrongnumberargumentsinclassinstantiation
Python: ObjectAPI to ValueAPI: WrongNumberArgumentsInClassInstantiation
2020-04-14 12:46:29 +02:00
semmle-qlci
e21164e5ac Merge pull request #3258 from erik-krogh/NormalPathSanitizer-patch1
Approved by asgerf
2020-04-14 11:31:45 +01:00
semmle-qlci
52b76b1373 Merge pull request #3233 from RasmusWL/python-use-getAbsolutePath
Approved by BekaValentine
2020-04-14 10:43:24 +01:00
Mathias Vorreiter Pedersen
419b511ddb C++: Format 2020-04-14 11:39:44 +02:00
semmle-qlci
2e95cab970 Merge pull request #3234 from RasmusWL/python-modenise-files
Approved by BekaValentine
2020-04-14 10:38:26 +01:00
Asger Feldthaus
3515a2b412 JS: Update test output 2020-04-14 10:31:31 +01:00
Asger Feldthaus
88667206fc JS: Remove default hasLocationInfo case 2020-04-14 10:03:10 +01:00
Asger Feldthaus
5da968e34c JS: Specialize ASTNode.getFile 2020-04-14 10:03:10 +01:00
Asger Feldthaus
244a304e1d JS: Implement getFile() directly instead of via locations 2020-04-14 10:03:10 +01:00
Asger Feldthaus
dc084628cc JS: Avoid the special name getURL 2020-04-14 10:03:09 +01:00
Erik Krogh Kristensen
6827b84bdc change docstring to inline comment, and refer directly to array class 2020-04-14 10:32:16 +02:00
Erik Krogh Kristensen
e47575ce5b more precise getChild for matching "../" 2020-04-14 10:24:08 +02:00
Mathias Vorreiter Pedersen
d8dcbe3cbd C++: QLDoc for FileClosed, LoopBounds and MemoryFreed 2020-04-14 10:21:11 +02:00
Tom Hvitved
a9b88b6eaa C#: Update data flow tests 2020-04-14 09:31:10 +02:00
Robert Marsh
10824f9612 C++: add method qldoc in Class.qll 2020-04-13 15:49:37 -07:00
Dave Bartolomeo
1bde11706e C++: Connect InitializeIndirection to UnmodeledDefinition
The IR generation for `InitializeIndirection` currently connects its load operand to the result of the corresponding `InitializeParameter` instruction. This isn't exactly wrong, but it doesn't fit the IR invariant of "All unmodeled uses consume `UnmodeledDefinition`". Our current code doesn't care, because we just throw away all of the existing def-use information, modeled or otherwise, when we build unaliased SSA. However, some upcoming SSA changes don't work correctly if this invariant is broken.

I've added the trivial IR generation change, along with a new sanity query.
2020-04-13 18:37:47 -04:00
Dave Bartolomeo
603a3af19b C++: Treat implicit end of body of non-void function as Unreached
When the extractor can't prove that control flow will never reach the end of a non-`void`-returning function without reaching an explicit `return` statement, it inserts an implicit `return` without an operand. If control actually reaches this point, the behavior is undefined.

We were previously generating invalid IR for these implicit `return` statements, because the lack of an operand meant that there was no definition of the return value variable along that path. Instead, I've changed the IR generation to emit an `Unreached` instruction for the implicit `return`. This ensures that we don't create a control flow edge from the end of the body to the function epilogue.

The change to the range analysis test avoids having that test depend on the previous bad IR behavior, while still preserving the original spirit of the test.
2020-04-13 18:09:44 -04:00
Robert Marsh
f24c4e51c5 C++: add method qldoc in Diagnostics.qll 2020-04-13 14:58:30 -07:00
Robert Marsh
d065389a6b C++: add method commetns in Compilation.qll 2020-04-13 14:41:25 -07:00
Robert Marsh
de29d93ede C++: add method qldoc for Comment.qll 2020-04-13 14:39:51 -07:00
Mathias Vorreiter Pedersen
cde34c9b1b C++: Accept test output which I previously forgot to accept 2020-04-13 16:19:21 +02:00
Mathias Vorreiter Pedersen
daac5c5ab3 Merge branch 'master' into ir-flow-fields 2020-04-13 14:19:17 +02:00
Mathias Vorreiter Pedersen
945ecffd05 C++: Add charpred to ParameterNode 2020-04-13 14:18:57 +02:00
Pavel Avgustinov
7c5c9ea8ea Merge pull request #3240 from Semmle/update-license-in-readme
Update README to reflect new license
2020-04-10 17:36:36 +01:00
Rebecca Valentine
8e91f10030 Python: ObjectAPI to ValueAPI: UselessClass: Adds preliminary modernization 2020-04-09 15:25:38 -07:00
Rebecca Valentine
339758fa70 Python: ObjectAPI to ValueAPI: WrongNameForArgumentInClassInstantiation: Adds preliminary modernization 2020-04-09 15:04:44 -07:00
Rebecca Valentine
8dc1933a02 Python: ObjectAPI to ValueAPI: WrongNumberArgumentsInClassInstantiation: Adds preliminary modernization 2020-04-09 14:58:30 -07:00
Rebecca Valentine
336e48c5c6 Python: ObjectAPI to ValueAPI: IncorrectlySpecifiedOverriddenMethod: Adds preliminary modernization 2020-04-09 14:50:26 -07:00
Rebecca Valentine
be00d71b99 Python: ObjectAPI to ValueAPI: IncorrectlyOverriddenMethod: Adds preliminary modernization 2020-04-09 14:41:22 -07:00
Rebecca Valentine
7a586c97a4 Python: ObjectAPI to ValueAPI: IterReturnsNonIterature: Replaces custom return_type predicate with call to getAnInferredReturnType 2020-04-09 14:30:40 -07:00
Mathias Vorreiter Pedersen
7f5330dd0a Merge branch 'master' into ir-flow-fields 2020-04-09 16:08:44 +02:00
Henry Mercer
5af7d5f03a Update README to reflect new license
Per https://github.com/Semmle/ql/pull/3205, code is now licensed under the MIT License.
2020-04-09 13:06:53 +01:00
Asger Feldthaus
c070416fbe JS: Update test output 2020-04-09 12:24:11 +01:00
Asger Feldthaus
25d5cc78cb JS: Use entry location instead of whole container 2020-04-09 09:18:26 +01:00
Asger Feldthaus
d9f81b082b JS: Autoformat 2020-04-09 07:45:00 +01:00
luchua-bc
b7f2d32fb0 Address improper URL authorization 2020-04-08 22:41:11 -04:00
luchua-bc
e1a680cd86 Address improper URL authorization 2020-04-08 22:41:11 -04:00
Asger Feldthaus
47934310ef JS: Hide captured nodes in path explanations 2020-04-08 19:58:36 +01:00
Rasmus Wriedt Larsen
a2440f0fcd Python: Modernise semmle/python/dataflow/Files.qll 2020-04-08 16:53:19 +02:00
Rasmus Wriedt Larsen
32c04ad765 Python: Use getAbsolutePath() instead of deprecated getName() 2020-04-08 16:46:33 +02:00
Rasmus Wriedt Larsen
ac3acb9187 Python: Add more deprecated annotations
These classes/predicates are not used by anything in our codebase, and is using
deprecated classes/predicates, so I think it's safe to assume they should also
have been marked with the deprecated annotation.

Changes the QL compiler warnings with:

-WARNING: Type Configuration has been deprecated and may be removed in future (/home/rasmus/code/ql/python/ql/src/semmle/python/dataflow/TaintTracking.qll:663,50-63)
-WARNING: Type Configuration has been deprecated and may be removed in future (/home/rasmus/code/ql/python/ql/src/semmle/python/dataflow/TaintTracking.qll:666,19-32)
-WARNING: Type Configuration has been deprecated and may be removed in future (/home/rasmus/code/ql/python/ql/src/semmle/python/dataflow/TaintTracking.qll:671,19-32)
-WARNING: Type Configuration has been deprecated and may be removed in future (/home/rasmus/code/ql/python/ql/src/semmle/python/dataflow/TaintTracking.qll:733,16-39)

-WARNING: Type CustomPointsToAttribute has been deprecated and may be removed in future (/home/rasmus/code/ql/python/ql/src/semmle/python/types/Extensions.qll:181,28-51)

-WARNING: Type CustomPointsToFact has been deprecated and may be removed in future (/home/rasmus/code/ql/python/ql/src/semmle/python/types/Extensions.qll:155,60-78)
-WARNING: Type CustomPointsToFact has been deprecated and may be removed in future (/home/rasmus/code/ql/python/ql/src/semmle/python/types/Extensions.qll:159,19-37)
-WARNING: Type CustomPointsToFact has been deprecated and may be removed in future (/home/rasmus/code/ql/python/ql/src/semmle/python/types/Extensions.qll:41,33-51)
+WARNING: Type CustomPointsToFact has been deprecated and may be removed in future (/home/rasmus/code/ql/python/ql/src/semmle/python/types/Extensions.qll:41,44-62)
2020-04-08 15:10:35 +02:00
Mathias Vorreiter Pedersen
d65c52d281 Merge branch 'master' into ir-flow-fields 2020-04-08 09:16:42 +02:00
Rebecca Valentine
0d65db148f Python: ObjectAPI to ValueAPI: IterReturnsNonIterator: Adds preliminary modernization 2020-04-07 21:14:25 -07:00
Rebecca Valentine
1d4f341b16 Merge branch 'master' into python-objectapi-to-valueapi-wrongnumberargumentsincall 2020-04-07 13:33:25 -07:00
Mathias Vorreiter Pedersen
52b179aee5 Merge branch 'master' into ir-flow-fields 2020-04-07 21:27:17 +02:00
Calum Grant
4c7d413fa4 C#: Address review comment. 2020-04-07 19:58:48 +01:00
Asger Feldthaus
1f496d3c6b JS: Add CapturedVariableNode 2020-04-07 19:02:46 +01:00
Mathias Vorreiter Pedersen
d56284fe8f C++: Move added flow from simpleLocalFlowStep to simpleInstructionLocalFlowStep and remove flow that could cause field conflation 2020-04-07 16:00:40 +02:00
Rasmus Wriedt Larsen
7af5f038ab Python: Add missing override to ClassValue.hasAttribute
I was considering if this was actually something different than
Value.hasAttribute, and the names were just accidentially the same. But after
looking at the definition for Value, I'm happy about marking this as an
override (I did not test whether it was neede though):

```codeql
class Value extends TObject {
    ...

    /** Holds if this value has the attribute `name` */
    predicate hasAttribute(string name) { this.(ObjectInternal).hasAttribute(name) }
```
2020-04-07 14:02:53 +02:00
Calum Grant
abf6be6030 C#: Avoid qualifying explicit interface implementations. 2020-04-07 11:17:35 +01:00
Calum Grant
9ec0c8f3ec C#: Qualify type parameters with the entity that declares them 2020-04-07 11:17:35 +01:00
Calum Grant
39eb1a3825 C#: Remove assembly qualifier from some trap-ids. 2020-04-07 11:17:34 +01:00
Mathias Vorreiter Pedersen
5719967a8e C++: Remove single-field case from PostUpdateNode and accept tests 2020-04-07 12:03:28 +02:00
Rasmus Wriedt Larsen
befe73df14 Python: supress non-useful results (w/ tests) for iter str/seq query
Fixes https://github.com/Semmle/ql/issues/3207
2020-04-07 11:46:36 +02:00
Rasmus Wriedt Larsen
94ccc16f85 Python: iter str/seq query gives non-useful results with tests 2020-04-07 11:46:35 +02:00
Rasmus Wriedt Larsen
46ecbef8f2 Python: Consistenly use TestScope instead of Test
It's not clear which one is the correct to use, but there were more uses of
TestScope than Test, so I'm assuming that is the right one ¯\_(ツ)_/¯
2020-04-07 11:42:13 +02:00
Rasmus Wriedt Larsen
2871eb307a Python: Fix (some) shortcomings of tests filter 2020-04-07 11:24:06 +02:00
Rasmus Wriedt Larsen
6ed7b3dd92 Python: Add tests to illustrate shortcomings of current tests filter 2020-04-07 11:22:16 +02:00
Rasmus Wriedt Larsen
75e6470009 Python: Fix FN in py/unused-import 2020-04-07 09:41:42 +02:00
Rasmus Wriedt Larsen
1077ce3a35 Python: Add FN for py/unused-import 2020-04-07 09:26:14 +02:00
Rebecca Valentine
c1ba1345df Python: ObjAPI to ValAPI: WrongNumArgsInCall: ObjectAPI.qll: Adds doc for getAnInferredType 2020-04-06 11:03:42 -07:00
Rebecca Valentine
16eedf9ea5 Merge branch 'master' into python-objectapi-to-valueapi-wrongnumberargumentsincall 2020-04-06 10:35:49 -07:00
Jonas Jensen
0743c42807 Merge remote-tracking branch 'upstream/master' into dataflow-indirect-args
Accepted test results that were in semantic merge conflict between
these branches. The changed results are due to a bug that that's part of
https://github.com/github/codeql-c-analysis-team/issues/35.
2020-04-06 19:26:08 +02:00
Jonas Jensen
e37aab5002 C++: Suppress FieldAddressInstruction taint
See code comment. This fixes false positives on openjdk/jdk.
2020-04-06 16:14:26 +02:00
Jonas Jensen
3b76509159 C++: Test DefaultTaintTracking field conflation 2020-04-06 16:13:41 +02:00
Mathias Vorreiter Pedersen
c577541850 C++: Fix reverse read dataflow consistency failure and accept tests 2020-04-06 15:50:08 +02:00
Jonas Jensen
bf7614a4c9 C++: Move Expr location workaround to Expr.qll
This workaround from `DataFlowUtil.qll` should be useful for any query
that selects an `Expr`. In particular, it's useful for IR data flow.

This commit does not include test changes.
2020-04-06 14:13:22 +02:00
Jonas Jensen
d4338473b0 C++: Enforce unique enclosing callable
Every data-flow node should have a unique enclosing function (_callable_
in the terminology of the data-flow library), but this was not evident
for the optimizer, and it led to a bad join order in `pathStep`. This
commit fixes the join order for C++ AST data flow. All other copies of
data flow seem to be fine.

These are the tuple counts for OpenJDK before this commit:

    (231s) Tuple counts for DataFlowImplLocal::pathStep#fffff#cur_delta:
    5882       ~0%       {6} r1 = SCAN DataFlowImplLocal::PathNodeMid#class#ffffff#prev_delta AS I OUTPUT I.<2>, I.<0>, I.<1>, I.<3>, I.<4>, I.<5>
    1063406780 ~0%       {7} r2 = JOIN r1 WITH DataFlowImplCommon::CallContext::relevantFor_dispred#ff AS R ON FIRST 1 OUTPUT r1.<2>, R.<1>, r1.<1>, r1.<0>, r1.<3>, r1.<4>, r1.<5>
    5882       ~1%       {6} r3 = JOIN r2 WITH DataFlowUtil::Node::getFunction_dispred#ff AS R ON FIRST 2 OUTPUT r2.<0>, r2.<6>, r2.<2>, r2.<3>, r2.<4>, r2.<5>
    105        ~0%       {5} r4 = JOIN r3 WITH project#DataFlowImplLocal::LocalFlowBigStep::localFlowBigStep#ffffff_021#join_rhs AS R ON FIRST 2 OUTPUT r3.<2>, r3.<3>, r3.<4>, r3.<5>, R.<2>
    5882       ~1%       {6} r5 = JOIN r2 WITH DataFlowUtil::Node::getFunction_dispred#ff AS R ON FIRST 2 OUTPUT r2.<5>, r2.<2>, r2.<0>, r2.<3>, r2.<4>, r2.<6>
    5882       ~0%       {6} r6 = JOIN r5 WITH DataFlowImplLocal::TNil#ff_1#join_rhs AS R ON FIRST 1 OUTPUT r5.<2>, false, r5.<5>, r5.<1>, r5.<3>, r5.<4>
    0          ~0%       {5} r7 = JOIN r6 WITH DataFlowImplLocal::LocalFlowBigStep::localFlowBigStep#ffffff_02413#join_rhs AS R ON FIRST 3 OUTPUT R.<4>, r6.<3>, r6.<4>, r6.<5>, R.<3>
    0          ~0%       {5} r8 = JOIN r7 WITH DataFlowImplLocal::TNil#ff AS R ON FIRST 1 OUTPUT r7.<1>, r7.<2>, r7.<3>, R.<1>, r7.<4>
    105        ~0%       {5} r9 = r4 \/ r8

The problem is that `DataFlowUtil::Node::getFunction_dispred#ff`
(`getEnclosingCallable`) is joined too late.

After this commit, the tuple counts look like this:

    (13s) Tuple counts for DataFlowImplLocal::pathStep#fffff#cur_delta:
    5882    ~1%       {6} r1 = SCAN DataFlowImplLocal::PathNodeMid#class#ffffff#prev_delta AS I OUTPUT I.<1>, I.<0>, I.<2>, I.<3>, I.<4>, I.<5>
    5882    ~3%       {7} r2 = JOIN r1 WITH DataFlowUtil::Node::getEnclosingCallable_dispred#ff AS R ON FIRST 1 OUTPUT r1.<2>, R.<1>, r1.<1>, r1.<0>, r1.<3>, r1.<4>, r1.<5>
    5882    ~1%       {6} r3 = JOIN r2 WITH DataFlowImplCommon::CallContext::relevantFor_dispred#ff AS R ON FIRST 2 OUTPUT r2.<3>, r2.<6>, r2.<2>, r2.<0>, r2.<4>, r2.<5>
    105     ~0%       {5} r4 = JOIN r3 WITH project#DataFlowImplLocal::LocalFlowBigStep::localFlowBigStep#ffffff_021#join_rhs AS R ON FIRST 2 OUTPUT r3.<2>, r3.<3>, r3.<4>, r3.<5>, R.<2>
    5882    ~1%       {6} r5 = JOIN r2 WITH DataFlowImplCommon::CallContext::relevantFor_dispred#ff AS R ON FIRST 2 OUTPUT r2.<5>, r2.<2>, r2.<3>, r2.<0>, r2.<4>, r2.<6>
    5882    ~0%       {6} r6 = JOIN r5 WITH DataFlowImplLocal::TNil#ff_1#join_rhs AS R ON FIRST 1 OUTPUT r5.<2>, false, r5.<5>, r5.<1>, r5.<3>, r5.<4>
    0       ~0%       {5} r7 = JOIN r6 WITH DataFlowImplLocal::LocalFlowBigStep::localFlowBigStep#ffffff_02413#join_rhs AS R ON FIRST 3 OUTPUT R.<4>, r6.<3>, r6.<4>, r6.<5>, R.<3>
    0       ~0%       {5} r8 = JOIN r7 WITH DataFlowImplLocal::TNil#ff AS R ON FIRST 1 OUTPUT r7.<1>, r7.<2>, r7.<3>, R.<1>, r7.<4>
    105     ~0%       {5} r9 = r4 \/ r8

There is a slight slowdown coming from the introduction of a new
predicate `DataFlowImplLocal::pathStep#fffff#join_rhs`, which is used
only in the standard order:

    (12s) Tuple counts for DataFlowImplLocal::pathStep#fffff#join_rhs:
    282057  ~0%     {2} r1 = SCAN DataFlowImplCommon::CallContext::relevantFor_dispred#ff AS I OUTPUT I.<1>, I.<0>
    9159890 ~1%     {2} r2 = JOIN r1 WITH DataFlowUtil::Node::getEnclosingCallable_dispred#ff_10#join_rhs AS R ON FIRST 1 OUTPUT R.<1>, r1.<1>
                    return r2

The evaluation of `unique` is cheap but not free:

    DataFlowUtil::Node::getEnclosingCallable_dispred#ff .............. 3.9s
    DataFlowUtil::Node::getEnclosingCallable_dispred#ff_10#join_rhs .. 3.5s

The first of these two predicates evaluates `unique`, and the second
simply reorders columns. They take about the same time, which suggests
that `unique` is about as fast as it can be, given the number of tuples
it needs to push around. Note that the column reordering predicate is
only needed because of the standard order.
2020-04-06 12:04:39 +02:00
Mathias Vorreiter Pedersen
3aa293210d C++: Ensure that only non-conflated chi instructions are used everywhere 2020-04-06 12:02:56 +02:00
Jonas Jensen
46fc91315b Java/C++/C#: Revert the join order fix from #2872
This revert brings back the performance problems in
`DataFlowImplLocal.qll` so they can be fixed in a different way. The fix
in #2872 was asymptotically good but had undesired overhead because it
introduced another predicate in the SCC that existed purely for join
ordering.

I did the revert by inlining the helper predicate, eliminating the
`enclosing` variable, and re-ordering the resulting lines to what they
were before #2872.
2020-04-06 10:04:50 +02:00
Mathias Vorreiter Pedersen
317734f41e C++: Attach PostUpdateNodes to Chi nodes following aschackmull's suggestion 2020-04-05 22:35:26 +02:00
Rebecca Valentine
01aac8273c Python: ObjAPI to ValAPI: WrongNumArgsInCall: Update queries to use objectapi 2020-04-04 03:11:25 -07:00
Rebecca Valentine
8c1aeb24cb Python: ObjAPI to ValAPI: WrongNumArgsInCall: Updates query expected results 2020-04-04 00:57:09 -07:00
Rebecca Valentine
88be3359ac Python: ObjAPI to ValAPI: WrongNumForArgsInCall: Update affected queries to use objectapi 2020-04-04 00:15:10 -07:00
Rebecca Valentine
26bdb9ab04 Python: ObjAPI to ValAPI: WrongNumArgsInCall: Exceptions.qll: Removes extraneous spaces in comments 2020-04-03 20:33:17 -07:00
Rebecca Valentine
bbe7314c17 Python: ObjAPI to ValAPI: WrongNumArgsInCall: Autoformats ObjectAPI.qll 2020-04-03 20:30:24 -07:00
Rebecca Valentine
7615452b31 Python: ObjAPI to ValAPI: WrongNumArgsInCall: Autoformat CallArgs.qll 2020-04-03 20:28:19 -07:00
Rebecca Valentine
1e76720a92 Merge branch 'master' into python-objectapi-to-valueapi-wrongnumberargumentsincall 2020-04-03 20:25:53 -07:00
Rebecca Valentine
e0f26d4f7e Python: ObjectAPI to ValueAPI: WrongNumberArgumentsInCall: Updates expected results 2020-04-03 20:11:42 -07:00
Rebecca Valentine
f25428b7a9 Python: ObjectAPI to ValueAPI: WrongNumberArgumentsInCall: Exceptions.qll: Fixes incorrect implementation of localRaisedType 2020-04-03 20:08:00 -07:00
Rebecca Valentine
c6fbbb1cd1 Python: ObjectAPI to ValueAPI: WrongNumberArgumentsInCall: CallArgs.qll: Fixes too_*_args refs to getA*Call 2020-04-03 20:06:43 -07:00
Rebecca Valentine
2ad0f5af2d Python: ObjectAPI to ValueAPI: WrongNumberArgumentsInCall: ObjectAPI.qll: Adds getAFunctionCall and getAMethodCall predicates to FunctionValue 2020-04-03 20:04:32 -07:00
Grzegorz Golawski
1d8da905ac Make the test runnable via codeql test run 2020-04-03 21:44:13 +02:00
ggolawski
79d7ea36ff Update java/ql/src/experimental/Security/CWE/CWE-016/SpringBootActuators.qll
Co-Authored-By: Anders Schack-Mulligen <aschackmull@users.noreply.github.com>
2020-04-03 21:36:34 +02:00
Tom Hvitved
8d81b885c6 C#: Unset Platform env variable when invoking vcvarsall.bat 2020-04-03 14:47:34 +02:00
Grzegorz Golawski
6ca963a8c8 Fix 2020-04-03 00:30:02 +02:00
Grzegorz Golawski
f05b2af69d Move to experimental 2020-04-03 00:27:51 +02:00
Grzegorz Golawski
cffe89f652 Merge branch 'master' into java-spring-boot-actuators 2020-04-02 22:06:25 +02:00
Rebecca Valentine
2a7b77c0e1 Python: ObjectAPI to ValueAPI: WrongNumberArgumentsInCall: Adds new version of FunctionObject.qll 2020-04-02 12:18:07 -07:00
Rebecca Valentine
161613f59e Python: ObjectAPI to ValueAPI: WrongNumberArgumentsInCall: Adds new version of Exceptions.qll 2020-04-02 12:17:14 -07:00
Rebecca Valentine
6517feda9a Python: ObjectAPI to ValueAPI: WrongNumberArgumentsInCall: Adds new version of ObjectsAPI.qll 2020-04-02 11:56:15 -07:00
Erik Krogh Kristensen
845020d2ae change getReceiver to getAMethodCall 2020-04-02 20:28:27 +02:00
Erik Krogh Kristensen
2c0bae4937 Apply suggestions from code review
Co-Authored-By: Esben Sparre Andreasen <esbena@github.com>
2020-04-02 20:28:04 +02:00
Mathias Vorreiter Pedersen
ce5d8d516f Merge branch 'master' into ir-flow-fields 2020-04-02 15:23:00 +02:00
Mathias Vorreiter Pedersen
dda3aaa8aa C++: Add QLDoc to public classes and predicates 2020-04-02 14:00:33 +02:00
Mathias Vorreiter Pedersen
af9e05b9cd C++: Accept test 2020-04-02 10:57:11 +02:00
Mathias Vorreiter Pedersen
020c273dc9 Merge branch 'master' into ir-flow-fields 2020-04-02 10:45:58 +02:00
Erik Krogh Kristensen
75b183bc33 update expected output 2020-04-01 20:46:49 +02:00
Erik Krogh Kristensen
32b86ab91a autoformat 2020-04-01 20:44:47 +02:00
Geoffrey White
452d1d084f Add details about query tagging to supported-queries.md
Add some details about query tagging (see https://wiki.semmle.com/display/IN/Query+tags and https://wiki.semmle.com/display/IN/Modelling+CWEs+at+Semmle).
2020-04-01 16:36:06 +01:00
Erik Krogh Kristensen
957b60f84b split fuzzy read/writes on collections into 2 pseudo-properties 2020-04-01 14:25:41 +02:00
Erik Krogh Kristensen
b1bf7f9f3d introduce pseudoProperty helper predicates 2020-04-01 14:08:56 +02:00
Erik Krogh Kristensen
59840149e8 introduce a PseudoProperty type in Collections.qll 2020-04-01 12:16:09 +02:00
Erik Krogh Kristensen
b2b009cdd9 qldoc adjustment 2020-04-01 11:34:25 +02:00
Erik Krogh Kristensen
1be326a37b add a CopyStep type-tracking step, for loadStoreSteps that loads and stores the same property 2020-04-01 11:21:05 +02:00
Erik Krogh Kristensen
9fc8ed17cd remove unused import 2020-04-01 11:18:11 +02:00
Erik Krogh Kristensen
a188c6f804 qldoc changes and renaming 2020-04-01 11:12:54 +02:00
Rebecca Valentine
0256eb15bf Merge branch 'master' into python-objectapi-to-valueapi-wrongnumberargumentsincall 2020-03-31 22:58:11 -07:00
Rebecca Valentine
741317bd05 Python: ObjectAPI to ValueAPI: Makes isAbstract a predicate in CallArgs 2020-03-31 22:56:44 -07:00
Erik Krogh Kristensen
49a8a48a72 autoformat 2020-03-31 20:27:05 +02:00
Erik Krogh Kristensen
cec2cd3b14 update expected output 2020-03-31 14:05:05 +02:00
Erik Krogh Kristensen
64c813612f autoformat 2020-03-31 13:56:01 +02:00
Erik Krogh Kristensen
8ae55fb1c4 add top level QLDoc to MapAndSet.qll 2020-03-31 13:55:34 +02:00
Erik Krogh Kristensen
546431c83d dataflow and typetracking steps for Maps and Sets 2020-03-31 11:21:34 +02:00
Erik Krogh Kristensen
25aea900b6 add more dataflow steps for Arrays 2020-03-31 11:21:25 +02:00
Erik Krogh Kristensen
a02213e745 change LoadStoreStep such that it can store in different property 2020-03-31 11:20:57 +02:00
Erik Krogh Kristensen
f55005a0ec more precise warning message for implicit string/number conversions 2020-03-30 11:17:56 +02:00
Dave Bartolomeo
6b24e3c8be C++: Fix formatting 2020-03-29 08:18:05 -04:00
luchua-bc
000d894d99 Include Gradle Logging 2020-03-28 14:00:28 -04:00
Mathias Vorreiter Pedersen
7fce4ce9d1 Include join order fix from #3142 2020-03-28 12:34:05 +01:00
Dave Bartolomeo
434e11c0c5 C++: Fix test output 2020-03-27 19:47:08 -04:00
Dave Bartolomeo
39dd9b7099 C++/C#: Fix formatting 2020-03-27 19:46:53 -04:00
luchua-bc
048a33e143 Remove user ids from the check since they get logged a lot and are less sensitive 2020-03-27 19:40:00 -04:00
Dave Bartolomeo
c3a6ca0d9a C++: Better support for complex numbers in IR and AST
This PR adds better support for differentiating complex and imaginary floating-point types from real floating-point types, in both the AST and in the IR type system.

*AST Changes*
- Introduces the new class `TypeDomain`, which can be either `RealDomain`, `ImaginaryDomain` or `ComplexDomain`. "type domain" is the term used for this concept in the C standard, and I couldn't think of a better one.
- Introduces `FloatingPointType.getDomain()`, to get the type domain of the type.
- Introduces `FloatingPointType.getBase()`, to get the numeric base of the type (either 2 or 10).
- Introduces three new subtypes of `FloatingPointType`: `RealNumberType`, `ComplexNumberType`, and `ImaginaryNumberType`, which differentiate between the types based on their type domain. Note that the decimal types (e.g., `_Decimal32`) are included in `RealNumberType`.
- Introduces two new subtypes of `FloatingPointType`: `BinaryFloatingPointType` and `DecimalFloatingPointType`, which differentiate between the types based on their numeric base, independent of type domain.

*IR Changes*
- `IRFloatingPointType` now has two additional parameters: the base and the type domain.
- New test that ensures that C++ types get mapped to the correct IR types.
- New IR test that verifies the IR for some basic usage of complex FP types.
2020-03-27 18:08:14 -04:00
Jonas Jensen
710eb0cab9 C++: Replace "min = max" with "unique"
With the new `unique` aggregate added to QL, we can express directly
what the "min = max" pattern emulates.

Replacing "min and max" with `unique` might in general lead to fewer
results, but that happens only in cases where the aggregate expression
has multiple values. For the three predicates changed in this commit,
that should only happen on malformed databases.
2020-03-27 17:15:09 +01:00
Mathias Vorreiter Pedersen
5ba5791ec6 C++: Only allow flow through non-conflated chi instructions 2020-03-27 13:37:17 +01:00
Mathias Vorreiter Pedersen
580310f321 Merge branch 'master' into ir-flow-fields 2020-03-27 13:32:26 +01:00
Jonas Jensen
95f116eb48 Merge branch 'DefaultTaintTracking-argv' into dataflow-indirect-args 2020-03-26 20:47:50 +01:00
Jonas Jensen
08c53d4a61 C++: Clean up the ParameterNode class tree
The new names are chosen to align with Java's `DataFlowUtil.qll`.
2020-03-26 11:57:53 +01:00
Mathias Vorreiter Pedersen
a43abaaed9 Merge branch 'master' into ir-flow-fields 2020-03-26 11:51:07 +01:00
Mathias Vorreiter Pedersen
c6c613840a C++: Removed toString from PostUpdateNodes. They were more confusing than helpful 2020-03-26 11:43:40 +01:00
Mathias Vorreiter Pedersen
fbef146a49 C++: Remove PositionalArgumentWithoutWriteSideEffectNode (since not all arguments need a PostUpdateNode). Also generalized the added flow rule in simpleLocalFlowStep since there isn't always a ChiInstruction - for instance of it's a write to a struct that only has a single field. 2020-03-26 11:39:20 +01:00
Jonas Jensen
b622d62d3c C++: Wire up param/arg indirections in data flow 2020-03-25 15:23:43 +01:00
Mathias Vorreiter Pedersen
f92dd3c565 C++: Autoformat 2020-03-24 22:28:55 +01:00
Mathias Vorreiter Pedersen
077c282cd3 C++: Add field flow and accept tests 2020-03-24 22:28:54 +01:00
Mathias Vorreiter Pedersen
a5f08e1ea6 C++: Split parameter node class into an explicit and implicit version 2020-03-24 22:28:54 +01:00
Mathias Vorreiter Pedersen
22381f3ee6 C++: Demonstrate amount of field flow already present 2020-03-24 22:28:54 +01:00
luchua-bc
d9327705d2 Fix the issue of mixed tabs and spaces 2020-03-20 08:16:45 -04:00
luchua-bc
dfb42ecf42 Address sensitive info logging 2020-03-20 08:14:48 -04:00
Rebecca Valentine
85eb43de7d Merge branch 'master' into python-objectapi-to-valueapi-wrongnumberargumentsincall 2020-03-10 08:26:52 -07:00
Rebecca Valentine
84875d70ff Adds preliminary modernization
This will overlapp with/depend on changes to CallArgs and ObjectAPI that are already in the WrongNamedArgumentInCall PR
2020-02-26 21:42:52 -08:00
Grzegorz Golawski
fda4ab155a CodeQL query to detect open Spring Boot actuator endpoints 2020-02-23 20:03:41 +01:00
3203 changed files with 183761 additions and 94654 deletions

View File

@@ -1,5 +1,6 @@
{ "provide": [ "*/ql/src/qlpack.yml",
"*/ql/test/qlpack.yml",
"*/ql/examples/qlpack.yml",
"*/upgrades/qlpack.yml",
"misc/legacy-support/*/qlpack.yml",
"misc/suite-helpers/qlpack.yml" ] }

View File

@@ -0,0 +1,9 @@
{
"extensions": [
"github.vscode-codeql",
"slevesque.vscode-zipexplorer"
],
"settings": {
"codeQL.experimentalBqrsParsing": true
}
}

9
.github/codeql/codeql-config.yml vendored Normal file
View File

@@ -0,0 +1,9 @@
name: "CodeQL config"
queries:
- uses: security-and-quality
paths-ignore:
- '/cpp/'
- '/java/'
- '/python/'

52
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@@ -0,0 +1,52 @@
name: "Code scanning - action"
on:
push:
pull_request:
schedule:
- cron: '0 9 * * 1'
jobs:
CodeQL-Build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
with:
languages: csharp
config-file: ./.github/codeql/codeql-config.yml
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

1
.gitignore vendored
View File

@@ -21,4 +21,3 @@
/codeql/
csharp/extractor/Semmle.Extraction.CSharp.Driver/Properties/launchSettings.json
.vscode

1
.vscode/.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
*.json linguist-language=JSON-with-Comments

10
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,10 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"github.vscode-codeql"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
}

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"omnisharp.autoStart": false
}

27
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,27 @@
{
// To run a task, select the `Terminal | Run Task...` menu option, and then select the task from
// the list in the dropdown, or invoke the `Tasks: Run Task` command from the command palette/
// To bind a keyboard shortcut to invoke a task, see https://code.visualstudio.com/docs/editor/tasks#_binding-keyboard-shortcuts-to-tasks.
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Sync Identical Files",
"type": "process",
// Non-Windows OS will usually have Python 3 already installed at /usr/bin/python3.
"command": "python3",
"args": [
"config/sync-files.py",
"--latest"
],
"group": "build",
"windows": {
// On Windows, use whatever Python interpreter is configured for this workspace. The default is
// just `python`, so if Python is already on the path, this will find it.
"command": "${config:python.pythonPath}",
},
"problemMatcher": []
}
]
}

View File

@@ -1,11 +1,20 @@
/cpp/ @Semmle/cpp-analysis
/csharp/ @Semmle/cs
/java/ @Semmle/java
/javascript/ @Semmle/js
/python/ @Semmle/python
/cpp/ @github/codeql-c-analysis
/csharp/ @github/codeql-csharp
/java/ @github/codeql-java
/javascript/ @github/codeql-javascript
/python/ @github/codeql-python
# Assign query help for docs review
/cpp/**/*.qhelp @hubwriter
/csharp/**/*.qhelp @jf205
/java/**/*.qhelp @felicitymay
/javascript/**/*.qhelp @mchammer01
/python/**/*.qhelp @felicitymay
/docs/language/ @shati-patel @jf205
# Exclude help for experimental queries from docs review
/cpp/**/experimental/**/*.qhelp @github/codeql-c-analysis
/csharp/**/experimental/**/*.qhelp @github/codeql-csharp
/java/**/experimental/**/*.qhelp @github/codeql-java
/javascript/**/experimental/**/*.qhelp @github/codeql-javascript
/python/**/experimental/**/*.qhelp @github/codeql-python

View File

@@ -1,39 +1,126 @@
# Code of Conduct
## Our Pledge
This code of conduct outlines expectations for participation in the Semmle open source community, including any open source repositories on GitHub.com, as well as steps for reporting unacceptable behavior. We are committed to providing a welcoming and inspiring community for all.
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
People violating this code of conduct may be banned from the community.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
Our community strives to:
* Be friendly and patient: Remember you might not be communicating in someone elses primary spoken or programming language, and others may not have your level of understanding.
* Be welcoming: Our community welcomes and supports people of all backgrounds and identities. This includes, but is not limited to members of any race, ethnicity, culture, national origin, color, immigration status, social and economic class, educational level, sex, sexual orientation, gender identity and expression, age, size, family status, political belief, religion, and mental and physical ability.
* Be respectful: We are a world-wide community of professionals, and we conduct ourselves professionally. Disagreement is no excuse for poor behavior and poor manners. Disrespectful and unacceptable behavior includes, but is not limited to:
* Violent threats or language.
* Discriminatory or derogatory jokes and language.
* Posting sexually explicit or violent material.
* Posting, or threatening to post, peoples personally identifying information (“doxing”).
* Insults, especially those using discriminatory terms or slurs.
* Behavior that could be perceived as sexual attention.
* Advocating for or encouraging any of the above behaviors.
* Understand disagreements: Disagreements, both social and technical, are useful learning opportunities. Seek to understand others viewpoints and resolve differences constructively.
## Our Standards
This code is not exhaustive or complete. It serves to capture our common understanding of a productive, collaborative environment. We expect the code to be followed in spirit as much as in the letter.
Examples of behavior that contributes to a positive environment for our
community include:
# Scope
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
This code of conduct applies to all repositories and communities for Semmle open source projects, regardless of whether or not the repository explicitly calls out its use of this code. The code also applies in public spaces when an individual is representing the Semmle open source community. Examples include using an official project email address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
# Reporting Code of Conduct Issues
We encourage members of the community to resolve issues on their own whenever possible. This builds a broader and deeper understanding and ultimately a healthier interaction. In the event that an issue cannot be resolved locally, please feel free to report your concerns by contacting code-of-conduct@semmle.com.
In your report please include:
* Your contact information.
* Names (real, usernames or pseudonyms) of any individuals involved. If there are additional witnesses, please include them as well.
* Your account of what occurred, and if you believe the incident is ongoing. If there is a publicly available record (e.g. a mailing list archive or a public chat log), please include a link or attachment.
* Any additional information that may be helpful.
## Enforcement Responsibilities
All reports will be reviewed by a multi-person team and will result in a response that is deemed necessary and appropriate to the circumstances. Where additional perspectives are needed, the team may seek insight from others with relevant expertise or experience. The confidentiality of the person reporting the incident will be kept at all times. Involved parties are never part of the review team.
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Anyone asked to stop unacceptable behavior is expected to comply immediately. If an individual engages in unacceptable behavior, the review team may take any action they deem appropriate, including a permanent ban from the community.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
*This text is licensed under the [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/) license. It is based on a template established by the [TODO Group](http://todogroup.org/) and variants thereof used by numerous other large communities (e.g., [Microsoft](https://microsoft.github.io/codeofconduct/), [Facebook](https://code.fb.com/codeofconduct/), [Yahoo](https://yahoo.github.io/codeofconduct), [Twitter](https://github.com/twitter/code-of-conduct), [GitHub](https://blog.github.com/2015-07-20-adopting-the-open-code-of-conduct/)) and the Scope section from the [Contributor Covenant version 1.4](http://contributor-covenant.org/version/1/4/).*
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
opensource@github.com.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.

View File

@@ -53,14 +53,6 @@ After the experimental query is merged, we welcome pull requests to improve it.
## Using your personal data
If you contribute to this project, we will record your name and email
address (as provided by you with your contributions) as part of the code
repositories, which are public. We might also use this information
to contact you in relation to your contributions, as well as in the
normal course of software development. We also store records of your
CLA agreements. Under GDPR legislation, we do this
on the basis of our legitimate interest in creating the CodeQL product.
Please do get in touch (privacy@github.com) if you have any questions about
this or our data protection policies.
If you contribute to this project, we will record your name and email address (as provided by you with your contributions) as part of the code repositories, which are public. We might also use this information to contact you in relation to your contributions, as well as in the normal course of software development. We also store records of CLA agreements signed in the past, but no longer require contributors to sign a CLA. Under GDPR legislation, we do this on the basis of our legitimate interest in creating the CodeQL product.
Please do get in touch (privacy@github.com) if you have any questions about this or our data protection policies.

View File

@@ -1,6 +1,6 @@
# CodeQL
This open source repository contains the standard CodeQL libraries and queries that power [LGTM](https://lgtm.com) and the other CodeQL products that [GitHub](https://github.com) makes available to its customers worldwide.
This open source repository contains the standard CodeQL libraries and queries that power [LGTM](https://lgtm.com) and the other CodeQL products that [GitHub](https://github.com) makes available to its customers worldwide. For the queries, libraries, and extractor that power Go analysis, visit the [CodeQL for Go repository](https://github.com/github/codeql-go).
## How do I learn CodeQL and run queries?
@@ -9,8 +9,20 @@ You can use the [interactive query console](https://lgtm.com/help/lgtm/using-que
## Contributing
We welcome contributions to our standard library and standard checks. Do you have an idea for a new check, or how to improve an existing query? Then please go ahead and open a pull request! Before you do, though, please take the time to read our [contributing guidelines](CONTRIBUTING.md). You can also consult our [style guides](https://github.com/github/codeql/tree/master/docs) to learn how to format your code for consistency and clarity, how to write query metadata, and how to write query help documentation for your query.
We welcome contributions to our standard library and standard checks. Do you have an idea for a new check, or how to improve an existing query? Then please go ahead and open a pull request! Before you do, though, please take the time to read our [contributing guidelines](CONTRIBUTING.md). You can also consult our [style guides](https://github.com/github/codeql/tree/main/docs) to learn how to format your code for consistency and clarity, how to write query metadata, and how to write query help documentation for your query.
## License
The code in this repository is licensed under [Apache License 2.0](LICENSE) by [GitHub](https://github.com).
The code in this repository is licensed under the [MIT License](LICENSE) by [GitHub](https://github.com).
## Visual Studio Code integration
If you use Visual Studio Code to work in this repository, there are a few integration features to make development easier.
### CodeQL for Visual Studio Code
You can install the [CodeQL for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-codeql) extension to get syntax highlighting, IntelliSense, and code navigation for the QL language, as well as unit test support for testing CodeQL libraries and queries.
### Tasks
The `.vscode/tasks.json` file defines custom tasks specific to working in this repository. To invoke one of these tasks, select the `Terminal | Run Task...` menu option, and then select the desired task from the dropdown. You can also invoke the `Tasks: Run Task` command from the command palette.

View File

@@ -0,0 +1,46 @@
# Improvements to C/C++ analysis
The following changes in version 1.25 affect C/C++ analysis in all applications.
## General improvements
## New queries
| **Query** | **Tags** | **Purpose** |
|-----------------------------|-----------|--------------------------------------------------------------------|
## Changes to existing queries
| **Query** | **Expected impact** | **Change** |
|----------------------------|------------------------|------------------------------------------------------------------|
| Uncontrolled format string (`cpp/tainted-format-string`) | | This query is now displayed by default on LGTM. |
| Uncontrolled format string (through global variable) (`cpp/tainted-format-string-through-global`) | | This query is now displayed by default on LGTM. |
## Changes to libraries
* The library `VCS.qll` and all queries that imported it have been removed.
* The data-flow library has been improved, which affects most security queries by potentially
adding more results. Flow through functions now takes nested field reads/writes into account.
For example, the library is able to track flow from `taint()` to `sink()` via the method
`getf2f1()` in
```c
struct C {
int f1;
};
struct C2
{
C f2;
int getf2f1() {
return f2.f1; // Nested field read
}
void m() {
f2.f1 = taint();
sink(getf2f1()); // NEW: taint() reaches here
}
};
```
* The security pack taint tracking library (`semmle.code.cpp.security.TaintTracking`) now considers that equality checks may block the flow of taint. This results in fewer false positive results from queries that use this library.
* The length of a tainted string (such as the return value of a call to `strlen` or `strftime` with tainted parameters) is no longer itself considered tainted by the `models` library. This leads to fewer false positive results in queries that use any of our taint libraries.

View File

@@ -0,0 +1,78 @@
# Improvements to C# analysis
The following changes in version 1.25 affect C# analysis in all applications.
## New queries
| **Query** | **Tags** | **Purpose** |
|-----------------------------|-----------|--------------------------------------------------------------------|
## Changes to existing queries
| **Query** | **Expected impact** | **Change** |
|------------------------------|------------------------|-----------------------------------|
## Removal of old queries
## Changes to code extraction
* Index initializers, of the form `{ [1] = "one" }`, are extracted correctly. Previously, the kind of the
expression was incorrect, and the index was not extracted.
## Changes to libraries
* The class `UnboundGeneric` has been refined to only be those declarations that actually
have type parameters. This means that non-generic nested types inside constructed types,
such as `A<int>.B`, no longer are considered unbound generics. (Such nested types do,
however, still have relevant `.getSourceDeclaration()`s, for example `A<>.B`.)
* The data-flow library has been improved, which affects most security queries by potentially
adding more results:
- Flow through methods now takes nested field reads/writes into account.
For example, the library is able to track flow from `"taint"` to `Sink()` via the method
`GetF2F1()` in
```csharp
class C1
{
string F1;
}
class C2
{
C1 F2;
string GetF2F1() => F2.F1; // Nested field read
void M()
{
F2 = new C1() { F1 = "taint" };
Sink(GetF2F1()); // NEW: "taint" reaches here
}
}
```
- Flow through collections is now modeled precisely. For example, instead of modeling an array
store `a[i] = x` as a taint-step from `x` to `a`, we now model it as a data-flow step that
stores `x` into `a`. To get the value back out, a matching read step must be taken.
For source-code based data-flow analysis, the following constructs are modeled as stores into
collections:
- Direct array assignments, `a[i] = x`.
- Array initializers, `new [] { x }`.
- C# 6-style array initializers, `new C() { Array = { [i] = x } }`.
- Call arguments that match a `params` parameter, where the C# compiler creates an array under-the-hood.
- `yield return` statements.
The following source-code constructs read from a collection:
- Direct array reads, `a[i]`.
- `foreach` statements.
For calls out to library code, existing flow summaries have been refined to precisely
capture how they interact with collection contents. For example, a call to
`System.Collections.Generic.List<T>.Add(T)` stores the value of the argument into the
qualifier, and a call to `System.Collections.Generic.List<T>.get_Item(int)` (that is, an
indexer call) reads contents out of the qualifier. Moreover, the effect of
collection-clearing methods such as `System.Collections.Generic.List<T>.Clear()` is now
also modeled.
## Changes to autobuilder

View File

@@ -0,0 +1,49 @@
# Improvements to Java analysis
The following changes in version 1.25 affect Java analysis in all applications.
## General improvements
The Java autobuilder has been improved to detect more Gradle Java versions.
## Changes to existing queries
| **Query** | **Expected impact** | **Change** |
|------------------------------|------------------------|-----------------------------------|
| Hard-coded credential in API call (`java/hardcoded-credential-api-call`) | More results | The query now recognizes the `BasicAWSCredentials` class of the Amazon client SDK library with hardcoded access key/secret key. |
| Deserialization of user-controlled data (`java/unsafe-deserialization`) | Fewer false positive results | The query no longer reports results using `org.apache.commons.io.serialization.ValidatingObjectInputStream`. |
| Use of a broken or risky cryptographic algorithm (`java/weak-cryptographic-algorithm`) | More results | The query now recognizes the `MessageDigest.getInstance` method. |
| Use of a potentially broken or risky cryptographic algorithm (`java/potentially-weak-cryptographic-algorithm`) | More results | The query now recognizes the `MessageDigest.getInstance` method. |
| Reading from a world writable file (`java/world-writable-file-read`) | More results | The query now recognizes more JDK file operations. |
## Changes to libraries
* The data-flow library has been improved with more taint flow modeling for the
Collections framework and other classes of the JDK. This affects all security
queries using data flow and can yield additional results.
* The data-flow library has been improved with more taint flow modeling for the
Spring framework. This affects all security queries using data flow and can
yield additional results on project that rely on the Spring framework.
* The data-flow library has been improved, which affects most security queries by potentially
adding more results. Flow through methods now takes nested field reads/writes into account.
For example, the library is able to track flow from `"taint"` to `sink()` via the method
`getF2F1()` in
```java
class C1 {
String f1;
C1(String f1) { this.f1 = f1; }
}
class C2 {
C1 f2;
String getF2F1() {
return this.f2.f1; // Nested field read
}
void m() {
this.f2 = new C1("taint");
sink(this.getF2F1()); // NEW: "taint" reaches here
}
}
```
* The library has been extended with more support for Java 14 features
(`switch` expressions and pattern-matching for `instanceof`).

View File

@@ -0,0 +1,111 @@
# Improvements to JavaScript analysis
## General improvements
* Support for the following frameworks and libraries has been improved:
- [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
- [bluebird](http://bluebirdjs.com/)
- [express](https://www.npmjs.com/package/express)
- [execa](https://www.npmjs.com/package/execa)
- [fancy-log](https://www.npmjs.com/package/fancy-log)
- [fastify](https://www.npmjs.com/package/fastify)
- [foreground-child](https://www.npmjs.com/package/foreground-child)
- [fstream](https://www.npmjs.com/package/fstream)
- [jGrowl](https://github.com/stanlemon/jGrowl)
- [jQuery](https://jquery.com/)
- [marsdb](https://www.npmjs.com/package/marsdb)
- [micro](https://www.npmjs.com/package/micro/)
- [minimongo](https://www.npmjs.com/package/minimongo/)
- [mssql](https://www.npmjs.com/package/mssql)
- [mysql](https://www.npmjs.com/package/mysql)
- [npmlog](https://www.npmjs.com/package/npmlog)
- [opener](https://www.npmjs.com/package/opener)
- [pg](https://www.npmjs.com/package/pg)
- [sequelize](https://www.npmjs.com/package/sequelize)
- [spanner](https://www.npmjs.com/package/spanner)
- [sqlite](https://www.npmjs.com/package/sqlite)
- [ssh2-streams](https://www.npmjs.com/package/ssh2-streams)
- [ssh2](https://www.npmjs.com/package/ssh2)
- [vue](https://www.npmjs.com/package/vue)
- [yargs](https://www.npmjs.com/package/yargs)
- [webpack-dev-server](https://www.npmjs.com/package/webpack-dev-server)
* TypeScript 3.9 is now supported.
* TypeScript code embedded in HTML and Vue files is now extracted and analyzed.
* The analysis of sanitizers has improved, leading to more accurate
results from the security queries.
## New queries
| **Query** | **Tags** | **Purpose** |
|---------------------------------------------------------------------------------|-------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| DOM text reinterpreted as HTML (`js/xss-through-dom`) | security, external/cwe/cwe-079, external/cwe/cwe-116 | Highlights potential XSS vulnerabilities where existing text from the DOM is used as HTML. Results are shown on LGTM by default. |
| Incomplete HTML attribute sanitization (`js/incomplete-html-attribute-sanitization`) | security, external/cwe/cwe-20, external/cwe/cwe-079, external/cwe/cwe-116 | Highlights potential XSS vulnerabilities due to incomplete sanitization of HTML meta-characters. Results are shown on LGTM by default. |
| Unsafe expansion of self-closing HTML tag (`js/unsafe-html-expansion`) | security, external/cwe/cwe-079, external/cwe/cwe-116 | Highlights potential XSS vulnerabilities caused by unsafe expansion of self-closing HTML tags. |
| Unsafe shell command constructed from library input (`js/shell-command-constructed-from-input`) | correctness, security, external/cwe/cwe-078, external/cwe/cwe-088 | Highlights potential command injections due to a shell command being constructed from library inputs. Results are shown on LGTM by default. |
| Download of sensitive file through insecure connection (`js/insecure-download`) | security, external/cwe/cwe-829 | Highlights downloads of sensitive files through an unencrypted protocol. Results are shown on LGTM by default. |
| Exposure of private files (`js/exposure-of-private-files`) | security, external/cwe/cwe-200 | Highlights servers that serve private files. Results are shown on LGTM by default. |
| Creating biased random numbers from a cryptographically secure source (`js/biased-cryptographic-random`) | security, external/cwe/cwe-327 | Highlights mathematical operations on cryptographically secure numbers that can create biased results. Results are shown on LGTM by default. |
| Storage of sensitive information in build artifact (`js/build-artifact-leak`) | security, external/cwe/cwe-312 | Highlights storage of sensitive information in build artifacts. Results are shown on LGTM by default. |
| Improper code sanitization (`js/bad-code-sanitization`) | security, external/cwe/cwe-094, external/cwe/cwe-079, external/cwe/cwe-116 | Highlights string concatenation where code is constructed without proper sanitization. Results are shown on LGTM by default. |
| Disabling certificate validation (`js/disabling-certificate-validation`) | security, external/cwe-295 | Highlights locations where SSL certificate validation is disabled. Results are shown on LGTM by default. |
| Incomplete multi-character sanitization (`js/incomplete-multi-character-sanitization`) | correctness, security, external/cwe/cwe-20, external/cwe/cwe-116 | Highlights sanitizers that fail to remove dangerous substrings completely. Results are shown on LGTM by default. |
## Changes to existing queries
| **Query** | **Expected impact** | **Change** |
|--------------------------------|------------------------------|---------------------------------------------------------------------------|
| Client-side cross-site scripting (`js/xss`) | Fewer results | This query now recognizes additional safe patterns of constructing HTML. |
| Client-side URL redirect (`js/client-side-unvalidated-url-redirection`) | Fewer results | This query now recognizes additional safe patterns of doing URL redirects. |
| Code injection (`js/code-injection`) | More results | More potential vulnerabilities involving NoSQL code operators are now recognized. |
| Exception text reinterpreted as HTML (`js/exception-xss`) | Rephrased and changed visibility | Rephrased name and alert message. Severity lowered from error to warning. Results are now shown on LGTM by default. |
| Expression has no effect (`js/useless-expression`) | Fewer results | This query no longer flags an expression when that expression is the only content of the containing file. |
| Hard-coded credentials (`js/hardcoded-credentials`) | More results | This query now recognizes hard-coded credentials sent via HTTP authorization headers. |
| Incomplete URL scheme check (`js/incomplete-url-scheme-check`) | More results | This query now recognizes additional url scheme checks. |
| Insecure randomness (`js/insecure-randomness`) | Fewer results | This query now recognizes when an insecure random value is used as a fallback when secure random values are unsupported. |
| Misspelled variable name (`js/misspelled-variable-name`) | Message changed | The message for this query now correctly identifies the misspelled variable in additional cases. |
| Non-linear pattern (`js/non-linear-pattern`) | Fewer duplicates and message changed | This query now generates fewer duplicate alerts and has a clearer explanation in case of type annotations used in a pattern. |
| Prototype pollution in utility function (`js/prototype-pollution-utility`) | More results | This query now recognizes additional utility functions as vulnerable to prototype polution. |
| Uncontrolled command line (`js/command-line-injection`) | More results | This query now recognizes additional command execution calls. |
| Uncontrolled data used in path expression (`js/path-injection`) | More results | This query now recognizes additional file system calls. |
| Uncontrolled data used in path expression (`js/path-injection`) | Fewer results | This query no longer flags paths that have been checked to be part of a collection. |
| Unknown directive (`js/unknown-directive`) | Fewer results | This query no longer flags directives generated by the Babel compiler. |
| Unneeded defensive code (`js/unneeded-defensive-code`) | Fewer false-positive results | This query now recognizes checks meant to handle the `document.all` object. |
| Unused property (`js/unused-property`) | Fewer results | This query no longer flags properties of objects that are operands of `yield` expressions. |
| Zip Slip (`js/zipslip`) | More results | This query now recognizes additional vulnerabilities. |
The following low-precision queries are no longer run by default on LGTM (their results already were not displayed):
- `js/angular/dead-event-listener`
- `js/angular/unused-dependency`
- `js/bitwise-sign-check`
- `js/comparison-of-identical-expressions`
- `js/conflicting-html-attribute`
- `js/ignored-setter-parameter`
- `js/jsdoc/malformed-param-tag`
- `js/jsdoc/missing-parameter`
- `js/jsdoc/unknown-parameter`
- `js/json-in-javascript-file`
- `js/misspelled-identifier`
- `js/nested-loops-with-same-variable`
- `js/node/cyclic-import`
- `js/node/unused-npm-dependency`
- `js/omitted-array-element`
- `js/return-outside-function`
- `js/single-run-loop`
- `js/too-many-parameters`
- `js/unused-property`
- `js/useless-assignment-to-global`
## Changes to libraries
* A library `semmle.javascript.explore.CallGraph` has been added to help write queries for exploring the call graph.
* Added data flow for `Map` and `Set`, and added matching type-tracking steps that can accessed using the `CollectionsTypeTracking` module.
* The data-flow node representing a parameter or destructuring pattern is now always the `ValueNode` corresponding to that AST node. This has a few consequences:
- `Parameter.flow()` now gets the correct data flow node for a parameter. Previously this had a result, but the node was disconnected from the data flow graph.
- `ParameterNode.asExpr()` and `.getAstNode()` now gets the parameter's AST node, whereas previously it had no result.
- `Expr.flow()` now has a more meaningful result for destructuring patterns. Previously this node was disconnected from the data flow graph. Now it represents the values being destructured by the pattern.
* The global data-flow and taint-tracking libraries now model indirect parameter accesses through the `arguments` object in some cases, which may lead to additional results from some of the security queries, particularly "Prototype pollution in utility function".
* The predicates `Type.getProperty()` and variants of `Type.getMethod()` have been deprecated due to lack of use-cases. Looking up a named property of a static type is no longer supported, favoring faster extraction times instead.

View File

@@ -0,0 +1,9 @@
# Improvements to Python analysis
* Importing `semmle.python.web.HttpRequest` will no longer import `UntrustedStringKind` transitively. `UntrustedStringKind` is the most commonly used non-abstract subclass of `ExternalStringKind`. If not imported (by one mean or another), taint-tracking queries that concern `ExternalStringKind` will not produce any results. Please ensure such queries contain an explicit import (`import semmle.python.security.strings.Untrusted`).
* Added model of taint sources for HTTP servers using `http.server`.
* Added taint modeling of routed parameters in Flask.
* Improved modeling of built-in methods on strings for taint tracking.
* Improved classification of test files.
* New class `BoundMethodValue` represents a bound method during runtime.
* The query `py/command-line-injection` now recognizes command execution with the `fabric` and `invoke` Python libraries.

View File

@@ -1,5 +1,5 @@
{
"DataFlow Java/C++/C#": [
"DataFlow Java/C++/C#/Python": [
"java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl.qll",
"java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl2.qll",
"java/ql/src/semmle/code/java/dataflow/internal/DataFlowImpl3.qll",
@@ -18,15 +18,18 @@
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl2.qll",
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll",
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll",
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll"
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll",
"python/ql/src/experimental/dataflow/internal/DataFlowImpl.qll",
"python/ql/src/experimental/dataflow/internal/DataFlowImpl2.qll"
],
"DataFlow Java/C++/C# Common": [
"DataFlow Java/C++/C#/Python Common": [
"java/ql/src/semmle/code/java/dataflow/internal/DataFlowImplCommon.qll",
"cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImplCommon.qll",
"cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImplCommon.qll",
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImplCommon.qll"
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImplCommon.qll",
"python/ql/src/experimental/dataflow/internal/DataFlowImplCommon.qll"
],
"TaintTracking::Configuration Java/C++/C#": [
"TaintTracking::Configuration Java/C++/C#/Python": [
"cpp/ql/src/semmle/code/cpp/dataflow/internal/tainttracking1/TaintTrackingImpl.qll",
"cpp/ql/src/semmle/code/cpp/dataflow/internal/tainttracking2/TaintTrackingImpl.qll",
"cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/tainttracking1/TaintTrackingImpl.qll",
@@ -37,13 +40,15 @@
"csharp/ql/src/semmle/code/csharp/dataflow/internal/tainttracking4/TaintTrackingImpl.qll",
"csharp/ql/src/semmle/code/csharp/dataflow/internal/tainttracking5/TaintTrackingImpl.qll",
"java/ql/src/semmle/code/java/dataflow/internal/tainttracking1/TaintTrackingImpl.qll",
"java/ql/src/semmle/code/java/dataflow/internal/tainttracking2/TaintTrackingImpl.qll"
"java/ql/src/semmle/code/java/dataflow/internal/tainttracking2/TaintTrackingImpl.qll",
"python/ql/src/experimental/dataflow/internal/tainttracking1/TaintTrackingImpl.qll"
],
"DataFlow Java/C++/C# Consistency checks": [
"DataFlow Java/C++/C#/Python Consistency checks": [
"java/ql/src/semmle/code/java/dataflow/internal/DataFlowImplConsistency.qll",
"cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImplConsistency.qll",
"cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowImplConsistency.qll",
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImplConsistency.qll"
"csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImplConsistency.qll",
"python/ql/src/experimental/dataflow/internal/DataFlowImplConsistency.qll"
],
"C++ SubBasicBlocks": [
"cpp/ql/src/semmle/code/cpp/controlflow/SubBasicBlocks.qll",
@@ -53,114 +58,122 @@
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Instruction.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/Instruction.qll"
"csharp/ql/src/experimental/ir/implementation/raw/Instruction.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Instruction.qll"
],
"IR IRBlock": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRBlock.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRBlock.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRBlock.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/IRBlock.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/IRBlock.qll"
"csharp/ql/src/experimental/ir/implementation/raw/IRBlock.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/IRBlock.qll"
],
"IR IRVariable": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRVariable.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRVariable.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRVariable.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/IRVariable.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/IRVariable.qll"
"csharp/ql/src/experimental/ir/implementation/raw/IRVariable.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/IRVariable.qll"
],
"IR IRFunction": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRFunction.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRFunction.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRFunction.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/IRFunction.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/IRFunction.qll"
"csharp/ql/src/experimental/ir/implementation/raw/IRFunction.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/IRFunction.qll"
],
"IR Operand": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Operand.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Operand.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Operand.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Operand.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/Operand.qll"
"csharp/ql/src/experimental/ir/implementation/raw/Operand.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Operand.qll"
],
"IR IRType": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/IRType.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/IRType.qll"
"csharp/ql/src/experimental/ir/implementation/IRType.qll"
],
"IR IRConfiguration": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/IRConfiguration.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/IRConfiguration.qll"
"csharp/ql/src/experimental/ir/implementation/IRConfiguration.qll"
],
"IR UseSoundEscapeAnalysis": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/UseSoundEscapeAnalysis.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/UseSoundEscapeAnalysis.qll"
"csharp/ql/src/experimental/ir/implementation/UseSoundEscapeAnalysis.qll"
],
"IR IRFunctionBase": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/internal/IRFunctionBase.qll",
"csharp/ql/src/experimental/ir/implementation/internal/IRFunctionBase.qll"
],
"IR Operand Tag": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/internal/OperandTag.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/internal/OperandTag.qll"
"csharp/ql/src/experimental/ir/implementation/internal/OperandTag.qll"
],
"IR TInstruction":[
"cpp/ql/src/semmle/code/cpp/ir/implementation/internal/TInstruction.qll",
"csharp/ql/src/experimental/ir/implementation/internal/TInstruction.qll"
],
"IR TIRVariable":[
"cpp/ql/src/semmle/code/cpp/ir/implementation/internal/TIRVariable.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/internal/TIRVariable.qll"
"csharp/ql/src/experimental/ir/implementation/internal/TIRVariable.qll"
],
"IR IR": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IR.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IR.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IR.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/IR.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/IR.qll"
"csharp/ql/src/experimental/ir/implementation/raw/IR.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/IR.qll"
],
"IR IRSanity": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRSanity.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRSanity.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRSanity.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/IRSanity.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/IRSanity.qll"
"IR IRConsistency": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRConsistency.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRConsistency.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRConsistency.qll",
"csharp/ql/src/experimental/ir/implementation/raw/IRConsistency.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/IRConsistency.qll"
],
"IR PrintIR": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/PrintIR.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/PrintIR.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/PrintIR.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/PrintIR.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/PrintIR.qll"
"csharp/ql/src/experimental/ir/implementation/raw/PrintIR.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/PrintIR.qll"
],
"IR IntegerConstant": [
"cpp/ql/src/semmle/code/cpp/ir/internal/IntegerConstant.qll",
"csharp/ql/src/semmle/code/csharp/ir/internal/IntegerConstant.qll"
"csharp/ql/src/experimental/ir/internal/IntegerConstant.qll"
],
"IR IntegerInteval": [
"cpp/ql/src/semmle/code/cpp/ir/internal/IntegerInterval.qll",
"csharp/ql/src/semmle/code/csharp/ir/internal/IntegerInterval.qll"
"csharp/ql/src/experimental/ir/internal/IntegerInterval.qll"
],
"IR IntegerPartial": [
"cpp/ql/src/semmle/code/cpp/ir/internal/IntegerPartial.qll",
"csharp/ql/src/semmle/code/csharp/ir/internal/IntegerPartial.qll"
"csharp/ql/src/experimental/ir/internal/IntegerPartial.qll"
],
"IR Overlap": [
"cpp/ql/src/semmle/code/cpp/ir/internal/Overlap.qll",
"csharp/ql/src/semmle/code/csharp/ir/internal/Overlap.qll"
"csharp/ql/src/experimental/ir/internal/Overlap.qll"
],
"IR EdgeKind": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/EdgeKind.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/EdgeKind.qll"
"csharp/ql/src/experimental/ir/implementation/EdgeKind.qll"
],
"IR MemoryAccessKind": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/MemoryAccessKind.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/MemoryAccessKind.qll"
"csharp/ql/src/experimental/ir/implementation/MemoryAccessKind.qll"
],
"IR TempVariableTag": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/TempVariableTag.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/TempVariableTag.qll"
"csharp/ql/src/experimental/ir/implementation/TempVariableTag.qll"
],
"IR Opcode": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/Opcode.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/Opcode.qll"
"csharp/ql/src/experimental/ir/implementation/Opcode.qll"
],
"IR SSASanity": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSASanity.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSASanity.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/SSASanity.qll"
"IR SSAConsistency": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConsistency.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConsistency.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConsistency.qll"
],
"C++ IR InstructionImports": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/InstructionImports.qll",
@@ -177,6 +190,11 @@
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/IRBlockImports.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/IRBlockImports.qll"
],
"C++ IR IRFunctionImports": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/IRFunctionImports.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/IRFunctionImports.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/IRFunctionImports.qll"
],
"C++ IR IRVariableImports": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/IRVariableImports.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/IRVariableImports.qll",
@@ -199,7 +217,7 @@
"SSA AliasAnalysis": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/AliasAnalysis.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasAnalysis.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/AliasAnalysis.qll"
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/AliasAnalysis.qll"
],
"C++ SSA AliasAnalysisImports": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/AliasAnalysisImports.qll",
@@ -212,42 +230,42 @@
],
"IR SSA SimpleSSA": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll"
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SimpleSSA.qll"
],
"IR AliasConfiguration (unaliased_ssa)": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/AliasConfiguration.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/AliasConfiguration.qll"
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/AliasConfiguration.qll"
],
"IR SSA SSAConstruction": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll"
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll"
],
"IR SSA PrintSSA": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/PrintSSA.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/PrintSSA.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/PrintSSA.qll"
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/PrintSSA.qll"
],
"IR ValueNumberInternal": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/gvn/internal/ValueNumberingInternal.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingInternal.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/gvn/internal/ValueNumberingInternal.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/gvn/internal/ValueNumberingInternal.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingInternal.qll"
"csharp/ql/src/experimental/ir/implementation/raw/gvn/internal/ValueNumberingInternal.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingInternal.qll"
],
"C++ IR ValueNumber": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/gvn/ValueNumbering.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/ValueNumbering.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/gvn/ValueNumbering.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/gvn/ValueNumbering.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/gvn/ValueNumbering.qll"
"csharp/ql/src/experimental/ir/implementation/raw/gvn/ValueNumbering.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/gvn/ValueNumbering.qll"
],
"C++ IR PrintValueNumbering": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/gvn/PrintValueNumbering.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/gvn/PrintValueNumbering.qll",
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/gvn/PrintValueNumbering.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/gvn/PrintValueNumbering.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/gvn/PrintValueNumbering.qll"
"csharp/ql/src/experimental/ir/implementation/raw/gvn/PrintValueNumbering.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/gvn/PrintValueNumbering.qll"
],
"C++ IR ConstantAnalysis": [
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/constant/ConstantAnalysis.qll",
@@ -276,32 +294,36 @@
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/reachability/PrintDominance.qll"
],
"C# IR InstructionImports": [
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/InstructionImports.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/InstructionImports.qll"
"csharp/ql/src/experimental/ir/implementation/raw/internal/InstructionImports.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/InstructionImports.qll"
],
"C# IR IRImports": [
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/IRImports.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/IRImports.qll"
"csharp/ql/src/experimental/ir/implementation/raw/internal/IRImports.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/IRImports.qll"
],
"C# IR IRBlockImports": [
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/IRBlockImports.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/IRBlockImports.qll"
"csharp/ql/src/experimental/ir/implementation/raw/internal/IRBlockImports.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/IRBlockImports.qll"
],
"C# IR IRFunctionImports": [
"csharp/ql/src/experimental/ir/implementation/raw/internal/IRFunctionImports.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/IRFunctionImports.qll"
],
"C# IR IRVariableImports": [
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/IRVariableImports.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/IRVariableImports.qll"
"csharp/ql/src/experimental/ir/implementation/raw/internal/IRVariableImports.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/IRVariableImports.qll"
],
"C# IR OperandImports": [
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/OperandImports.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/OperandImports.qll"
"csharp/ql/src/experimental/ir/implementation/raw/internal/OperandImports.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/OperandImports.qll"
],
"C# IR PrintIRImports": [
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/PrintIRImports.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/internal/PrintIRImports.qll"
"csharp/ql/src/experimental/ir/implementation/raw/internal/PrintIRImports.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/PrintIRImports.qll"
],
"C# IR ValueNumberingImports": [
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/gvn/internal/ValueNumberingImports.qll",
"csharp/ql/src/semmle/code/csharp/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingImports.qll"
"csharp/ql/src/experimental/ir/implementation/raw/gvn/internal/ValueNumberingImports.qll",
"csharp/ql/src/experimental/ir/implementation/unaliased_ssa/gvn/internal/ValueNumberingImports.qll"
],
"XML": [
"cpp/ql/src/semmle/code/cpp/XML.qll",

102
config/opcode-qldoc.py Normal file
View File

@@ -0,0 +1,102 @@
#!/usr/bin/env python3
import os
import re
path = os.path
needs_an_re = re.compile(r'^(?!Unary)[AEIOU]') # Name requiring "an" instead of "a".
start_qldoc_re = re.compile(r'^\s*/\*\*') # Start of a QLDoc comment
end_qldoc_re = re.compile(r'\*/\s*$') # End of a QLDoc comment
blank_qldoc_line_re = re.compile(r'^\s*\*\s*$') # A line in a QLDoc comment with only the '*'
instruction_class_re = re.compile(r'^class (?P<name>[A-aa-z0-9]+)Instruction\s') # Declaration of an `Instruction` class
opcode_base_class_re = re.compile(r'^abstract class (?P<name>[A-aa-z0-9]+)Opcode\s') # Declaration of an `Opcode` base class
opcode_class_re = re.compile(r'^ class (?P<name>[A-aa-z0-9]+)\s') # Declaration of an `Opcode` class
script_dir = path.realpath(path.dirname(__file__))
instruction_path = path.realpath(path.join(script_dir, '../cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll'))
opcode_path = path.realpath(path.join(script_dir, '../cpp/ql/src/semmle/code/cpp/ir/implementation/Opcode.qll'))
# Scan `Instruction.qll`, keeping track of the QLDoc comment attached to each declaration of a class
# whose name ends with `Instruction`.
instruction_comments = {}
in_qldoc = False
saw_blank_line_in_qldoc = False
qldoc_lines = []
with open(instruction_path, 'r', encoding='utf-8') as instr:
for line in instr:
if in_qldoc:
if end_qldoc_re.search(line):
qldoc_lines.append(line)
in_qldoc = False
elif blank_qldoc_line_re.search(line):
# We're going to skip any lines after the first blank line, to avoid duplicating all
# of the verbose description.
saw_blank_line_in_qldoc = True
elif not saw_blank_line_in_qldoc:
qldoc_lines.append(line)
else:
if start_qldoc_re.search(line):
# Starting a new QLDoc comment.
saw_blank_line_in_qldoc = False
qldoc_lines.append(line)
if not end_qldoc_re.search(line):
in_qldoc = True
else:
instruction_match = instruction_class_re.search(line)
if instruction_match:
# Found the declaration of an `Instruction` class. Record the QLDoc comments.
instruction_comments[instruction_match.group('name')] = qldoc_lines
qldoc_lines = []
# Scan `Opcode.qll`. Whenever we see the declaration of an `Opcode` class for which we have a
# corresponding `Instruction` class, we'll attach a copy of the `Instruction`'s QLDoc comment.
in_qldoc = False
qldoc_lines = []
output_lines = []
with open(opcode_path, 'r', encoding='utf-8') as opcode:
for line in opcode:
if in_qldoc:
qldoc_lines.append(line)
if end_qldoc_re.search(line):
in_qldoc = False
else:
if start_qldoc_re.search(line):
qldoc_lines.append(line)
if not end_qldoc_re.search(line):
in_qldoc = True
else:
name_without_suffix = None
name = None
indent = ''
opcode_base_match = opcode_base_class_re.search(line)
if opcode_base_match:
name_without_suffix = opcode_base_match.group('name')
name = name_without_suffix + 'Opcode'
else:
opcode_match = opcode_class_re.search(line)
if opcode_match:
name_without_suffix = opcode_match.group('name')
name = name_without_suffix
# Indent by two additional spaces, since opcodes are declared in the
# `Opcode` module.
indent = ' '
if name_without_suffix:
# Found an `Opcode` that matches a known `Instruction`. Replace the QLDoc with
# a copy of the one from the `Instruction`.
if instruction_comments.get(name_without_suffix):
article = 'an' if needs_an_re.search(name_without_suffix) else 'a'
qldoc_lines = [
indent + '/**\n',
indent + ' * The `Opcode` for ' + article + ' `' + name_without_suffix + 'Instruction`.\n',
indent + ' *\n',
indent + ' * See the `' + name_without_suffix + 'Instruction` documentation for more details.\n',
indent + ' */\n'
]
output_lines.extend(qldoc_lines)
qldoc_lines = []
output_lines.append(line)
# Write out the updated `Opcode.qll`
with open(opcode_path, 'w', encoding='utf-8') as opcode:
opcode.writelines(output_lines)

View File

@@ -59,21 +59,32 @@ def file_checksum(filename):
return hashlib.sha1(file_handle.read()).hexdigest()
def check_group(group_name, files, master_file_picker, emit_error):
checksums = {file_checksum(f) for f in files}
if len(checksums) == 1:
extant_files = [f for f in files if path.isfile(f)]
if len(extant_files) == 0:
emit_error(__file__, 0, "No files found from group '" + group_name + "'.")
emit_error(__file__, 0,
"Create one of the following files, and then run this script with "
"the --latest switch to sync it to the other file locations.")
for filename in files:
emit_error(__file__, 0, " " + filename)
return
master_file = master_file_picker(files)
checksums = {file_checksum(f) for f in extant_files}
if len(checksums) == 1 and len(extant_files) == len(files):
# All files are present and identical.
return
master_file = master_file_picker(extant_files)
if master_file is None:
emit_error(__file__, 0,
"Files from group '"+ group_name +"' not in sync.")
emit_error(__file__, 0,
"Run this script with a file-name argument among the "
"following to overwrite the remaining files with the contents "
"of that file or run with the --latest switch to update each "
"of that file, or run with the --latest switch to update each "
"group of files from the most recently modified file in the group.")
for filename in files:
for filename in extant_files:
emit_error(__file__, 0, " " + filename)
else:
print(" Syncing others from", master_file)
@@ -81,7 +92,8 @@ def check_group(group_name, files, master_file_picker, emit_error):
if filename == master_file:
continue
print(" " + filename)
os.replace(filename, filename + '~')
if path.isfile(filename):
os.replace(filename, filename + '~')
shutil.copy(master_file, filename)
print(" Backups written with '~' appended to file names")
@@ -107,7 +119,7 @@ def choose_latest_file(files):
local_error_count = 0
def emit_local_error(path, line, error):
print('ERROR: ' + path + ':' + line + " - " + error)
print('ERROR: ' + path + ':' + str(line) + " - " + error)
global local_error_count
local_error_count += 1

13
cpp/autobuilder/.gitignore vendored Normal file
View File

@@ -0,0 +1,13 @@
obj/
TestResults/
*.manifest
*.pdb
*.suo
*.mdb
*.vsmdi
csharp.log
**/bin/Debug
**/bin/Release
*.tlog
.vs
*.user

View File

@@ -0,0 +1,296 @@
using Xunit;
using Semmle.Autobuild.Shared;
using System.Collections.Generic;
using System;
using System.Linq;
using Microsoft.Build.Construction;
using System.Xml;
namespace Semmle.Autobuild.Cpp.Tests
{
/// <summary>
/// Test class to script Autobuilder scenarios.
/// For most methods, it uses two fields:
/// - an IList to capture the the arguments passed to it
/// - an IDictionary of possible return values.
/// </summary>
class TestActions : IBuildActions
{
/// <summary>
/// List of strings passed to FileDelete.
/// </summary>
public IList<string> FileDeleteIn = new List<string>();
void IBuildActions.FileDelete(string file)
{
FileDeleteIn.Add(file);
}
public IList<string> FileExistsIn = new List<string>();
public IDictionary<string, bool> FileExists = new Dictionary<string, bool>();
bool IBuildActions.FileExists(string file)
{
FileExistsIn.Add(file);
if (FileExists.TryGetValue(file, out var ret))
return ret;
if (FileExists.TryGetValue(System.IO.Path.GetFileName(file), out ret))
return ret;
throw new ArgumentException("Missing FileExists " + file);
}
public IList<string> RunProcessIn = new List<string>();
public IDictionary<string, int> RunProcess = new Dictionary<string, int>();
public IDictionary<string, string> RunProcessOut = new Dictionary<string, string>();
public IDictionary<string, string> RunProcessWorkingDirectory = new Dictionary<string, string>();
int IBuildActions.RunProcess(string cmd, string args, string? workingDirectory, IDictionary<string, string>? env, out IList<string> stdOut)
{
var pattern = cmd + " " + args;
RunProcessIn.Add(pattern);
if (RunProcessOut.TryGetValue(pattern, out var str))
stdOut = str.Split("\n");
else
throw new ArgumentException("Missing RunProcessOut " + pattern);
RunProcessWorkingDirectory.TryGetValue(pattern, out var wd);
if (wd != workingDirectory)
throw new ArgumentException("Missing RunProcessWorkingDirectory " + pattern);
if (RunProcess.TryGetValue(pattern, out var ret))
return ret;
throw new ArgumentException("Missing RunProcess " + pattern);
}
int IBuildActions.RunProcess(string cmd, string args, string? workingDirectory, IDictionary<string, string>? env)
{
var pattern = cmd + " " + args;
RunProcessIn.Add(pattern);
RunProcessWorkingDirectory.TryGetValue(pattern, out var wd);
if (wd != workingDirectory)
throw new ArgumentException("Missing RunProcessWorkingDirectory " + pattern);
if (RunProcess.TryGetValue(pattern, out var ret))
return ret;
throw new ArgumentException("Missing RunProcess " + pattern);
}
public IList<string> DirectoryDeleteIn = new List<string>();
void IBuildActions.DirectoryDelete(string dir, bool recursive)
{
DirectoryDeleteIn.Add(dir);
}
public IDictionary<string, bool> DirectoryExists = new Dictionary<string, bool>();
public IList<string> DirectoryExistsIn = new List<string>();
bool IBuildActions.DirectoryExists(string dir)
{
DirectoryExistsIn.Add(dir);
if (DirectoryExists.TryGetValue(dir, out var ret))
return ret;
throw new ArgumentException("Missing DirectoryExists " + dir);
}
public IDictionary<string, string?> GetEnvironmentVariable = new Dictionary<string, string?>();
string? IBuildActions.GetEnvironmentVariable(string name)
{
if (GetEnvironmentVariable.TryGetValue(name, out var ret))
return ret;
throw new ArgumentException("Missing GetEnvironmentVariable " + name);
}
public string GetCurrentDirectory = "";
string IBuildActions.GetCurrentDirectory()
{
return GetCurrentDirectory;
}
public IDictionary<string, string> EnumerateFiles = new Dictionary<string, string>();
IEnumerable<string> IBuildActions.EnumerateFiles(string dir)
{
if (EnumerateFiles.TryGetValue(dir, out var str))
return str.Split("\n");
throw new ArgumentException("Missing EnumerateFiles " + dir);
}
public IDictionary<string, string> EnumerateDirectories = new Dictionary<string, string>();
IEnumerable<string> IBuildActions.EnumerateDirectories(string dir)
{
if (EnumerateDirectories.TryGetValue(dir, out var str))
return string.IsNullOrEmpty(str) ? Enumerable.Empty<string>() : str.Split("\n");
throw new ArgumentException("Missing EnumerateDirectories " + dir);
}
public bool IsWindows;
bool IBuildActions.IsWindows() => IsWindows;
string IBuildActions.PathCombine(params string[] parts)
{
return string.Join(IsWindows ? '\\' : '/', parts.Where(p => !string.IsNullOrWhiteSpace(p)));
}
string IBuildActions.GetFullPath(string path) => path;
void IBuildActions.WriteAllText(string filename, string contents)
{
}
public IDictionary<string, XmlDocument> LoadXml = new Dictionary<string, XmlDocument>();
XmlDocument IBuildActions.LoadXml(string filename)
{
if (LoadXml.TryGetValue(filename, out var xml))
return xml;
throw new ArgumentException("Missing LoadXml " + filename);
}
public string EnvironmentExpandEnvironmentVariables(string s)
{
foreach (var kvp in GetEnvironmentVariable)
s = s.Replace($"%{kvp.Key}%", kvp.Value);
return s;
}
}
/// <summary>
/// A fake solution to build.
/// </summary>
class TestSolution : ISolution
{
public IEnumerable<SolutionConfigurationInSolution> Configurations => throw new NotImplementedException();
public string DefaultConfigurationName => "Release";
public string DefaultPlatformName => "x86";
public string FullPath { get; set; }
public Version ToolsVersion => new Version("14.0");
public IEnumerable<IProjectOrSolution> IncludedProjects => throw new NotImplementedException();
public TestSolution(string path)
{
FullPath = path;
}
}
public class BuildScriptTests
{
TestActions Actions = new TestActions();
// Records the arguments passed to StartCallback.
IList<string> StartCallbackIn = new List<string>();
void StartCallback(string s, bool silent)
{
StartCallbackIn.Add(s);
}
// Records the arguments passed to EndCallback
IList<string> EndCallbackIn = new List<string>();
IList<int> EndCallbackReturn = new List<int>();
void EndCallback(int ret, string s, bool silent)
{
EndCallbackReturn.Add(ret);
EndCallbackIn.Add(s);
}
CppAutobuilder CreateAutoBuilder(bool isWindows,
string? buildless = null, string? solution = null, string? buildCommand = null, string? ignoreErrors = null,
string? msBuildArguments = null, string? msBuildPlatform = null, string? msBuildConfiguration = null, string? msBuildTarget = null,
string? dotnetArguments = null, string? dotnetVersion = null, string? vsToolsVersion = null,
string? nugetRestore = null, string? allSolutions = null,
string cwd = @"C:\Project")
{
string codeqlUpperLanguage = Language.Cpp.UpperCaseName;
Actions.GetEnvironmentVariable[$"CODEQL_AUTOBUILDER_{codeqlUpperLanguage}_NO_INDEXING"] = "false";
Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_TRAP_DIR"] = "";
Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_SOURCE_ARCHIVE_DIR"] = "";
Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_ROOT"] = $@"C:\codeql\{codeqlUpperLanguage.ToLowerInvariant()}";
Actions.GetEnvironmentVariable["CODEQL_JAVA_HOME"] = @"C:\codeql\tools\java";
Actions.GetEnvironmentVariable["SEMMLE_DIST"] = @"C:\odasa";
Actions.GetEnvironmentVariable["SEMMLE_JAVA_HOME"] = @"C:\odasa\tools\java";
Actions.GetEnvironmentVariable["SEMMLE_PLATFORM_TOOLS"] = @"C:\odasa\tools";
Actions.GetEnvironmentVariable["LGTM_INDEX_VSTOOLS_VERSION"] = vsToolsVersion;
Actions.GetEnvironmentVariable["LGTM_INDEX_MSBUILD_ARGUMENTS"] = msBuildArguments;
Actions.GetEnvironmentVariable["LGTM_INDEX_MSBUILD_PLATFORM"] = msBuildPlatform;
Actions.GetEnvironmentVariable["LGTM_INDEX_MSBUILD_CONFIGURATION"] = msBuildConfiguration;
Actions.GetEnvironmentVariable["LGTM_INDEX_MSBUILD_TARGET"] = msBuildTarget;
Actions.GetEnvironmentVariable["LGTM_INDEX_DOTNET_ARGUMENTS"] = dotnetArguments;
Actions.GetEnvironmentVariable["LGTM_INDEX_DOTNET_VERSION"] = dotnetVersion;
Actions.GetEnvironmentVariable["LGTM_INDEX_BUILD_COMMAND"] = buildCommand;
Actions.GetEnvironmentVariable["LGTM_INDEX_SOLUTION"] = solution;
Actions.GetEnvironmentVariable["LGTM_INDEX_IGNORE_ERRORS"] = ignoreErrors;
Actions.GetEnvironmentVariable["LGTM_INDEX_BUILDLESS"] = buildless;
Actions.GetEnvironmentVariable["LGTM_INDEX_ALL_SOLUTIONS"] = allSolutions;
Actions.GetEnvironmentVariable["LGTM_INDEX_NUGET_RESTORE"] = nugetRestore;
Actions.GetEnvironmentVariable["ProgramFiles(x86)"] = isWindows ? @"C:\Program Files (x86)" : null;
Actions.GetCurrentDirectory = cwd;
Actions.IsWindows = isWindows;
var options = new AutobuildOptions(Actions, Language.Cpp);
return new CppAutobuilder(Actions, options);
}
void TestAutobuilderScript(Autobuilder autobuilder, int expectedOutput, int commandsRun)
{
Assert.Equal(expectedOutput, autobuilder.GetBuildScript().Run(Actions, StartCallback, EndCallback));
// Check expected commands actually ran
Assert.Equal(commandsRun, StartCallbackIn.Count);
Assert.Equal(commandsRun, EndCallbackIn.Count);
Assert.Equal(commandsRun, EndCallbackReturn.Count);
var action = Actions.RunProcess.GetEnumerator();
for (int cmd = 0; cmd < commandsRun; ++cmd)
{
Assert.True(action.MoveNext());
Assert.Equal(action.Current.Key, StartCallbackIn[cmd]);
Assert.Equal(action.Current.Value, EndCallbackReturn[cmd]);
}
}
[Fact]
public void TestDefaultCppAutobuilder()
{
Actions.EnumerateFiles[@"C:\Project"] = "";
Actions.EnumerateDirectories[@"C:\Project"] = "";
var autobuilder = CreateAutoBuilder(true);
var script = autobuilder.GetBuildScript();
// Fails due to no solutions present.
Assert.NotEqual(0, script.Run(Actions, StartCallback, EndCallback));
}
[Fact]
public void TestCppAutobuilderSuccess()
{
Actions.RunProcess[@"cmd.exe /C C:\odasa\tools\csharp\nuget\nuget.exe restore C:\Project\test.sln"] = 1;
Actions.RunProcess[@"cmd.exe /C CALL ^""C:\Program Files ^(x86^)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat^"" && set Platform=&& type NUL && C:\odasa\tools\odasa index --auto msbuild C:\Project\test.sln /p:UseSharedCompilation=false /t:rebuild /p:Platform=""x86"" /p:Configuration=""Release"" /p:MvcBuildViews=true"] = 0;
Actions.RunProcessOut[@"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe -prerelease -legacy -property installationPath"] = "";
Actions.RunProcess[@"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe -prerelease -legacy -property installationPath"] = 1;
Actions.RunProcess[@"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe -prerelease -legacy -property installationVersion"] = 0;
Actions.RunProcessOut[@"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe -prerelease -legacy -property installationVersion"] = "";
Actions.FileExists[@"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"] = true;
Actions.FileExists[@"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"] = true;
Actions.FileExists[@"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"] = true;
Actions.FileExists[@"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"] = true;
Actions.FileExists[@"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"] = true;
Actions.EnumerateFiles[@"C:\Project"] = "foo.cs\ntest.slx";
Actions.EnumerateDirectories[@"C:\Project"] = "";
var autobuilder = CreateAutoBuilder(true);
var solution = new TestSolution(@"C:\Project\test.sln");
autobuilder.ProjectsOrSolutionsToBuild.Add(solution);
TestAutobuilderScript(autobuilder, 0, 2);
}
}
}

View File

@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Semmle.Autobuild.Cpp\Semmle.Autobuild.Cpp.csproj" />
<ProjectReference Include="..\..\..\csharp\autobuilder\Semmle.Autobuild.Shared\Semmle.Autobuild.Shared.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,23 @@
using Semmle.Autobuild.Shared;
namespace Semmle.Autobuild.Cpp
{
public class CppAutobuilder : Autobuilder
{
public CppAutobuilder(IBuildActions actions, AutobuildOptions options) : base(actions, options) { }
public override BuildScript GetBuildScript()
{
if (Options.BuildCommand != null)
return new BuildCommandRule((_, f) => f(null)).Analyse(this, false);
return
// First try MSBuild
new MsBuildRule().Analyse(this, true) |
// Then look for a script that might be a build script
(() => new BuildCommandAutoRule((_, f) => f(null)).Analyse(this, true)) |
// All attempts failed: print message
AutobuildFailure();
}
}
}

View File

@@ -1,6 +1,7 @@
using System;
using Semmle.Autobuild.Shared;
namespace Semmle.Autobuild
namespace Semmle.Autobuild.Cpp
{
class Program
{
@@ -10,11 +11,11 @@ namespace Semmle.Autobuild
try
{
var actions = SystemBuildActions.Instance;
var options = new AutobuildOptions(actions);
var options = new AutobuildOptions(actions, Language.Cpp);
try
{
Console.WriteLine($"Semmle autobuilder for {options.Language}");
var builder = new Autobuilder(actions, options);
Console.WriteLine("CodeQL C++ autobuilder");
var builder = new CppAutobuilder(actions, options);
return builder.AttemptBuild();
}
catch(InvalidEnvironmentException ex)

View File

@@ -4,12 +4,12 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Semmle.Autobuild.Tests")]
[assembly: AssemblyTitle("Semmle.Autobuild.Cpp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Semmle.Extraction.Tests")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyCompany("GitHub")]
[assembly: AssemblyProduct("CodeQL autobuilder for C++")]
[assembly: AssemblyCopyright("Copyright © GitHub 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

View File

@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>Semmle.Autobuild.Cpp</AssemblyName>
<RootNamespace>Semmle.Autobuild.Cpp</RootNamespace>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="16.0.461" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\csharp\extractor\Semmle.Util\Semmle.Util.csproj" />
<ProjectReference Include="..\..\..\csharp\autobuilder\Semmle.Autobuild.Shared\Semmle.Autobuild.Shared.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,3 @@
name: codeql-cpp-examples
version: 0.0.0
libraryPathDependencies: codeql-cpp

View File

@@ -1,5 +1,6 @@
import semmle.code.cpp.pointsto.PointsTo
/** Holds if there exists a call to a function that might close the file specified by `e`. */
predicate closed(Expr e) {
fcloseCall(_, e) or
exists(ExprCall c |
@@ -8,10 +9,19 @@ predicate closed(Expr e) {
)
}
/** An expression for which there exists a function call that might close it. */
class ClosedExpr extends PointsToExpr {
ClosedExpr() { closed(this) }
override predicate interesting() { closed(this) }
}
/**
* Holds if `fc` is a call to a function that opens a file that might be closed. For example:
* ```
* FILE* f = fopen("file.txt", "r");
* ...
* fclose(f);
* ```
*/
predicate fopenCallMayBeClosed(FunctionCall fc) { fopenCall(fc) and anythingPointsTo(fc) }

View File

@@ -2,12 +2,24 @@
import cpp
/**
* An assignment to a variable with the value `0`. For example:
* ```
* int x;
* x = 0;
* ```
* but not:
* ```
* int x = 0;
* ```
*/
class ZeroAssignment extends AssignExpr {
ZeroAssignment() {
this.getAnOperand() instanceof VariableAccess and
this.getAnOperand() instanceof Zero
}
/** Gets a variable that is assigned the value `0`. */
Variable assignedVariable() { result.getAnAccess() = this.getAnOperand() }
}

View File

@@ -9,10 +9,19 @@ private predicate freed(Expr e) {
)
}
/** An expression that might be deallocated. */
class FreedExpr extends PointsToExpr {
FreedExpr() { freed(this) }
override predicate interesting() { freed(this) }
}
/**
* An allocation expression that might be deallocated. For example:
* ```
* int* p = new int;
* ...
* delete p;
* ```
*/
predicate allocMayBeFreed(AllocationExpr alloc) { anythingPointsTo(alloc) }

View File

@@ -1,10 +1,19 @@
import cpp
/**
* Holds if `val` is an access to the variable `v`, or if `val`
* is an assignment with an access to `v` on the left-hand side.
*/
predicate valueOfVar(Variable v, Expr val) {
val = v.getAnAccess() or
val.(AssignExpr).getLValue() = v.getAnAccess()
}
/**
* Holds if either:
* - `cond` is an (in)equality expression that compares the variable `v` to the value `-1`, or
* - `cond` is a relational expression that compares the variable `v` to a constant.
*/
predicate boundsCheckExpr(Variable v, Expr cond) {
exists(EQExpr eq |
cond = eq and
@@ -43,6 +52,18 @@ predicate boundsCheckExpr(Variable v, Expr cond) {
)
}
/**
* Holds if `node` is an expression in a conditional statement and `succ` is an
* immediate successor of `node` that may be reached after evaluating `node`.
* For example, given
* ```
* if (a < 10 && b) func1();
* else func2();
* ```
* this predicate holds when either:
* - `node` is `a < 10` and `succ` is `func2()` or `b`, or
* - `node` is `b` and `succ` is `func1()` or `func2()`
*/
predicate conditionalSuccessor(ControlFlowNode node, ControlFlowNode succ) {
if node.isCondition()
then succ = node.getATrueSuccessor() or succ = node.getAFalseSuccessor()
@@ -52,6 +73,12 @@ predicate conditionalSuccessor(ControlFlowNode node, ControlFlowNode succ) {
)
}
/**
* Holds if the current value of the variable `v` at control-flow
* node `n` has been used either in:
* - an (in)equality comparison with the value `-1`, or
* - a relational comparison that compares `v` to a constant.
*/
predicate boundsChecked(Variable v, ControlFlowNode node) {
exists(Expr test |
boundsCheckExpr(v, test) and
@@ -63,6 +90,14 @@ predicate boundsChecked(Variable v, ControlFlowNode node) {
)
}
/**
* Holds if `cond` compares `v` to some common error values. Specifically, this
* predicate holds when:
* - `cond` checks that `v` is equal to `-1`, or
* - `cond` checks that `v` is less than `0`, or
* - `cond` checks that `v` is less than or equal to `-1`, or
* - `cond` checks that `v` is not some common success value (see `successCondition`).
*/
predicate errorCondition(Variable v, Expr cond) {
exists(EQExpr eq |
cond = eq and
@@ -88,6 +123,14 @@ predicate errorCondition(Variable v, Expr cond) {
)
}
/**
* Holds if `cond` compares `v` to some common success values. Specifically, this
* predicate holds when:
* - `cond` checks that `v` is not equal to `-1`, or
* - `cond` checks that `v` is greater than or equal than `0`, or
* - `cond` checks that `v` is greater than `-1`, or
* - `cond` checks that `v` is not some common error value (see `errorCondition`).
*/
predicate successCondition(Variable v, Expr cond) {
exists(NEExpr ne |
cond = ne and
@@ -113,6 +156,11 @@ predicate successCondition(Variable v, Expr cond) {
)
}
/**
* Holds if there exists a comparison operation that checks whether `v`
* represents some common *error* values, and `n` may be reached
* immediately following the comparison operation.
*/
predicate errorSuccessor(Variable v, ControlFlowNode n) {
exists(Expr cond |
errorCondition(v, cond) and n = cond.getATrueSuccessor()
@@ -121,6 +169,11 @@ predicate errorSuccessor(Variable v, ControlFlowNode n) {
)
}
/**
* Holds if there exists a comparison operation that checks whether `v`
* represents some common *success* values, and `n` may be reached
* immediately following the comparison operation.
*/
predicate successSuccessor(Variable v, ControlFlowNode n) {
exists(Expr cond |
successCondition(v, cond) and n = cond.getATrueSuccessor()
@@ -129,6 +182,10 @@ predicate successSuccessor(Variable v, ControlFlowNode n) {
)
}
/**
* Holds if the current value of the variable `v` at control-flow node
* `n` may have been checked against a common set of *error* values.
*/
predicate checkedError(Variable v, ControlFlowNode n) {
errorSuccessor(v, n)
or
@@ -139,6 +196,10 @@ predicate checkedError(Variable v, ControlFlowNode n) {
)
}
/**
* Holds if the current value of the variable `v` at control-flow node
* `n` may have been checked against a common set of *success* values.
*/
predicate checkedSuccess(Variable v, ControlFlowNode n) {
successSuccessor(v, n)
or

View File

@@ -4,6 +4,10 @@
import cpp
/**
* Gets a string representation of the comment `c` containing the caption 'TODO' or 'FIXME'.
* If `c` spans multiple lines, all lines after the first are abbreviated as [...].
*/
string getCommentTextCaptioned(Comment c, string caption) {
(caption = "TODO" or caption = "FIXME") and
exists(

View File

@@ -1,3 +1,7 @@
/**
* Provides classes and predicates for identifying C/C++ comments that look like code.
*/
import cpp
/**
@@ -137,8 +141,14 @@ class CommentBlock extends Comment {
)
}
/**
* Gets the last comment associated with this comment block.
*/
Comment lastComment() { result = this.getComment(max(int i | exists(this.getComment(i)))) }
/**
* Gets the contents of the `i`'th comment associated with this comment block.
*/
string getLine(int i) {
this instanceof CStyleComment and
result = this.getContents().regexpCapture("(?s)/\\*+(.*)\\*+/", 1).splitAt("\n", i)
@@ -146,14 +156,24 @@ class CommentBlock extends Comment {
this instanceof CppStyleComment and result = this.getComment(i).getContents().suffix(2)
}
/**
* Gets the number of lines in the comments associated with this comment block.
*/
int numLines() {
result = strictcount(int i, string line | line = this.getLine(i) and line.trim() != "")
}
/**
* Gets the number of lines that look like code in the comments associated with this comment block.
*/
int numCodeLines() {
result = strictcount(int i, string line | line = this.getLine(i) and looksLikeCode(line))
}
/**
* Holds if the comment block is a C-style comment, and each
* comment line starts with a *.
*/
predicate isDocumentation() {
// If a C-style comment starts each line with a *, then it's
// probably documentation rather than code.
@@ -161,6 +181,12 @@ class CommentBlock extends Comment {
forex(int i | i in [1 .. this.numLines() - 1] | this.getLine(i).trim().matches("*%"))
}
/**
* Holds if this comment block looks like code that has been commented out. Specifically:
* 1. It does not look like documentation (see `isDocumentation`).
* 2. It is not in a header file without any declaration entries or top level declarations.
* 3. More than half of the lines in the comment block look like code.
*/
predicate isCommentedOutCode() {
not this.isDocumentation() and
not this.getFile().(HeaderFile).noTopLevelCode() and

View File

@@ -30,7 +30,7 @@ predicate allowedTypedefs(TypedefType t) {
* Gets a type which appears literally in the declaration of `d`.
*/
Type getAnImmediateUsedType(Declaration d) {
d.isDefined() and
d.hasDefinition() and
(
result = d.(Function).getType() or
result = d.(Variable).getType()

View File

@@ -15,6 +15,15 @@ import cpp
import semmle.code.cpp.models.implementations.Strcpy
import semmle.code.cpp.dataflow.DataFlow
/**
* A string copy function that returns a string, rather than an error code (for
* example, `strcpy` returns a string, whereas `strcpy_s` returns an error
* code).
*/
class InterestingStrcpyFunction extends StrcpyFunction {
InterestingStrcpyFunction() { getType().getUnspecifiedType() instanceof PointerType }
}
predicate isBoolean(Expr e1) {
exists(Type t1 |
t1 = e1.getType() and
@@ -25,12 +34,12 @@ predicate isBoolean(Expr e1) {
predicate isStringCopyCastedAsBoolean(FunctionCall func, Expr expr1, string msg) {
DataFlow::localExprFlow(func, expr1) and
isBoolean(expr1.getConversion*()) and
func.getTarget() instanceof StrcpyFunction and
func.getTarget() instanceof InterestingStrcpyFunction and
msg = "Return value of " + func.getTarget().getName() + " used as a Boolean."
}
predicate isStringCopyUsedInLogicalOperationOrCondition(FunctionCall func, Expr expr1, string msg) {
func.getTarget() instanceof StrcpyFunction and
func.getTarget() instanceof InterestingStrcpyFunction and
(
(
// it is being used in an equality or logical operation

View File

@@ -23,7 +23,7 @@ import semmle.code.cpp.ir.ValueNumbering
class NullInstruction extends ConstantValueInstruction {
NullInstruction() {
this.getValue() = "0" and
this.getResultType().getUnspecifiedType() instanceof PointerType
this.getResultIRType() instanceof IRAddressType
}
}
@@ -44,8 +44,8 @@ predicate explicitNullTestOfInstruction(Instruction checked, Instruction bool) {
bool =
any(ConvertInstruction convert |
checked = convert.getUnary() and
convert.getResultType() instanceof BoolType and
checked.getResultType() instanceof PointerType
convert.getResultIRType() instanceof IRBooleanType and
checked.getResultIRType() instanceof IRAddressType
)
}

View File

@@ -6,29 +6,50 @@
import cpp
// True if function was ()-declared, but not (void)-declared or K&R-defined
/**
* Holds if `fde` has a parameter declaration that's clear on the minimum
* number of parameters. This is essentially true for everything except
* `()`-declarations.
*/
private predicate hasDefiniteNumberOfParameters(FunctionDeclarationEntry fde) {
fde.hasVoidParamList()
or
fde.getNumberOfParameters() > 0
or
fde.isDefinition()
}
/* Holds if function was ()-declared, but not (void)-declared or K&R-defined. */
private predicate hasZeroParamDecl(Function f) {
exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |
not fde.hasVoidParamList() and fde.getNumberOfParameters() = 0 and not fde.isDefinition()
not hasDefiniteNumberOfParameters(fde)
)
}
// True if this file (or header) was compiled as a C file
/* Holds if this file (or header) was compiled as a C file. */
private predicate isCompiledAsC(File f) {
f.compiledAsC()
or
exists(File src | isCompiledAsC(src) | src.getAnIncludedFile() = f)
}
/** Holds if `fc` is a call to `f` with too few arguments. */
predicate tooFewArguments(FunctionCall fc, Function f) {
f = fc.getTarget() and
not f.isVarargs() and
not f instanceof BuiltInFunction and
// This query should only have results on C (not C++) functions that have a
// `()` parameter list somewhere. If it has results on other functions, then
// it's probably because the extractor only saw a partial compilation.
hasZeroParamDecl(f) and
isCompiledAsC(f.getFile()) and
// There is an explicit declaration of the function whose parameter count is larger
// than the number of call arguments
exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |
// Produce an alert when all declarations that are authoritative on the
// parameter count specify a parameter count larger than the number of call
// arguments.
forex(FunctionDeclarationEntry fde |
fde = f.getADeclarationEntry() and
hasDefiniteNumberOfParameters(fde)
|
fde.getNumberOfParameters() > fc.getNumberOfArguments()
)
}

View File

@@ -1,27 +0,0 @@
/**
* @name Churned lines per file
* @description Number of churned lines per file, across the revision
* history in the database.
* @kind treemap
* @id cpp/historical-churn
* @treemap.warnOn highValues
* @metricType file
* @metricAggregate avg sum max
* @tags external-data
* @deprecated
*/
import cpp
import external.VCS
from File f, int n
where
n =
sum(Commit entry, int churn |
churn = entry.getRecentChurnForFile(f) and
not artificialChange(entry)
|
churn
) and
exists(f.getMetrics().getNumberOfLinesOfCode())
select f, n order by n desc

View File

@@ -1,27 +0,0 @@
/**
* @name Added lines per file
* @description Number of added lines per file, across the revision
* history in the database.
* @kind treemap
* @id cpp/historical-lines-added
* @treemap.warnOn highValues
* @metricType file
* @metricAggregate avg sum max
* @tags external-data
* @deprecated
*/
import cpp
import external.VCS
from File f, int n
where
n =
sum(Commit entry, int churn |
churn = entry.getRecentAdditionsForFile(f) and
not artificialChange(entry)
|
churn
) and
exists(f.getMetrics().getNumberOfLinesOfCode())
select f, n order by n desc

View File

@@ -1,27 +0,0 @@
/**
* @name Deleted lines per file
* @description Number of deleted lines per file, across the revision
* history in the database.
* @kind treemap
* @id cpp/historical-lines-deleted
* @treemap.warnOn highValues
* @metricType file
* @metricAggregate avg sum max
* @tags external-data
* @deprecated
*/
import cpp
import external.VCS
from File f, int n
where
n =
sum(Commit entry, int churn |
churn = entry.getRecentDeletionsForFile(f) and
not artificialChange(entry)
|
churn
) and
exists(f.getMetrics().getNumberOfLinesOfCode())
select f, n order by n desc

View File

@@ -1,18 +0,0 @@
/**
* @name Number of authors
* @description Number of distinct authors for each file.
* @kind treemap
* @id cpp/historical-number-of-authors
* @treemap.warnOn highValues
* @metricType file
* @metricAggregate avg min max
* @tags external-data
* @deprecated
*/
import cpp
import external.VCS
from File f
where exists(f.getMetrics().getNumberOfLinesOfCode())
select f, count(Author author | author.getAnEditedFile() = f)

View File

@@ -1,19 +0,0 @@
/**
* @name Number of file-level changes
* @description The number of file-level changes made (by version
* control history).
* @kind treemap
* @id cpp/historical-number-of-changes
* @treemap.warnOn highValues
* @metricType file
* @metricAggregate avg min max sum
* @tags external-data
* @deprecated
*/
import cpp
import external.VCS
from File f
where exists(f.getMetrics().getNumberOfLinesOfCode())
select f, count(Commit svn | f = svn.getAnAffectedFile() and not artificialChange(svn))

View File

@@ -1,21 +0,0 @@
/**
* @name Number of co-committed files
* @description The average number of other files that are touched
* whenever a file is affected by a commit.
* @kind treemap
* @id cpp/historical-number-of-co-commits
* @treemap.warnOn highValues
* @metricType file
* @metricAggregate avg min max
* @tags external-data
* @deprecated
*/
import cpp
import external.VCS
int committedFiles(Commit commit) { result = count(commit.getAnAffectedFile()) }
from File f
where exists(f.getMetrics().getNumberOfLinesOfCode())
select f, avg(Commit commit | commit.getAnAffectedFile() = f | committedFiles(commit) - 1)

View File

@@ -1,37 +0,0 @@
/**
* @name Number of re-commits for each file
* @description A re-commit is taken to mean a commit to a file that
* was touched less than five days ago.
* @kind treemap
* @id cpp/historical-number-of-re-commits
* @treemap.warnOn highValues
* @metricType file
* @metricAggregate avg min max
* @tags external-data
* @deprecated
*/
import cpp
import external.VCS
predicate inRange(Commit first, Commit second) {
first.getAnAffectedFile() = second.getAnAffectedFile() and
first != second and
exists(int n |
n = first.getDate().daysTo(second.getDate()) and
n >= 0 and
n < 5
)
}
int recommitsForFile(File f) {
result =
count(Commit recommit |
f = recommit.getAnAffectedFile() and
exists(Commit prev | inRange(prev, recommit))
)
}
from File f
where exists(f.getMetrics().getNumberOfLinesOfCode())
select f, recommitsForFile(f)

View File

@@ -1,27 +0,0 @@
/**
* @name Number of recent authors
* @description Number of distinct authors that have recently made
* changes.
* @kind treemap
* @id cpp/historical-number-of-recent-authors
* @treemap.warnOn highValues
* @metricType file
* @metricAggregate avg min max
* @tags external-data
* @deprecated
*/
import cpp
import external.VCS
from File f
where exists(f.getMetrics().getNumberOfLinesOfCode())
select f,
count(Author author |
exists(Commit e |
e = author.getACommit() and
f = e.getAnAffectedFile() and
e.daysToNow() <= 180 and
not artificialChange(e)
)
)

View File

@@ -1,24 +0,0 @@
/**
* @name Recently changed files
* @description Number of files recently edited.
* @kind treemap
* @id cpp/historical-number-of-recent-changed-files
* @treemap.warnOn highValues
* @metricType file
* @metricAggregate avg min max sum
* @tags external-data
* @deprecated
*/
import cpp
import external.VCS
from File f
where
exists(Commit e |
e.getAnAffectedFile() = f and
e.daysToNow() <= 180 and
not artificialChange(e)
) and
exists(f.getMetrics().getNumberOfLinesOfCode())
select f, 1

View File

@@ -1,25 +0,0 @@
/**
* @name Recent changes
* @description Number of recent commits to this file.
* @kind treemap
* @id cpp/historical-number-of-recent-changes
* @treemap.warnOn highValues
* @metricType file
* @metricAggregate avg min max sum
* @tags external-data
* @deprecated
*/
import cpp
import external.VCS
from File f, int n
where
n =
count(Commit e |
e.getAnAffectedFile() = f and
e.daysToNow() <= 180 and
not artificialChange(e)
) and
exists(f.getMetrics().getNumberOfLinesOfCode())
select f, n order by n desc

View File

@@ -5,7 +5,7 @@
* or data representation problems.
* @kind path-problem
* @problem.severity warning
* @precision medium
* @precision high
* @id cpp/tainted-format-string
* @tags reliability
* security

View File

@@ -5,7 +5,7 @@
* or data representation problems.
* @kind path-problem
* @problem.severity warning
* @precision medium
* @precision high
* @id cpp/tainted-format-string-through-global
* @tags reliability
* security

View File

@@ -18,7 +18,7 @@ abstract class InsecureCryptoSpec extends Locatable {
}
Function getAnInsecureFunction() {
result.getName().regexpMatch(algorithmBlacklistRegex()) and
result.getName().regexpMatch(getInsecureAlgorithmRegex()) and
exists(result.getACallToThisFunction())
}
@@ -33,7 +33,7 @@ class InsecureFunctionCall extends InsecureCryptoSpec, FunctionCall {
}
Macro getAnInsecureMacro() {
result.getName().regexpMatch(algorithmBlacklistRegex()) and
result.getName().regexpMatch(getInsecureAlgorithmRegex()) and
exists(result.getAnInvocation())
}

View File

@@ -198,12 +198,12 @@ class InitializationFunction extends Function {
)
or
// If we have no definition, we look at SAL annotations
not this.isDefined() and
not this.hasDefinition() and
this.getParameter(i).(SALParameter).isOut() and
evidence = SuggestiveSALAnnotation()
or
// We have some external information that this function conditionally initializes
not this.isDefined() and
not this.hasDefinition() and
any(ValidatedExternalCondInitFunction vc).isExternallyVerified(this, i) and
evidence = ExternalEvidence()
}
@@ -406,7 +406,7 @@ class ConditionalInitializationFunction extends InitializationFunction {
* Explicitly ignore pure virtual functions.
*/
this.isDefined() and
this.hasDefinition() and
this.paramNotReassignedAt(this, i, c) and
not this instanceof PureVirtualFunction
)
@@ -616,11 +616,11 @@ private predicate functionSignature(Function f, string qualifiedName, string typ
* are never statically linked together.
*/
private Function getAPossibleDefinition(Function undefinedFunction) {
not undefinedFunction.isDefined() and
not undefinedFunction.hasDefinition() and
exists(string qn, string typeSig |
functionSignature(undefinedFunction, qn, typeSig) and functionSignature(result, qn, typeSig)
) and
result.isDefined()
result.hasDefinition()
}
/**
@@ -631,7 +631,7 @@ private Function getAPossibleDefinition(Function undefinedFunction) {
*/
private Function getTarget1(Call c) {
result = VirtualDispatch::getAViableTarget(c) and
result.isDefined()
result.hasDefinition()
}
/**

View File

@@ -21,7 +21,7 @@ where
destBase = baseType(destType) and
destBase.getSize() != sourceBase.getSize() and
not dest.isInMacroExpansion() and
// If the source type is a char* or void* then don't
// If the source type is a `char*` or `void*` then don't
// produce a result, because it is likely to be a false
// positive.
not sourceBase instanceof CharType and

View File

@@ -21,7 +21,7 @@ where
destBase = baseType(destType) and
destBase.getSize() != sourceBase.getSize() and
not dest.isInMacroExpansion() and
// If the source type is a char* or void* then don't
// If the source type is a `char*` or `void*` then don't
// produce a result, because it is likely to be a false
// positive.
not sourceBase instanceof CharType and

View File

@@ -24,7 +24,7 @@ private predicate isCharSzPtrExpr(Expr e) {
from Expr sizeofExpr, Expr e
where
// If we see an addWithSizeof then we expect the type of
// the pointer expression to be char* or void*. Otherwise it
// the pointer expression to be `char*` or `void*`. Otherwise it
// is probably a mistake.
addWithSizeof(e, sizeofExpr, _) and not isCharSzPtrExpr(e)
select sizeofExpr,

View File

@@ -2,3 +2,5 @@
- qlpack: codeql-cpp
- apply: code-scanning-selectors.yml
from: codeql-suite-helpers
- apply: codeql-suites/exclude-slow-queries.yml
from: codeql-cpp

View File

@@ -2,13 +2,17 @@
- qlpack: codeql-cpp
- apply: lgtm-selectors.yml
from: codeql-suite-helpers
# These queries are infeasible to compute on large projects:
- apply: codeql-suites/exclude-slow-queries.yml
from: codeql-cpp
# These are only for IDE use.
- exclude:
query path:
- Security/CWE/CWE-497/ExposedSystemData.ql
- Critical/DescriptorMayNotBeClosed.ql
- Critical/DescriptorNeverClosed.ql
- Critical/FileMayNotBeClosed.ql
- Critical/FileNeverClosed.ql
- Critical/MemoryMayNotBeFreed.ql
- Critical/MemoryNeverFreed.ql
tags contain:
- ide-contextual-queries/local-definitions
- ide-contextual-queries/local-references
- query: Metrics/Dependencies/ExternalDependencies.ql
- query: Metrics/Dependencies/ExternalDependenciesSourceLinks.ql
- query: Metrics/Files/FLinesOfCode.ql
- query: Metrics/Files/FLinesOfCommentedOutCode.ql
- query: Metrics/Files/FLinesOfComments.ql
- query: Metrics/Files/FLinesOfDuplicatedCode.ql
- query: Metrics/Files/FNumberOfTests.ql

View File

@@ -0,0 +1,6 @@
- description: Security-and-quality queries for C and C++
- qlpack: codeql-cpp
- apply: security-and-quality-selectors.yml
from: codeql-suite-helpers
- apply: codeql-suites/exclude-slow-queries.yml
from: codeql-cpp

View File

@@ -0,0 +1,6 @@
- description: Security-extended queries for C and C++
- qlpack: codeql-cpp
- apply: security-extended-selectors.yml
from: codeql-suite-helpers
- apply: codeql-suites/exclude-slow-queries.yml
from: codeql-cpp

View File

@@ -0,0 +1,11 @@
- description: C/C++ queries which are infeasible to compute on large projects
# These queries are infeasible to compute on large projects:
- exclude:
query path:
- Security/CWE/CWE-497/ExposedSystemData.ql
- Critical/DescriptorMayNotBeClosed.ql
- Critical/DescriptorNeverClosed.ql
- Critical/FileMayNotBeClosed.ql
- Critical/FileNeverClosed.ql
- Critical/MemoryMayNotBeFreed.ql
- Critical/MemoryNeverFreed.ql

View File

@@ -32,6 +32,7 @@ import semmle.code.cpp.Enum
import semmle.code.cpp.Member
import semmle.code.cpp.Field
import semmle.code.cpp.Function
import semmle.code.cpp.MemberFunction
import semmle.code.cpp.Parameter
import semmle.code.cpp.Variable
import semmle.code.cpp.Initializer

View File

@@ -1 +1,7 @@
/**
* DEPRECATED: use `import cpp` instead of `import default`.
*
* Provides classes and predicates for working with C/C++ code.
*/
import cpp

View File

@@ -132,6 +132,7 @@ private predicate constructorCallTypeMention(ConstructorCall cc, TypeMention tm)
* - `"X"` for macro accesses
* - `"I"` for import / include directives
*/
cached
Top definitionOf(Top e, string kind) {
(
// call -> function called
@@ -213,3 +214,11 @@ Top definitionOf(Top e, string kind) {
// later on.
strictcount(result.getLocation()) < 10
}
/**
* Returns an appropriately encoded version of a filename `name`
* passed by the VS Code extension in order to coincide with the
* output of `.getFile()` on locatable entities.
*/
cached
File getEncodedFile(string name) { result.getAbsolutePath().replaceAll(":", "_") = name }

View File

@@ -0,0 +1,282 @@
/**
* Provides precise tracking of how big the memory pointed to by pointers is.
* For each pointer, we start tracking (starting from the allocation or an array declaration)
* 1) how long is the chunk of memory allocated
* 2) where the current pointer is in this chunk of memory
* As computing this information is obviously not possible for all pointers,
* we do not guarantee the existence of length/offset information for all pointers.
* However, when it exists it is guaranteed to be accurate.
*
* The length and offset are tracked in a similar way to the Rangeanalysis.
* Each length is a `ValueNumber + delta`, and each Offset is an `Operand + delta`.
* We choose to track a `ValueNumber` for length, because the Rangeanalysis offers
* integer bounds on instructions and operands in terms of `ValueNumber`s,
* and `Operand` for offset because integer bounds on `Operand`s are
* tighter than bounds on `Instruction`s.
*/
import cpp
import semmle.code.cpp.ir.IR
private import semmle.code.cpp.ir.ValueNumbering
private import semmle.code.cpp.ir.internal.CppType
private import semmle.code.cpp.models.interfaces.Allocation
private import experimental.semmle.code.cpp.rangeanalysis.RangeUtils
private newtype TLength =
TZeroLength() or
TVNLength(ValueNumber vn) {
not vn.getAnInstruction() instanceof ConstantInstruction and
exists(Instruction i |
vn.getAnInstruction() = i and
(
i.getResultIRType() instanceof IRSignedIntegerType or
i.getResultIRType() instanceof IRUnsignedIntegerType
)
|
i instanceof PhiInstruction
or
i instanceof InitializeParameterInstruction
or
i instanceof CallInstruction
or
i.(LoadInstruction).getSourceAddress() instanceof VariableAddressInstruction
or
i.(LoadInstruction).getSourceAddress() instanceof FieldAddressInstruction
or
i.getAUse() instanceof ArgumentOperand
)
}
/**
* Array lengths are represented in a ValueNumber | Zero + delta format.
* This class keeps track of the ValueNumber or Zero.
* The delta is tracked in the predicate `knownArrayLength`.
*/
class Length extends TLength {
string toString() { none() } // overridden in subclasses
}
/**
* This length class corresponds to an array having a constant length
* that is tracked by the delta value.
*/
class ZeroLength extends Length, TZeroLength {
override string toString() { result = "ZeroLength" }
}
/**
* This length class corresponds to an array having variable length, i.e. the
* length is tracked by a value number. One example is an array having length
* `count` for an integer variable `count` in the program.
*/
class VNLength extends Length, TVNLength {
ValueNumber vn;
VNLength() { this = TVNLength(vn) }
/** Gets an instruction with this value number bound. */
Instruction getInstruction() { this = TVNLength(valueNumber(result)) }
ValueNumber getValueNumber() { result = vn }
override string toString() { result = "VNLength(" + vn.getExampleInstruction().toString() + ")" }
}
private newtype TOffset =
TZeroOffset() or
TOpOffset(Operand op) {
op.getAnyDef().getResultIRType() instanceof IRSignedIntegerType or
op.getAnyDef().getResultIRType() instanceof IRUnsignedIntegerType
}
/**
* This class describes the offset of a pointer in a chunk of memory.
* It is either an `Operand` or zero, an additional integer delta is added later.
*/
class Offset extends TOffset {
string toString() { none() } // overridden in subclasses
}
/**
* This class represents a fixed offset, only specified by a delta.
*/
class ZeroOffset extends Offset, TZeroOffset {
override string toString() { result = "ZeroOffset" }
}
/**
* This class represents an offset of an operand.
*/
class OpOffset extends Offset, TOpOffset {
Operand op;
OpOffset() { this = TOpOffset(op) }
Operand getOperand() { result = op }
override string toString() { result = "OpOffset(" + op.getDef().toString() + ")" }
}
private int getBaseSizeForPointerType(PointerType type) { result = type.getBaseType().getSize() }
/**
* Holds if pointer `prev` that points at offset `prevOffset + prevOffsetDelta`
* steps to `array` that points to `offset + offsetDelta` in one step.
* This predicate does not contain any recursive steps.
*/
bindingset[prevOffset, prevOffsetDelta]
predicate simpleArrayLengthStep(
Instruction array, Offset offset, int offsetDelta, Instruction prev, Offset prevOffset,
int prevOffsetDelta
) {
// array assign
array.(CopyInstruction).getSourceValue() = prev and
offset = prevOffset and
offsetDelta = prevOffsetDelta
or
// pointer add with constant
array.(PointerAddInstruction).getLeft() = prev and
offset = prevOffset and
offsetDelta = prevOffsetDelta + getConstantValue(array.(PointerAddInstruction).getRight())
or
// pointer add with variable
array.(PointerAddInstruction).getLeft() = prev and
prevOffset instanceof ZeroOffset and
offset.(OpOffset).getOperand() = array.(PointerAddInstruction).getRightOperand() and
offsetDelta = prevOffsetDelta and
not exists(getConstantValue(array.(PointerAddInstruction).getRight()))
or
// pointer sub with constant
array.(PointerSubInstruction).getLeft() = prev and
offset = prevOffset and
offsetDelta = prevOffsetDelta - getConstantValue(array.(PointerSubInstruction).getRight())
or
// array to pointer decay
array.(ConvertInstruction).getUnary() = prev and
array.getConvertedResultExpression() instanceof ArrayToPointerConversion and
offset = prevOffset and
offsetDelta = prevOffsetDelta
or
// cast of pointer to pointer with the same element size
exists(PointerType fromTyp, PointerType toTyp |
array.(PtrToPtrCastInstruction).getUnary() = prev and
prev.getResultLanguageType().hasType(fromTyp, false) and
array.getResultLanguageType().hasType(toTyp, false) and
offset = prevOffset and
offsetDelta = prevOffsetDelta and
if fromTyp instanceof VoidPointerType
then getBaseSizeForPointerType(toTyp) = 1
else (
if toTyp instanceof VoidPointerType
then getBaseSizeForPointerType(fromTyp) = 1
else getBaseSizeForPointerType(toTyp) = getBaseSizeForPointerType(fromTyp)
)
)
}
/**
* Parses a `sizeExpr` of malloc into a variable part (`lengthExpr`) and an integer offset (`delta`).
*/
private predicate deconstructMallocSizeExpr(Expr sizeExpr, Expr lengthExpr, int delta) {
sizeExpr instanceof AddExpr and
exists(Expr constantExpr |
lengthExpr = sizeExpr.(AddExpr).getAnOperand() and
constantExpr = sizeExpr.(AddExpr).getAnOperand() and
lengthExpr != constantExpr and
delta = constantExpr.getValue().toInt()
)
or
sizeExpr instanceof SubExpr and
exists(Expr constantExpr |
lengthExpr = sizeExpr.(SubExpr).getLeftOperand() and
constantExpr = sizeExpr.(SubExpr).getRightOperand() and
delta = -constantExpr.getValue().toInt()
)
}
/**
* Holds if the instruction `array` is a dynamic memory allocation of `length`+`delta` elements.
*/
private predicate allocation(Instruction array, Length length, int delta) {
exists(AllocationExpr alloc, Type ptrTyp |
array.getUnconvertedResultExpression() = alloc and
array.getResultLanguageType().hasType(ptrTyp, false) and
// ensure that we have the same type of the allocation and the pointer
ptrTyp.stripTopLevelSpecifiers().(PointerType).getBaseType().getUnspecifiedType() =
alloc.getAllocatedElementType().getUnspecifiedType() and
// ensure that the size multiplier of the allocation is the same as the
// size of the type we are allocating
alloc.getSizeMult() = getBaseSizeForPointerType(ptrTyp) and
(
length instanceof ZeroLength and
delta = alloc.getSizeExpr().getValue().toInt()
or
not exists(alloc.getSizeExpr().getValue().toInt()) and
(
exists(Expr lengthExpr |
deconstructMallocSizeExpr(alloc.getSizeExpr(), lengthExpr, delta) and
length.(VNLength).getInstruction().getConvertedResultExpression() = lengthExpr
)
or
not exists(int d | deconstructMallocSizeExpr(alloc.getSizeExpr(), _, d)) and
length.(VNLength).getInstruction().getConvertedResultExpression() = alloc.getSizeExpr() and
delta = 0
)
)
)
}
/**
* Holds if `array` is declared as an array with length `length + lengthDelta`
*/
private predicate arrayDeclaration(Instruction array, Length length, int lengthDelta) {
(
array instanceof VariableAddressInstruction or
array instanceof FieldAddressInstruction
) and
exists(ArrayType type | array.getResultLanguageType().hasType(type, _) |
length instanceof ZeroLength and
lengthDelta = type.getArraySize()
)
}
/**
* Holds if `array` is declared as an array or allocated
* with length `length + lengthDelta`
*/
predicate arrayAllocationOrDeclaration(Instruction array, Length length, int lengthDelta) {
allocation(array, length, lengthDelta)
or
// declaration of variable of array type
arrayDeclaration(array, length, lengthDelta)
}
/**
* Holds if the instruction `array` represents a pointer to a chunk of memory that holds
* `length + lengthDelta` elements, using only local analysis.
* `array` points at `offset + offsetDelta` in the chunk of memory.
* The pointer is in-bounds if `offset + offsetDelta < length + lengthDelta` and
* `offset + offsetDelta >= 0` holds.
* The pointer is out-of-bounds if `offset + offsetDelta >= length + lengthDelta`
* or `offset + offsetDelta < 0` holds.
* All pointers in this predicate are guaranteed to be non-null,
* but are not guaranteed to be live.
*/
predicate knownArrayLength(
Instruction array, Length length, int lengthDelta, Offset offset, int offsetDelta
) {
arrayAllocationOrDeclaration(array, length, lengthDelta) and
offset instanceof ZeroOffset and
offsetDelta = 0
or
// simple step (no phi nodes)
exists(Instruction prev, Offset prevOffset, int prevOffsetDelta |
knownArrayLength(prev, length, lengthDelta, prevOffset, prevOffsetDelta) and
simpleArrayLengthStep(array, offset, offsetDelta, prev, prevOffset, prevOffsetDelta)
)
or
// merge control flow after phi node - but only if all the bounds agree
forex(Instruction input | array.(PhiInstruction).getAnInput() = input |
knownArrayLength(input, length, lengthDelta, offset, offsetDelta)
)
}

View File

@@ -8,8 +8,8 @@ private newtype TBound =
exists(Instruction i |
vn.getAnInstruction() = i and
(
i.getResultType() instanceof IntegralType or
i.getResultType() instanceof PointerType
i.getResultIRType() instanceof IRIntegerType or
i.getResultIRType() instanceof IRAddressType
) and
not vn.getAnInstruction() instanceof ConstantInstruction
|
@@ -68,7 +68,7 @@ class ValueNumberBound extends Bound, TBoundValueNumber {
ValueNumberBound() { this = TBoundValueNumber(vn) }
/** Gets the SSA variable that equals this bound. */
/** Gets an `Instruction` that equals this bound. */
override Instruction getInstruction(int delta) {
this = TBoundValueNumber(valueNumber(result)) and delta = 0
}
@@ -76,4 +76,7 @@ class ValueNumberBound extends Bound, TBoundValueNumber {
override string toString() { result = vn.getExampleInstruction().toString() }
override Location getLocation() { result = vn.getLocation() }
/** Gets the value number that equals this bound. */
ValueNumber getValueNumber() { result = vn }
}

View File

@@ -0,0 +1,105 @@
/**
* This library proves that a subset of pointer dereferences in a program are
* safe, i.e. in-bounds.
* It does so by first defining what a pointer dereference is (on the IR
* `Instruction` level), and then using the array length analysis and the range
* analysis together to prove that some of these pointer dereferences are safe.
*
* The analysis is soundy, i.e. it is sound if no undefined behaviour is present
* in the program.
* Furthermore, it crucially depends on the soundiness of the range analysis and
* the array length analysis.
*/
import cpp
private import experimental.semmle.code.cpp.rangeanalysis.ArrayLengthAnalysis
private import experimental.semmle.code.cpp.rangeanalysis.RangeAnalysis
/**
* Gets the instruction that computes the address of memory that `i` accesses.
* Only holds if `i` dereferences a pointer, not when the computation of the
* memory address is constant, or if the address of a local variable is loaded/stored to.
*/
private Instruction getMemoryAddressInstruction(Instruction i) {
(
result = i.(FieldAddressInstruction).getObjectAddress() or
result = i.(LoadInstruction).getSourceAddress() or
result = i.(StoreInstruction).getDestinationAddress()
) and
not result instanceof FieldAddressInstruction and
not result instanceof VariableAddressInstruction and
not result instanceof ConstantValueInstruction
}
/**
* All instructions that dereference a pointer.
*/
class PointerDereferenceInstruction extends Instruction {
PointerDereferenceInstruction() { exists(getMemoryAddressInstruction(this)) }
Instruction getAddress() { result = getMemoryAddressInstruction(this) }
}
/**
* Holds if `ptrDeref` can be proven to always access allocated memory.
*/
predicate inBounds(PointerDereferenceInstruction ptrDeref) {
exists(Length length, int lengthDelta, Offset offset, int offsetDelta |
knownArrayLength(ptrDeref.getAddress(), length, lengthDelta, offset, offsetDelta) and
// lower bound - note that we treat a pointer that accesses an array of
// length 0 as on upper-bound violation, but not as a lower-bound violation
(
offset instanceof ZeroOffset and
offsetDelta >= 0
or
offset instanceof OpOffset and
exists(int lowerBoundDelta |
boundedOperand(offset.(OpOffset).getOperand(), any(ZeroBound b), lowerBoundDelta,
/*upper*/ false, _) and
lowerBoundDelta + offsetDelta >= 0
)
) and
// upper bound
(
// both offset and length are only integers
length instanceof ZeroLength and
offset instanceof ZeroOffset and
offsetDelta < lengthDelta
or
exists(int lengthBound |
// array length is variable+integer, and there's a fixed (integer-only)
// lower bound on the variable, so we can guarantee this access is always in-bounds
length instanceof VNLength and
offset instanceof ZeroOffset and
boundedInstruction(length.(VNLength).getInstruction(), any(ZeroBound b), lengthBound,
/* upper*/ false, _) and
offsetDelta < lengthBound + lengthDelta
)
or
exists(int offsetBoundDelta |
length instanceof ZeroLength and
offset instanceof OpOffset and
boundedOperand(offset.(OpOffset).getOperand(), any(ZeroBound b), offsetBoundDelta,
/* upper */ true, _) and
// offset <= offsetBoundDelta, so offset + offsetDelta <= offsetDelta + offsetBoundDelta
// Thus, in-bounds if offsetDelta + offsetBoundDelta < lengthDelta
// as we have length instanceof ZeroLength
offsetDelta + offsetBoundDelta < lengthDelta
)
or
exists(ValueNumberBound b, int offsetBoundDelta |
length instanceof VNLength and
offset instanceof OpOffset and
b.getValueNumber() = length.(VNLength).getValueNumber() and
// It holds that offset <= length + offsetBoundDelta
boundedOperand(offset.(OpOffset).getOperand(), b, offsetBoundDelta, /*upper*/ true, _) and
// it also holds that
offsetDelta < lengthDelta - offsetBoundDelta
// taking both inequalities together we get
// offset <= length + offsetBoundDelta
// => offset + offsetDelta <= length + offsetBoundDelta + offsetDelta < length + offsetBoundDelta + lengthDelta - offsetBoundDelta
// as required
)
)
)
}

View File

@@ -241,49 +241,17 @@ class CondReason extends Reason, TCondReason {
override string toString() { result = getCond().toString() }
}
/**
* Holds if a cast from `fromtyp` to `totyp` can be ignored for the purpose of
* range analysis.
*/
pragma[inline]
private predicate safeCast(IntegralType fromtyp, IntegralType totyp) {
fromtyp.getSize() < totyp.getSize() and
(
fromtyp.isUnsigned()
or
totyp.isSigned()
)
or
fromtyp.getSize() <= totyp.getSize() and
(
fromtyp.isSigned() and
totyp.isSigned()
or
fromtyp.isUnsigned() and
totyp.isUnsigned()
)
}
private class SafeCastInstruction extends ConvertInstruction {
SafeCastInstruction() {
safeCast(getUnary().getResultType(), getResultType())
or
getResultType() instanceof PointerType and
getUnary().getResultType() instanceof PointerType
}
}
/**
* Holds if `typ` is a small integral type with the given lower and upper bounds.
*/
private predicate typeBound(IntegralType typ, int lowerbound, int upperbound) {
typ.isSigned() and typ.getSize() = 1 and lowerbound = -128 and upperbound = 127
private predicate typeBound(IRIntegerType typ, int lowerbound, int upperbound) {
typ.isSigned() and typ.getByteSize() = 1 and lowerbound = -128 and upperbound = 127
or
typ.isUnsigned() and typ.getSize() = 1 and lowerbound = 0 and upperbound = 255
typ.isUnsigned() and typ.getByteSize() = 1 and lowerbound = 0 and upperbound = 255
or
typ.isSigned() and typ.getSize() = 2 and lowerbound = -32768 and upperbound = 32767
typ.isSigned() and typ.getByteSize() = 2 and lowerbound = -32768 and upperbound = 32767
or
typ.isUnsigned() and typ.getSize() = 2 and lowerbound = 0 and upperbound = 65535
typ.isUnsigned() and typ.getByteSize() = 2 and lowerbound = 0 and upperbound = 65535
}
/**
@@ -292,14 +260,14 @@ private predicate typeBound(IntegralType typ, int lowerbound, int upperbound) {
private class NarrowingCastInstruction extends ConvertInstruction {
NarrowingCastInstruction() {
not this instanceof SafeCastInstruction and
typeBound(getResultType(), _, _)
typeBound(getResultIRType(), _, _)
}
/** Gets the lower bound of the resulting type. */
int getLowerBound() { typeBound(getResultType(), result, _) }
int getLowerBound() { typeBound(getResultIRType(), result, _) }
/** Gets the upper bound of the resulting type. */
int getUpperBound() { typeBound(getResultType(), _, result) }
int getUpperBound() { typeBound(getResultIRType(), _, result) }
}
/**

View File

@@ -80,3 +80,55 @@ predicate backEdge(PhiInstruction phi, PhiInputOperand op) {
phi.getAnOperand() = op and
phi.getBlock() = op.getPredecessorBlock().getBackEdgeSuccessor(_)
}
/**
* Holds if a cast from `fromtyp` to `totyp` can be ignored for the purpose of
* range analysis.
*/
pragma[inline]
private predicate safeCast(IRIntegerType fromtyp, IRIntegerType totyp) {
fromtyp.getByteSize() < totyp.getByteSize() and
(
fromtyp.isUnsigned()
or
totyp.isSigned()
)
or
fromtyp.getByteSize() <= totyp.getByteSize() and
(
fromtyp.isSigned() and
totyp.isSigned()
or
fromtyp.isUnsigned() and
totyp.isUnsigned()
)
}
/**
* A `ConvertInstruction` which casts from one pointer type to another.
*/
class PtrToPtrCastInstruction extends ConvertInstruction {
PtrToPtrCastInstruction() {
getResultIRType() instanceof IRAddressType and
getUnary().getResultIRType() instanceof IRAddressType
}
}
/**
* A `ConvertInstruction` which casts from one integer type to another in a way
* that cannot overflow or underflow.
*/
class SafeIntCastInstruction extends ConvertInstruction {
SafeIntCastInstruction() { safeCast(getUnary().getResultIRType(), getResultIRType()) }
}
/**
* A `ConvertInstruction` which does not invalidate bounds determined by
* range analysis.
*/
class SafeCastInstruction extends ConvertInstruction {
SafeCastInstruction() {
this instanceof PtrToPtrCastInstruction or
this instanceof SafeIntCastInstruction
}
}

View File

@@ -278,8 +278,6 @@ private predicate unknownSign(Instruction i) {
// non-positive, non-zero}, which would mean that the representation of the sign of an unknown
// value would be the empty set.
(
i instanceof UnmodeledDefinitionInstruction
or
i instanceof UninitializedInstruction
or
i instanceof InitializeParameterInstruction
@@ -471,7 +469,7 @@ module SignAnalysisCached {
not exists(certainInstructionSign(i)) and
not (
result = TNeg() and
i.getResultType().(IntegralType).isUnsigned()
i.getResultIRType().(IRIntegerType).isUnsigned()
) and
(
unknownSign(i)
@@ -479,9 +477,13 @@ module SignAnalysisCached {
exists(ConvertInstruction ci, Instruction prior, boolean fromSigned, boolean toSigned |
i = ci and
prior = ci.getUnary() and
(if ci.getResultType().(IntegralType).isSigned() then toSigned = true else toSigned = false) and
(
if prior.getResultType().(IntegralType).isSigned()
if ci.getResultIRType().(IRIntegerType).isSigned()
then toSigned = true
else toSigned = false
) and
(
if prior.getResultIRType().(IRIntegerType).isSigned()
then fromSigned = true
else fromSigned = false
) and
@@ -514,11 +516,11 @@ module SignAnalysisCached {
i instanceof ShiftLeftInstruction and result = s1.lshift(s2)
or
i instanceof ShiftRightInstruction and
i.getResultType().(IntegralType).isSigned() and
i.getResultIRType().(IRIntegerType).isSigned() and
result = s1.rshift(s2)
or
i instanceof ShiftRightInstruction and
not i.getResultType().(IntegralType).isSigned() and
not i.getResultIRType().(IRIntegerType).isSigned() and
result = s1.urshift(s2)
)
or

View File

@@ -1,3 +1,5 @@
/** Provides classes for detecting duplicate or similar code. */
import cpp
private string relativePath(File file) { result = file.getRelativePath().replaceAll("\\", "/") }
@@ -8,9 +10,12 @@ private predicate tokenLocation(string path, int sl, int sc, int ec, int el, Cop
tokens(copy, index, sl, sc, ec, el)
}
/** A token block used for detection of duplicate and similar code. */
class Copy extends @duplication_or_similarity {
/** Gets the index of the last token in this block. */
private int lastToken() { result = max(int i | tokens(this, i, _, _, _, _) | i) }
/** Gets the index of the token in this block starting at the location `loc`, if any. */
int tokenStartingAt(Location loc) {
exists(string filepath, int startline, int startcol |
loc.hasLocationInfo(filepath, startline, startcol, _, _) and
@@ -18,6 +23,7 @@ class Copy extends @duplication_or_similarity {
)
}
/** Gets the index of the token in this block ending at the location `loc`, if any. */
int tokenEndingAt(Location loc) {
exists(string filepath, int endline, int endcol |
loc.hasLocationInfo(filepath, _, _, endline, endcol) and
@@ -25,24 +31,38 @@ class Copy extends @duplication_or_similarity {
)
}
/** Gets the line on which the first token in this block starts. */
int sourceStartLine() { tokens(this, 0, result, _, _, _) }
/** Gets the column on which the first token in this block starts. */
int sourceStartColumn() { tokens(this, 0, _, result, _, _) }
/** Gets the line on which the last token in this block ends. */
int sourceEndLine() { tokens(this, lastToken(), _, _, result, _) }
/** Gets the column on which the last token in this block ends. */
int sourceEndColumn() { tokens(this, lastToken(), _, _, _, result) }
/** Gets the number of lines containing at least (part of) one token in this block. */
int sourceLines() { result = this.sourceEndLine() + 1 - this.sourceStartLine() }
/** Gets an opaque identifier for the equivalence class of this block. */
int getEquivalenceClass() { duplicateCode(this, _, result) or similarCode(this, _, result) }
/** Gets the source file in which this block appears. */
File sourceFile() {
exists(string name | duplicateCode(this, name, _) or similarCode(this, name, _) |
name.replaceAll("\\", "/") = relativePath(result)
)
}
/**
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
*/
predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
@@ -53,25 +73,30 @@ class Copy extends @duplication_or_similarity {
endcolumn = sourceEndColumn()
}
/** Gets a textual representation of this element. */
string toString() { none() }
}
/** A block of duplicated code. */
class DuplicateBlock extends Copy, @duplication {
override string toString() { result = "Duplicate code: " + sourceLines() + " duplicated lines." }
}
/** A block of similar code. */
class SimilarBlock extends Copy, @similarity {
override string toString() {
result = "Similar code: " + sourceLines() + " almost duplicated lines."
}
}
/** Gets a function with a body and a location. */
FunctionDeclarationEntry sourceMethod() {
result.isDefinition() and
exists(result.getLocation()) and
numlines(unresolveElement(result.getFunction()), _, _, _)
}
/** Gets the number of member functions in `c` with a body and a location. */
int numberOfSourceMethods(Class c) {
result =
count(FunctionDeclarationEntry m |
@@ -108,6 +133,10 @@ private predicate duplicateStatement(
)
}
/**
* Holds if `m1` is a function with `total` lines, and `m2` is a function
* that has `duplicate` lines in common with `m1`.
*/
predicate duplicateStatements(
FunctionDeclarationEntry m1, FunctionDeclarationEntry m2, int duplicate, int total
) {
@@ -115,13 +144,16 @@ predicate duplicateStatements(
total = strictcount(statementInMethod(m1))
}
/**
* Find pairs of methods are identical
*/
/** Holds if `m` and other are identical functions. */
predicate duplicateMethod(FunctionDeclarationEntry m, FunctionDeclarationEntry other) {
exists(int total | duplicateStatements(m, other, total, total))
}
/**
* INTERNAL: do not use.
*
* Holds if `line` in `f` is similar to a line somewhere else.
*/
predicate similarLines(File f, int line) {
exists(SimilarBlock b | b.sourceFile() = f and line in [b.sourceStartLine() .. b.sourceEndLine()])
}
@@ -152,6 +184,7 @@ private predicate similarLinesCoveredFiles(File f, File otherFile) {
)
}
/** Holds if `coveredLines` lines of `f` are similar to lines in `otherFile`. */
predicate similarLinesCovered(File f, int coveredLines, File otherFile) {
exists(int numLines | numLines = f.getMetrics().getNumberOfLines() |
similarLinesCoveredFiles(f, otherFile) and
@@ -166,6 +199,11 @@ predicate similarLinesCovered(File f, int coveredLines, File otherFile) {
)
}
/**
* INTERNAL: do not use.
*
* Holds if `line` in `f` is duplicated by a line somewhere else.
*/
predicate duplicateLines(File f, int line) {
exists(DuplicateBlock b |
b.sourceFile() = f and line in [b.sourceStartLine() .. b.sourceEndLine()]
@@ -182,6 +220,7 @@ private predicate duplicateLinesPerEquivalenceClass(int equivClass, int lines, F
)
}
/** Holds if `coveredLines` lines of `f` are duplicates of lines in `otherFile`. */
predicate duplicateLinesCovered(File f, int coveredLines, File otherFile) {
exists(int numLines | numLines = f.getMetrics().getNumberOfLines() |
exists(int coveredApprox |
@@ -206,6 +245,7 @@ predicate duplicateLinesCovered(File f, int coveredLines, File otherFile) {
)
}
/** Holds if most of `f` (`percent`%) is similar to `other`. */
predicate similarFiles(File f, File other, int percent) {
exists(int covered, int total |
similarLinesCovered(f, covered, other) and
@@ -216,6 +256,7 @@ predicate similarFiles(File f, File other, int percent) {
not duplicateFiles(f, other, _)
}
/** Holds if most of `f` (`percent`%) is duplicated by `other`. */
predicate duplicateFiles(File f, File other, int percent) {
exists(int covered, int total |
duplicateLinesCovered(f, covered, other) and
@@ -225,6 +266,10 @@ predicate duplicateFiles(File f, File other, int percent) {
)
}
/**
* Holds if most member functions of `c` (`numDup` out of `total`) are
* duplicates of member functions in `other`.
*/
predicate mostlyDuplicateClassBase(Class c, Class other, int numDup, int total) {
numDup =
strictcount(FunctionDeclarationEntry m1 |
@@ -240,6 +285,11 @@ predicate mostlyDuplicateClassBase(Class c, Class other, int numDup, int total)
(numDup * 100) / total > 80
}
/**
* Holds if most member functions of `c` are duplicates of member functions in
* `other`. Provides the human-readable `message` to describe the amount of
* duplication.
*/
predicate mostlyDuplicateClass(Class c, Class other, string message) {
exists(int numDup, int total |
mostlyDuplicateClassBase(c, other, numDup, total) and
@@ -264,12 +314,21 @@ predicate mostlyDuplicateClass(Class c, Class other, string message) {
)
}
/** Holds if `f` and `other` are similar or duplicates. */
predicate fileLevelDuplication(File f, File other) {
similarFiles(f, other, _) or duplicateFiles(f, other, _)
}
/**
* Holds if most member functions of `c` are duplicates of member functions in
* `other`.
*/
predicate classLevelDuplication(Class c, Class other) { mostlyDuplicateClass(c, other, _) }
/**
* Holds if `line` in `f` should be allowed to be duplicated. This is the case
* for `#include` directives.
*/
predicate whitelistedLineForDuplication(File f, int line) {
exists(Include i | i.getFile() = f and i.getLocation().getStartLine() = line)
}

View File

@@ -1,31 +1,52 @@
/** Provides a class for working with defect query results stored in dashboard databases. */
import cpp
/**
* Holds if `id` in the opaque identifier of a result reported by query `queryPath`,
* such that `message` is the associated message and the location of the result spans
* column `startcolumn` of line `startline` to column `endcolumn` of line `endline`
* in file `filepath`.
*
* For more information, see [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
*/
external predicate defectResults(
int id, string queryPath, string file, int startline, int startcol, int endline, int endcol,
string message
);
/**
* A defect query result stored in a dashboard database.
*/
class DefectResult extends int {
DefectResult() { defectResults(this, _, _, _, _, _, _, _) }
/** Gets the path of the query that reported the result. */
string getQueryPath() { defectResults(this, result, _, _, _, _, _, _) }
/** Gets the file in which this query result was reported. */
File getFile() {
exists(string path |
defectResults(this, _, path, _, _, _, _, _) and result.getAbsolutePath() = path
)
}
/** Gets the line on which the location of this query result starts. */
int getStartLine() { defectResults(this, _, _, result, _, _, _, _) }
/** Gets the column on which the location of this query result starts. */
int getStartColumn() { defectResults(this, _, _, _, result, _, _, _) }
/** Gets the line on which the location of this query result ends. */
int getEndLine() { defectResults(this, _, _, _, _, result, _, _) }
/** Gets the column on which the location of this query result ends. */
int getEndColumn() { defectResults(this, _, _, _, _, _, result, _) }
/** Gets the message associated with this query result. */
string getMessage() { defectResults(this, _, _, _, _, _, _, result) }
/** Gets the URL corresponding to the location of this query result. */
string getURL() {
result =
"file://" + getFile().getAbsolutePath() + ":" + getStartLine() + ":" + getStartColumn() + ":" +

View File

@@ -1,26 +1,45 @@
/**
* Provides classes for working with external data.
*/
import cpp
/**
* An external data item.
*/
class ExternalData extends @externalDataElement {
/** Gets the path of the file this data was loaded from. */
string getDataPath() { externalData(this, result, _, _) }
/**
* Gets the path of the file this data was loaded from, with its
* extension replaced by `.ql`.
*/
string getQueryPath() { result = getDataPath().regexpReplaceAll("\\.[^.]*$", ".ql") }
/** Gets the number of fields in this data item. */
int getNumFields() { result = 1 + max(int i | externalData(this, _, i, _) | i) }
string getField(int index) { externalData(this, _, index, result) }
/** Gets the value of the `i`th field of this data item. */
string getField(int i) { externalData(this, _, i, result) }
int getFieldAsInt(int index) { result = getField(index).toInt() }
/** Gets the integer value of the `i`th field of this data item. */
int getFieldAsInt(int i) { result = getField(i).toInt() }
float getFieldAsFloat(int index) { result = getField(index).toFloat() }
/** Gets the floating-point value of the `i`th field of this data item. */
float getFieldAsFloat(int i) { result = getField(i).toFloat() }
date getFieldAsDate(int index) { result = getField(index).toDate() }
/** Gets the value of the `i`th field of this data item, interpreted as a date. */
date getFieldAsDate(int i) { result = getField(i).toDate() }
/** Gets a textual representation of this data item. */
string toString() { result = getQueryPath() + ": " + buildTupleString(0) }
private string buildTupleString(int start) {
start = getNumFields() - 1 and result = getField(start)
/** Gets a textual representation of this data item, starting with the `n`th field. */
private string buildTupleString(int n) {
n = getNumFields() - 1 and result = getField(n)
or
start < getNumFields() - 1 and result = getField(start) + "," + buildTupleString(start + 1)
n < getNumFields() - 1 and result = getField(n) + "," + buildTupleString(n + 1)
}
}
@@ -33,7 +52,9 @@ class DefectExternalData extends ExternalData {
this.getNumFields() = 2
}
/** Gets the URL associated with this data item. */
string getURL() { result = getField(0) }
/** Gets the message associated with this data item. */
string getMessage() { result = getField(1) }
}

View File

@@ -1,31 +1,58 @@
/** Provides a class for working with metric query results stored in dashboard databases. */
import cpp
/**
* Holds if `id` in the opaque identifier of a result reported by query `queryPath`,
* such that `value` is the reported metric value and the location of the result spans
* column `startcolumn` of line `startline` to column `endcolumn` of line `endline`
* in file `filepath`.
*
* For more information, see [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
*/
external predicate metricResults(
int id, string queryPath, string file, int startline, int startcol, int endline, int endcol,
float value
);
/**
* A metric query result stored in a dashboard database.
*/
class MetricResult extends int {
MetricResult() { metricResults(this, _, _, _, _, _, _, _) }
/** Gets the path of the query that reported the result. */
string getQueryPath() { metricResults(this, result, _, _, _, _, _, _) }
/** Gets the file in which this query result was reported. */
File getFile() {
exists(string path |
metricResults(this, _, path, _, _, _, _, _) and result.getAbsolutePath() = path
)
}
/** Gets the line on which the location of this query result starts. */
int getStartLine() { metricResults(this, _, _, result, _, _, _, _) }
/** Gets the column on which the location of this query result starts. */
int getStartColumn() { metricResults(this, _, _, _, result, _, _, _) }
/** Gets the line on which the location of this query result ends. */
int getEndLine() { metricResults(this, _, _, _, _, result, _, _) }
/** Gets the column on which the location of this query result ends. */
int getEndColumn() { metricResults(this, _, _, _, _, _, result, _) }
/**
* Holds if there is a `Location` entity whose location is the same as
* the location of this query result.
*/
predicate hasMatchingLocation() { exists(this.getMatchingLocation()) }
/**
* Gets the `Location` entity whose location is the same as the location
* of this query result.
*/
Location getMatchingLocation() {
result.getFile() = this.getFile() and
result.getStartLine() = this.getStartLine() and
@@ -34,8 +61,10 @@ class MetricResult extends int {
result.getEndColumn() = this.getEndColumn()
}
/** Gets the value associated with this query result. */
float getValue() { metricResults(this, _, _, _, _, _, _, result) }
/** Gets the URL corresponding to the location of this query result. */
string getURL() {
result =
"file://" + getFile().getAbsolutePath() + ":" + getStartLine() + ":" + getStartColumn() + ":" +

View File

@@ -1,92 +0,0 @@
import cpp
class Commit extends @svnentry {
Commit() {
svnaffectedfiles(this, _, _) and
exists(date svnDate, date snapshotDate |
svnentries(this, _, _, svnDate, _) and
snapshotDate(snapshotDate) and
svnDate <= snapshotDate
)
}
string toString() { result = this.getRevisionName() }
string getRevisionName() { svnentries(this, result, _, _, _) }
string getAuthor() { svnentries(this, _, result, _, _) }
date getDate() { svnentries(this, _, _, result, _) }
int getChangeSize() { svnentries(this, _, _, _, result) }
string getMessage() { svnentrymsg(this, result) }
string getAnAffectedFilePath(string action) {
exists(File rawFile | svnaffectedfiles(this, unresolveElement(rawFile), action) |
result = rawFile.getAbsolutePath()
)
}
string getAnAffectedFilePath() { result = getAnAffectedFilePath(_) }
File getAnAffectedFile(string action) {
// Workaround for incorrect keys in SVN data
exists(File svnFile | svnFile.getAbsolutePath() = result.getAbsolutePath() |
svnaffectedfiles(this, unresolveElement(svnFile), action)
) and
exists(result.getMetrics().getNumberOfLinesOfCode())
}
File getAnAffectedFile() { exists(string action | result = this.getAnAffectedFile(action)) }
private predicate churnForFile(File f, int added, int deleted) {
// Workaround for incorrect keys in SVN data
exists(File svnFile | svnFile.getAbsolutePath() = f.getAbsolutePath() |
svnchurn(this, unresolveElement(svnFile), added, deleted)
) and
exists(f.getMetrics().getNumberOfLinesOfCode())
}
int getRecentChurnForFile(File f) {
exists(int added, int deleted | churnForFile(f, added, deleted) and result = added + deleted)
}
int getRecentAdditionsForFile(File f) { churnForFile(f, result, _) }
int getRecentDeletionsForFile(File f) { churnForFile(f, _, result) }
predicate isRecent() { recentCommit(this) }
int daysToNow() {
exists(date now | snapshotDate(now) | result = getDate().daysTo(now) and result >= 0)
}
}
class Author extends string {
Author() { exists(Commit e | this = e.getAuthor()) }
Commit getACommit() { result.getAuthor() = this }
File getAnEditedFile() { result = this.getACommit().getAnAffectedFile() }
}
predicate recentCommit(Commit e) {
exists(date snapshotDate, date commitDate, int days |
snapshotDate(snapshotDate) and
e.getDate() = commitDate and
days = commitDate.daysTo(snapshotDate) and
days >= 0 and
days <= 60
)
}
date firstChange(File f) {
result = min(Commit e, date toMin | f = e.getAnAffectedFile() and toMin = e.getDate() | toMin)
}
predicate firstCommit(Commit e) {
not exists(File f | f = e.getAnAffectedFile() | firstChange(f) < e.getDate())
}
predicate artificialChange(Commit e) { firstCommit(e) or e.getChangeSize() >= 50000 }

View File

@@ -1,20 +0,0 @@
/**
* @name Defect from SVN
* @description A test case for creating a defect from SVN data.
* @kind problem
* @problem.severity warning
* @tags external-data
* @deprecated
*/
import cpp
import external.ExternalArtifact
import external.VCS
predicate numCommits(File f, int i) { i = count(Commit e | e.getAnAffectedFile() = f) }
predicate maxCommits(int i) { i = max(File f, int j | numCommits(f, j) | j) }
from File f, int i
where numCommits(f, i) and maxCommits(i)
select f, "This file has " + i + " commits."

View File

@@ -1,17 +0,0 @@
/**
* @name Metric from SVN
* @description Find number of commits for a file
* @treemap.warnOn lowValues
* @metricType file
* @tags external-data
* @deprecated
*/
import cpp
import external.VCS
predicate numCommits(File f, int i) { i = count(Commit e | e.getAnAffectedFile() = f) }
from File f, int i
where numCommits(f, i)
select f, i

View File

@@ -1,25 +0,0 @@
/**
* @name Filter: exclude results from files that have not recently been
* edited
* @description Use this filter to return results only if they are
* located in files that have been modified in the 60 days
* before the date of the snapshot.
* @kind problem
* @id cpp/recent-defects-filter
* @tags filter
* external-data
* @deprecated
*/
import cpp
import external.DefectFilter
import external.VCS
pragma[noopt]
private predicate recent(File file) {
exists(Commit e | file = e.getAnAffectedFile() | e.isRecent() and not artificialChange(e))
}
from DefectResult res
where recent(res.getFile())
select res, res.getMessage()

View File

@@ -1,25 +0,0 @@
/**
* @name Metric filter: exclude results from files that have not
* recently been edited
* @description Use this filter to return results only if they are
* located in files that have been modified in the 60 days
* before the snapshot.
* @kind treemap
* @id cpp/recent-defects-for-metric-filter
* @tags filter
* external-data
* @deprecated
*/
import cpp
import external.MetricFilter
import external.VCS
pragma[noopt]
private predicate recent(File file) {
exists(Commit e | file = e.getAnAffectedFile() | e.isRecent() and not artificialChange(e))
}
from MetricResult res
where recent(res.getFile())
select res, res.getValue()

View File

@@ -0,0 +1,16 @@
/**
* @name Jump-to-definition links
* @description Generates use-definition pairs that provide the data
* for jump-to-definition in the code viewer.
* @kind definitions
* @id cpp/ide-jump-to-definition
* @tags ide-contextual-queries/local-definitions
*/
import definitions
external string selectedSourceFile();
from Top e, Top def, string kind
where def = definitionOf(e, kind) and e.getFile() = getEncodedFile(selectedSourceFile())
select e, def, kind

View File

@@ -0,0 +1,16 @@
/**
* @name Find-references links
* @description Generates use-definition pairs that provide the data
* for find-references in the code viewer.
* @kind definitions
* @id cpp/ide-find-references
* @tags ide-contextual-queries/local-references
*/
import definitions
external string selectedSourceFile();
from Top e, Top def, string kind
where def = definitionOf(e, kind) and def.getFile() = getEncodedFile(selectedSourceFile())
select e, def, kind

View File

@@ -1 +1,7 @@
/**
* DEPRECATED: Objective C is no longer supported.
*
* Import `cpp` instead of `objc`.
*/
import cpp

27
cpp/ql/src/printAst.ql Normal file
View File

@@ -0,0 +1,27 @@
/**
* @name Print AST
* @description Outputs a representation of a file's Abstract Syntax Tree. This
* query is used by the VS Code extension.
* @id cpp/print-ast
* @kind graph
* @tags ide-contextual-queries/print-ast
*/
import cpp
import semmle.code.cpp.PrintAST
import definitions
/**
* The source file to generate an AST from.
*/
external string selectedSourceFile();
class Cfg extends PrintASTConfiguration {
/**
* Holds if the AST for `func` should be printed.
* Print All functions from the selected file.
*/
override predicate shouldPrintFunction(Function func) {
func.getFile() = getEncodedFile(selectedSourceFile())
}
}

View File

@@ -0,0 +1,9 @@
/**
* @name AST Consistency Check
* @description Performs consistency checks on the Abstract Syntax Tree. This query should have no results.
* @kind table
* @id cpp/ast-consistency-check
*/
import cpp
import CastConsistency

View File

@@ -1,9 +0,0 @@
/**
* @name AST Sanity Check
* @description Performs sanity checks on the Abstract Syntax Tree. This query should have no results.
* @kind table
* @id cpp/ast-sanity-check
*/
import cpp
import CastSanity

View File

@@ -1,3 +1,8 @@
/**
* Provides a class and predicate for recognizing files that are likely to have been generated
* automatically.
*/
import semmle.code.cpp.Comments
import semmle.code.cpp.File
import semmle.code.cpp.Preprocessor

View File

@@ -1,3 +1,7 @@
/**
* Provides classes representing C++ classes, including structs, unions, and template classes.
*/
import semmle.code.cpp.Type
import semmle.code.cpp.UserType
import semmle.code.cpp.metrics.MetricClass
@@ -29,7 +33,7 @@ private import semmle.code.cpp.internal.ResolveClass
class Class extends UserType {
Class() { isClass(underlyingElement(this)) }
override string getCanonicalQLClass() { result = "Class" }
override string getAPrimaryQlClass() { result = "Class" }
/** Gets a child declaration of this class, struct or union. */
override Declaration getADeclaration() { result = this.getAMember() }
@@ -458,6 +462,15 @@ class Class extends UserType {
exists(ClassDerivation d | d.getDerivedClass() = this and d = result)
}
/**
* Gets class derivation number `index` of this class/struct, for example the
* `public B` is derivation 1 in the following code:
* ```
* class D : public A, public B, public C {
* ...
* };
* ```
*/
ClassDerivation getDerivation(int index) {
exists(ClassDerivation d | d.getDerivedClass() = this and d.getIndex() = index and d = result)
}
@@ -755,7 +768,7 @@ class ClassDerivation extends Locatable, @derivation {
*/
Class getBaseClass() { result = getBaseType().getUnderlyingType() }
override string getCanonicalQLClass() { result = "ClassDerivation" }
override string getAPrimaryQlClass() { result = "ClassDerivation" }
/**
* Gets the type from which we are deriving, without resolving any
@@ -836,9 +849,7 @@ class ClassDerivation extends Locatable, @derivation {
class LocalClass extends Class {
LocalClass() { isLocal() }
override string getCanonicalQLClass() {
not this instanceof LocalStruct and result = "LocalClass"
}
override string getAPrimaryQlClass() { not this instanceof LocalStruct and result = "LocalClass" }
override Function getEnclosingAccessHolder() { result = this.getEnclosingFunction() }
}
@@ -859,7 +870,7 @@ class LocalClass extends Class {
class NestedClass extends Class {
NestedClass() { this.isMember() }
override string getCanonicalQLClass() {
override string getAPrimaryQlClass() {
not this instanceof NestedStruct and result = "NestedClass"
}
@@ -880,7 +891,7 @@ class NestedClass extends Class {
class AbstractClass extends Class {
AbstractClass() { exists(PureVirtualFunction f | this.getAMemberFunction() = f) }
override string getCanonicalQLClass() { result = "AbstractClass" }
override string getAPrimaryQlClass() { result = "AbstractClass" }
}
/**
@@ -900,12 +911,28 @@ class AbstractClass extends Class {
class TemplateClass extends Class {
TemplateClass() { usertypes(underlyingElement(this), _, 6) }
/**
* Gets a class instantiated from this template.
*
* For example for `MyTemplateClass<T>` in the following code, the results are
* `MyTemplateClass<int>` and `MyTemplateClass<long>`:
* ```
* template<class T>
* class MyTemplateClass {
* ...
* };
*
* MyTemplateClass<int> instance;
*
* MyTemplateClass<long> instance;
* ```
*/
Class getAnInstantiation() {
result.isConstructedFrom(this) and
exists(result.getATemplateArgument())
}
override string getCanonicalQLClass() { result = "TemplateClass" }
override string getAPrimaryQlClass() { result = "TemplateClass" }
}
/**
@@ -926,7 +953,7 @@ class ClassTemplateInstantiation extends Class {
ClassTemplateInstantiation() { tc.getAnInstantiation() = this }
override string getCanonicalQLClass() { result = "ClassTemplateInstantiation" }
override string getAPrimaryQlClass() { result = "ClassTemplateInstantiation" }
/**
* Gets the class template from which this instantiation was instantiated.
@@ -967,7 +994,7 @@ abstract class ClassTemplateSpecialization extends Class {
count(int i | exists(result.getTemplateArgument(i)))
}
override string getCanonicalQLClass() { result = "ClassTemplateSpecialization" }
override string getAPrimaryQlClass() { result = "ClassTemplateSpecialization" }
}
/**
@@ -996,7 +1023,7 @@ class FullClassTemplateSpecialization extends ClassTemplateSpecialization {
not this instanceof ClassTemplateInstantiation
}
override string getCanonicalQLClass() { result = "FullClassTemplateSpecialization" }
override string getAPrimaryQlClass() { result = "FullClassTemplateSpecialization" }
}
/**
@@ -1035,7 +1062,7 @@ class PartialClassTemplateSpecialization extends ClassTemplateSpecialization {
count(int i | exists(getTemplateArgument(i)))
}
override string getCanonicalQLClass() { result = "PartialClassTemplateSpecialization" }
override string getAPrimaryQlClass() { result = "PartialClassTemplateSpecialization" }
}
/**
@@ -1060,7 +1087,7 @@ deprecated class Interface extends Class {
)
}
override string getCanonicalQLClass() { result = "Interface" }
override string getAPrimaryQlClass() { result = "Interface" }
}
/**
@@ -1075,7 +1102,7 @@ deprecated class Interface extends Class {
class VirtualClassDerivation extends ClassDerivation {
VirtualClassDerivation() { hasSpecifier("virtual") }
override string getCanonicalQLClass() { result = "VirtualClassDerivation" }
override string getAPrimaryQlClass() { result = "VirtualClassDerivation" }
}
/**
@@ -1095,7 +1122,7 @@ class VirtualClassDerivation extends ClassDerivation {
class VirtualBaseClass extends Class {
VirtualBaseClass() { exists(VirtualClassDerivation cd | cd.getBaseClass() = this) }
override string getCanonicalQLClass() { result = "VirtualBaseClass" }
override string getAPrimaryQlClass() { result = "VirtualBaseClass" }
/** A virtual class derivation of which this class/struct is the base. */
VirtualClassDerivation getAVirtualDerivation() { result.getBaseClass() = this }
@@ -1117,7 +1144,7 @@ class VirtualBaseClass extends Class {
class ProxyClass extends UserType {
ProxyClass() { usertypes(underlyingElement(this), _, 9) }
override string getCanonicalQLClass() { result = "ProxyClass" }
override string getAPrimaryQlClass() { result = "ProxyClass" }
/** Gets the location of the proxy class. */
override Location getLocation() { result = getTemplateParameter().getDefinitionLocation() }

View File

@@ -1,3 +1,7 @@
/**
* Provides classes representing C and C++ comments.
*/
import semmle.code.cpp.Location
import semmle.code.cpp.Element
@@ -13,8 +17,20 @@ class Comment extends Locatable, @comment {
override Location getLocation() { comments(underlyingElement(this), _, result) }
/**
* Gets the text of this comment, including the opening `//` or `/*`, and the closing `*``/` if
* present.
*/
string getContents() { comments(underlyingElement(this), result, _) }
/**
* Gets the AST element this comment is associated with. For example, the comment in the
* following code is associated with the declaration of `j`.
* ```
* int i;
* int j; // Comment on j
* ```
*/
Element getCommentedElement() {
commentbinding(underlyingElement(this), unresolveElement(result))
}

View File

@@ -1,3 +1,7 @@
/**
* Provides a class representing individual compiler invocations that occurred during the build.
*/
import semmle.code.cpp.File
/*
@@ -40,6 +44,7 @@ class Compilation extends @compilation {
/** Gets a file compiled during this invocation. */
File getAFileCompiled() { result = getFileCompiled(_) }
/** Gets the `i`th file compiled during this invocation */
File getFileCompiled(int i) { compilation_compiling_files(this, i, unresolveElement(result)) }
/**

View File

@@ -1,3 +1,7 @@
/**
* Provides classes for working with C and C++ declarations.
*/
import semmle.code.cpp.Element
import semmle.code.cpp.Specifier
import semmle.code.cpp.Namespace
@@ -98,7 +102,12 @@ class Declaration extends Locatable, @declaration {
this.hasQualifiedName(namespaceQualifier, "", baseName)
}
override string toString() { result = this.getName() }
/**
* Gets a description of this `Declaration` for display purposes.
*/
string getDescription() { result = this.getName() }
final override string toString() { result = this.getDescription() }
/**
* Gets the name of this declaration.
@@ -115,7 +124,7 @@ class Declaration extends Locatable, @declaration {
* To test whether this declaration has a particular name in the global
* namespace, use `hasGlobalName`.
*/
abstract string getName();
string getName() { none() } // overridden in subclasses
/** Holds if this declaration has the given name. */
predicate hasName(string name) { name = this.getName() }
@@ -131,7 +140,7 @@ class Declaration extends Locatable, @declaration {
}
/** Gets a specifier of this declaration. */
abstract Specifier getASpecifier();
Specifier getASpecifier() { none() } // overridden in subclasses
/** Holds if this declaration has a specifier with the given name. */
predicate hasSpecifier(string name) { this.getASpecifier().hasName(name) }
@@ -147,7 +156,7 @@ class Declaration extends Locatable, @declaration {
* Gets the location of a declaration entry corresponding to this
* declaration.
*/
abstract Location getADeclarationLocation();
Location getADeclarationLocation() { none() } // overridden in subclasses
/**
* Gets the declaration entry corresponding to this declaration that is a
@@ -156,11 +165,12 @@ class Declaration extends Locatable, @declaration {
DeclarationEntry getDefinition() { none() }
/** Gets the location of the definition, if any. */
abstract Location getDefinitionLocation();
Location getDefinitionLocation() { none() } // overridden in subclasses
/** Holds if the declaration has a definition. */
predicate hasDefinition() { exists(this.getDefinition()) }
/** DEPRECATED: Use `hasDefinition` instead. */
predicate isDefined() { hasDefinition() }
/** Gets the preferred location of this declaration, if any. */
@@ -279,6 +289,8 @@ class Declaration extends Locatable, @declaration {
}
}
private class TDeclarationEntry = @var_decl or @type_decl or @fun_decl;
/**
* A C/C++ declaration entry. For example the following code contains five
* declaration entries:
@@ -294,16 +306,16 @@ class Declaration extends Locatable, @declaration {
* See the comment above `Declaration` for an explanation of the relationship
* between `Declaration` and `DeclarationEntry`.
*/
abstract class DeclarationEntry extends Locatable {
class DeclarationEntry extends Locatable, TDeclarationEntry {
/** Gets a specifier associated with this declaration entry. */
abstract string getASpecifier();
string getASpecifier() { none() } // overridden in subclasses
/**
* Gets the name associated with the corresponding definition (where
* available), or the name declared by this entry otherwise.
*/
string getCanonicalName() {
if getDeclaration().isDefined()
if getDeclaration().hasDefinition()
then result = getDeclaration().getDefinition().getName()
else result = getName()
}
@@ -319,10 +331,10 @@ abstract class DeclarationEntry extends Locatable {
* `I.getADeclarationEntry()` returns `D`
* but `D.getDeclaration()` only returns `C`
*/
abstract Declaration getDeclaration();
Declaration getDeclaration() { none() } // overridden in subclasses
/** Gets the name associated with this declaration entry, if any. */
abstract string getName();
string getName() { none() } // overridden in subclasses
/**
* Gets the type associated with this declaration entry.
@@ -331,7 +343,7 @@ abstract class DeclarationEntry extends Locatable {
* For function declarations, get the return type of the function.
* For type declarations, get the type being declared.
*/
abstract Type getType();
Type getType() { none() } // overridden in subclasses
/**
* Gets the type associated with this declaration entry after specifiers
@@ -349,7 +361,7 @@ abstract class DeclarationEntry extends Locatable {
predicate hasSpecifier(string specifier) { getASpecifier() = specifier }
/** Holds if this declaration entry is a definition. */
abstract predicate isDefinition();
predicate isDefinition() { none() } // overridden in subclasses
override string toString() {
if isDefinition()
@@ -361,6 +373,8 @@ abstract class DeclarationEntry extends Locatable {
}
}
private class TAccessHolder = @function or @usertype;
/**
* A declaration that can potentially have more C++ access rights than its
* enclosing element. This comprises `Class` (they have access to their own
@@ -382,7 +396,7 @@ abstract class DeclarationEntry extends Locatable {
* the informal phrase "_R_ occurs in a member or friend of class C", where
* `AccessHolder` corresponds to this _R_.
*/
abstract class AccessHolder extends Declaration {
class AccessHolder extends Declaration, TAccessHolder {
/**
* Holds if `this` can access private members of class `c`.
*
@@ -400,7 +414,7 @@ abstract class AccessHolder extends Declaration {
/**
* Gets the nearest enclosing `AccessHolder`.
*/
abstract AccessHolder getEnclosingAccessHolder();
AccessHolder getEnclosingAccessHolder() { none() } // overridden in subclasses
/**
* Holds if a base class `base` of `derived` _is accessible at_ `this` (N4140

View File

@@ -1,3 +1,7 @@
/**
* Provides classes representing warnings generated during compilation.
*/
import semmle.code.cpp.Location
/** A compiler-generated error, warning or remark. */
@@ -11,6 +15,7 @@ class Diagnostic extends Locatable, @diagnostic {
/** Gets the error code for this compiler message. */
string getTag() { diagnostics(underlyingElement(this), _, result, _, _, _) }
/** Holds if `s` is the error code for this compiler message. */
predicate hasTag(string s) { this.getTag() = s }
/**

View File

@@ -1,3 +1,8 @@
/**
* Provides the `Element` class, which is the base class for all classes representing C or C++
* program elements.
*/
import semmle.code.cpp.Location
private import semmle.code.cpp.Enclosing
private import semmle.code.cpp.internal.ResolveClass
@@ -50,12 +55,21 @@ class ElementBase extends @element {
cached
string toString() { none() }
/** DEPRECATED: use `getAPrimaryQlClass` instead. */
deprecated string getCanonicalQLClass() { result = this.getAPrimaryQlClass() }
/**
* Canonical QL class corresponding to this element.
* Gets the name of a primary CodeQL class to which this element belongs.
*
* ElementBase is the root class for this predicate.
* For most elements, this is simply the most precise syntactic category to
* which they belong; for example, `AddExpr` is a primary class, but
* `BinaryOperation` is not.
*
* This predicate always has a result. If no primary class can be
* determined, the result is `"???"`. If multiple primary classes match,
* this predicate can have multiple results.
*/
string getCanonicalQLClass() { result = "???" }
string getAPrimaryQlClass() { result = "???" }
}
/**
@@ -183,7 +197,8 @@ class Element extends ElementBase {
initialisers(underlyingElement(this), unresolveElement(result), _, _) or
exprconv(unresolveElement(result), underlyingElement(this)) or
param_decl_bind(underlyingElement(this), _, unresolveElement(result)) or
using_container(unresolveElement(result), underlyingElement(this))
using_container(unresolveElement(result), underlyingElement(this)) or
static_asserts(unresolveElement(this), _, _, _, underlyingElement(result))
}
/** Gets the closest `Element` enclosing this one. */
@@ -261,9 +276,15 @@ private predicate isFromUninstantiatedTemplateRec(Element e, Element template) {
class StaticAssert extends Locatable, @static_assert {
override string toString() { result = "static_assert(..., \"" + getMessage() + "\")" }
Expr getCondition() { static_asserts(underlyingElement(this), unresolveElement(result), _, _) }
/**
* Gets the expression which this static assertion ensures is true.
*/
Expr getCondition() { static_asserts(underlyingElement(this), unresolveElement(result), _, _, _) }
string getMessage() { static_asserts(underlyingElement(this), _, result, _) }
/**
* Gets the message which will be reported by the compiler if this static assertion fails.
*/
string getMessage() { static_asserts(underlyingElement(this), _, result, _, _) }
override Location getLocation() { static_asserts(underlyingElement(this), _, _, result) }
override Location getLocation() { static_asserts(underlyingElement(this), _, _, result, _) }
}

View File

@@ -1,3 +1,7 @@
/**
* Provides predicates for finding the smallest element that encloses an expression or statement.
*/
import cpp
/**

View File

@@ -1,3 +1,7 @@
/**
* Provides classes representing C/C++ enums and enum constants.
*/
import semmle.code.cpp.Type
private import semmle.code.cpp.internal.ResolveClass
@@ -19,11 +23,22 @@ class Enum extends UserType, IntegralOrEnumType {
/** Gets an enumerator of this enumeration. */
EnumConstant getAnEnumConstant() { result.getDeclaringEnum() = this }
/**
* Gets the enumerator of this enumeration that was declared at the zero-based position `index`.
* For example, `zero` is at index 2 in the following declaration:
* ```
* enum ReversedOrder {
* two = 2,
* one = 1,
* zero = 0
* };
* ```
*/
EnumConstant getEnumConstant(int index) {
enumconstants(unresolveElement(result), underlyingElement(this), index, _, _, _)
}
override string getCanonicalQLClass() { result = "Enum" }
override string getAPrimaryQlClass() { result = "Enum" }
/**
* Gets a descriptive string for the enum. This method is only intended to
@@ -72,7 +87,7 @@ class Enum extends UserType, IntegralOrEnumType {
class LocalEnum extends Enum {
LocalEnum() { isLocal() }
override string getCanonicalQLClass() { result = "LocalEnum" }
override string getAPrimaryQlClass() { result = "LocalEnum" }
}
/**
@@ -90,7 +105,7 @@ class LocalEnum extends Enum {
class NestedEnum extends Enum {
NestedEnum() { this.isMember() }
override string getCanonicalQLClass() { result = "NestedEnum" }
override string getAPrimaryQlClass() { result = "NestedEnum" }
/** Holds if this member is private. */
predicate isPrivate() { this.hasSpecifier("private") }
@@ -115,7 +130,7 @@ class NestedEnum extends Enum {
class ScopedEnum extends Enum {
ScopedEnum() { usertypes(underlyingElement(this), _, 13) }
override string getCanonicalQLClass() { result = "ScopedEnum" }
override string getAPrimaryQlClass() { result = "ScopedEnum" }
}
/**
@@ -138,7 +153,7 @@ class EnumConstant extends Declaration, @enumconstant {
enumconstants(underlyingElement(this), unresolveElement(result), _, _, _, _)
}
override string getCanonicalQLClass() { result = "EnumConstant" }
override string getAPrimaryQlClass() { result = "EnumConstant" }
override Class getDeclaringType() { result = this.getDeclaringEnum().getDeclaringType() }

View File

@@ -1,3 +1,7 @@
/**
* Provides classes representing C structure members and C++ non-static member variables.
*/
import semmle.code.cpp.Variable
import semmle.code.cpp.Enum
import semmle.code.cpp.exprs.Access
@@ -19,7 +23,7 @@ import semmle.code.cpp.exprs.Access
class Field extends MemberVariable {
Field() { fieldoffsets(underlyingElement(this), _, _) }
override string getCanonicalQLClass() { result = "Field" }
override string getAPrimaryQlClass() { result = "Field" }
/**
* Gets the offset of this field in bytes from the start of its declaring
@@ -86,7 +90,7 @@ class Field extends MemberVariable {
class BitField extends Field {
BitField() { bitfield(underlyingElement(this), _, _) }
override string getCanonicalQLClass() { result = "BitField" }
override string getAPrimaryQlClass() { result = "BitField" }
/**
* Gets the size of this bitfield in bits (on the machine where facts

View File

@@ -1,9 +1,13 @@
/**
* Provides classes representing files and folders.
*/
import semmle.code.cpp.Element
import semmle.code.cpp.Declaration
import semmle.code.cpp.metrics.MetricFile
/** A file or folder. */
abstract class Container extends Locatable, @container {
class Container extends Locatable, @container {
/**
* Gets the absolute, canonical path of this container, using forward slashes
* as path separator.
@@ -28,7 +32,7 @@ abstract class Container extends Locatable, @container {
* a bare root prefix, that is, the path has no path segments. A container
* whose absolute path has no segments is always a `Folder`, not a `File`.
*/
abstract string getAbsolutePath();
string getAbsolutePath() { none() } // overridden by subclasses
/**
* DEPRECATED: Use `getLocation` instead.
@@ -36,7 +40,7 @@ abstract class Container extends Locatable, @container {
*
* For more information see [Providing URLs](https://help.semmle.com/QL/learn-ql/ql/locations.html#providing-urls).
*/
abstract deprecated string getURL();
deprecated string getURL() { none() } // overridden by subclasses
/**
* Gets the relative path of this file or folder from the root folder of the
@@ -174,7 +178,7 @@ class Folder extends Container, @folder {
result.hasLocationInfo(_, 0, 0, 0, 0)
}
override string getCanonicalQLClass() { result = "Folder" }
override string getAPrimaryQlClass() { result = "Folder" }
/**
* DEPRECATED: Use `getLocation` instead.
@@ -242,7 +246,7 @@ class File extends Container, @file {
override string toString() { result = Container.super.toString() }
override string getCanonicalQLClass() { result = "File" }
override string getAPrimaryQlClass() { result = "File" }
override Location getLocation() {
result.getContainer() = this and
@@ -261,18 +265,6 @@ class File extends Container, @file {
/** Holds if this file was compiled as C++ (at any point). */
predicate compiledAsCpp() { fileannotations(underlyingElement(this), 1, "compiled as c++", "1") }
/**
* DEPRECATED: Objective-C is no longer supported.
* Holds if this file was compiled as Objective C (at any point).
*/
deprecated predicate compiledAsObjC() { none() }
/**
* DEPRECATED: Objective-C is no longer supported.
* Holds if this file was compiled as Objective C++ (at any point).
*/
deprecated predicate compiledAsObjCpp() { none() }
/**
* Holds if this file was compiled by a Microsoft compiler (at any point).
*
@@ -316,14 +308,6 @@ class File extends Container, @file {
exists(Include i | i.getFile() = this and i.getIncludedFile() = result)
}
/**
* DEPRECATED: use `getParentContainer` instead.
* Gets the folder which contains this file.
*/
deprecated Folder getParent() {
containerparent(unresolveElement(result), underlyingElement(this))
}
/**
* Holds if this file may be from source. This predicate holds for all files
* except the dummy file, whose name is the empty string, which contains
@@ -341,28 +325,6 @@ class File extends Container, @file {
/** Gets the metric file. */
MetricFile getMetrics() { result = this }
/**
* DEPRECATED: Use `getAbsolutePath` instead.
* Gets the full name of this file, for example:
* "/usr/home/me/myprogram.c".
*/
deprecated string getName() { files(underlyingElement(this), result, _, _, _) }
/**
* DEPRECATED: Use `getAbsolutePath` instead.
* Holds if this file has the specified full name.
*
* Example usage: `f.hasName("/usr/home/me/myprogram.c")`.
*/
deprecated predicate hasName(string name) { name = this.getName() }
/**
* DEPRECATED: Use `getAbsolutePath` instead.
* Gets the full name of this file, for example
* "/usr/home/me/myprogram.c".
*/
deprecated string getFullName() { result = this.getName() }
/**
* Gets the remainder of the base name after the first dot character. Note
* that the name of this predicate is in plural form, unlike `getExtension`,
@@ -377,22 +339,6 @@ class File extends Container, @file {
*/
string getExtensions() { files(underlyingElement(this), _, _, result, _) }
/**
* DEPRECATED: Use `getBaseName` instead.
* Gets the name and extension(s), but not path, of a file. For example,
* if the full name is "/path/to/filename.a.bcd" then the filename is
* "filename.a.bcd".
*/
deprecated string getFileName() {
// [a/b.c/d/]fileName
// ^ beginAfter
exists(string fullName, int beginAfter |
fullName = this.getName() and
beginAfter = max(int i | i = -1 or fullName.charAt(i) = "/" | i) and
result = fullName.suffix(beginAfter + 1)
)
}
/**
* Gets the short name of this file, that is, the prefix of its base name up
* to (but not including) the first dot character if there is one, or the
@@ -436,7 +382,7 @@ class HeaderFile extends File {
exists(Include i | i.getIncludedFile() = this)
}
override string getCanonicalQLClass() { result = "HeaderFile" }
override string getAPrimaryQlClass() { result = "HeaderFile" }
/**
* Holds if this header file does not contain any declaration entries or top level
@@ -462,7 +408,7 @@ class HeaderFile extends File {
class CFile extends File {
CFile() { exists(string ext | ext = this.getExtension().toLowerCase() | ext = "c" or ext = "i") }
override string getCanonicalQLClass() { result = "CFile" }
override string getAPrimaryQlClass() { result = "CFile" }
}
/**
@@ -490,7 +436,7 @@ class CppFile extends File {
)
}
override string getCanonicalQLClass() { result = "CppFile" }
override string getAPrimaryQlClass() { result = "CppFile" }
}
/**

View File

@@ -1,3 +1,7 @@
/**
* Provides a class representing C++ `friend` declarations.
*/
import semmle.code.cpp.Declaration
private import semmle.code.cpp.internal.ResolveClass
@@ -23,7 +27,7 @@ class FriendDecl extends Declaration, @frienddecl {
*/
override Location getADeclarationLocation() { result = this.getLocation() }
override string getCanonicalQLClass() { result = "FriendDecl" }
override string getAPrimaryQlClass() { result = "FriendDecl" }
/**
* Implements the abstract method `Declaration.getDefinitionLocation`. A

View File

@@ -1,5 +1,8 @@
/**
* Provides classes for working with functions, including template functions.
*/
import semmle.code.cpp.Location
import semmle.code.cpp.Member
import semmle.code.cpp.Class
import semmle.code.cpp.Parameter
import semmle.code.cpp.exprs.Call
@@ -103,6 +106,9 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
/**
* Holds if this function is declared to be `constexpr`.
*
* Note that this does not hold if the function has been declared
* `consteval`.
*/
predicate isDeclaredConstexpr() { this.hasSpecifier("declared_constexpr") }
@@ -115,9 +121,16 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
* template <typename T> constexpr int g(T x) { return f(x); }
* ```
* `g<int>` is declared constexpr, but is not constexpr.
*
* Will also hold if this function is `consteval`.
*/
predicate isConstexpr() { this.hasSpecifier("is_constexpr") }
/**
* Holds if this function is declared to be `consteval`.
*/
predicate isConsteval() { this.hasSpecifier("is_consteval") }
/**
* Holds if this function is declared with `__attribute__((naked))` or
* `__declspec(naked)`.
@@ -174,17 +187,8 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
* For example: for a function `int Foo(int p1, int p2)` this would
* return `int p1, int p2`.
*/
string getParameterString() { result = getParameterStringFrom(0) }
private string getParameterStringFrom(int index) {
index = getNumberOfParameters() and
result = ""
or
index = getNumberOfParameters() - 1 and
result = getParameter(index).getTypedName()
or
index < getNumberOfParameters() - 1 and
result = getParameter(index).getTypedName() + ", " + getParameterStringFrom(index + 1)
string getParameterString() {
result = concat(int i | | min(getParameter(i).getTypedName()), ", " order by i)
}
/** Gets a call to this function. */
@@ -509,7 +513,7 @@ class FunctionDeclarationEntry extends DeclarationEntry, @fun_decl {
/** Gets the function which is being declared or defined. */
override Function getDeclaration() { result = getFunction() }
override string getCanonicalQLClass() { result = "FunctionDeclarationEntry" }
override string getAPrimaryQlClass() { result = "FunctionDeclarationEntry" }
/** Gets the function which is being declared or defined. */
Function getFunction() { fun_decls(underlyingElement(this), unresolveElement(result), _, _, _) }
@@ -606,18 +610,8 @@ class FunctionDeclarationEntry extends DeclarationEntry, @fun_decl {
* For example: for a function 'int Foo(int p1, int p2)' this would
* return 'int p1, int p2'.
*/
string getParameterString() { result = getParameterStringFrom(0) }
private string getParameterStringFrom(int index) {
index = getNumberOfParameters() and
result = ""
or
index = getNumberOfParameters() - 1 and
result = getParameterDeclarationEntry(index).getTypedName()
or
index < getNumberOfParameters() - 1 and
result =
getParameterDeclarationEntry(index).getTypedName() + ", " + getParameterStringFrom(index + 1)
string getParameterString() {
result = concat(int i | | min(getParameterDeclarationEntry(i).getTypedName()), ", " order by i)
}
/**
@@ -704,428 +698,7 @@ class FunctionDeclarationEntry extends DeclarationEntry, @fun_decl {
class TopLevelFunction extends Function {
TopLevelFunction() { not this.isMember() }
override string getCanonicalQLClass() { result = "TopLevelFunction" }
}
/**
* A C++ function declared as a member of a class [N4140 9.3]. This includes
* static member functions. For example the functions `MyStaticMemberFunction`
* and `MyMemberFunction` in:
* ```
* class MyClass {
* public:
* void MyMemberFunction() {
* DoSomething();
* }
*
* static void MyStaticMemberFunction() {
* DoSomething();
* }
* };
* ```
*/
class MemberFunction extends Function {
MemberFunction() { this.isMember() }
override string getCanonicalQLClass() {
not this instanceof CopyAssignmentOperator and
not this instanceof MoveAssignmentOperator and
result = "MemberFunction"
}
/**
* Gets the number of parameters of this function, including any implicit
* `this` parameter.
*/
override int getEffectiveNumberOfParameters() {
if isStatic() then result = getNumberOfParameters() else result = getNumberOfParameters() + 1
}
/** Holds if this member is private. */
predicate isPrivate() { this.hasSpecifier("private") }
/** Holds if this member is protected. */
predicate isProtected() { this.hasSpecifier("protected") }
/** Holds if this member is public. */
predicate isPublic() { this.hasSpecifier("public") }
/** Holds if this function overrides that function. */
predicate overrides(MemberFunction that) {
overrides(underlyingElement(this), unresolveElement(that))
}
/** Gets a directly overridden function. */
MemberFunction getAnOverriddenFunction() { this.overrides(result) }
/** Gets a directly overriding function. */
MemberFunction getAnOverridingFunction() { result.overrides(this) }
/**
* Gets the declaration entry for this member function that is within the
* class body.
*/
FunctionDeclarationEntry getClassBodyDeclarationEntry() {
if strictcount(getADeclarationEntry()) = 1
then result = getDefinition()
else (
result = getADeclarationEntry() and result != getDefinition()
)
}
}
/**
* A C++ virtual function. For example the two functions called
* `myVirtualFunction` in the following code are each a
* `VirtualFunction`:
* ```
* class A {
* public:
* virtual void myVirtualFunction() = 0;
* };
*
* class B: public A {
* public:
* virtual void myVirtualFunction() {
* doSomething();
* }
* };
* ```
*/
class VirtualFunction extends MemberFunction {
VirtualFunction() { this.hasSpecifier("virtual") or purefunctions(underlyingElement(this)) }
override string getCanonicalQLClass() { result = "VirtualFunction" }
/** Holds if this virtual function is pure. */
predicate isPure() { this instanceof PureVirtualFunction }
/**
* Holds if this function was declared with the `override` specifier
* [N4140 10.3].
*/
predicate isOverrideExplicit() { this.hasSpecifier("override") }
}
/**
* A C++ pure virtual function [N4140 10.4]. For example the first function
* called `myVirtualFunction` in the following code:
* ```
* class A {
* public:
* virtual void myVirtualFunction() = 0;
* };
*
* class B: public A {
* public:
* virtual void myVirtualFunction() {
* doSomething();
* }
* };
* ```
*/
class PureVirtualFunction extends VirtualFunction {
PureVirtualFunction() { purefunctions(underlyingElement(this)) }
override string getCanonicalQLClass() { result = "PureVirtualFunction" }
}
/**
* A const C++ member function [N4140 9.3.1/4]. A const function has the
* `const` specifier and does not modify the state of its class. For example
* the member function `day` in the following code:
* ```
* class MyClass {
* ...
*
* int day() const {
* return d;
* }
*
* ...
* };
* ```
*/
class ConstMemberFunction extends MemberFunction {
ConstMemberFunction() { this.hasSpecifier("const") }
override string getCanonicalQLClass() { result = "ConstMemberFunction" }
}
/**
* A C++ constructor [N4140 12.1]. For example the function `MyClass` in the
* following code is a constructor:
* ```
* class MyClass {
* public:
* MyClass() {
* ...
* }
* };
* ```
*/
class Constructor extends MemberFunction {
Constructor() { functions(underlyingElement(this), _, 2) }
override string getCanonicalQLClass() { result = "Constructor" }
/**
* Holds if this constructor serves as a default constructor.
*
* This holds for constructors with zero formal parameters. It also holds
* for constructors which have a non-zero number of formal parameters,
* provided that every parameter has a default value.
*/
predicate isDefault() { forall(Parameter p | p = this.getAParameter() | p.hasInitializer()) }
/**
* Gets an entry in the constructor's initializer list, or a
* compiler-generated action which initializes a base class or member
* variable.
*/
ConstructorInit getAnInitializer() { result = getInitializer(_) }
/**
* Gets an entry in the constructor's initializer list, or a
* compiler-generated action which initializes a base class or member
* variable. The index specifies the order in which the initializer is
* to be evaluated.
*/
ConstructorInit getInitializer(int i) {
exprparents(unresolveElement(result), i, underlyingElement(this))
}
}
/**
* A function that defines an implicit conversion.
*/
abstract class ImplicitConversionFunction extends MemberFunction {
abstract Type getSourceType();
abstract Type getDestType();
}
/**
* A C++ constructor that also defines an implicit conversion. For example the
* function `MyClass` in the following code is a `ConversionConstructor`:
* ```
* class MyClass {
* public:
* MyClass(const MyOtherClass &from) {
* ...
* }
* };
* ```
*/
class ConversionConstructor extends Constructor, ImplicitConversionFunction {
ConversionConstructor() {
strictcount(Parameter p | p = getAParameter() and not p.hasInitializer()) = 1 and
not hasSpecifier("explicit") and
not this instanceof CopyConstructor
}
override string getCanonicalQLClass() {
not this instanceof MoveConstructor and result = "ConversionConstructor"
}
/** Gets the type this `ConversionConstructor` takes as input. */
override Type getSourceType() { result = this.getParameter(0).getType() }
/** Gets the type this `ConversionConstructor` is a constructor of. */
override Type getDestType() { result = this.getDeclaringType() }
}
private predicate hasCopySignature(MemberFunction f) {
f.getParameter(0).getUnspecifiedType().(LValueReferenceType).getBaseType() = f.getDeclaringType()
}
private predicate hasMoveSignature(MemberFunction f) {
f.getParameter(0).getUnspecifiedType().(RValueReferenceType).getBaseType() = f.getDeclaringType()
}
/**
* A C++ copy constructor [N4140 12.8]. For example the function `MyClass` in
* the following code is a `CopyConstructor`:
* ```
* class MyClass {
* public:
* MyClass(const MyClass &from) {
* ...
* }
* };
* ```
*
* As per the standard, a copy constructor of class `T` is a non-template
* constructor whose first parameter has type `T&`, `const T&`, `volatile
* T&`, or `const volatile T&`, and either there are no other parameters,
* or the rest of the parameters all have default values.
*
* For template classes, it can generally not be determined until instantiation
* whether a constructor is a copy constructor. For such classes, `CopyConstructor`
* over-approximates the set of copy constructors; if an under-approximation is
* desired instead, see the member predicate
* `mayNotBeCopyConstructorInInstantiation`.
*/
class CopyConstructor extends Constructor {
CopyConstructor() {
hasCopySignature(this) and
(
// The rest of the parameters all have default values
forall(int i | i > 0 and exists(getParameter(i)) | getParameter(i).hasInitializer())
or
// or this is a template class, in which case the default values have
// not been extracted even if they exist. In that case, we assume that
// there are default values present since that is the most common case
// in real-world code.
getDeclaringType() instanceof TemplateClass
) and
not exists(getATemplateArgument())
}
override string getCanonicalQLClass() { result = "CopyConstructor" }
/**
* Holds if we cannot determine that this constructor will become a copy
* constructor in all instantiations. Depending on template parameters of the
* enclosing class, this may become an ordinary constructor or a copy
* constructor.
*/
predicate mayNotBeCopyConstructorInInstantiation() {
// In general, default arguments of template classes can only be
// type-checked for each template instantiation; if an argument in an
// instantiation fails to type-check then the corresponding parameter has
// no default argument in the instantiation.
getDeclaringType() instanceof TemplateClass and
getNumberOfParameters() > 1
}
}
/**
* A C++ move constructor [N4140 12.8]. For example the function `MyClass` in
* the following code is a `MoveConstructor`:
* ```
* class MyClass {
* public:
* MyClass(MyClass &&from) {
* ...
* }
* };
* ```
*
* As per the standard, a move constructor of class `T` is a non-template
* constructor whose first parameter is `T&&`, `const T&&`, `volatile T&&`,
* or `const volatile T&&`, and either there are no other parameters, or
* the rest of the parameters all have default values.
*
* For template classes, it can generally not be determined until instantiation
* whether a constructor is a move constructor. For such classes, `MoveConstructor`
* over-approximates the set of move constructors; if an under-approximation is
* desired instead, see the member predicate
* `mayNotBeMoveConstructorInInstantiation`.
*/
class MoveConstructor extends Constructor {
MoveConstructor() {
hasMoveSignature(this) and
(
// The rest of the parameters all have default values
forall(int i | i > 0 and exists(getParameter(i)) | getParameter(i).hasInitializer())
or
// or this is a template class, in which case the default values have
// not been extracted even if they exist. In that case, we assume that
// there are default values present since that is the most common case
// in real-world code.
getDeclaringType() instanceof TemplateClass
) and
not exists(getATemplateArgument())
}
override string getCanonicalQLClass() { result = "MoveConstructor" }
/**
* Holds if we cannot determine that this constructor will become a move
* constructor in all instantiations. Depending on template parameters of the
* enclosing class, this may become an ordinary constructor or a move
* constructor.
*/
predicate mayNotBeMoveConstructorInInstantiation() {
// In general, default arguments of template classes can only be
// type-checked for each template instantiation; if an argument in an
// instantiation fails to type-check then the corresponding parameter has
// no default argument in the instantiation.
getDeclaringType() instanceof TemplateClass and
getNumberOfParameters() > 1
}
}
/**
* A C++ constructor that takes no arguments ('default' constructor). This
* is the constructor that is invoked when no initializer is given. For
* example the function `MyClass` in the following code is a
* `NoArgConstructor`:
* ```
* class MyClass {
* public:
* MyClass() {
* ...
* }
* };
* ```
*/
class NoArgConstructor extends Constructor {
NoArgConstructor() { this.getNumberOfParameters() = 0 }
}
/**
* A C++ destructor [N4140 12.4]. For example the function `~MyClass` in the
* following code is a destructor:
* ```
* class MyClass {
* public:
* ~MyClass() {
* ...
* }
* };
* ```
*/
class Destructor extends MemberFunction {
Destructor() { functions(underlyingElement(this), _, 3) }
override string getCanonicalQLClass() { result = "Destructor" }
/**
* Gets a compiler-generated action which destructs a base class or member
* variable.
*/
DestructorDestruction getADestruction() { result = getDestruction(_) }
/**
* Gets a compiler-generated action which destructs a base class or member
* variable. The index specifies the order in which the destruction should
* be evaluated.
*/
DestructorDestruction getDestruction(int i) {
exprparents(unresolveElement(result), i, underlyingElement(this))
}
}
/**
* A C++ conversion operator [N4140 12.3.2]. For example the function
* `operator int` in the following code is a `ConversionOperator`:
* ```
* class MyClass {
* public:
* operator int();
* };
* ```
*/
class ConversionOperator extends MemberFunction, ImplicitConversionFunction {
ConversionOperator() { functions(underlyingElement(this), _, 4) }
override string getCanonicalQLClass() { result = "ConversionOperator" }
override Type getSourceType() { result = this.getDeclaringType() }
override Type getDestType() { result = this.getType() }
override string getAPrimaryQlClass() { result = "TopLevelFunction" }
}
/**
@@ -1134,69 +707,11 @@ class ConversionOperator extends MemberFunction, ImplicitConversionFunction {
class Operator extends Function {
Operator() { functions(underlyingElement(this), _, 5) }
override string getCanonicalQLClass() {
override string getAPrimaryQlClass() {
not this instanceof MemberFunction and result = "Operator"
}
}
/**
* A C++ copy assignment operator [N4140 12.8]. For example the function
* `operator=` in the following code is a `CopyAssignmentOperator`:
* ```
* class MyClass {
* public:
* MyClass &operator=(const MyClass &other);
* };
* ```
*
* As per the standard, a copy assignment operator of class `T` is a
* non-template non-static member function with the name `operator=` that
* takes exactly one parameter of type `T`, `T&`, `const T&`, `volatile
* T&`, or `const volatile T&`.
*/
class CopyAssignmentOperator extends Operator {
CopyAssignmentOperator() {
hasName("operator=") and
(
hasCopySignature(this)
or
// Unlike CopyConstructor, this member allows a non-reference
// parameter.
getParameter(0).getUnspecifiedType() = getDeclaringType()
) and
not exists(this.getParameter(1)) and
not exists(getATemplateArgument())
}
override string getCanonicalQLClass() { result = "CopyAssignmentOperator" }
}
/**
* A C++ move assignment operator [N4140 12.8]. For example the function
* `operator=` in the following code is a `MoveAssignmentOperator`:
* ```
* class MyClass {
* public:
* MyClass &operator=(MyClass &&other);
* };
* ```
*
* As per the standard, a move assignment operator of class `T` is a
* non-template non-static member function with the name `operator=` that
* takes exactly one parameter of type `T&&`, `const T&&`, `volatile T&&`,
* or `const volatile T&&`.
*/
class MoveAssignmentOperator extends Operator {
MoveAssignmentOperator() {
hasName("operator=") and
hasMoveSignature(this) and
not exists(this.getParameter(1)) and
not exists(getATemplateArgument())
}
override string getCanonicalQLClass() { result = "MoveAssignmentOperator" }
}
/**
* A C++ function which has a non-empty template argument list. For example
* the function `myTemplateFunction` in the following code:
@@ -1223,7 +738,7 @@ class TemplateFunction extends Function {
is_function_template(underlyingElement(this)) and exists(getATemplateArgument())
}
override string getCanonicalQLClass() { result = "TemplateFunction" }
override string getAPrimaryQlClass() { result = "TemplateFunction" }
/**
* Gets a compiler-generated instantiation of this function template.
@@ -1263,7 +778,7 @@ class FunctionTemplateInstantiation extends Function {
FunctionTemplateInstantiation() { tf.getAnInstantiation() = this }
override string getCanonicalQLClass() { result = "FunctionTemplateInstantiation" }
override string getAPrimaryQlClass() { result = "FunctionTemplateInstantiation" }
/**
* Gets the function template from which this instantiation was instantiated.
@@ -1308,7 +823,7 @@ class FunctionTemplateInstantiation extends Function {
class FunctionTemplateSpecialization extends Function {
FunctionTemplateSpecialization() { this.isSpecialization() }
override string getCanonicalQLClass() { result = "FunctionTemplateSpecialization" }
override string getAPrimaryQlClass() { result = "FunctionTemplateSpecialization" }
/**
* Gets the primary template for the specialization (the function template

View File

@@ -1,3 +1,8 @@
/**
* Provides classes representing C/C++ `#include`, `#include_next`, and `#import` preprocessor
* directives.
*/
import semmle.code.cpp.Preprocessor
/**

View File

@@ -1,3 +1,7 @@
/**
* Provides the `Initializer` class, representing C/C++ declaration initializers.
*/
import semmle.code.cpp.controlflow.ControlFlowGraph
/**
@@ -18,7 +22,7 @@ import semmle.code.cpp.controlflow.ControlFlowGraph
class Initializer extends ControlFlowNode, @initialiser {
override Location getLocation() { initialisers(underlyingElement(this), _, _, result) }
override string getCanonicalQLClass() { result = "Initializer" }
override string getAPrimaryQlClass() { result = "Initializer" }
/** Holds if this initializer is explicit in the source. */
override predicate fromSource() { not this.getLocation() instanceof UnknownLocation }

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