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

Appearance settings

Commit f9a503b

Browse filesBrowse files
authored
Merge branch 'main' into knewbury01/fix-381
2 parents 644d0ff + eb04437 commit f9a503b
Copy full SHA for f9a503b
Expand file treeCollapse file tree

35 files changed

+145
-108
lines changed

‎.github/workflows/bump-version.yml

Copy file name to clipboardExpand all lines: .github/workflows/bump-version.yml
-33Lines changed: 0 additions & 33 deletions
This file was deleted.

‎.github/workflows/finalize-release.yml

Copy file name to clipboardExpand all lines: .github/workflows/finalize-release.yml
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,21 @@ jobs:
9999
next_version=$(python scripts/release/next-version.py --component minor --pre-release dev -- $version)
100100
echo "NEXT_VERSION=$next_version" >> "$GITHUB_ENV"
101101
working-directory: tooling
102+
103+
- name: Generate token
104+
if: env.HOTFIX_RELEASE == 'false'
105+
id: generate-token
106+
uses: actions/create-github-app-token@eaddb9eb7e4226c68cf4b39f167c83e5bd132b3e
107+
with:
108+
app-id: ${{ vars.AUTOMATION_APP_ID }}
109+
private-key: ${{ secrets.AUTOMATION_PRIVATE_KEY }}
110+
owner: ${{ github.repository_owner }}
111+
repositories: "codeql-coding-standards"
102112

103113
- name: Bump main version
114+
if: env.HOTFIX_RELEASE == 'false'
104115
env:
105-
GH_TOKEN: ${{ github.token }}
116+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
106117
run: |
107118
echo "Bumping main version to $NEXT_VERSION"
108119

‎c/cert/src/qlpack.yml

Copy file name to clipboardExpand all lines: c/cert/src/qlpack.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cert-c-coding-standards
2-
version: 2.25.0-dev
2+
version: 2.28.0-dev
33
description: CERT C 2016
44
suites: codeql-suites
55
license: MIT

‎c/cert/test/qlpack.yml

Copy file name to clipboardExpand all lines: c/cert/test/qlpack.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cert-c-coding-standards-tests
2-
version: 2.25.0-dev
2+
version: 2.28.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

‎c/common/src/qlpack.yml

Copy file name to clipboardExpand all lines: c/common/src/qlpack.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/common-c-coding-standards
2-
version: 2.25.0-dev
2+
version: 2.28.0-dev
33
license: MIT
44
dependencies:
55
codeql/common-cpp-coding-standards: '*'

‎c/common/test/qlpack.yml

Copy file name to clipboardExpand all lines: c/common/test/qlpack.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/common-c-coding-standards-tests
2-
version: 2.25.0-dev
2+
version: 2.28.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

‎c/misra/src/qlpack.yml

Copy file name to clipboardExpand all lines: c/misra/src/qlpack.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/misra-c-coding-standards
2-
version: 2.25.0-dev
2+
version: 2.28.0-dev
33
description: MISRA C 2012
44
suites: codeql-suites
55
license: MIT

‎c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql

Copy file name to clipboardExpand all lines: c/misra/src/rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql
+19-8Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,33 @@
1212

1313
import cpp
1414
import codingstandards.c.misra
15+
import codingstandards.cpp.Compiler
1516

