Skip to content

Commit e786157

Browse files
authored
Merge pull request #362 from github/codeql/upgrade-to-2.13.5
Upgrading `github/codeql` dependency to 2.13.5
2 parents 47c8a57 + 34539a7 commit e786157

File tree

326 files changed

+752
-519
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

326 files changed

+752
-519
lines changed

c/cert/src/codeql-pack.lock.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.6.1
5+
version: 0.7.4
66
codeql/ssa:
7-
version: 0.0.14
7+
version: 0.0.19
88
codeql/tutorial:
9-
version: 0.0.7
9+
version: 0.0.12
10+
codeql/util:
11+
version: 0.0.12
1012
compiled: false

c/cert/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ suites: codeql-suites
55
license: MIT
66
dependencies:
77
codeql/common-c-coding-standards: '*'
8-
codeql/cpp-all: 0.6.1
8+
codeql/cpp-all: 0.7.4

c/cert/src/rules/ARR30-C/DoNotFormOutOfBoundsPointersOrArraySubscripts.ql

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,42 @@
1212
* external/cert/obligation/rule
1313
*/
1414

15-
import cpp
16-
import codingstandards.c.cert
17-
import codingstandards.c.OutOfBounds
18-
19-
from
20-
OOB::BufferAccess ba, Expr bufferArg, Expr sizeArg, OOB::PointerToObjectSource bufferSource,
21-
string message
22-
where
23-
not isExcluded(ba, OutOfBoundsPackage::doNotFormOutOfBoundsPointersOrArraySubscriptsQuery()) and
24-
// exclude loops
25-
not exists(Loop loop | loop.getStmt().getChildStmt*() = ba.getEnclosingStmt()) and
26-
// exclude size arguments that are of type ssize_t
27-
not sizeArg.getAChild*().(VariableAccess).getTarget().getType() instanceof Ssize_t and
28-
// exclude size arguments that are assigned the result of a function call e.g. ftell
29-
not sizeArg.getAChild*().(VariableAccess).getTarget().getAnAssignedValue() instanceof FunctionCall and
30-
// exclude field or array accesses for the size arguments
31-
not sizeArg.getAChild*() instanceof FieldAccess and
32-
not sizeArg.getAChild*() instanceof ArrayExpr and
33-
(
34-
exists(int sizeArgValue, int bufferArgSize |
35-
OOB::isSizeArgGreaterThanBufferSize(bufferArg, sizeArg, bufferSource, bufferArgSize, sizeArgValue, ba) and
36-
message =
37-
"Buffer accesses offset " + sizeArgValue +
38-
" which is greater than the fixed size " + bufferArgSize + " of the $@."
39-
)
40-
or
41-
exists(int sizeArgUpperBound, int sizeMult, int bufferArgSize |
42-
OOB::isSizeArgNotCheckedLessThanFixedBufferSize(bufferArg, sizeArg, bufferSource,
43-
bufferArgSize, ba, sizeArgUpperBound, sizeMult) and
44-
message =
45-
"Buffer may access up to offset " + sizeArgUpperBound + "*" + sizeMult +
46-
" which is greater than the fixed size " + bufferArgSize + " of the $@."
47-
)
48-
or
49-
OOB::isSizeArgNotCheckedGreaterThanZero(bufferArg, sizeArg, bufferSource, ba) and
50-
message = "Buffer access may be to a negative index in the buffer."
51-
)
52-
select ba, message, bufferSource, "buffer"
15+
import cpp
16+
import codingstandards.c.cert
17+
import codingstandards.c.OutOfBounds
18+
19+
from
20+
OOB::BufferAccess ba, Expr bufferArg, Expr sizeArg, OOB::PointerToObjectSource bufferSource,
21+
string message
22+
where
23+
not isExcluded(ba, OutOfBoundsPackage::doNotFormOutOfBoundsPointersOrArraySubscriptsQuery()) and
24+
// exclude loops
25+
not exists(Loop loop | loop.getStmt().getChildStmt*() = ba.getEnclosingStmt()) and
26+
// exclude size arguments that are of type ssize_t
27+
not sizeArg.getAChild*().(VariableAccess).getTarget().getType() instanceof Ssize_t and
28+
// exclude size arguments that are assigned the result of a function call e.g. ftell
29+
not sizeArg.getAChild*().(VariableAccess).getTarget().getAnAssignedValue() instanceof FunctionCall and
30+
// exclude field or array accesses for the size arguments
31+
not sizeArg.getAChild*() instanceof FieldAccess and
32+
not sizeArg.getAChild*() instanceof ArrayExpr and
33+
(
34+
exists(int sizeArgValue, int bufferArgSize |
35+
OOB::isSizeArgGreaterThanBufferSize(bufferArg, sizeArg, bufferSource, bufferArgSize,
36+
sizeArgValue, ba) and
37+
message =
38+
"Buffer accesses offset " + sizeArgValue + " which is greater than the fixed size " +
39+
bufferArgSize + " of the $@."
40+
)
41+
or
42+
exists(int sizeArgUpperBound, int sizeMult, int bufferArgSize |
43+
OOB::isSizeArgNotCheckedLessThanFixedBufferSize(bufferArg, sizeArg, bufferSource,
44+
bufferArgSize, ba, sizeArgUpperBound, sizeMult) and
45+
message =
46+
"Buffer may access up to offset " + sizeArgUpperBound + "*" + sizeMult +
47+
" which is greater than the fixed size " + bufferArgSize + " of the $@."
48+
)
49+
or
50+
OOB::isSizeArgNotCheckedGreaterThanZero(bufferArg, sizeArg, bufferSource, ba) and
51+
message = "Buffer access may be to a negative index in the buffer."
52+
)
53+
select ba, message, bufferSource, "buffer"

