mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Python: Move AdvancedFormatting dependents over to suffixed API
This commit is contained in:
@@ -13,6 +13,6 @@
|
||||
import python
|
||||
import AdvancedFormatting
|
||||
|
||||
from AdvancedFormattingCall call, AdvancedFormatString fmt
|
||||
from AdvancedFormattingCall_objectapi call, AdvancedFormatString_objectapi fmt
|
||||
where call.getAFormat() = fmt and fmt.isImplicitlyNumbered() and fmt.isExplicitlyNumbered()
|
||||
select fmt, "Formatting string mixes implicitly and explicitly numbered fields."
|
||||
@@ -16,11 +16,11 @@ import python
|
||||
import python
|
||||
import AdvancedFormatting
|
||||
|
||||
int field_count(AdvancedFormatString fmt) { result = max(fmt.getFieldNumber(_, _)) + 1 }
|
||||
int field_count(AdvancedFormatString_objectapi fmt) { result = max(fmt.getFieldNumber(_, _)) + 1 }
|
||||
|
||||
from AdvancedFormattingCall call, AdvancedFormatString fmt, int arg_count, int max_field
|
||||
from AdvancedFormattingCall_objectapi call, AdvancedFormatString_objectapi fmt, int arg_count, int max_field
|
||||
where arg_count = call.providedArgCount() and max_field = field_count(fmt) and
|
||||
call.getAFormat() = fmt and not exists(call.getStarargs()) and
|
||||
forall(AdvancedFormatString other | other = call.getAFormat() | field_count(other) < arg_count)
|
||||
forall(AdvancedFormatString_objectapi other | other = call.getAFormat() | field_count(other) < arg_count)
|
||||
select call, "Too many arguments for string format. Format $@ requires only " + max_field + ", but " +
|
||||
arg_count.toString() + " are provided.", fmt, "\"" + fmt.getText() + "\""
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
import python
|
||||
import AdvancedFormatting
|
||||
|
||||
from AdvancedFormattingCall call, AdvancedFormatString fmt, string name, string fmt_repr
|
||||
from AdvancedFormattingCall_objectapi call, AdvancedFormatString_objectapi fmt, string name, string fmt_repr
|
||||
where call.getAFormat() = fmt and
|
||||
name = call.getAKeyword().getArg() and
|
||||
forall(AdvancedFormatString format | format = call.getAFormat() | not format.getFieldName(_, _) = name)
|
||||
forall(AdvancedFormatString_objectapi format | format = call.getAFormat() | not format.getFieldName(_, _) = name)
|
||||
and not exists(call.getKwargs()) and
|
||||
(strictcount(call.getAFormat()) = 1 and fmt_repr = "format \"" + fmt.getText() + "\""
|
||||
or
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
import python
|
||||
import AdvancedFormatting
|
||||
|
||||
from AdvancedFormattingCall call, AdvancedFormatString fmt, string name
|
||||
from AdvancedFormattingCall_objectapi call, AdvancedFormatString_objectapi fmt, string name
|
||||
where call.getAFormat() = fmt and
|
||||
not name = call.getAKeyword().getArg() and
|
||||
fmt.getFieldName(_, _) = name
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
import python
|
||||
import AdvancedFormatting
|
||||
|
||||
from AdvancedFormattingCall call, AdvancedFormatString fmt,
|
||||
from AdvancedFormattingCall_objectapi call, AdvancedFormatString_objectapi fmt,
|
||||
int arg_count, int max_field, string provided
|
||||
where arg_count = call.providedArgCount() and max_field = max(fmt.getFieldNumber(_, _)) and
|
||||
call.getAFormat() = fmt and not exists(call.getStarargs()) and arg_count <= max_field and
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import python
|
||||
import Expressions.Formatting.AdvancedFormatting
|
||||
|
||||
from AdvancedFormatString a, string name, int start, int end
|
||||
from AdvancedFormatString_objectapi a, string name, int start, int end
|
||||
where
|
||||
name = "'" + a.getFieldName(start, end) + "'"
|
||||
or
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
import python
|
||||
import Expressions.Formatting.AdvancedFormatting
|
||||
|
||||
from AdvancedFormatString a, int start, int end
|
||||
from AdvancedFormatString_objectapi a, int start, int end
|
||||
select a.getLocation().getStartLine(), a.getText(), start, end, a.getField(start, end)
|
||||
|
||||
Reference in New Issue
Block a user