16-
predicate isAppropriatePrimitive(Type type) {
17-
/* An appropriate primitive types to which a bit-field can be declared. */
18-
type instanceof IntType and
17+
Type getSupportedBitFieldType(Compiler compiler) {
18+
compiler instanceof UnsupportedCompiler and
1919
(
20-
type.(IntegralType).isExplicitlySigned() or
21-
type.(IntegralType).isExplicitlyUnsigned()
20+
result instanceof IntType and
21+
(
22+
result.(IntegralType).isExplicitlySigned() or
23+
result.(IntegralType).isExplicitlyUnsigned()
24+
)
25+
or
26+
result instanceof BoolType
2227
)
2328
or
24-
type instanceof BoolType
29+
(compiler instanceof Gcc or compiler instanceof Clang) and
30+
(
31+
result instanceof IntegralOrEnumType
32+
or
33+
result instanceof BoolType
34+
)
2535
}
2636

2737
from BitField bitField
2838
where
2939
not isExcluded(bitField,
3040
BitfieldTypesPackage::bitFieldsShallOnlyBeDeclaredWithAnAppropriateTypeQuery()) and
3141
/* A violation would neither be an appropriate primitive type nor an appropriate typedef. */
32-
not isAppropriatePrimitive(bitField.getType().resolveTypedefs())
33-
select bitField, "Bit-field " + bitField + " is declared on type " + bitField.getType() + "."
42+
not getSupportedBitFieldType(getCompiler(bitField.getFile())) =
43+
bitField.getType().resolveTypedefs()
44+
select bitField, "Bit-field '" + bitField + "' is declared on type '" + bitField.getType() + "'."

‎c/misra/test/qlpack.yml

Copy file name to clipboardExpand all lines: c/misra/test/qlpack.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/misra-c-coding-standards-tests
2-
version: 2.25.0-dev
2+
version: 2.28.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| test.c:6:7:6:8 | x1 | Bit-field x1 is declared on type int. |
2-
| test.c:10:15:10:16 | x5 | Bit-field x5 is declared on type signed long. |
3-
| test.c:12:15:12:16 | x6 | Bit-field x6 is declared on type signed char. |
4-
| test.c:14:14:14:15 | x7 | Bit-field x7 is declared on type Color. |
1+
| test.c:6:7:6:8 | x1 | Bit-field 'x1' is declared on type 'int'. |
2+
| test.c:10:15:10:16 | x5 | Bit-field 'x5' is declared on type 'signed long'. |
3+
| test.c:12:15:12:16 | x6 | Bit-field 'x6' is declared on type 'signed char'. |
4+
| test.c:14:14:14:15 | x7 | Bit-field 'x7' is declared on type 'Color'. |

‎c/misra/test/rules/RULE-6-1/clang/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected

Copy file name to clipboardExpand all lines: c/misra/test/rules/RULE-6-1/clang/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected
Whitespace-only changes.
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle-extractor-options:--mimic clang --std=c11 --edg --diag_error=implicit_func_decl -nostdinc -I../../../../common/test/includes/standard-library
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
typedef unsigned int UINT16;
2+
3+
enum Color { R, G, B };
4+
5+
struct SampleStruct {
6+
int x1 : 2; // COMPLIANT
7+
unsigned int x2 : 2; // COMPLIANT - explicitly unsigned
8+
signed int x3 : 2; // COMPLIANT - explicitly signed
9+
UINT16 x4 : 2; // COMPLIANT - type alias resolves to a compliant type
10+
signed long x5 : 2; // COMPLIANT
11+
signed char x6 : 2; // COMPLIANT
12+
enum Color x7 : 3; // COMPLIANT
13+
//_Atomic(int) x8 : 2; // NON_COMPLIANT[COMPILER_CHECKED] - atomic types are
14+
// not permitted for bit-fields.
15+
} sample_struct;

‎c/misra/test/rules/RULE-6-1/gcc/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected

Copy file name to clipboardExpand all lines: c/misra/test/rules/RULE-6-1/gcc/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.expected
Whitespace-only changes.
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rules/RULE-6-1/BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle-extractor-options:--mimic gcc --std=c11 --edg --diag_error=implicit_func_decl -nostdinc -I../../../../common/test/includes/standard-library
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
typedef unsigned int UINT16;
2+
3+
enum Color { R, G, B };
4+
5+
struct SampleStruct {
6+
int x1 : 2; // COMPLIANT
7+
unsigned int x2 : 2; // COMPLIANT - explicitly unsigned
8+
signed int x3 : 2; // COMPLIANT - explicitly signed
9+
UINT16 x4 : 2; // COMPLIANT - type alias resolves to a compliant type
10+
signed long x5 : 2; // COMPLIANT
11+
signed char x6 : 2; // COMPLIANT
12+
enum Color x7 : 3; // COMPLIANT
13+
//_Atomic(int) x8 : 2; // NON_COMPLIANT[COMPILER_CHECKED] - atomic types are
14+
// not permitted for bit-fields.
15+
} sample_struct;

‎c/misra/test/rules/RULE-6-1/options

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle-extractor-options:--no-clang --std=c11 --edg --diag_error=implicit_func_decl -nostdinc -I../../../../common/test/includes/standard-library
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `A13-2-2` - `BinaryOperatorAndBitwiseOperatorReturnAPrvalue.ql`:
2+
- Replaced the usage of getIdentityString() with toString() to avoid expensive computation to display the Operator names which were causing crashes on production code.
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `RULE-6-1` - `BitFieldsShallOnlyBeDeclaredWithAnAppropriateType.ql`:
2+
- Address FP reported in #318. Add support for implementation specific bitfield types for Clang and Gcc.

‎cpp/autosar/src/qlpack.yml

Copy file name to clipboardExpand all lines: cpp/autosar/src/qlpack.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/autosar-cpp-coding-standards
2-
version: 2.25.0-dev
2+
version: 2.28.0-dev
33
description: AUTOSAR C++14 Guidelines R22-11, R21-11, R20-11, R19-11 and R19-03
44
suites: codeql-suites
55
license: MIT

‎cpp/autosar/src/rules/A13-2-2/BinaryOperatorAndBitwiseOperatorReturnAPrvalue.ql

Copy file name to clipboardExpand all lines: cpp/autosar/src/rules/A13-2-2/BinaryOperatorAndBitwiseOperatorReturnAPrvalue.ql
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,4 @@ where
3131
o.getType() instanceof ReferenceType
3232
)
3333
select o,
34-
"User-defined bitwise or arithmetic operator " + getIdentityString(o) +
35-
" does not return a prvalue."
34+
"User-defined bitwise or arithmetic operator " + o.toString() + " does not return a prvalue."

