Python: Add getClassName for immutable literals

Used for queries where we mention the class of a literal in the alert
message.
This commit is contained in:
Taus
2026-03-23 16:18:32 +00:00
parent 6efedb7d00
commit ec9e72ee09

View File

@@ -2158,6 +2158,23 @@ module DuckTyping {
or
f.getADecorator().(Name).getId() = "property"
}
/** Gets the name of the builtin class of the immutable literal `lit`. */
string getClassName(ImmutableLiteral lit) {
lit instanceof IntegerLiteral and result = "int"
or
lit instanceof FloatLiteral and result = "float"
or
lit instanceof ImaginaryLiteral and result = "complex"
or
lit instanceof NegativeIntegerLiteral and result = "int"
or
lit instanceof StringLiteral and result = "str"
or
lit instanceof BooleanLiteral and result = "bool"
or
lit instanceof None and result = "NoneType"
}
}
/**