JS: Ignore Angular templates in a few non-security queries

This commit is contained in:
Asger Feldthaus
2021-01-27 10:59:16 +00:00
parent aec0e9808b
commit 1637b72092
4 changed files with 10 additions and 3 deletions

View File

@@ -68,5 +68,7 @@ where
not exists(SsaImplicitInit init | init.getVariable().getSourceVariable() = v) // the variable is dead at the hoisted implicit initialization. not exists(SsaImplicitInit init | init.getVariable().getSourceVariable() = v) // the variable is dead at the hoisted implicit initialization.
then msg = "The initial value of " + v.getName() + " is unused, since it is always overwritten." then msg = "The initial value of " + v.getName() + " is unused, since it is always overwritten."
else msg = "The value assigned to " + v.getName() + " here is unused." else msg = "The value assigned to " + v.getName() + " here is unused."
) ) and
// ignore Angular templates
not dead.(ASTNode).getTopLevel() instanceof Angular2::TemplateTopLevel
select dead, msg select dead, msg

View File

@@ -299,7 +299,9 @@ where
assign1 instanceof CallToObjectDefineProperty assign1 instanceof CallToObjectDefineProperty
implies implies
assign1.(CallToObjectDefineProperty).hasPropertyAttributeWrite("value", _) assign1.(CallToObjectDefineProperty).hasPropertyAttributeWrite("value", _)
) ) and
// ignore Angular templates
not assign1.getTopLevel() instanceof Angular2::TemplateTopLevel
select assign1.getWriteNode(), select assign1.getWriteNode(),
"This write to property '" + name + "' is useless, since $@ always overrides it.", "This write to property '" + name + "' is useless, since $@ always overrides it.",
assign2.getWriteNode(), "another property write" assign2.getWriteNode(), "another property write"

View File

@@ -164,5 +164,7 @@ predicate hasNoEffect(Expr e) {
top = e.getParent().(ExprStmt).getParent() and top = e.getParent().(ExprStmt).getParent() and
top.getNumChild() = 1 and top.getNumChild() = 1 and
not exists(Function fun | fun.getEnclosingContainer() = top) not exists(Function fun | fun.getEnclosingContainer() = top)
) ) and
// ignore Angular templates
not e.getTopLevel() instanceof Angular2::TemplateTopLevel
} }

View File

@@ -13,4 +13,5 @@
import javascript import javascript
from JSParseError pe from JSParseError pe
where not pe.getTopLevel() instanceof Angular2::TemplateTopLevel
select pe, pe.getMessage() select pe, pe.getMessage()