‎cpp/autosar/test/qlpack.yml

Copy file name to clipboardExpand all lines: cpp/autosar/test/qlpack.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/autosar-cpp-coding-standards-tests
2-
version: 2.25.0-dev
2+
version: 2.28.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| test.cpp:16:9:16:17 | operator- | User-defined bitwise or arithmetic operator A const operator-(A const&, int) does not return a prvalue. |
2-
| test.cpp:20:4:20:12 | operator\| | User-defined bitwise or arithmetic operator A* operator\|(A const&, A const&) does not return a prvalue. |
3-
| test.cpp:24:9:24:18 | operator<< | User-defined bitwise or arithmetic operator A const operator<<(A const&, A const&) does not return a prvalue. |
4-
| test.cpp:34:6:34:14 | operator+ | User-defined bitwise or arithmetic operator int& NS_C::operator+(C const&, C const&) does not return a prvalue. |
1+
| test.cpp:16:9:16:17 | operator- | User-defined bitwise or arithmetic operator operator- does not return a prvalue. |
2+
| test.cpp:20:4:20:12 | operator\| | User-defined bitwise or arithmetic operator operator\| does not return a prvalue. |
3+
| test.cpp:24:9:24:18 | operator<< | User-defined bitwise or arithmetic operator operator<< does not return a prvalue. |
4+
| test.cpp:34:6:34:14 | operator+ | User-defined bitwise or arithmetic operator operator+ does not return a prvalue. |

‎cpp/cert/src/qlpack.yml

Copy file name to clipboardExpand all lines: cpp/cert/src/qlpack.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cert-cpp-coding-standards
2-
version: 2.25.0-dev
2+
version: 2.28.0-dev
33
description: CERT C++ 2016
44
suites: codeql-suites
55
license: MIT

‎cpp/cert/test/qlpack.yml

Copy file name to clipboardExpand all lines: cpp/cert/test/qlpack.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cert-cpp-coding-standards-tests
2-
version: 2.25.0-dev
2+
version: 2.28.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:
+39Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/** A module to reason about the compiler used to compile translation units. */
2+
3+
import cpp
4+
import codingstandards.cpp.Scope
5+
6+
newtype Compiler =
7+
Gcc() or
8+
Clang() or
9+
UnsupportedCompiler()
10+
11+
/** Get the match pattern to detect the compiler being mimicked by the extractor to determine the compiler used to compile a file. */
12+
string getMimicMatch(Compiler compiler) {
13+
result = ["%gcc", "%g++"] and compiler instanceof Gcc
14+
or
15+
result = ["%clang", "%clang++"] and compiler instanceof Clang
16+
}
17+
18+
/** Get the compiler used to compile the translation unit the file `f` is part of. */
19+
Compiler getCompiler(File f) {
20+
exists(Compilation compilation, TranslationUnit translationUnit |
21+
compilation.getAFileCompiled() = translationUnit and
22+
(f = translationUnit or f = translationUnit.getAUserFile())
23+
|
24+
if exists(int mimicIndex | compilation.getArgument(mimicIndex) = "--mimic")
25+
then
26+
exists(int mimicIndex |
27+
compilation.getArgument(mimicIndex) = "--mimic" and
28+
(
29+
compilation.getArgument(mimicIndex + 1).matches(getMimicMatch(result))
30+
or
31+
forall(string match | match = getMimicMatch(_) |
32+
not compilation.getArgument(mimicIndex + 1).matches(match)
33+
) and
34+
result = UnsupportedCompiler()
35+
)
36+
)
37+
else result = UnsupportedCompiler()
38+
)
39+
}

‎cpp/common/src/qlpack.yml

Copy file name to clipboardExpand all lines: cpp/common/src/qlpack.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/common-cpp-coding-standards
2-
version: 2.25.0-dev
2+
version: 2.28.0-dev
33
license: MIT
44
dependencies:
55
codeql/cpp-all: 0.9.3

‎cpp/common/test/qlpack.yml

Copy file name to clipboardExpand all lines: cpp/common/test/qlpack.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/common-cpp-coding-standards-tests
2-
version: 2.25.0-dev
2+
version: 2.28.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

‎cpp/misra/src/qlpack.yml

Copy file name to clipboardExpand all lines: cpp/misra/src/qlpack.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/misra-cpp-coding-standards
2-
version: 2.25.0-dev
2+
version: 2.28.0-dev
33
description: MISRA C++ 2008
44
suites: codeql-suites
55
license: MIT

‎cpp/misra/test/qlpack.yml

Copy file name to clipboardExpand all lines: cpp/misra/test/qlpack.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/misra-cpp-coding-standards-tests
2-
version: 2.25.0-dev
2+
version: 2.28.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

‎cpp/report/src/qlpack.yml

Copy file name to clipboard
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/report-cpp-coding-standards
2-
version: 2.25.0-dev
2+
version: 2.28.0-dev
33
license: MIT
44
dependencies:
55
codeql/cpp-all: 0.9.3

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.