mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
JS: Mark type-annotated nodes as SourceNode
This commit is contained in:
@@ -333,7 +333,13 @@ module SourceNode {
|
||||
astNode instanceof TaggedTemplateExpr or
|
||||
astNode instanceof Templating::PipeRefExpr or
|
||||
astNode instanceof Templating::TemplateVarRefExpr or
|
||||
astNode instanceof StringLiteral
|
||||
astNode instanceof StringLiteral or
|
||||
astNode instanceof TypeAssertion
|
||||
)
|
||||
or
|
||||
exists(VariableDeclarator decl |
|
||||
exists(decl.getTypeAnnotation()) and
|
||||
this = DataFlow::valueNode(decl.getBindingPattern())
|
||||
)
|
||||
or
|
||||
DataFlow::parameterNode(this, _)
|
||||
|
||||
@@ -189,7 +189,12 @@ module TypeResolution {
|
||||
)
|
||||
}
|
||||
|
||||
private predicate contextualType(Node value, Node type) {
|
||||
predicate contextualType(Node value, Node type) {
|
||||
exists(LocalVariable v |
|
||||
type = v.getADeclaration().getTypeAnnotation() and
|
||||
value = v.getAnAssignedExpr()
|
||||
)
|
||||
or
|
||||
exists(InvokeExpr call, Function target, int i |
|
||||
callTarget(call, target) and
|
||||
value = call.getArgument(i) and
|
||||
@@ -228,6 +233,8 @@ module TypeResolution {
|
||||
predicate valueHasType(Node value, Node type) {
|
||||
value.(BindingPattern).getTypeAnnotation() = type
|
||||
or
|
||||
value.(TypeAssertion).getTypeAnnotation() = type
|
||||
or
|
||||
exists(VarDecl decl |
|
||||
// ValueFlow::step is restricted to variables with at most one assignment. Allow the type annotation
|
||||
// of a variable to propagate to its uses, even if the variable has multiple assignments.
|
||||
|
||||
Reference in New Issue
Block a user