c/cert/src/rules/ARR36-C/DoNotRelatePointersThatDoNotReferToTheSameArray.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import cpp
1515
import codingstandards.c.cert
1616
import codingstandards.cpp.rules.donotuserelationaloperatorswithdifferingarrays.DoNotUseRelationalOperatorsWithDifferingArrays
1717

18-
class DoNotRelatePointersThatDoNotReferToTheSameArrayQuery extends DoNotUseRelationalOperatorsWithDifferingArraysSharedQuery {
18+
class DoNotRelatePointersThatDoNotReferToTheSameArrayQuery extends DoNotUseRelationalOperatorsWithDifferingArraysSharedQuery
19+
{
1920
DoNotRelatePointersThatDoNotReferToTheSameArrayQuery() {
2021
this = Memory2Package::doNotRelatePointersThatDoNotReferToTheSameArrayQuery()
2122
}

c/cert/src/rules/ARR36-C/DoNotSubtractPointersThatDoNotReferToTheSameArray.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import cpp
1515
import codingstandards.c.cert
1616
import codingstandards.cpp.rules.donotsubtractpointersaddressingdifferentarrays.DoNotSubtractPointersAddressingDifferentArrays
1717

18-
class DoNotSubtractPointersThatDoNotReferToTheSameArrayQuery extends DoNotSubtractPointersAddressingDifferentArraysSharedQuery {
18+
class DoNotSubtractPointersThatDoNotReferToTheSameArrayQuery extends DoNotSubtractPointersAddressingDifferentArraysSharedQuery
19+
{
1920
DoNotSubtractPointersThatDoNotReferToTheSameArrayQuery() {
2021
this = Memory2Package::doNotSubtractPointersThatDoNotReferToTheSameArrayQuery()
2122
}

c/cert/src/rules/ARR38-C/LibraryFunctionArgumentOutOfBounds.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ from
2222
where
2323
not isExcluded(fc, OutOfBoundsPackage::libraryFunctionArgumentOutOfBoundsQuery()) and
2424
OOB::problems(fc, message, bufferArg, bufferArgStr, sizeOrOtherBufferArg, otherStr)
25-
select fc, message, bufferArg, bufferArgStr, sizeOrOtherBufferArg, otherStr
25+
select fc, message, bufferArg, bufferArgStr, sizeOrOtherBufferArg, otherStr

c/cert/src/rules/CON31-C/DoNotAllowAMutexToGoOutOfScopeWhileLocked.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import cpp
1616
import codingstandards.c.cert
1717
import codingstandards.cpp.rules.donotallowamutextogooutofscopewhilelocked.DoNotAllowAMutexToGoOutOfScopeWhileLocked
1818

19-
class DoNotAllowAMutexToGoOutOfScopeWhileLockedQuery extends DoNotAllowAMutexToGoOutOfScopeWhileLockedSharedQuery {
19+
class DoNotAllowAMutexToGoOutOfScopeWhileLockedQuery extends DoNotAllowAMutexToGoOutOfScopeWhileLockedSharedQuery
20+
{
2021
DoNotAllowAMutexToGoOutOfScopeWhileLockedQuery() {
2122
this = Concurrency3Package::doNotAllowAMutexToGoOutOfScopeWhileLockedQuery()
2223
}

c/cert/src/rules/CON33-C/RaceConditionsWhenUsingLibraryFunctions.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ where
2424
"setlocale", "atomic_init", "ATOMIC_VAR_INIT", "tmpnam", "mbrtoc16", "c16rtomb", "mbrtoc32",
2525
"c32rtomb"
2626
]
27-
select node,
28-
"Concurrent call to non-reeantrant function $@.", node.(FunctionCall).getTarget(), node.(FunctionCall).getTarget().getName()
27+
select node, "Concurrent call to non-reeantrant function $@.", node.(FunctionCall).getTarget(),
28+
node.(FunctionCall).getTarget().getName()

c/cert/src/rules/CON35-C/DeadlockByLockingInPredefinedOrder.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import cpp
1616
import codingstandards.c.cert
1717
import codingstandards.cpp.rules.preventdeadlockbylockinginpredefinedorder.PreventDeadlockByLockingInPredefinedOrder
1818

19-
class DeadlockByLockingInPredefinedOrderQuery extends PreventDeadlockByLockingInPredefinedOrderSharedQuery {
19+
class DeadlockByLockingInPredefinedOrderQuery extends PreventDeadlockByLockingInPredefinedOrderSharedQuery
20+
{
2021
DeadlockByLockingInPredefinedOrderQuery() {
2122
this = Concurrency2Package::deadlockByLockingInPredefinedOrderQuery()
2223
}

c/cert/src/rules/CON37-C/DoNotCallSignalInMultithreadedProgram.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,4 @@ where
2424
not isExcluded(fc, Concurrency1Package::doNotCallSignalInMultithreadedProgramQuery()) and
2525
fc.getTarget().getName() = "signal" and
2626
exists(ThreadedFunction f)
27-
select fc,
28-
"Call to `signal()` in multithreaded programs."
27+
select fc, "Call to `signal()` in multithreaded programs."

c/cert/src/rules/CON38-C/PreserveSafetyWhenUsingConditionVariables.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import cpp
1616
import codingstandards.c.cert
1717
import codingstandards.cpp.rules.preservesafetywhenusingconditionvariables.PreserveSafetyWhenUsingConditionVariables
1818

19-
class PreserveSafetyWhenUsingConditionVariablesQuery extends PreserveSafetyWhenUsingConditionVariablesSharedQuery {
19+
class PreserveSafetyWhenUsingConditionVariablesQuery extends PreserveSafetyWhenUsingConditionVariablesSharedQuery
20+
{
2021
PreserveSafetyWhenUsingConditionVariablesQuery() {
2122
this = Concurrency3Package::preserveSafetyWhenUsingConditionVariablesQuery()
2223
}

c/cert/src/rules/CON41-C/WrapFunctionsThatCanFailSpuriouslyInLoop.ql

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@
1212
* external/cert/obligation/rule
1313
*/
1414

15-
import cpp
16-
import codingstandards.c.cert
17-
import codingstandards.cpp.Concurrency
18-
15+
import cpp
16+
import codingstandards.c.cert
17+
import codingstandards.cpp.Concurrency
1918

20-
from AtomicCompareExchange ace
21-
where
22-
not isExcluded(ace, Concurrency3Package::wrapFunctionsThatCanFailSpuriouslyInLoopQuery()) and
23-
(
24-
forex(StmtParent sp | sp = ace.getStmt() | not sp.(Stmt).getParentStmt*() instanceof Loop) or
25-
forex(Expr e | e = ace.getExpr() | not e.getEnclosingStmt().getParentStmt*()
26-
instanceof Loop)
27-
)
28-
select ace, "Function that can spuriously fail not wrapped in a loop."
29-
19+
from AtomicCompareExchange ace
20+
where
21+
not isExcluded(ace, Concurrency3Package::wrapFunctionsThatCanFailSpuriouslyInLoopQuery()) and
22+
(
23+
forex(StmtParent sp | sp = ace.getStmt() | not sp.(Stmt).getParentStmt*() instanceof Loop)
24+
or
25+
forex(Expr e | e = ace.getExpr() | not e.getEnclosingStmt().getParentStmt*() instanceof Loop)
26+
)
27+
select ace, "Function that can spuriously fail not wrapped in a loop."

c/cert/src/rules/DCL30-C/AppropriateStorageDurationsStackAdressEscape.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import cpp
1515
import codingstandards.c.cert
1616
import codingstandards.cpp.rules.donotcopyaddressofautostorageobjecttootherobject.DoNotCopyAddressOfAutoStorageObjectToOtherObject
1717

18-
class AppropriateStorageDurationsStackAdressEscapeQuery extends DoNotCopyAddressOfAutoStorageObjectToOtherObjectSharedQuery {
18+
class AppropriateStorageDurationsStackAdressEscapeQuery extends DoNotCopyAddressOfAutoStorageObjectToOtherObjectSharedQuery
19+
{
1920
AppropriateStorageDurationsStackAdressEscapeQuery() {
2021
this = Declarations8Package::appropriateStorageDurationsStackAdressEscapeQuery()
2122
}

c/cert/src/rules/DCL39-C/InformationLeakageAcrossTrustBoundariesC.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import cpp
1515
import codingstandards.c.cert
1616
import codingstandards.cpp.rules.informationleakageacrossboundaries.InformationLeakageAcrossBoundaries
1717

18-
class InformationLeakageAcrossTrustBoundariesCQuery extends InformationLeakageAcrossBoundariesSharedQuery {
18+
class InformationLeakageAcrossTrustBoundariesCQuery extends InformationLeakageAcrossBoundariesSharedQuery
19+
{
1920
InformationLeakageAcrossTrustBoundariesCQuery() {
2021
this = Declarations7Package::informationLeakageAcrossTrustBoundariesCQuery()
2122
}

c/cert/src/rules/ENV34-C/DoNotStorePointersReturnedByEnvironmentFunWarn.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import cpp
1616
import codingstandards.c.cert
1717
import codingstandards.cpp.rules.invalidatedenvstringpointerswarn.InvalidatedEnvStringPointersWarn
1818

19-
class DoNotStorePointersReturnedByEnvironmentFunWarnQuery extends InvalidatedEnvStringPointersWarnSharedQuery {
19+
class DoNotStorePointersReturnedByEnvironmentFunWarnQuery extends InvalidatedEnvStringPointersWarnSharedQuery
20+
{
2021
DoNotStorePointersReturnedByEnvironmentFunWarnQuery() {
2122
this = Contracts2Package::doNotStorePointersReturnedByEnvironmentFunWarnQuery()
2223
}

c/cert/src/rules/ERR32-C/DoNotRelyOnIndeterminateValuesOfErrno.ql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import codingstandards.c.Errno
1616
import codingstandards.c.Signal
1717
import semmle.code.cpp.controlflow.Guards
1818

19-
2019
/**
2120
* A check on `signal` call return value
2221
* `if (signal(SIGINT, handler) == SIG_ERR)`

c/cert/src/rules/EXP36-C/DoNotCastPointerToMoreStrictlyAlignedPointerType.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ class DefaultAlignedPointerExpr extends UnconvertedCastFromNonVoidPointerExpr, E
118118
* to exclude an `DefaultAlignedPointerAccessExpr` as a source if a preceding source
119119
* defined by this configuration provides more accurate alignment information.
120120
*/
121-
class AllocationOrAddressOfExprToUnconvertedCastFromNonVoidPointerExprConfig extends DataFlow2::Configuration {
121+
class AllocationOrAddressOfExprToUnconvertedCastFromNonVoidPointerExprConfig extends DataFlow2::Configuration
122+
{
122123
AllocationOrAddressOfExprToUnconvertedCastFromNonVoidPointerExprConfig() {
123124
this = "AllocationOrAddressOfExprToUnconvertedCastFromNonVoidPointerExprConfig"
124125
}

c/cert/src/rules/EXP39-C/DoNotAccessVariableViaPointerOfIncompatibleType.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ Type compatibleTypes(Type type) {
163163
(
164164
type.stripType() instanceof Struct and
165165
type.getUnspecifiedType() = result.getUnspecifiedType() and
166-
not type.getName() = "struct <unnamed>" and
167-
not result.getName() = "struct <unnamed>"
166+
not type.(Struct).isAnonymous() and
167+
not result.(Struct).isAnonymous()
168168
or
169169
not type.stripType() instanceof Struct and
170170
(

c/cert/src/rules/EXP42-C/DoNotComparePaddingData.ql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,5 @@ import codingstandards.c.cert
1515
import codingstandards.cpp.rules.memcmpusedtocomparepaddingdata.MemcmpUsedToComparePaddingData
1616

1717
class DoNotComparePaddingDataQuery extends MemcmpUsedToComparePaddingDataSharedQuery {
18-
DoNotComparePaddingDataQuery() {
19-
this = Memory2Package::doNotComparePaddingDataQuery()
20-
}
18+
DoNotComparePaddingDataQuery() { this = Memory2Package::doNotComparePaddingDataQuery() }
2119
}

c/cert/src/rules/FIO32-C/DoNotPerformFileOperationsOnDevices.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ module TaintedPathConfiguration implements DataFlow::ConfigSig {
8989
}
9090
}
9191

92-
module TaintedPath = TaintTracking::Make<TaintedPathConfiguration>;
92+
module TaintedPath = TaintTracking::Global<TaintedPathConfiguration>;
9393

9494
from
9595
FileFunction fileFunction, Expr taintedArg, FlowSource taintSource,
@@ -98,7 +98,7 @@ where
9898
not isExcluded(taintedArg, IO3Package::doNotPerformFileOperationsOnDevicesQuery()) and
9999
taintedArg = sinkNode.getNode().asIndirectArgument() and
100100
fileFunction.outermostWrapperFunctionCall(taintedArg, callChain) and
101-
TaintedPath::hasFlowPath(sourceNode, sinkNode) and
101+
TaintedPath::flowPath(sourceNode, sinkNode) and
102102
taintSource = sourceNode.getNode()
103103
select taintedArg, sourceNode, sinkNode,
104104
"This argument to a file access function is derived from $@ and then passed to " + callChain + ".",

c/cert/src/rules/FIO39-C/DoNotAlternatelyIOFromAStreamWithoutPositioning.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import cpp
1515
import codingstandards.c.cert
1616
import codingstandards.cpp.rules.iofstreammissingpositioning.IOFstreamMissingPositioning
1717

18-
class DoNotAlternatelyIOFromAStreamWithoutPositioningQuery extends IOFstreamMissingPositioningSharedQuery {
18+
class DoNotAlternatelyIOFromAStreamWithoutPositioningQuery extends IOFstreamMissingPositioningSharedQuery
19+
{
1920
DoNotAlternatelyIOFromAStreamWithoutPositioningQuery() {
2021
this = IO1Package::doNotAlternatelyIOFromAStreamWithoutPositioningQuery()
2122
}

c/cert/src/rules/FIO42-C/CloseFilesWhenTheyAreNoLongerNeeded.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import cpp
1616
import codingstandards.c.cert
1717
import codingstandards.cpp.rules.closefilehandlewhennolongerneededshared.CloseFileHandleWhenNoLongerNeededShared
1818

19-
class CloseFilesWhenTheyAreNoLongerNeededQuery extends CloseFileHandleWhenNoLongerNeededSharedSharedQuery {
19+
class CloseFilesWhenTheyAreNoLongerNeededQuery extends CloseFileHandleWhenNoLongerNeededSharedSharedQuery
20+
{
2021
CloseFilesWhenTheyAreNoLongerNeededQuery() {
2122
this = IO1Package::closeFilesWhenTheyAreNoLongerNeededQuery()
2223
}

c/cert/src/rules/MEM34-C/OnlyFreeMemoryAllocatedDynamicallyCert.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import cpp
1616
import codingstandards.c.cert
1717
import codingstandards.cpp.rules.onlyfreememoryallocateddynamicallyshared.OnlyFreeMemoryAllocatedDynamicallyShared
1818

19-
class OnlyFreeMemoryAllocatedDynamicallyCertQuery extends OnlyFreeMemoryAllocatedDynamicallySharedSharedQuery {
19+
class OnlyFreeMemoryAllocatedDynamicallyCertQuery extends OnlyFreeMemoryAllocatedDynamicallySharedSharedQuery
20+
{
2021
OnlyFreeMemoryAllocatedDynamicallyCertQuery() {
2122
this = Memory2Package::onlyFreeMemoryAllocatedDynamicallyCertQuery()
2223
}

c/cert/src/rules/MSC30-C/RandUsedForGeneratingPseudorandomNumbers.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import cpp
1414
import codingstandards.c.cert
1515
import codingstandards.cpp.rules.donotuserandforgeneratingpseudorandomnumbers.DoNotUseRandForGeneratingPseudorandomNumbers
1616

17-
class RandUsedForGeneratingPseudorandomNumbersQuery extends DoNotUseRandForGeneratingPseudorandomNumbersSharedQuery {
17+
class RandUsedForGeneratingPseudorandomNumbersQuery extends DoNotUseRandForGeneratingPseudorandomNumbersSharedQuery
18+
{
1819
RandUsedForGeneratingPseudorandomNumbersQuery() {
1920
this = MiscPackage::randUsedForGeneratingPseudorandomNumbersQuery()
2021
}

c/cert/src/rules/MSC32-C/ProperlySeedPseudorandomNumberGenerators.ql

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,22 @@ import codingstandards.c.cert
1515

1616
/** Defines a class that models function calls to srandom() */
1717
class SRandomCall extends FunctionCall {
18-
SRandomCall(){
19-
getTarget().hasGlobalOrStdName("srandom")
20-
}
18+
SRandomCall() { getTarget().hasGlobalOrStdName("srandom") }
2119

2220
/** Holds if the call is not obviously trivial. */
23-
predicate isTrivial(){
24-
getArgument(0) instanceof Literal
25-
}
21+
predicate isTrivial() { getArgument(0) instanceof Literal }
2622
}
2723

2824
from FunctionCall fc
2925
where
3026
not isExcluded(fc, MiscPackage::properlySeedPseudorandomNumberGeneratorsQuery()) and
31-
32-
// find all calls to random()
33-
fc.getTarget().hasGlobalOrStdName("random") and
34-
27+
// find all calls to random()
28+
fc.getTarget().hasGlobalOrStdName("random") and
3529
// where there isn't a call to srandom that comes before it that is
3630
// non-trivial
3731
not exists(SRandomCall sr |
38-
// normally we would want to do this in reverse --- but srandom() is
39-
// not pure and the order does not matter.
32+
// normally we would want to do this in reverse --- but srandom() is
33+
// not pure and the order does not matter.
4034
sr.getASuccessor*() = fc and not sr.isTrivial()
4135
)
42-
43-
4436
select fc, "Call to `random()` without a valid call to `srandom()`."

c/cert/src/rules/MSC37-C/ControlFlowReachesTheEndOfANonVoidFunction.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import cpp
1515
import codingstandards.c.cert
1616
import codingstandards.cpp.rules.nonvoidfunctiondoesnotreturn.NonVoidFunctionDoesNotReturn
1717

18-
class ControlFlowReachesTheEndOfANonVoidFunctionQuery extends NonVoidFunctionDoesNotReturnSharedQuery {
18+
class ControlFlowReachesTheEndOfANonVoidFunctionQuery extends NonVoidFunctionDoesNotReturnSharedQuery
19+
{
1920
ControlFlowReachesTheEndOfANonVoidFunctionQuery() {
2021
this = MiscPackage::controlFlowReachesTheEndOfANonVoidFunctionQuery()
2122
}

c/cert/test/codeql-pack.lock.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.6.1
5+
version: 0.7.4
66
codeql/ssa:
7-
version: 0.0.14
7+
version: 0.0.19
88
codeql/tutorial:
9-
version: 0.0.7
9+
version: 0.0.12
10+
codeql/util:
11+
version: 0.0.12
1012
compiled: false

0 commit comments

Comments
 (0)