Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite7455c0

Browse files
Merge remote-tracking branch 'origin/main' into michaelrfairhurst/implement-rule-amendments-tc2
2 parentsc55a173 +a7955d8 commite7455c0

File tree

306 files changed

+7961
-1887
lines changed

Some content is hidden

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

306 files changed

+7961
-1887
lines changed

‎.github/workflows/upgrade_codeql_dependencies.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
find c \( -name '*.ql' -or -name '*.qll' \) -print0 | xargs -0 --max-procs "$XARGS_MAX_PROCS" codeql query format --in-place
5454
5555
-name:Create Pull Request
56-
uses:peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f# v7.0.5
56+
uses:peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e# v7.0.8
5757
with:
5858
title:"Upgrade `github/codeql` dependency to ${{ github.event.inputs.codeql_cli_version }}"
5959
body:|

‎amendments.csv‎

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,50 @@
11
language,standard,amendment,rule_id,supportable,implementation_category,implemented,difficulty
2-
c,MISRA-C-2012,Amendment3,DIR-4-6,Yes,Expand,No,Easy
2+
c,MISRA-C-2012,Amendment3,DIR-4-6,Yes,Expand,Yes,Easy
33
c,MISRA-C-2012,Amendment3,DIR-4-9,Yes,Refine,No,Easy
44
c,MISRA-C-2012,Amendment3,DIR-4-11,Yes,Refine,No,Import
55
c,MISRA-C-2012,Amendment3,RULE-1-4,Yes,Replace,No,Easy
6-
c,MISRA-C-2012,Amendment3,RULE-10-1,Yes,Replace,No,Easy
7-
c,MISRA-C-2012,Amendment3,RULE-10-3,Yes,Refine,No,Easy
8-
c,MISRA-C-2012,Amendment3,RULE-10-4,Yes,Refine,No,Import
9-
c,MISRA-C-2012,Amendment3,RULE-10-5,Yes,Expand,No,Easy
10-
c,MISRA-C-2012,Amendment3,RULE-10-7,Yes,Refine,No,Import
11-
c,MISRA-C-2012,Amendment3,RULE-10-8,Yes,Refine,No,Import
12-
c,MISRA-C-2012,Amendment3,RULE-21-11,Yes,Clarification,No,Import
6+
c,MISRA-C-2012,Amendment3,RULE-10-1,Yes,Replace,Yes,Easy
7+
c,MISRA-C-2012,Amendment3,RULE-10-3,Yes,Refine,Yes,Easy
8+
c,MISRA-C-2012,Amendment3,RULE-10-4,Yes,Refine,Yes,Import
9+
c,MISRA-C-2012,Amendment3,RULE-10-5,Yes,Expand,Yes,Easy
10+
c,MISRA-C-2012,Amendment3,RULE-10-7,Yes,Refine,Yes,Import
11+
c,MISRA-C-2012,Amendment3,RULE-10-8,Yes,Refine,Yes,Import
12+
c,MISRA-C-2012,Amendment3,RULE-21-11,Yes,Clarification,Yes,Import
1313
c,MISRA-C-2012,Amendment3,RULE-21-12,Yes,Replace,No,Easy
1414
c,MISRA-C-2012,Amendment4,RULE-11-3,Yes,Expand,No,Easy
1515
c,MISRA-C-2012,Amendment4,RULE-11-8,Yes,Expand,No,Easy
1616
c,MISRA-C-2012,Amendment4,RULE-13-2,Yes,Expand,No,Very Hard
1717
c,MISRA-C-2012,Amendment4,RULE-18-6,Yes,Expand,No,Medium
1818
c,MISRA-C-2012,Amendment4,RULE-18-8,Yes,Split,Yes,Easy
19-
c,MISRA-C-2012,Corrigendum2,RULE-2-2,Yes,Clarification,No,Import
20-
c,MISRA-C-2012,Corrigendum2,RULE-2-7,Yes,Clarification,No,Import
21-
c,MISRA-C-2012,Corrigendum2,RULE-3-1,Yes,Refine,No,Easy
22-
c,MISRA-C-2012,Corrigendum2,RULE-8-6,Yes,Clarification,No,Import
23-
c,MISRA-C-2012,Corrigendum2,RULE-8-9,Yes,Clarification,No,Import
24-
c,MISRA-C-2012,Corrigendum2,RULE-9-4,Yes,Clarification,No,Import
25-
c,MISRA-C-2012,Corrigendum2,RULE-10-1,Yes,Clarification,No,Import
26-
c,MISRA-C-2012,Corrigendum2,RULE-18-3,Yes,Clarification,No,Import
27-
c,MISRA-C-2012,Corrigendum2,RULE-1-4,Yes,Replace,No,Easy
28-
c,MISRA-C-2012,Corrigendum2,RULE-9-1,Yes,Refine,No,Easy
29-
c,MISRA-C-2012,Corrigendum2,RULE-9-2,Yes,Refine,No,Import
30-
c,MISRA-C-2012,Corrigendum2,DIR-4-10,Yes,Clarification,No,Import
19+
c,MISRA-C-2012,Amendment4,RULE-2-2,Yes,Clarification,Yes,Import
20+
c,MISRA-C-2012,Amendment4,RULE-2-7,Yes,Clarification,Yes,Import
21+
c,MISRA-C-2012,Amendment4,RULE-3-1,Yes,Refine,No,Easy
22+
c,MISRA-C-2012,Amendment4,RULE-8-6,Yes,Clarification,Yes,Import
23+
c,MISRA-C-2012,Amendment4,RULE-8-9,Yes,Clarification,Yes,Import
24+
c,MISRA-C-2012,Amendment4,RULE-9-4,Yes,Clarification,Yes,Import
25+
c,MISRA-C-2012,Amendment4,RULE-10-1,Yes,Clarification,Yes,Import
26+
c,MISRA-C-2012,Amendment4,RULE-18-3,Yes,Clarification,Yes,Import
27+
c,MISRA-C-2012,Amendment4,RULE-1-4,Yes,Replace,No,Easy
28+
c,MISRA-C-2012,Amendment4,RULE-9-1,Yes,Refine,No,Easy
29+
c,MISRA-C-2012,Amendment4,RULE-9-2,Yes,Refine,No,Import
30+
c,MISRA-C-2012,Corrigendum2,DIR-4-10,Yes,Clarification,Yes,Import
3131
c,MISRA-C-2012,Corrigendum2,RULE-7-4,Yes,Refine,Yes,Easy
32-
c,MISRA-C-2012,Corrigendum2,RULE-8-2,Yes,Clarification,No,Import
32+
c,MISRA-C-2012,Corrigendum2,RULE-8-2,Yes,Clarification,Yes,Import
3333
c,MISRA-C-2012,Corrigendum2,RULE-8-3,Yes,Refine,Yes,Easy
34-
c,MISRA-C-2012,Corrigendum2,RULE-8-7,Yes,Clarification,No,Import
34+
c,MISRA-C-2012,Corrigendum2,RULE-8-7,Yes,Clarification,Yes,Import
35+
c,MISRA-C-2012,Corrigendum2,RULE-10-1,Yes,Clarification,Yes,Import
3536
c,MISRA-C-2012,Corrigendum2,RULE-10-2,Yes,Refine,Yes,Easy
36-
c,MISRA-C-2012,Corrigendum2,RULE-10-3,Yes,Clarification,No,Import
37-
c,MISRA-C-2012,Corrigendum2,RULE-11-3,Yes,Clarification,No,Import
38-
c,MISRA-C-2012,Corrigendum2,RULE-11-6,Yes,Clarification,No,Import
39-
c,MISRA-C-2012,Corrigendum2,RULE-13-2,Yes,Clarification,No,Import
40-
c,MISRA-C-2012,Corrigendum2,RULE-13-6,Yes,Clarification,No,Import
37+
c,MISRA-C-2012,Corrigendum2,RULE-10-3,Yes,Clarification,Yes,Import
38+
c,MISRA-C-2012,Corrigendum2,RULE-11-3,Yes,Clarification,Yes,Import
39+
c,MISRA-C-2012,Corrigendum2,RULE-11-6,Yes,Clarification,Yes,Import
40+
c,MISRA-C-2012,Corrigendum2,RULE-13-2,Yes,Clarification,Yes,Import
41+
c,MISRA-C-2012,Corrigendum2,RULE-13-6,Yes,Clarification,Yes,Import
4142
c,MISRA-C-2012,Corrigendum2,RULE-14-3,Yes,Refine,Yes,Easy
42-
c,MISRA-C-2012,Corrigendum2,RULE-15-7,Yes,Clarification,No,Import
43-
c,MISRA-C-2012,Corrigendum2,RULE-17-4,Yes,Clarification,No,Import
44-
c,MISRA-C-2012,Corrigendum2,RULE-17-5,Yes,Clarification,No,Import
43+
c,MISRA-C-2012,Corrigendum2,RULE-15-7,Yes,Clarification,Yes,Import
44+
c,MISRA-C-2012,Corrigendum2,RULE-17-4,Yes,Clarification,Yes,Import
45+
c,MISRA-C-2012,Corrigendum2,RULE-17-5,Yes,Clarification,Yes,Import
4546
c,MISRA-C-2012,Corrigendum2,RULE-18-1,Yes,Refine,Yes,Easy
46-
c,MISRA-C-2012,Corrigendum2,RULE-20-14,No,Clarification,No,Import
47-
c,MISRA-C-2012,Corrigendum2,RULE-21-19,Yes,Clarification,No,Import
47+
c,MISRA-C-2012,Corrigendum2,RULE-20-14,No,Clarification,Yes,Import
48+
c,MISRA-C-2012,Corrigendum2,RULE-21-19,Yes,Clarification,Yes,Import
4849
c,MISRA-C-2012,Corrigendum2,RULE-21-20,Yes,Refine,Yes,Easy
49-
c,MISRA-C-2012,Corrigendum2,RULE-22-9,Yes,Clarification,No,Import
50+
c,MISRA-C-2012,Corrigendum2,RULE-22-9,Yes,Clarification,Yes,Import

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
lockVersion:1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version:1.4.2
5+
version:2.1.1
66
codeql/dataflow:
7-
version:1.1.1
7+
version:1.1.6
88
codeql/mad:
9-
version:1.0.7
9+
version:1.0.12
1010
codeql/rangeanalysis:
11-
version:1.0.7
11+
version:1.0.12
1212
codeql/ssa:
13-
version:1.0.7
13+
version:1.0.12
1414
codeql/tutorial:
15-
version:1.0.7
15+
version:1.0.12
1616
codeql/typeflow:
17-
version:1.0.7
17+
version:1.0.12
1818
codeql/typetracking:
19-
version:1.0.7
19+
version:1.0.12
2020
codeql/util:
21-
version:1.0.7
21+
version:1.0.12
2222
codeql/xml:
23-
version:1.0.7
23+
version:1.0.12
2424
compiled:false

