Commit Graph

29908 Commits

Author SHA1 Message Date
Jonas Jensen
01dc4385cd C++: Don't use dbtypes in TaintTracking.qll 2018-08-28 14:58:39 +02:00
Jonas Jensen
854d0db552 C++: Don't use dbtypes in ClassesWithManyFields.ql
This changes the test output because `VariableDeclarationGroup.toString`
changes to be the one inherited from VariableDeclarationEntry. This
should not affect the output as shown by any front end because
the string to be displayed to the user for a `$@` interpolation comes
from the following column instead.
2018-08-28 14:58:39 +02:00
Jonas Jensen
1d11a13230 C++: Don't use dbtypes in SuppressionScope
This avoids using a raw db type.

It is possible for `SuppressionComment` and `SuppressionScope` to have
different locations because `SuppressionScope` defines `hasLocationInfo`
as a new rootdef whereas `SuppressionComment` only responds to
`getLocation` that it inherited. In interpretation of query results, a
`hasLocationInfo` predicate is preferred over `getLocation` if it
exists.
2018-08-28 14:58:39 +02:00
Jonas Jensen
f005d45c63 C++: Change SuppressionScope.toString
This should have no effect in itself but changes the test output to
correspond with the change coming next.
2018-08-28 14:58:39 +02:00
Jonas Jensen
367776511f C++: Don't use dbtypes in ControlFlowNode etc.
Many classes have been declared with `extends @cfgnode` because they
should be implemented internally as a control-flow node but should not
expose the member predicates of `ControlFlowNode` to their users. After
the transition in a1e44041e it became mandatory to convert explicitly
between the `Element`-derived `ControlFlowNode` and the raw dbtype
`@cfgnode`, and that commit inserted numerous such conversions as a
result of having all those classes that did not derive from `Element` in
the standard library.

It was also confusing and error-prone that the libraries implementing
`ControlFlowNode` referred to `ControlFlowNode`. This seemingly cyclic
reference worked out because the libraries did not call the predicates
on `ControlFlowNode` whose implementation they were part of.

Both these problems are now solved by adding a new class
`ControlFlowNodeBase extends Element` that should be used in preference
to `@cfgnode` everywhere. This class is for exactly those use cases
where `@cfgnode` should be seen as an `Element` without having too many
member predicates on it.

The classes that move from extending `@cfgnode` to extending
`ControlFlowNodeBase` are: `BasicBlock`, `AdditionalControlFlowEdge`,
`DefOrUse`, `SsaDefinition`, `SubBasicBlock` and `RangeSsaDefinition`.
These previously had to define their own `toString` rootdef, which
typically had some dummy string as result (like `"BasicBlock"`), but now
their `toString` is part of the `Element` rootdef and should not be
overridden otherwise `Element.toString` will sometimes have multiple
results. Removing these dummy `toString` predicates had some effects on
the tests that are included in this commit.

