Python: Remove points-to from Expr

This commit is contained in:
Taus
2025-10-30 11:52:39 +00:00
parent b434ce460e
commit b93ce98612
35 changed files with 164 additions and 119 deletions

View File

@@ -14,20 +14,21 @@
*/
import python
import LegacyPointsTo
import semmle.python.objects.ObjectInternal
import semmle.python.strings
predicate string_format(BinaryExpr operation, StringLiteral str, Value args, AstNode origin) {
operation.getOp() instanceof Mod and
exists(Context ctx |
operation.getLeft().pointsTo(ctx, _, str) and
operation.getRight().pointsTo(ctx, args, origin)
operation.getLeft().(ExprWithPointsTo).pointsTo(ctx, _, str) and
operation.getRight().(ExprWithPointsTo).pointsTo(ctx, args, origin)
)
}
int sequence_length(Value args) {
/* Guess length of sequence */
exists(Tuple seq | seq.pointsTo(args, _) |
exists(Tuple seq | seq.(ExprWithPointsTo).pointsTo(args, _) |
result = strictcount(seq.getAnElt()) and
not seq.getAnElt() instanceof Starred
)