Commit Graph

15194 Commits

Author SHA1 Message Date
Rasmus Wriedt Larsen
0cc018fec0 Python: Taint tracking setup alá Go
\## TaintFlow sources

The class `RemoteFlowSource` is very similarly defined as the other languages [C++](ac22e7950c/cpp/ql/src/semmle/code/cpp/security/FlowSources.qll), [Java](6de612a566/java/ql/src/semmle/code/java/dataflow/FlowSources.qll), [C#](fddbce0b7b/csharp/ql/src/semmle/code/csharp/security/dataflow/flowsources/Remote.qll), [JS](78334af354/javascript/ql/src/semmle/javascript/security/dataflow/RemoteFlowSources.qll), and [Go](24b3133e0c/ql/src/semmle/go/security/FlowSources.qll). There are some minor differences:

- Java/C++ defines the class in `FlowSources.qll`
- C# uses `csharp/ql/src/semmle/code/csharp/security/dataflow/flowsources/Remote.qll`, and provide `StoredFlowSource` and `LocalFlowSource` in separate classes.
- JS uses `RemoteFlowSources.qll`.
- JS defines additional predicate `RemoteFlowSource.isUserControlledObject`
- Go uses the class name `UntrustedFlowSource`, but still defined in `ql/src/semmle/go/security/FlowSources.qll`
- Go uses the `::Range` pattern to allow both extensibility and refinement

The big difference is how a RemoteFlowSource is specified:

- Java and C# have all subclasses of `RemoteFlowSource` defined in the same file
- Go and JS defines subclasses for frameworks in the actual framework `.qll` file, and all frameworks are transitively imported by `import go` or `import javascript` (so subclasses are always in scope).
- C++ uses class `RemoteFlowFunction` to do all the heavy lifting (and its subclasses are transitively imported).

\### What we will do

Use file `RemoteFlowSource.qll`, define subclasses in framework library classes.

_Why? Personally I really like it, Go/JS is already doing it, and Tom expressed a preference for doing the same for C# (although that is not what they are doing today)._

Jonas gave this advice:
> Whether you split the definitions between multiple files or keep them all in one file, the property you want is that all definitions are included when the abstract class is included. Otherwise you can get unexpected results via transitive includes.

We will make imports of all frameworks in the same file that defines `RemoteFlowSource`, as it seems to be the least intrusive change. If that turns out to be a problem, we can also move them to `python.qll` (the other way is not so easy).

\## TaintFlow sinks

[JS](473787a426/javascript/ql/src/semmle/javascript/Concepts.qll) and [Go](ecff1e6a16/ql/src/semmle/go/Concepts.qll) defines abstract base classes for interesting sinks in `Concepts.qll` (and all uses the `::Range` pattern in Go).

I really like this idea, since it allows multiple queries to reuse the same sink definitions, and it makes it _easy_ to discover what default sinks are available.

Personally I'm not 100% on board with the naming, but I don't have any good reason to change the naming convention.

\## Framework modeling

Following the model from Go ([example](https://github.com/github/codeql-go/blob/main/ql/src/semmle/go/frameworks/Gin.qll)), I propose that we make every definition in a framework modeling `private`. This allows some greater flexibility in changing our modeling, since we don't need to think about keeping deprecated versions around for a whole year.

It _does_ have the downside that someone writing a query can't reuse the classes/predicates for a framework, but it didn't seem to be too big of a concern. If we need to provide access, we can always make the definitions non-private (the other way is not so easy).

\## Customizations

Also introduced `Customizations.qll` like in JS/Java/Go (to replace `site.qll`)
2020-09-01 14:37:11 +02:00
CodeQL CI
b9a6183ec2 Merge pull request #4175 from aschackmull/java/adjust-cwe-089-qltest
Approved by aibaars
2020-09-01 12:43:56 +01:00
Arthur Baars
2729d109a5 Merge pull request #4123 from aschackmull/java/records-dataflow
Java: Add data flow for record getters.
2020-09-01 13:02:24 +02:00
Anders Schack-Mulligen
e5d7208c12 Java: Adjust a few qltests. 2020-09-01 12:49:09 +02:00
Mathias Vorreiter Pedersen
aa3b268525 Merge pull request #4162 from jbj/ssa-ref-parameters
C++: SSA and range analysis for reference parameters
2020-09-01 11:48:41 +02:00
Anders Schack-Mulligen
82692876d8 Java: Add some test cases. 2020-09-01 11:24:30 +02:00
Anders Schack-Mulligen
c25dd4be8c Merge pull request #3363 from ggolawski/xslt-injection
CodeQL query to detect XSLT injections
2020-09-01 11:03:19 +02:00
Anders Schack-Mulligen
1dae99e4a5 Merge pull request #3543 from porcupineyhairs/WebsocketReadAsSource
Java: add websocket reads as remote flow source.
2020-09-01 10:58:02 +02:00
Anders Schack-Mulligen
beca44ec2f Merge pull request #4172 from rvermeulen/java/xss-sink-extensible
Java: Customizable XSS analysis
2020-09-01 09:27:50 +02:00
Remco Vermeulen
2bdd3d7712 Apply qldoc suggestions
Co-authored-by: Anders Schack-Mulligen <aschackmull@users.noreply.github.com>
2020-08-31 17:28:51 +02:00
CodeQL CI
35494ab97c Merge pull request #4171 from max-schaefer/js/promise-flow-public
Approved by erik-krogh
2020-08-31 15:15:27 +01:00
CodeQL CI
79e87a6c3d Merge pull request #4088 from aschackmull/java/string-formatted
Approved by aibaars
2020-08-31 15:02:49 +01:00
Tom Hvitved
4e963a8a8e Merge pull request #4165 from hvitved/csharp/foreach-guard
C#: Fix bug in guards logic for `foreach` loops
2020-08-31 14:32:09 +02:00
CodeQL CI
dc9cc20fdd Merge pull request #4161 from yoff/SharedDataflow_PostUpdateNodes
Approved by RasmusWL, aschackmull, hvitved, jbj
2020-08-31 11:57:44 +01:00
Max Schaefer
22ccae6006 JavaScript: Make PromiseFlow module public. 2020-08-31 11:55:10 +01:00
CodeQL CI
9d6b2e7684 Merge pull request #4042 from aschackmull/java/xsssink-extensible
Approved by aibaars
2020-08-31 11:54:25 +01:00
Anders Schack-Mulligen
b89a22b583 Merge pull request #4170 from aibaars/drop-inefficient-toarray
Java: remove InefficientToArray.ql
2020-08-31 12:45:06 +02:00
Arthur Baars
66d39bb5f6 Java: remove InefficientToArray.ql
This query was deprecated 4 years ago.

Fixes: #4167
2020-08-31 10:39:03 +02:00
Grzegorz Golawski
0f555d42ed Fix test 2020-08-30 22:55:17 +02:00
Grzegorz Golawski
5e462a897d Merge branch 'main' into xslt-injection 2020-08-30 22:45:31 +02:00
Grzegorz Golawski
37f4410764 Fix test 2020-08-30 22:32:57 +02:00
Porcupiney Hairs
4f07733b06 remove U+200B 2020-08-30 04:54:02 +05:30
Jonas Jensen
023f2e97c1 C++: Really accept test results this time 2020-08-28 16:50:23 +02:00
Tom Hvitved
b205702853 C#: Fix bug in guards logic for foreach loops 2020-08-28 15:19:11 +02:00
Tom Hvitved
ddb33c914b C#: Add test that demonstrates issue with guards logic for foreach statements 2020-08-28 15:13:18 +02:00
Asger F
813d14791d Merge pull request #4043 from erik-krogh/ts4
JS: Add support for TypeScript 4
2020-08-28 14:02:08 +01:00
Rasmus Lerchedahl Petersen
750735c70c Dataflow: Update test expectations 2020-08-28 15:00:01 +02:00
Jonas Jensen
2c613a72b9 C++: Autoformat 2020-08-28 14:56:19 +02:00
Jonas Jensen
a25cc2d9c7 C++: Accept range-analysis test results 2020-08-28 14:54:44 +02:00
lcartey@github.com
a4cb774932 C++: Support dereferenced variables in simple range analysis
- Support inference of guards on reference variables
 - Support type bounds for reference variables
 - Support reference variables when widening
 - Support reference variables when determining arithmetic assignment
2020-08-28 14:52:36 +02:00
Jonas Jensen
027f22d8e7 C++: Test that range analysis ignores references 2020-08-28 14:41:57 +02:00
Jonas Jensen
a3a3423db2 C++: Treat reference parameters as non-references 2020-08-28 14:33:01 +02:00
Rasmus Lerchedahl Petersen
6b8d9f2a77 Merge branch 'main' of github.com:github/codeql into SharedDataflow_PostUpdateNodes 2020-08-28 13:01:14 +02:00
Rasmus Lerchedahl Petersen
9503c5d8bb Python: Add post-update nodes 2020-08-28 12:59:11 +02:00
Erik Krogh Kristensen
f4060723bb add stats for new properties 2020-08-28 12:43:26 +02:00
Calum Grant
93e0bd9d85 Merge pull request #4126 from tamasvajk/feature/array-index
C#: Fix computed sizes for implicitly sized array creation
2020-08-28 11:21:39 +01:00
Tom Hvitved
6eca97bc32 Merge pull request #4113 from tamasvajk/feature/nullability-extraction-cil
Enable nullability checks on Semmle.Extraction.CIL
2020-08-28 12:06:54 +02:00
Tom Hvitved
647ed03a2b Merge pull request #4136 from tamasvajk/feature/qldocs
C#: Add missing QlDocs
2020-08-28 12:03:03 +02:00
Taus
8caaf8f17c Merge pull request #4158 from RasmusWL/python-reformualte-js-team-comment
Python: Reformualte explanation of experience from JS
2020-08-28 11:33:00 +02:00
Rasmus Wriedt Larsen
496d856c48 Python: Reformualte explanation of experience from JS 2020-08-28 10:49:33 +02:00
Erik Krogh Kristensen
038cca814a Merge branch 'main' into ts4 2020-08-28 10:27:49 +02:00
Taus
afe234dade Merge pull request #4156 from RasmusWL/python-fix-changenote-fstring-taint
Python: fstring taint change note should be for 1.26
2020-08-28 10:23:06 +02:00
Jonas Jensen
55d7ac88f9 Merge pull request #4148 from geoffw0/vecextra
C++: Improvements to string and vector models.
2020-08-28 10:05:42 +02:00
CodeQL CI
80cb8be405 Merge pull request #4155 from asger-semmle/js/lower-duplicate-element-id-precision
Approved by esbena
2020-08-28 08:52:58 +01:00
CodeQL CI
ac94869978 Merge pull request #3978 from dellalibera/js/insecure-cookies
Approved by esbena
2020-08-28 08:31:38 +01:00
Rasmus Wriedt Larsen
deff36e9af Python: fstring taint change note should be for 1.26
This fixes problem introduced in https://github.com/github/codeql/pull/4127
2020-08-28 09:00:07 +02:00
Tamas Vajk
29eaacdeaf Fix typos and comment styling 2020-08-28 08:41:46 +02:00
Mathias Vorreiter Pedersen
ceddc2497a Merge pull request #4151 from geoffw0/reftaint
C++: Taint tests for array and reference assignments.
2020-08-27 20:00:13 +02:00
Taus
1206ff5889 Merge pull request #4150 from RasmusWL/python-dataflow-private-import
Python: Make import of python private in shared dataflow
2020-08-27 18:05:55 +02:00
Geoffrey White
9b3da1f6c7 C++: Autoformat. 2020-08-27 16:55:45 +01:00