The `getLocation` family of predicates is affected like `toString`, but
the situation is slightly different. Some of these classes had genuinely
useful alternative definitions of locations. Fortunately, they all used
`hasLocationInfo`, which is preferred over `getLocation` by the QL
engine. Because `Element` does not define `getLocationInfo`, each class
can create its own rootdef of this predicate like before.
2018-08-28 14:27:32 +02:00
Nick Rolfe
f44f8d576d C++: test that __declspec(guard(...)) doesn't cause extractor errors 2018-08-28 10:24:53 +01:00
Dave Bartolomeo
6e0fe92434 C++: Fix comments to reference Call instead of Invoke 2018-08-27 11:02:07 -07:00
Dave Bartolomeo
b44c2c72a6 C++: Invoke -> Call
Now that opcodes are in their own module that isn't imported into the global namespace, `Opcode::Call` no longer conflicts with `Call` from the ASTs. I've renamed `Opcode::Invoke` to `Opcode::Call`.
2018-08-27 09:22:01 -07:00
Esben Sparre Andreasen
02d56306c9 JS: classify generated data files 2018-08-27 15:06:00 +02:00
Pavel Avgustinov
d0497a5cff Merge pull request #106 from dave-bartolomeo/dave/LF
Force LF line endings for .ql, .qll, .qlref, and .dbscheme
2018-08-27 10:04:53 +01:00
Jonas Jensen
dc0f3be753 Merge pull request #102 from ian-semmle/type_variants
C++: Tweak type_variants test
2018-08-27 10:34:45 +02:00
Anders Schack-Mulligen
f2760f2547 Java/C: Improve performance when multiple configs use field flow. 2018-08-27 10:00:58 +02:00
Dave Bartolomeo
2af82d9485 LF for .qhelp files too 2018-08-26 21:12:51 -07:00
ian-semmle
bafa3d79fe Merge pull request #101 from nickrolfe/edg5
C++: test fixes for extractor frontend upgrade
2018-08-26 19:33:01 +01:00
Dave Bartolomeo
dfb082e34f Add .editorconfig to use LF in .ql/.qlref/.qll/.dbscheme files 2018-08-24 13:20:40 -07:00
Jonas Jensen
1ed4a489ec C++: Make ControlFlowNode's predicates concrete
The presence of abstract predicates on this class made it hard to
specialize it, and this is one of the reasons why the raw db-type
`@cfgnode` is often used in preference to `ControlFlowNode`.
2018-08-24 22:03:59 +02:00
Dave Bartolomeo
12631e3fb1 Force LF line endings for .dbscheme files 2018-08-24 12:05:35 -07:00
Dave Bartolomeo
d920fc7d94 Force LF line endings for .ql, .qll, and .qlref files 2018-08-24 11:58:58 -07:00
Nick Rolfe
7cf550a70f C++: regression test for extractor bug with enum in template class 2018-08-24 18:41:37 +01:00
Nick Rolfe
193e013196 C++: accept more extraction of functions in local classes/lambdas 2018-08-24 18:41:37 +01:00
Nick Rolfe
da7d70662b C++: accept more test changes following extractor frontend upgrade 2018-08-24 18:41:37 +01:00
Nick Rolfe
04385a83ba C++: fix tests: frontend no longer optimises dynamic_cast to base type 2018-08-24 18:41:37 +01:00
Nick Rolfe
dd169d1b21 C++: fix test to enable C++11 support in frontend 2018-08-24 18:41:37 +01:00
Nick Rolfe
59ddda881e Merge pull request #104 from dave-bartolomeo/dave/ASTWobble
C++: Fix wobble in PrintAST test
2018-08-24 18:40:51 +01:00
Dave Bartolomeo
65ed9afdfb C++: Update test expectations for other PrintAST test 2018-08-24 08:50:35 -07:00
Dave Bartolomeo
c4d6e1b01c C++: Fix wobble in PrintAST test
PrintAST.ql orders the functions by location, then in lexicographical order of the function signature. This is supposed to ensure a stable ordering, but functions without a location were not getting assigned an order at all.
2018-08-24 08:36:30 -07:00
Dave Bartolomeo
7cae9be4bf Merge pull request #100 from jbj/sync-identical-files-ql
C++: Move the identical-files.json spec to ql repo
2018-08-24 07:31:48 -07:00
Ian Lynagh
01c7fc1c8b C++: Tweak type_variants test
It's now easier to see what's happening in cases where 2 functions have
the same name, or a function has 2 locations.
2018-08-24 14:46:02 +01:00
Luke Cartey
f9227eeee5 C#: ZipSlip - Module documentation improvements. 2018-08-24 14:34:20 +01:00
Luke Cartey
b1d5d5bf86 C#: ZipSlip - Refine StartsWith sanitizer.
ZipSlip can be avoided by checking that the combined and resolved
path `StartsWith` the appropriate destination directory. Refine the
`StartsWith` sanitizer to:

 * Consider expressions guarded by an appropriate StartsWith check to be
sanitized.
 * Consider a StartsWith check to be inappropriate if it is checking the
result of `Path.Combine`, as that has not been appropriately resolved.

Tests have been updated to reflect this refinement.
2018-08-24 14:27:25 +01:00
Luke Cartey
fc925d49f4 C#: ZipSlip - Treat the result of Substring as sanitized.
As with the previous commit, this considers the result of substring as
sanitized, rather than the argument.
2018-08-24 12:38:01 +01:00
Luke Cartey
43d7e598a5 C#: Treat GetFileName method call as sanitizer
Use the GetFileName call as a sanitizer, rather than an argument to that
call. It is the _result_ of the GetFileName call which should be
considered sanitized. By using the argument, we can spuriously suppress
use-use flow. Consider:
```
var path = Path.Combine(destDir, entry.GetFullName());
var fileName = Path.GetFileName(path);
log("Extracting " + fileName);
entry.ExtractToFile(path);
```
Previously, the `ExtractToFile(path)` call would not have been flagged,
because the `path` argument to `GetFileName` was considered sanitized,
and that argument formed a use-use pair with the `path` argument to
`ExtractToFile`. Now, this result would be flagged because only the
result of the `GetFileName` call is considered sanitized.
2018-08-24 12:08:57 +01:00
Jonas Jensen
d81e8081be C++: IRBlockConstruction in identical-files.json
These two files have been identical since dc2283325.
2018-08-24 11:41:06 +02:00
Jonas Jensen
dabbd83848 C++: Move the identical-files.json spec to ql repo
This file is used by the `sync-identical-files.py` pull-request check in
our internal repo, which can hopefully soon start running on this repo
as well. This initial commit moves over all the file group definitions
whose files are entirely within this repository.

This change is not synchronized with the internal repo, so the file
groups will appear in both repositories until they sync up. That should
not cause any problems.
2018-08-24 11:32:29 +02:00
Tom Hvitved
d4551e5897 Merge pull request #81 from lukecartey/csharp/zipslip-reformat
C#: ZipSlip - Rearrange query, add help and update doc
2018-08-24 09:40:20 +02:00
semmle-qlci
55ceb9be8b Merge pull request #91 from esben-semmle/js/additional-indexof-sanitizers
Approved by xiemaisi
2018-08-24 08:37:41 +01:00
Jonas Jensen
1f844e2a7c Merge pull request #95 from ian-semmle/resolveClass
C++: Rename resolve to resolveClass, and remove unused isElement
2018-08-23 22:13:13 +02:00
Jonas Jensen
58e993e877 Merge pull request #82 from dave-bartolomeo/dave/NewDelete2
C++: IR generation for `new` and `new[]`
2018-08-23 21:14:07 +02:00
calum
41382dd732 C#: A regression test for extractor crash when wrong expression type is used for a literal. 2018-08-23 17:45:40 +01:00
Dave Bartolomeo
72e72357c2 C++: Use glval<Unknown> as type of call target
Also shared some code between `TranslatedFunctionCall` and `TranslatedAllocatorCall`, and fixed dumps of glval<Unknown> to not print the size.
2018-08-23 09:43:58 -07:00
calumgrant
04bccd0137 Merge pull request #55 from denislevin/denisl/cs/DontInstallRootCertificate
cs: Don't Install Root Certificate (CWE-327)
2018-08-23 17:36:50 +01:00
Luke Cartey
86a7df0ef5 C#: ZipSlip - Address doc team comments. 2018-08-23 15:57:00 +01:00
Ian Lynagh
7ee5efcab0 C++: Rename internal.Type to internal.ResolveClass 2018-08-23 15:40:25 +01:00
shati-semmle
4965377283 QL style guide: Small fixes
- Don't suggest new line after `deprecated`
- Add a missing backtick
2018-08-23 15:15:47 +01:00
Esben Sparre Andreasen
a1d79ef906 JS: make the new .*indexOfSanitizer-classes private 2018-08-23 15:59:27 +02:00
Ian Lynagh
e808560c23 C++: Rename resolve to resolveClass, and remove unused isElement 2018-08-23 14:37:38 +01:00
Esben Sparre Andreasen
2b41f62eb0 JS: introduce RelationalComparison.isInclucive 2018-08-23 14:51:39 +02:00
Tom Hvitved
1dff900059 C#: Speed up throwMayBeUncaught() by not relying on definitelyHandles()
The `definitelyHandles()` predicate calculates the relation for all exception
types, not just the ones that can actually be thrown (no automatic magic).
This commit inlines the definition of `definitelyHandles()` to get the proper
context (manual magic).
2018-08-23 14:39:19 +02:00
Tom Hvitved
4684bc9d15 C#: Add QL doc to startsSplits() 2018-08-23 14:39:19 +02:00
Ian Lynagh
b76e03ca79 C++: Add a missing underlyingElement call 2018-08-23 13:14:04 +01:00