Releases: github/codeql-coding-standards
Releases · github/codeql-coding-standards
v2.55.0
Release summary
- New queries added for the following rule packages: Banned1, Classes2, DeadCode11, DeadCode3, DeadCode4, DeadCode5, DeadCode6, DeadCode7, DeadCode8, DeadCode9, Expressions2, Linkage2, Memory2, Memory3, Memory4, Memory5, Memory6, Naming2, Preprocessor, Preprocessor2, SideEffects4, SideEffects5, Toolchain3, Trigraph, Contracts7, Representation
- The following changes have been made for this release:
- All queries related to integer suffixes:
- No visible changes expected: the regex for parsing integer suffixes, and how they are treated after lexing, has been refactored.
RULE-18-9-ArraytoPointerConversionOfTemporaryObject.ql- The behavior for finding flow steps of temporary objects (for example, from ternary branches to the ternary expr result) has been extracted for reuse in other rules, no visible changes expected.
- "Function-like macros"
- The parameter list of variadic macros previously included the ellipsis in name of the final parameter, potentially leading to incorrect analysis. This has been corrected.
- The parameter list of function-like macros with no parameters (i.e.
MACRO()) was interpreted in a shared library as having a single parameter with an empty name. This does not seem to have had an impact on any existing queries, but has been fixed to correctly show no parameters.
M0-1-1,RULE-2-1-UnreachableCode.ql:- Updated detection of compiler generated code to include "handler" blocks, part of EDG's IR.
- "handler" blocks generated for
catch(...)blocks are not excluded for technical reasons related to how the CFG is constructed.
M15-3-6,ERR54-CPP-CatchBlockShadowingMisra.ql,CatchBlockShadowingCert.ql:- Altered semantics to detect shadowing for a catch block involving type
Tpreceding another catch block involving the same typeT, such ascatch(T&)shadowingcatch(T)and vice versa. Previously, the involved types had to have a subtype relationship. - Refactored catch block shadowing into a shared library for use in
RULE-0-0-1.
- Altered semantics to detect shadowing for a catch block involving type
- All queries related to integer suffixes:
M0-1-2-InfeasiblePath.ql:- Refactored to share logic with
RULE-0-0-2while allowing for different exceptional cases. No change in behavior expected.
- Refactored to share logic with
A3-1-1-ViolationsOfOneDefinitionRule.ql:- The query previously would incorrectly allow cases where something was defined with
externand did not use the defined external linkage library to find external linkage. This change may result in the query finding more results. Additionally a typo has been fixed in the alert message which will cause the old alerts for this query to now show up as new ones.
- The query previously would incorrectly allow cases where something was defined with
RULE-6-0-2,A3-1-4-ExternalLinkageArrayWithoutExplicitSizeMisra.ql,ExternalLinkageArrayWithoutExplicitSizeAutosar.ql:- The queries listed now find flexible member arrays in structs, as those do not have an explicit size.
A-23-0-1,A-23-0-2,CTR-51-CPP,CTR-52-CPP,CTR-53-CPP,CTR-54-CPP,CTR-55-CPP,STR-52-CPP-IteratorImplicitlyConvertedToConstIterator.ql,ValidContainerElementAccess.ql,UsesValidContainerElementAccess.ql,GuaranteeGenericCppLibraryFunctionsDoNotOverflow.ql,UseValidIteratorRanges.ql,DoNotSubtractIteratorsForDifferentContainers.ql,DoNotUseAnAdditiveOperatorOnAnIterator.ql,UseValidReferencesForElementsOfString.ql:- Iterator access methods
rbegin,rend,crbegin,crendare now recognized on containers. - Shared library
Iterators.qllhas been refactored by splitting out container type logic into a separate library and add logic to differentiate types of containers, such as associative, indexed, and strings. - Shared library
Iterators.qll, used by many queries, has been moved.
- Iterator access methods
M0-2-1,RULE-19-1,RULE-8-18-1-ObjectAssignedToAnOverlappingObject.ql,ObjectCopiedToAnOverlappingObject:- The query predicate
problemforObjectCopiedToAnOverlappingObjectis now shared acrossRULE-19-1andRULE-8-18-1. Also, the query predicate forObjectAssignedToAnOverlappingObjectis now shared across all of the three rules. - Due to the refactor, the queries listed may now emit slightly different results though it is highly unlikely.
- The query predicate
A0-1-2-UnusedReturnValue.ql:- Refactors the rule implementation into a shared library for usage in MISRA C++ ruleset. No externally visible changes expected.
- All rules using
Linkage.qll:extern constglobal variables are now properly analyzed as having external linkage, rather than internal linkage.- Linkage analysis has been fixed to properly handle nested classes, including anonymous and typedefs of anonymous classes.
- Linkage for names within classes with internal linkage is now properly inherited as internal, rather than external.
M0-1-3,RULE-2-8-UnusedLocalVariable.ql,UnusedMemberVariable.ql,UnusedGlobalOrNamespaceVariable.ql,UnusedObjectDefinition.ql,UnusedObjectDefinitionStrict.ql:- The organization of unused variable analysis has been reorganized to be usable in MISRA C++ rule 0.2.1, with no expected noticeable change in results.
A0-1-4,RULE-2-7-UnusedParameter.ql:- Refactored to be able to share most logic between MISRA C, MISRA C++, and AUTOSAR. No visible change in behavior expected.
RULE-2-3,A0-1-6-UnusedTypeDeclarations.ql:- Type usage analysis has been improved to find more possible type usages, including:
- Previous behavior considered anonymous types in variable declarations to be considered used by the variable definition itself. This has been improved to require that a field of the anonymous type is accessed for the type to be considered used.
- Usages of a template type inside a specialization of that template are no longer considered usages of the template type.
- Hidden friend declarations are no longer considered usages of the class they are declaring friendship for.
- Improved exclusions generally, for cases such as nested types and functions within functions. These previously were a source of incorrectly identified type uses.
- Additional case added to detect
template <Enum = Enum::Value>as a usage ofEnum, without an explicittpl<Enum::Value>usage.
- Type usage analysis has been improved to find more possible type usages, including:
M5-14-1-RightHandOperandOfALogicalAndOperatorsContainSideEffects.ql:- Implementation has been refactored to share logic with Rule 8.14.1. No observable changes to results expected.
A3-3-2-StaticOrThreadLocalObjectsNonConstantInit:- The checks for non-constant initialization have been moved to be usable in other queries, such as MISRA C++23 Rule 6.7.2.
- No visible changes in query results expected.
A5-0-1,EXP50-CPP-ExpressionShouldNotRelyONOrderOfEvaluation.ql,DoNotDependOnTheOrderOfScalarObjectEvaluationForSideEffects.ql:- Fixed a bug where some sequenced operations were not detected as such due to an error in the "candidate selection" process. This could have complex effects on results, but should mostly fix false positives. Some unsequenced operations that previously reported one alert may now report two, due to the extra candidates being considered.
- Sequencing between full expressions no longer requires that the expressions are sequential; expressions in separate if statements, for instance, are not necessarily sequential, but they are still ordered. It is unclear if this change will have any effect on results, but it should be more accurate to the standard.
RULE-13-2,A5-0-1,EXP50-CPP,EXP30-C-UnsequencedSideEffects.ql,UnsequencedAtomicReads.ql,ExpressionShouldNotRelyONOrderOfEvaluation.ql,DoNotDependOnTheOrderOfScalarObjectEvaluationForSideEffects.ql,DependenceOnOrderOfScalarEvaluationForSideEffects.ql:- Implementation of ordering has been refactored to share more code across specifications (C11-C17, C++14, and C++17 sequencing rules). No change in results is expected from this refactor.
Supported versions
- The LGTM pack is not supported on any released version of LGTM without support from GitHub Professional Services.
- The Code Scanning pack is supported when:
- Using the CodeQL CLI version
2.21.4in conjunction with a copy of the CodeQL standard library for C++ (github/codeql) set to the tagcodeql-cli/v2.21.4. - Using the CodeQL Action or CodeQL runner with the codeql-bundle-v2.21.4.
- Using the CodeQL CLI version
Appendix: AUTOSAR new queries
New queries added to cover the following rules:
- M0-2-1 -
ObjectAssignedToAnOverlappingObjectAutosarCpp.ql
Appendix: MISRA-C-2012 new queries
New queries added to cover the following rules:
- RULE-19-1 -
ObjectCopiedToAnOverlappingObjectMisraC.ql,ObjectAssignedToAnOverlappingObjectMisraC.ql
Appendix: MISRA-C++-2023 new queries
New queries added to cover the following rules:
- RULE-0-0-1 -
UnreachableStatement.ql - RULE-0-0-2 -
InvariantCondition.ql - RULE-0-1-1 -
UnnecessaryWriteToLocalObject.ql - RULE-0-1-2 -
UnusedReturnValueMisraCpp.ql - RULE-0-2-1 -
UnusedLimitedVisibilityVariable.ql - RULE-0-2-2 -
UnusedParameterMisraCpp.ql - RULE-0-2-3 -
UnusedTypeWithLimitedVisibility.ql - RULE-4-1-2 -
RedeclarationOfStaticConstexprDataMember.ql,ImplicitDeclarationOfCopyConstructor.ql,ImplicitDeclarationOfCopyConstructorAudit.ql,NoexceptSpecifierThrow.ql,UseOfDeprecatedCHeaders.ql,UseOfDeprecatedStrStreamClass.ql,UseOfUncaughtException.ql,UseOfDeprecatedFunctionBinderTypedefMember.ql,UseOfDeprecatedUnaryOrBinaryNegate.ql,UseOfDeprecatedAllocatorVoid.ql,UseOfDeprecatedStdAllocatorMember.ql,UseOfDeprecatedRawStorageIterator.ql,UseOfDeprecatedTemporaryBuffers.ql,UseOfDeprecatedIsLiteralTypeTraits.ql,UseOfDeprecatedStdIteratorBaseClass.ql,UseOfDeprecatedSharedPtrUnique.ql - RULE-4-6-1 -
MemoryUsageNotSequenced.ql - RULE-5-0-1 - `Trigr...
v2.54.0
Release summary
- New queries added for the following rule packages: Linkage1, Scope
- The following changes have been made for this release:
A3-1-4-ExternalLinkageArrayWithoutExplicitSizeAutosar.ql:ExternalLinkageArrayWithoutExplicitSize.qlhas been renamed toExternalLinkageArrayWithoutExplicitSizeAutosar.qlto reflect shared query implementation. Additionally the query previously only detected explicit uses ofexternto determine external linkage, and now would catch other cases that are possible where it is external linkage and an array is declared without an explicit size.
Supported versions
- The LGTM pack is not supported on any released version of LGTM without support from GitHub Professional Services.
- The Code Scanning pack is supported when:
- Using the CodeQL CLI version
2.21.4in conjunction with a copy of the CodeQL standard library for C++ (github/codeql) set to the tagcodeql-cli/v2.21.4. - Using the CodeQL Action or CodeQL runner with the codeql-bundle-v2.21.4.
- Using the CodeQL CLI version
Appendix: AUTOSAR new queries
New queries added to cover the following rules:
- A3-1-4 -
ExternalLinkageArrayWithoutExplicitSizeAutosar.ql
Appendix: MISRA-C++-2023 new queries
New queries added to cover the following rules:
- RULE-6-0-2 -
ExternalLinkageArrayWithoutExplicitSizeMisra.ql - RULE-6-5-1 -
ExternalLinkageNotDeclaredInHeaderFileMisra.ql
v2.53.0
Release summary
- New queries added for the following rule packages: Exceptions3, Preconditions4
Supported versions
- The LGTM pack is not supported on any released version of LGTM without support from GitHub Professional Services.
- The Code Scanning pack is supported when:
- Using the CodeQL CLI version
2.20.7in conjunction with a copy of the CodeQL standard library for C++ (github/codeql) set to the tagcodeql-cli/v2.20.7. - Using the CodeQL Action or CodeQL runner with the codeql-bundle-v2.20.7.
- Using the CodeQL CLI version
Appendix: MISRA-C++-2023 new queries
New queries added to cover the following rules:
- RULE-18-3-1 -
MissingCatchAllExceptionHandlerInMain.ql - RULE-18-3-2 -
ClassExceptionCaughtByValue.ql - RULE-18-4-1 -
ExceptionUnfriendlyFunctionMustBeNoexcept.ql - RULE-22-4-1 -
InvalidAssignmentToErrno.ql
v2.52.0
Release summary
- New queries added for the following rule packages: Preconditions1, Statements
- The following changes have been made for this release:
CON51-CPP-EnsureActivelyHeldLocksAreReleasedOnExceptionalConditions.ql:- Exclude RAII-style locks from query results, as they cannot be leaked, and are recommended to avoid alerts in this rule.
M0-1-3-UnusedLocalVariable.ql:- Improved performance of the unused local variable analysis by moving constant expression value extraction to a separate pass, eliminating certain expensive joins.
Supported versions
- The LGTM pack is not supported on any released version of LGTM without support from GitHub Professional Services.
- The Code Scanning pack is supported when:
- Using the CodeQL CLI version
2.20.7in conjunction with a copy of the CodeQL standard library for C++ (github/codeql) set to the tagcodeql-cli/v2.20.7. - Using the CodeQL Action or CodeQL runner with the codeql-bundle-v2.20.7.
- Using the CodeQL CLI version
Appendix: MISRA-C++-2023 new queries
New queries added to cover the following rules:
- RULE-8-2-9 -
PolymorphicClassTypeExpressionInTypeid.ql - RULE-9-4-2 -
AppropriateStructureOfSwitchStatement.ql - RULE-9-5-1 -
LegacyForStatementsShouldBeSimple.ql - RULE-9-5-2 -
ForRangeInitializerAtMostOneFunctionCall.ql
v2.51.0
Release summary
- New queries added for the following rule packages: Conversions2
- The following changes have been made for this release:
M5-2-2-PointerToAVirtualBaseClassCastToAPointer.ql:- Report casts where the from or to types are typedefs to virtual base classes or derived classes.
- Report casts to a reference type which is a derived type.
- Report casts where the base class is the parent of a virtual base class.
- The alert message has been updated to refer to the virtual base class derivation.
RULE-1-2,RULE-23-3,RULE-23-5,RULE-23-6:- Results that occur in nested macro invocations are now reported in the macro that defines the contravening code, rather than the macro which is first expanded.
- Results the occur in arguments to macro invocations are now reported in at the macro invocation site, instead of the macro definition site.
Supported versions
- The LGTM pack is not supported on any released version of LGTM without support from GitHub Professional Services.
- The Code Scanning pack is supported when:
- Using the CodeQL CLI version
2.20.7in conjunction with a copy of the CodeQL standard library for C++ (github/codeql) set to the tagcodeql-cli/v2.20.7. - Using the CodeQL Action or CodeQL runner with the codeql-bundle-v2.20.7.
- Using the CodeQL CLI version
Appendix: MISRA-C++-2023 new queries
New queries added to cover the following rules:
- RULE-8-2-1 -
VirtualBaseClassCastToDerived.ql - RULE-8-2-2 -
NoCStyleOrFunctionalCasts.ql - RULE-8-2-6 -
IntToPointerCastProhibited.ql - RULE-8-2-7 -
NoPointerToIntegralCast.ql - RULE-8-2-8 -
PointerToIntegralCast.ql - RULE-9-2-1 -
NoStandaloneTypeCastExpression.ql
v2.50.0
Release summary
- New queries added for the following rule packages: BannedAPIs, Conversions
- The following changes have been made for this release:
A3-9-1-VariableWidthIntegerTypesUsed.ql:- This query now reports the use of non-fixed width integer types in function return types, with the exception of
chartypes and formainfunctions.
- This query now reports the use of non-fixed width integer types in function return types, with the exception of
ENV34-C,RULE-21-20,RULE-25-5-3:DoNotStorePointersReturnedByEnvFunctions.ql,CallToSetlocaleInvalidatesOldPointers.ql,CallToSetlocaleInvalidatesOldPointersMisra.ql- Fixed a misspelling of "subsequent" in the alert message.
Supported versions
- The LGTM pack is not supported on any released version of LGTM without support from GitHub Professional Services.
- The Code Scanning pack is supported when:
- Using the CodeQL CLI version
2.20.7in conjunction with a copy of the CodeQL standard library for C++ (github/codeql) set to the tagcodeql-cli/v2.20.7. - Using the CodeQL Action or CodeQL runner with the codeql-bundle-v2.20.7.
- Using the CodeQL CLI version
Appendix: MISRA-C++-2023 new queries
New queries added to cover the following rules:
- RULE-6-9-2 -
AvoidStandardIntegerTypeNames.ql - RULE-7-0-1 -
NoConversionFromBool.ql - RULE-7-0-2 -
NoImplicitBoolConversion.ql - RULE-7-0-3 -
NoCharacterNumericalValue.ql - RULE-7-0-4 -
InappropriateBitwiseOrShiftOperands.ql - RULE-7-0-5 -
NoSignednessChangeFromPromotion.ql - RULE-7-0-6 -
NumericAssignmentTypeMismatch.ql - RULE-7-11-3 -
FunctionPointerConversionContext.ql - RULE-18-5-2 -
AvoidProgramTerminatingFunctions.ql - RULE-21-2-2 -
UnsafeStringHandlingFunctions.ql - RULE-21-2-3 -
BannedSystemFunction.ql - RULE-21-10-1 -
NoVariadicFunctionMacros.ql - RULE-21-10-2 -
NoCsetjmpHeader.ql - RULE-23-11-1 -
UseSmartPtrFactoryFunctions.ql - RULE-24-5-1 -
CharacterHandlingFunctionRestrictions.ql - RULE-24-5-2 -
NoMemoryFunctionsFromCString.ql - RULE-25-5-1 -
LocaleGlobalFunctionNotAllowed.ql
v2.49.0
Release summary
- New queries added for the following rule packages: Expressions2
- The following changes have been made for this release:
DCL40-C,RULE-8-4:IncompatibleFunctionDeclarations.ql,CompatibleDeclarationFunctionDefined.ql.- Fixed performance issues introduced when upgrading to CodeQL
2.20.7by removing unnecessary check that matching function declarations have matching names.
- Fixed performance issues introduced when upgrading to CodeQL
RULE-7-5:IncorrectlySizedIntegerConstantMacroArgument.ql.- Added a
bindingsetto improve performance when checking if a literal matches the size of an integer constant macro.
- Added a
Supported versions
- The LGTM pack is not supported on any released version of LGTM without support from GitHub Professional Services.
- The Code Scanning pack is supported when:
- Using the CodeQL CLI version
2.20.7in conjunction with a copy of the CodeQL standard library for C++ (github/codeql) set to the tagcodeql-cli/v2.20.7. - Using the CodeQL Action or CodeQL runner with the codeql-bundle-v2.20.7.
- Using the CodeQL CLI version
Appendix: CERT-C new queries
New queries added to cover the following rules:
- EXP16-C -
DoNotCompareFunctionPointersToConstantValues.ql
v2.48.0
Release summary
- No new queries were added for this release
- The following changes have been made for this release:
SIG30-C:CallOnlyAsyncSafeFunctionsWithinSignalHandlers.ql- Fixed a misspelling of "asynchronous" in the alert message.
Supported versions
- The LGTM pack is not supported on any released version of LGTM without support from GitHub Professional Services.
- The Code Scanning pack is supported when:
- Using the CodeQL CLI version
2.19.4in conjunction with a copy of the CodeQL standard library for C++ (github/codeql) set to the tagcodeql-cli/v2.19.4. - Using the CodeQL Action or CodeQL runner with the codeql-bundle-v2.19.4.
- Using the CodeQL CLI version
v2.47.0
Release summary
- No new queries were added for this release
- The following changes have been made for this release:
FIO39-C,FIO50-CPP,A27-0-3,RULE-30-0-2:IOFstreamMissingPositioning.ql,InterleavedInputOutputWithoutPosition.ql,InterleavedInputOutputWithoutFlush.ql,ReadsAndWritesOnStreamNotSeparatedByPositioning.ql.- Improved performance for codebases with large numbers of stream or file accesses.
Supported versions
- The LGTM pack is not supported on any released version of LGTM without support from GitHub Professional Services.
- The Code Scanning pack is supported when:
- Using the CodeQL CLI version
2.19.4in conjunction with a copy of the CodeQL standard library for C++ (github/codeql) set to the tagcodeql-cli/v2.19.4. - Using the CodeQL Action or CodeQL runner with the codeql-bundle-v2.19.4.
- Using the CodeQL CLI version
v2.46.0
Release summary
- No new queries were added for this release
Supported versions
- The LGTM pack is not supported on any released version of LGTM without support from GitHub Professional Services.
- The Code Scanning pack is supported when:
- Using the CodeQL CLI version
2.19.4in conjunction with a copy of the CodeQL standard library for C++ (github/codeql) set to the tagcodeql-cli/v2.19.4. - Using the CodeQL Action or CodeQL runner with the codeql-bundle-v2.19.4.
- Using the CodeQL CLI version