‎c/cert/src/qlpack.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name:codeql/cert-c-coding-standards
2-
version:2.41.0-dev
2+
version:2.43.0-dev
33
description:CERT C 2016
44
suites:codeql-suites
55
license:MIT
66
dependencies:
77
codeql/common-c-coding-standards:'*'
8-
codeql/cpp-all:1.4.2
8+
codeql/cpp-all:2.1.1

‎c/cert/src/rules/CON30-C/CleanUpThreadSpecificStorage.ql‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import cpp
1616
import codingstandards.c.cert
1717
import codingstandards.cpp.Concurrency
18-
import semmle.code.cpp.dataflow.TaintTracking
1918
import semmle.code.cpp.dataflow.DataFlow
2019

2120
module TssCreateToTssDeleteConfigimplements DataFlow::ConfigSig{

‎c/cert/src/rules/CON34-C/AppropriateThreadObjectStorageDurations.ql‎

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,43 @@
1414

1515
import cpp
1616
import codingstandards.c.cert
17+
import codingstandards.c.Objects
1718
import codingstandards.cpp.Concurrency
18-
import semmle.code.cpp.dataflow.TaintTracking
1919
import semmle.code.cpp.dataflow.DataFlow
2020
import semmle.code.cpp.commons.Alloc
2121

22-
fromC11ThreadCreateCalltcc,StackVariablesv,Exprarg,Expracc
22+
fromC11ThreadCreateCalltcc,Exprarg
2323
where
2424
notisExcluded(tcc, Concurrency4Package::appropriateThreadObjectStorageDurationsQuery())and
2525
tcc.getArgument(2)=argand
26-
sv.getAnAccess()=accand
27-
// a stack variable that is given as an argument to a thread
28-
TaintTracking::localTaint(DataFlow::exprNode(acc), DataFlow::exprNode(arg))and
29-
// or isn't one of the allowed usage patterns
30-
notexists(Exprmfc|
31-
isAllocationExpr(mfc)and
32-
sv.getAnAssignedValue()=mfcand
33-
acc.getAPredecessor*()=mfc
34-
)and
35-
notexists(TSSGetFunctionCalltsg,TSSSetFunctionCalltss, DataFlow::Nodesrc|
36-
sv.getAnAssignedValue()=tsgand
37-
acc.getAPredecessor*()=tsgand
38-
// there should be dataflow from somewhere (the same somewhere)
39-
// into each of the first arguments
40-
DataFlow::localFlow(src, DataFlow::exprNode(tsg.getArgument(0)))and
41-
DataFlow::localFlow(src, DataFlow::exprNode(tss.getArgument(0)))
26+
(
27+
exists(ObjectIdentityobj,Expracc|
28+
obj.getASubobjectAccess()=accand
29+
obj.getStorageDuration().isAutomatic()and
30+
exists(DataFlow::NodeaddrNode|
31+
(
32+
addrNode= DataFlow::exprNode(any(AddressOfExpre|e.getOperand()=acc))
33+
or
34+
addrNode= DataFlow::exprNode(acc)and
35+
exists(ArrayToPointerConversionc|c.getExpr()=acc)
36+
)and
37+
TaintTracking::localTaint(addrNode, DataFlow::exprNode(arg))
38+
)
39+
)
40+
or
41+
// TODO: This case is handling threadlocals in a useful way that's not intended to be covered
42+
// by the rule. See issue #801. The actual rule should expect no tss_t objects is used, and
43+
// this check that this is initialized doesn't seem to belong here. However, it is a useful
44+
// check in and of itself, so we should figure out if this is part of an optional rule we
45+
// haven't yet implemented and move this behavior there.
46+
exists(TSSGetFunctionCalltsg|
47+
TaintTracking::localTaint(DataFlow::exprNode(tsg), DataFlow::exprNode(arg))and
48+
notexists(TSSSetFunctionCalltss, DataFlow::Nodesrc|
49+
// there should be dataflow from somewhere (the same somewhere)
50+
// into each of the first arguments
51+
DataFlow::localFlow(src, DataFlow::exprNode(tsg.getArgument(0)))and
52+
DataFlow::localFlow(src, DataFlow::exprNode(tss.getArgument(0)))
53+
)
54+
)
4255
)
4356
selecttcc,"$@ not declared with appropriate storage duration",arg,"Shared object"

‎c/cert/src/rules/CON34-C/ThreadObjectStorageDurationsNotInitialized.ql‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import cpp
1717
import codingstandards.c.cert
1818
import codingstandards.cpp.Concurrency
19-
import semmle.code.cpp.dataflow.TaintTracking
2019
import semmle.code.cpp.dataflow.DataFlow
2120

2221
fromTSSGetFunctionCalltsg,ThreadedFunctiontf

‎c/cert/src/rules/CON39-C/ThreadWasPreviouslyJoinedOrDetached.ql‎

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,10 @@
1414

1515
import cpp
1616
import codingstandards.c.cert
17-
import codingstandards.cpp.Concurrency
17+
import codingstandards.cpp.rules.joinordetachthreadonlyonce.JoinOrDetachThreadOnlyOnce
1818

19-
// OK
20-
// 1) Thread calls detach parent DOES NOT call join
21-
// 2) Parent calls join, thread does NOT call detach()
22-
// NOT OK
23-
// 1) Thread calls detach, parent calls join
24-
// 2) Thread calls detach twice, parent does not call join
25-
// 3) Parent calls join twice, thread does not call detach
26-
fromC11ThreadCreateCalltcc
27-
where
28-
notisExcluded(tcc, Concurrency5Package::threadWasPreviouslyJoinedOrDetachedQuery())and
29-
// Note: These cases can be simplified but they are presented like this for clarity
30-
// case 1 - calls to `thrd_join` and `thrd_detach` within the parent or
31-
// within the parent / child CFG.
32-
exists(C11ThreadWaittw,C11ThreadDetachdt|
33-
tw=getAThreadContextAwareSuccessor(tcc)and
34-
dt=getAThreadContextAwareSuccessor(tcc)
35-
)
36-
or
37-
// case 2 - multiple calls to `thrd_detach` within the threaded CFG.
38-
exists(C11ThreadDetachdt1,C11ThreadDetachdt2|
39-
dt1=getAThreadContextAwareSuccessor(tcc)and
40-
dt2=getAThreadContextAwareSuccessor(tcc)and
41-
notdt1=dt2
42-
)
43-
or
44-
// case 3 - multiple calls to `thrd_join` within the threaded CFG.
45-
exists(C11ThreadWaittw1,C11ThreadWaittw2|
46-
tw1=getAThreadContextAwareSuccessor(tcc)and
47-
tw2=getAThreadContextAwareSuccessor(tcc)and
48-
nottw1=tw2
49-
)
50-
selecttcc,"Thread may call join or detach after the thread is joined or detached."
19+
classThreadWasPreviouslyJoinedOrDetachedQueryextendsJoinOrDetachThreadOnlyOnceSharedQuery{
20+
ThreadWasPreviouslyJoinedOrDetachedQuery(){
21+
this= Concurrency5Package::threadWasPreviouslyJoinedOrDetachedQuery()
22+
}
23+
}

‎c/cert/src/rules/DCL30-C/AppropriateStorageDurationsFunctionReturn.ql‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@
1313

1414
import cpp
1515
import codingstandards.c.cert
16+
import codingstandards.c.Objects
1617
import semmle.code.cpp.dataflow.DataFlow
1718

18-
classSourceextendsStackVariable{
19-
Source(){notthisinstanceofParameter}
19+
classSourceextendsExpr{
20+
ObjectIdentityrootObject;
21+
22+
Source(){
23+
rootObject.getStorageDuration().isAutomatic()and
24+
this=rootObject.getASubobjectAddressExpr()
25+
}
2026
}
2127

2228
classSinkextends DataFlow::Node{
@@ -40,7 +46,7 @@ from DataFlow::Node src, DataFlow::Node sink
4046
where
4147
notisExcluded(sink.asExpr(),
4248
Declarations8Package::appropriateStorageDurationsFunctionReturnQuery())and
43-
exists(Sources|src.asExpr()=s.getAnAccess())and
49+
exists(Sources|src.asExpr()=s)and
4450
sinkinstanceofSinkand
4551
DataFlow::localFlow(src,sink)
4652
selectsink,"$@ with automatic storage may be accessible outside of its lifetime.",src,

‎c/cert/src/rules/ERR30-C/ErrnoReadBeforeReturn.ql‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import cpp
1515
import codingstandards.c.cert
1616
import codingstandards.c.Errno
17+
import semmle.code.cpp.dataflow.DataFlow
1718

1819
/**
1920
* A call to an `OutOfBandErrnoSettingFunction`

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp