mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
Merge pull request #6085 from tamasvajk/feature/unsafe
C#: Fix `Modifiable::isUnsafe` to handle declarations extracted from assemblies
This commit is contained in:
2
csharp/change-notes/2021-06-15-unsafe-non-source-code.md
Normal file
2
csharp/change-notes/2021-06-15-unsafe-non-source-code.md
Normal file
@@ -0,0 +1,2 @@
|
||||
lgtm,codescanning
|
||||
* The `Modifiable::isUnsafe` predicate has been fixed to handle symbols that are not extracted from source code.
|
||||
@@ -86,7 +86,12 @@ class Modifiable extends Declaration, @modifiable {
|
||||
predicate isConst() { this.hasModifier("const") }
|
||||
|
||||
/** Holds if this declaration is `unsafe`. */
|
||||
predicate isUnsafe() { this.hasModifier("unsafe") }
|
||||
predicate isUnsafe() {
|
||||
this.hasModifier("unsafe") or
|
||||
this.(Parameterizable).getAParameter().getType() instanceof PointerType or
|
||||
this.(Property).getType() instanceof PointerType or
|
||||
this.(Callable).getReturnType() instanceof PointerType
|
||||
}
|
||||
|
||||
/** Holds if this declaration is `async`. */
|
||||
predicate isAsync() { this.hasModifier("async") }
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import csharp
|
||||
|
||||
select any(Modifiable m | m.isUnsafe())
|
||||
select any(Modifiable m | m.isUnsafe() and m.fromSource())
|
||||
|
||||
Reference in New Issue
Block a user