Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da90717

Browse files
authored
Merge pull request #4641 from aschackmull/autoformat-setliterals
C++/C#/Java/JavaScript/Python: Autoformat set literals.
2 parents 7e89e57 + 89ef6ea commit da90717

38 files changed

Lines changed: 344 additions & 241 deletions

File tree

cpp/ql/src/Likely Bugs/Leap Year/UncheckedReturnValueForTimeFunctions.ql

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ class SafeTimeGatheringFunction extends Function {
5050
class TimeConversionFunction extends Function {
5151
TimeConversionFunction() {
5252
this.getQualifiedName() =
53-
["FileTimeToSystemTime", "SystemTimeToFileTime", "SystemTimeToTzSpecificLocalTime",
54-
"SystemTimeToTzSpecificLocalTimeEx", "TzSpecificLocalTimeToSystemTime",
55-
"TzSpecificLocalTimeToSystemTimeEx", "RtlLocalTimeToSystemTime",
56-
"RtlTimeToSecondsSince1970", "_mkgmtime"]
53+
[
54+
"FileTimeToSystemTime", "SystemTimeToFileTime", "SystemTimeToTzSpecificLocalTime",
55+
"SystemTimeToTzSpecificLocalTimeEx", "TzSpecificLocalTimeToSystemTime",
56+
"TzSpecificLocalTimeToSystemTimeEx", "RtlLocalTimeToSystemTime",
57+
"RtlTimeToSecondsSince1970", "_mkgmtime"
58+
]
5759
}
5860
}
5961

cpp/ql/src/semmle/code/cpp/commons/Strcat.qll

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import cpp
99
class StrcatFunction extends Function {
1010
StrcatFunction() {
1111
getName() =
12-
["strcat", // strcat(dst, src)
13-
"strncat", // strncat(dst, src, max_amount)
14-
"wcscat", // wcscat(dst, src)
15-
"_mbscat", // _mbscat(dst, src)
16-
"wcsncat", // wcsncat(dst, src, max_amount)
17-
"_mbsncat", // _mbsncat(dst, src, max_amount)
18-
"_mbsncat_l"] // _mbsncat_l(dst, src, max_amount, locale)
12+
[
13+
"strcat", // strcat(dst, src)
14+
"strncat", // strncat(dst, src, max_amount)
15+
"wcscat", // wcscat(dst, src)
16+
"_mbscat", // _mbscat(dst, src)
17+
"wcsncat", // wcsncat(dst, src, max_amount)
18+
"_mbsncat", // _mbsncat(dst, src, max_amount)
19+
"_mbsncat_l" // _mbsncat_l(dst, src, max_amount, locale)
20+
]
1921
}
2022
}

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,10 @@ pragma[noinline]
243243
private predicate getWrittenField(Instruction instr, Field f, Class c) {
244244
exists(FieldAddressInstruction fa |
245245
fa =
246-
getFieldInstruction([instr.(StoreInstruction).getDestinationAddress(),
247-
instr.(WriteSideEffectInstruction).getDestinationAddress()]) and
246+
getFieldInstruction([
247+
instr.(StoreInstruction).getDestinationAddress(),
248+
instr.(WriteSideEffectInstruction).getDestinationAddress()
249+
]) and
248250
f = fa.getField() and
249251
c = f.getDeclaringType()
250252
)

cpp/ql/src/semmle/code/cpp/models/implementations/Iterator.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,10 @@ class IteratorAssignmentMemberOperator extends MemberFunction, TaintFunction {
308308
class BeginOrEndFunction extends MemberFunction, TaintFunction, GetIteratorFunction {
309309
BeginOrEndFunction() {
310310
this
311-
.hasName(["begin", "cbegin", "rbegin", "crbegin", "end", "cend", "rend", "crend",
312-
"before_begin", "cbefore_begin"]) and
311+
.hasName([
312+
"begin", "cbegin", "rbegin", "crbegin", "end", "cend", "rend", "crend", "before_begin",
313+
"cbefore_begin"
314+
]) and
313315
this.getType().getUnspecifiedType() instanceof Iterator
314316
}
315317

cpp/ql/src/semmle/code/cpp/models/implementations/Pure.qll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import semmle.code.cpp.models.interfaces.SideEffect
55

66
class PureStrFunction extends AliasFunction, ArrayFunction, TaintFunction, SideEffectFunction {
77
PureStrFunction() {
8-
hasGlobalOrStdName(["atof", "atoi", "atol", "atoll", "strcasestr", "strchnul", "strchr",
9-
"strchrnul", "strstr", "strpbrk", "strcmp", "strcspn", "strncmp", "strrchr", "strspn",
10-
"strtod", "strtof", "strtol", "strtoll", "strtoq", "strtoul"])
8+
hasGlobalOrStdName([
9+
"atof", "atoi", "atol", "atoll", "strcasestr", "strchnul", "strchr", "strchrnul", "strstr",
10+
"strpbrk", "strcmp", "strcspn", "strncmp", "strrchr", "strspn", "strtod", "strtof",
11+
"strtol", "strtoll", "strtoq", "strtoul"
12+
])
1113
}
1214

1315
override predicate hasArrayInput(int bufParam) {

cpp/ql/src/semmle/code/cpp/models/implementations/Strcpy.qll

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,24 @@ import semmle.code.cpp.models.interfaces.SideEffect
1414
class StrcpyFunction extends ArrayFunction, DataFlowFunction, TaintFunction, SideEffectFunction {
1515
StrcpyFunction() {
1616
getName() =
17-
["strcpy", // strcpy(dst, src)
18-
"wcscpy", // wcscpy(dst, src)
19-
"_mbscpy", // _mbscpy(dst, src)
20-
"strncpy", // strncpy(dst, src, max_amount)
21-
"_strncpy_l", // _strncpy_l(dst, src, max_amount, locale)
22-
"wcsncpy", // wcsncpy(dst, src, max_amount)
23-
"_wcsncpy_l", // _wcsncpy_l(dst, src, max_amount, locale)
24-
"_mbsncpy", // _mbsncpy(dst, src, max_amount)
25-
"_mbsncpy_l"] // _mbsncpy_l(dst, src, max_amount, locale)
17+
[
18+
"strcpy", // strcpy(dst, src)
19+
"wcscpy", // wcscpy(dst, src)
20+
"_mbscpy", // _mbscpy(dst, src)
21+
"strncpy", // strncpy(dst, src, max_amount)
22+
"_strncpy_l", // _strncpy_l(dst, src, max_amount, locale)
23+
"wcsncpy", // wcsncpy(dst, src, max_amount)
24+
"_wcsncpy_l", // _wcsncpy_l(dst, src, max_amount, locale)
25+
"_mbsncpy", // _mbsncpy(dst, src, max_amount)
26+
"_mbsncpy_l" // _mbsncpy_l(dst, src, max_amount, locale)
27+
]
2628
or
2729
getName() =
28-
["strcpy_s", // strcpy_s(dst, max_amount, src)
29-
"wcscpy_s", // wcscpy_s(dst, max_amount, src)
30-
"_mbscpy_s"] and // _mbscpy_s(dst, max_amount, src)
30+
[
31+
"strcpy_s", // strcpy_s(dst, max_amount, src)
32+
"wcscpy_s", // wcscpy_s(dst, max_amount, src)
33+
"_mbscpy_s" // _mbscpy_s(dst, max_amount, src)
34+
] and
3135
// exclude the 2-parameter template versions
3236
// that find the size of a fixed size destination buffer.
3337
getNumberOfParameters() = 3

cpp/ql/src/semmle/code/cpp/security/BufferWrite.qll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,11 @@ class SnprintfBW extends BufferWriteCall {
355355
class GetsBW extends BufferWriteCall {
356356
GetsBW() {
357357
getTarget().(TopLevelFunction).getName() =
358-
["gets", // gets(dst)
359-
"fgets", // fgets(dst, max_amount, src_stream)
360-
"fgetws"] // fgetws(dst, max_amount, src_stream)
358+
[
359+
"gets", // gets(dst)
360+
"fgets", // fgets(dst, max_amount, src_stream)
361+
"fgetws" // fgetws(dst, max_amount, src_stream)
362+
]
361363
}
362364

363365
/**

csharp/ql/src/semmle/code/csharp/dataflow/LibraryTypeDataFlow.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,8 +1751,10 @@ class SystemTupleFlow extends LibraryTypeDataFlow, ValueOrRefType {
17511751
result =
17521752
unique(AccessPath ap |
17531753
i in [1 .. count(this.getAMember())] and
1754-
ap in [AccessPath::field(this.getField("Item" + i)),
1755-
AccessPath::property(this.getProperty("Item" + i))]
1754+
ap in [
1755+
AccessPath::field(this.getField("Item" + i)),
1756+
AccessPath::property(this.getProperty("Item" + i))
1757+
]
17561758
|
17571759
ap
17581760
)

csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,10 @@ private predicate isParamsArg(Call c, Expr arg, Parameter p) {
382382
p.isParams() and
383383
numArgs = c.getNumberOfArguments() and
384384
arg =
385-
[getImplicitArgument(c, [p.getPosition() .. numArgs - 1]), getExplicitArgument(c, p.getName())]
385+
[
386+
getImplicitArgument(c, [p.getPosition() .. numArgs - 1]),
387+
getExplicitArgument(c, p.getName())
388+
]
386389
|
387390
numArgs > target.getNumberOfParameters()
388391
or

csharp/ql/src/semmle/code/csharp/dataflow/internal/rangeanalysis/SignAnalysisSpecific.qll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,9 @@ private module Impl {
160160

161161
/** Returned an expression that is assigned to `f`. */
162162
ExprNode getAssignedValueToField(Field f) {
163-
result.getExpr() in [f.getAnAssignedValue(),
164-
any(AssignOperation a | a.getLValue() = f.getAnAccess())]
163+
result.getExpr() in [
164+
f.getAnAssignedValue(), any(AssignOperation a | a.getLValue() = f.getAnAccess())
165+
]
165166
}
166167

167168
/** Holds if `f` can have any sign. */

0 commit comments

Comments
 (0)