diff --git a/analyzer/codechecker_analyzer/analyzer_context.py b/analyzer/codechecker_analyzer/analyzer_context.py index 16babf7b89..3d3f8593df 100644 --- a/analyzer/codechecker_analyzer/analyzer_context.py +++ b/analyzer/codechecker_analyzer/analyzer_context.py @@ -19,6 +19,7 @@ from codechecker_analyzer.arg import analyzer_binary from codechecker_common import logger from codechecker_common.checker_labels import CheckerLabels +from codechecker_common.guidelines import Guidelines from codechecker_common.singleton import Singleton from codechecker_common.util import load_json from pathlib import Path @@ -52,6 +53,9 @@ def __init__(self): if 'CC_TEST_LABELS_DIR' in os.environ: labels_dir = os.environ['CC_TEST_LABELS_DIR'] + guidelines_dir = os.path.join(self._data_files_dir_path, + 'config', 'guidelines') + cfg_dict = self.__get_package_config() self.env_vars = cfg_dict['environment_variables'] @@ -59,6 +63,7 @@ def __init__(self): self.pckg_layout = lcfg_dict['runtime'] self._checker_labels = CheckerLabels(labels_dir) + self._guidelines = Guidelines(guidelines_dir) self.__package_version = None self.__package_build_date = None self.__package_git_hash = None @@ -370,6 +375,10 @@ def checker_plugin(self): def checker_labels(self): return self._checker_labels + @property + def guideline(self): + return self._guidelines + def get_context(): try: diff --git a/codechecker_common/guidelines.py b/codechecker_common/guidelines.py new file mode 100644 index 0000000000..d8b01ba45c --- /dev/null +++ b/codechecker_common/guidelines.py @@ -0,0 +1,79 @@ +# ------------------------------------------------------------------------- +# +# Part of the CodeChecker project, under the Apache License v2.0 with +# LLVM Exceptions. See LICENSE for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +# ------------------------------------------------------------------------- +import os +from typing import DefaultDict, Dict, Iterable, List +from collections import defaultdict + +import yaml + + +class Guidelines: + def __init__(self, guidelines_dir: str): + if not os.path.isdir(guidelines_dir): + raise NotADirectoryError( + f'{guidelines_dir} is not a directory.') + + guideline_yaml_files = map( + lambda f: os.path.join(guidelines_dir, f), + os.listdir(guidelines_dir)) + + self.__all_rules = self.__union_guideline_files(guideline_yaml_files) + + def __union_guideline_files( + self, + guideline_files: Iterable[str] + ) -> DefaultDict[str, List[Dict[str, str]]]: + """ + This function creates a union object of the given guideline files. The + resulting object maps guidelines to the collection of their rules. + E.g.: + { + "guideline1": [ + { + "rule_id": ... + "rule_url": ... + "title": ... + }, + { + ... + } + ], + "guideline2": [ + ... + ], + } + """ + all_rules = defaultdict(list) + + for guideline_file in guideline_files: + with open(guideline_file, "r", encoding="utf-8") as gf: + guideline_data = yaml.safe_load(gf) + + guideline_name = guideline_data.get("guideline") + rules = guideline_data.get("rules") + + all_rules[guideline_name].extend(rules) + + return all_rules + + def rules_of_guideline( + self, + guideline_name: str, + ) -> List[Dict[str, str]]: + """ + Return the list of rules of a guideline. + """ + + guideline_rules = self.__all_rules.get(guideline_name) + print("guideline_rules") + print(guideline_rules) + + return guideline_rules + + def all_guideline_rules(self) -> DefaultDict[str, List[Dict[str, str]]]: + return self.__all_rules diff --git a/config/guidelines/sei-cert.yaml b/config/guidelines/sei-cert.yaml new file mode 100644 index 0000000000..c2ebdc7fd5 --- /dev/null +++ b/config/guidelines/sei-cert.yaml @@ -0,0 +1,661 @@ +guideline: sei-cert +rules: +- rule_id: con50-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CON50-CPP.+Do+not+destroy+a+mutex+while+it+is+locked + title: CON50-CPP. Do not destroy a mutex while it is locked +- rule_id: con51-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CON51-CPP.+Ensure+actively+held+locks+are+released+on+exceptional+conditions + title: CON51-CPP. Ensure actively held locks are released on exceptional conditions +- rule_id: con52-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CON52-CPP.+Prevent+data+races+when+accessing+bit-fields+from+multiple+threads + title: CON52-CPP. Prevent data races when accessing bit-fields from multiple threads +- rule_id: con53-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CON53-CPP.+Avoid+deadlock+by+locking+in+a+predefined+order + title: CON53-CPP. Avoid deadlock by locking in a predefined order +- rule_id: con54-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CON54-CPP.+Wrap+functions+that+can+spuriously+wake+up+in+a+loop + title: CON54-CPP. Wrap functions that can spuriously wake up in a loop +- rule_id: con55-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CON55-CPP.+Preserve+thread+safety+and+liveness+when+using+condition+variables + title: CON55-CPP. Preserve thread safety and liveness when using condition variables +- rule_id: con56-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CON56-CPP.+Do+not+speculatively+lock+a+non-recursive+mutex+that+is+already+owned+by+the+calling+thread + title: CON56-CPP. Do not speculatively lock a non-recursive mutex that is already + owned by the calling thread +- rule_id: ctr50-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CTR50-CPP.+Guarantee+that+container+indices+and+iterators+are+within+the+valid+range + title: CTR50-CPP. Guarantee that container indices and iterators are within the + valid range +- rule_id: ctr51-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CTR51-CPP.+Use+valid+references%2C+pointers%2C+and+iterators+to+reference+elements+of+a+container + title: CTR51-CPP. Use valid references, pointers, and iterators to reference elements + of a container +- rule_id: ctr52-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CTR52-CPP.+Guarantee+that+library+functions+do+not+overflow + title: CTR52-CPP. Guarantee that library functions do not overflow +- rule_id: ctr53-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CTR53-CPP.+Use+valid+iterator+ranges + title: CTR53-CPP. Use valid iterator ranges +- rule_id: ctr54-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CTR54-CPP.+Do+not+subtract+iterators+that+do+not+refer+to+the+same+container + title: CTR54-CPP. Do not subtract iterators that do not refer to the same container +- rule_id: ctr55-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CTR55-CPP.+Do+not+use+an+additive+operator+on+an+iterator+if+the+result+would+overflow + title: CTR55-CPP. Do not use an additive operator on an iterator if the result would + overflow +- rule_id: ctr56-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CTR56-CPP.+Do+not+use+pointer+arithmetic+on+polymorphic+objects + title: CTR56-CPP. Do not use pointer arithmetic on polymorphic objects +- rule_id: ctr57-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CTR57-CPP.+Provide+a+valid+ordering+predicate + title: CTR57-CPP. Provide a valid ordering predicate +- rule_id: ctr58-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/CTR58-CPP.+Predicate+function+objects+should+not+be+mutable + title: CTR58-CPP. Predicate function objects should not be mutable +- rule_id: dcl50-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL50-CPP.+Do+not+define+a+C-style+variadic+function + title: DCL50-CPP. Do not define a C-style variadic function +- rule_id: dcl51-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL51-CPP.+Do+not+declare+or+define+a+reserved+identifier + title: DCL51-CPP. Do not declare or define a reserved identifier +- rule_id: dcl52-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL52-CPP.+Never+qualify+a+reference+type+with+const+or+volatile + title: DCL52-CPP. Never qualify a reference type with const or volatile +- rule_id: dcl53-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL53-CPP.+Do+not+write+syntactically+ambiguous+declarations + title: DCL53-CPP. Do not write syntactically ambiguous declarations +- rule_id: dcl54-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL54-CPP.+Overload+allocation+and+deallocation+functions+as+a+pair+in+the+same+scope + title: DCL54-CPP. Overload allocation and deallocation functions as a pair in the + same scope +- rule_id: dcl55-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL55-CPP.+Avoid+information+leakage+when+passing+a+class+object+across+a+trust+boundary + title: DCL55-CPP. Avoid information leakage when passing a class object across a + trust boundary +- rule_id: dcl56-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL56-CPP.+Avoid+cycles+during+initialization+of+static+objects + title: DCL56-CPP. Avoid cycles during initialization of static objects +- rule_id: dcl57-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL57-CPP.+Do+not+let+exceptions+escape+from+destructors+or+deallocation+functions + title: DCL57-CPP. Do not let exceptions escape from destructors or deallocation + functions +- rule_id: dcl58-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL58-CPP.+Do+not+modify+the+standard+namespaces + title: DCL58-CPP. Do not modify the standard namespaces +- rule_id: dcl59-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL59-CPP.+Do+not+define+an+unnamed+namespace+in+a+header+file + title: DCL59-CPP. Do not define an unnamed namespace in a header file +- rule_id: dcl60-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL60-CPP.+Obey+the+one-definition+rule + title: DCL60-CPP. Obey the one-definition rule +- rule_id: err50-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/ERR50-CPP.+Do+not+abruptly+terminate+the+program + title: ERR50-CPP. Do not abruptly terminate the program +- rule_id: err51-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/ERR51-CPP.+Handle+all+exceptions + title: ERR51-CPP. Handle all exceptions +- rule_id: err52-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=88046492 + title: ERR52-CPP. Do not use setjmp() or longjmp() +- rule_id: err53-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/ERR53-CPP.+Do+not+reference+base+classes+or+class+data+members+in+a+constructor+or+destructor+function-try-block+handler + title: ERR53-CPP. Do not reference base classes or class data members in a constructor + or destructor function-try-block handler +- rule_id: err54-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/ERR54-CPP.+Catch+handlers+should+order+their+parameter+types+from+most+derived+to+least+derived + title: ERR54-CPP. Catch handlers should order their parameter types from most derived + to least derived +- rule_id: err55-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/ERR55-CPP.+Honor+exception+specifications + title: ERR55-CPP. Honor exception specifications +- rule_id: err56-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/ERR56-CPP.+Guarantee+exception+safety + title: ERR56-CPP. Guarantee exception safety +- rule_id: err57-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/ERR57-CPP.+Do+not+leak+resources+when+handling+exceptions + title: ERR57-CPP. Do not leak resources when handling exceptions +- rule_id: err58-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/ERR58-CPP.+Handle+all+exceptions+thrown+before+main%28%29+begins+executing + title: ERR58-CPP. Handle all exceptions thrown before main() begins executing +- rule_id: err59-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/ERR59-CPP.+Do+not+throw+an+exception+across+execution+boundaries + title: ERR59-CPP. Do not throw an exception across execution boundaries +- rule_id: err60-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/ERR60-CPP.+Exception+objects+must+be+nothrow+copy+constructible + title: ERR60-CPP. Exception objects must be nothrow copy constructible +- rule_id: err61-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/ERR61-CPP.+Catch+exceptions+by+lvalue+reference + title: ERR61-CPP. Catch exceptions by lvalue reference +- rule_id: err62-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/ERR62-CPP.+Detect+errors+when+converting+a+string+to+a+number + title: ERR62-CPP. Detect errors when converting a string to a number +- rule_id: exp50-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP50-CPP.+Do+not+depend+on+the+order+of+evaluation+for+side+effects + title: EXP50-CPP. Do not depend on the order of evaluation for side effects +- rule_id: exp51-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP51-CPP.+Do+not+delete+an+array+through+a+pointer+of+the+incorrect+type + title: EXP51-CPP. Do not delete an array through a pointer of the incorrect type +- rule_id: exp52-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP52-CPP.+Do+not+rely+on+side+effects+in+unevaluated+operands + title: EXP52-CPP. Do not rely on side effects in unevaluated operands +- rule_id: exp53-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP53-CPP.+Do+not+read+uninitialized+memory + title: EXP53-CPP. Do not read uninitialized memory +- rule_id: exp54-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP54-CPP.+Do+not+access+an+object+outside+of+its+lifetime + title: EXP54-CPP. Do not access an object outside of its lifetime +- rule_id: exp55-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP55-CPP.+Do+not+access+a+cv-qualified+object+through+a+cv-unqualified+type + title: EXP55-CPP. Do not access a cv-qualified object through a cv-unqualified type +- rule_id: exp56-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP56-CPP.+Do+not+call+a+function+with+a+mismatched+language+linkage + title: EXP56-CPP. Do not call a function with a mismatched language linkage +- rule_id: exp57-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP57-CPP.+Do+not+cast+or+delete+pointers+to+incomplete+classes + title: EXP57-CPP. Do not cast or delete pointers to incomplete classes +- rule_id: exp58-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP58-CPP.+Pass+an+object+of+the+correct+type+to+va_start + title: EXP58-CPP. Pass an object of the correct type to va_start +- rule_id: exp59-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP59-CPP.+Use+offsetof%28%29+on+valid+types+and+members + title: EXP59-CPP. Use offsetof() on valid types and members +- rule_id: exp60-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP60-CPP.+Do+not+pass+a+nonstandard-layout+type+object+across+execution+boundaries + title: EXP60-CPP. Do not pass a nonstandard-layout type object across execution + boundaries +- rule_id: exp61-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP61-CPP.+A+lambda+object+must+not+outlive+any+of+its+reference+captured+objects + title: EXP61-CPP. A lambda object must not outlive any of its reference captured + objects +- rule_id: exp62-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP62-CPP.+Do+not+access+the+bits+of+an+object+representation+that+are+not+part+of+the+object%27s+value+representation + title: EXP62-CPP. Do not access the bits of an object representation that are not + part of the object's value representation +- rule_id: exp63-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP63-CPP.+Do+not+rely+on+the+value+of+a+moved-from+object + title: EXP63-CPP. Do not rely on the value of a moved-from object +- rule_id: fio50-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/FIO50-CPP.+Do+not+alternately+input+and+output+from+a+file+stream+without+an+intervening+positioning+call + title: FIO50-CPP. Do not alternately input and output from a file stream without + an intervening positioning call +- rule_id: fio51-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/FIO51-CPP.+Close+files+when+they+are+no+longer+needed + title: FIO51-CPP. Close files when they are no longer needed +- rule_id: int50-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/INT50-CPP.+Do+not+cast+to+an+out-of-range+enumeration+value + title: INT50-CPP. Do not cast to an out-of-range enumeration value +- rule_id: mem50-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM50-CPP.+Do+not+access+freed+memory + title: MEM50-CPP. Do not access freed memory +- rule_id: mem51-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM51-CPP.+Properly+deallocate+dynamically+allocated+resources + title: MEM51-CPP. Properly deallocate dynamically allocated resources +- rule_id: mem52-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM52-CPP.+Detect+and+handle+memory+allocation+errors + title: MEM52-CPP. Detect and handle memory allocation errors +- rule_id: mem53-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM53-CPP.+Explicitly+construct+and+destruct+objects+when+manually+managing+object+lifetime + title: MEM53-CPP. Explicitly construct and destruct objects when manually managing + object lifetime +- rule_id: mem54-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM54-CPP.+Provide+placement+new+with+properly+aligned+pointers+to+sufficient+storage+capacity + title: MEM54-CPP. Provide placement new with properly aligned pointers to sufficient + storage capacity +- rule_id: mem55-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM55-CPP.+Honor+replacement+dynamic+storage+management+requirements + title: MEM55-CPP. Honor replacement dynamic storage management requirements +- rule_id: mem56-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM56-CPP.+Do+not+store+an+already-owned+pointer+value+in+an+unrelated+smart+pointer + title: MEM56-CPP. Do not store an already-owned pointer value in an unrelated smart + pointer +- rule_id: mem57-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM57-CPP.+Avoid+using+default+operator+new+for+over-aligned+types + title: MEM57-CPP. Avoid using default operator new for over-aligned types +- rule_id: msc50-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/MSC50-CPP.+Do+not+use+std%3A%3Arand%28%29+for+generating+pseudorandom+numbers + title: MSC50-CPP. Do not use std::rand() for generating pseudorandom numbers +- rule_id: msc51-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/MSC51-CPP.+Ensure+your+random+number+generator+is+properly+seeded + title: MSC51-CPP. Ensure your random number generator is properly seeded +- rule_id: msc52-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/MSC52-CPP.+Value-returning+functions+must+return+a+value+from+all+exit+paths + title: MSC52-CPP. Value-returning functions must return a value from all exit paths +- rule_id: msc53-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=88046346 + title: MSC53-CPP. Do not return from a function declared [[noreturn]] +- rule_id: msc54-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/MSC54-CPP.+A+signal+handler+must+be+a+plain+old+function + title: MSC54-CPP. A signal handler must be a plain old function +- rule_id: oop50-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP50-CPP.+Do+not+invoke+virtual+functions+from+constructors+or+destructors + title: OOP50-CPP. Do not invoke virtual functions from constructors or destructors +- rule_id: oop51-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP51-CPP.+Do+not+slice+derived+objects + title: OOP51-CPP. Do not slice derived objects +- rule_id: oop52-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP52-CPP.+Do+not+delete+a+polymorphic+object+without+a+virtual+destructor + title: OOP52-CPP. Do not delete a polymorphic object without a virtual destructor +- rule_id: oop53-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP53-CPP.+Write+constructor+member+initializers+in+the+canonical+order + title: OOP53-CPP. Write constructor member initializers in the canonical order +- rule_id: oop54-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP54-CPP.+Gracefully+handle+self-copy+assignment + title: OOP54-CPP. Gracefully handle self-copy assignment +- rule_id: oop55-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP55-CPP.+Do+not+use+pointer-to-member+operators+to+access+nonexistent+members + title: OOP55-CPP. Do not use pointer-to-member operators to access nonexistent members +- rule_id: oop56-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP56-CPP.+Honor+replacement+handler+requirements + title: OOP56-CPP. Honor replacement handler requirements +- rule_id: oop57-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP57-CPP.+Prefer+special+member+functions+and+overloaded+operators+to+C+Standard+Library+functions + title: OOP57-CPP. Prefer special member functions and overloaded operators to C + Standard Library functions +- rule_id: oop58-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP58-CPP.+Copy+operations+must+not+mutate+the+source+object + title: OOP58-CPP. Copy operations must not mutate the source object +- rule_id: str50-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/STR50-CPP.+Guarantee+that+storage+for+strings+has+sufficient+space+for+character+data+and+the+null+terminator + title: STR50-CPP. Guarantee that storage for strings has sufficient space for character + data and the null terminator +- rule_id: str51-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/STR51-CPP.+Do+not+attempt+to+create+a+std%3A%3Astring+from+a+null+pointer + title: STR51-CPP. Do not attempt to create a std::string from a null pointer +- rule_id: str52-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/STR52-CPP.+Use+valid+references%2C+pointers%2C+and+iterators+to+reference+elements+of+a+basic_string + title: STR52-CPP. Use valid references, pointers, and iterators to reference elements + of a basic_string +- rule_id: str53-cpp + rule_url: https://wiki.sei.cmu.edu/confluence/display/cplusplus/STR53-CPP.+Range+check+element+access + title: STR53-CPP. Range check element access +- rule_id: arr30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/ARR30-C.+Do+not+form+or+use+out-of-bounds+pointers+or+array+subscripts + title: ARR30-C. Do not form or use out-of-bounds pointers or array subscripts +- rule_id: arr32-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/ARR32-C.+Ensure+size+arguments+for+variable+length+arrays+are+in+a+valid+range + title: ARR32-C. Ensure size arguments for variable length arrays are in a valid + range +- rule_id: arr36-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/ARR36-C.+Do+not+subtract+or+compare+two+pointers+that+do+not+refer+to+the+same+array + title: ARR36-C. Do not subtract or compare two pointers that do not refer to the + same array +- rule_id: arr37-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/ARR37-C.+Do+not+add+or+subtract+an+integer+to+a+pointer+to+a+non-array+object + title: ARR37-C. Do not add or subtract an integer to a pointer to a non-array object +- rule_id: arr38-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/ARR38-C.+Guarantee+that+library+functions+do+not+form+invalid+pointers + title: ARR38-C. Guarantee that library functions do not form invalid pointers +- rule_id: arr39-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/ARR39-C.+Do+not+add+or+subtract+a+scaled+integer+to+a+pointer + title: ARR39-C. Do not add or subtract a scaled integer to a pointer +- rule_id: con30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/CON30-C.+Clean+up+thread-specific+storage + title: CON30-C. Clean up thread-specific storage +- rule_id: con31-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/CON31-C.+Do+not+destroy+a+mutex+while+it+is+locked + title: CON31-C. Do not destroy a mutex while it is locked +- rule_id: con32-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/CON32-C.+Prevent+data+races+when+accessing+bit-fields+from+multiple+threads + title: CON32-C. Prevent data races when accessing bit-fields from multiple threads +- rule_id: con33-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/CON33-C.+Avoid+race+conditions+when+using+library+functions + title: CON33-C. Avoid race conditions when using library functions +- rule_id: con34-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/CON34-C.+Declare+objects+shared+between+threads+with+appropriate+storage+durations + title: CON34-C. Declare objects shared between threads with appropriate storage + durations +- rule_id: con35-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/CON35-C.+Avoid+deadlock+by+locking+in+a+predefined+order + title: CON35-C. Avoid deadlock by locking in a predefined order +- rule_id: con36-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/CON36-C.+Wrap+functions+that+can+spuriously+wake+up+in+a+loop + title: CON36-C. Wrap functions that can spuriously wake up in a loop +- rule_id: con37-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/CON37-C.+Do+not+call+signal%28%29+in+a+multithreaded+program + title: CON37-C. Do not call signal() in a multithreaded program +- rule_id: con38-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/CON38-C.+Preserve+thread+safety+and+liveness+when+using+condition+variables + title: CON38-C. Preserve thread safety and liveness when using condition variables +- rule_id: con39-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/CON39-C.+Do+not+join+or+detach+a+thread+that+was+previously+joined+or+detached + title: CON39-C. Do not join or detach a thread that was previously joined or detached +- rule_id: con40-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/CON40-C.+Do+not+refer+to+an+atomic+variable+twice+in+an+expression + title: CON40-C. Do not refer to an atomic variable twice in an expression +- rule_id: con41-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/CON41-C.+Wrap+functions+that+can+fail+spuriously+in+a+loop + title: CON41-C. Wrap functions that can fail spuriously in a loop +- rule_id: con43-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/CON43-C.+Do+not+allow+data+races+in+multithreaded+code + title: CON43-C. Do not allow data races in multithreaded code +- rule_id: dcl30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/DCL30-C.+Declare+objects+with+appropriate+storage+durations + title: DCL30-C. Declare objects with appropriate storage durations +- rule_id: dcl31-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/DCL31-C.+Declare+identifiers+before+using+them + title: DCL31-C. Declare identifiers before using them +- rule_id: dcl36-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/DCL36-C.+Do+not+declare+an+identifier+with+conflicting+linkage+classifications + title: DCL36-C. Do not declare an identifier with conflicting linkage classifications +- rule_id: dcl37-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/DCL37-C.+Do+not+declare+or+define+a+reserved+identifier + title: DCL37-C. Do not declare or define a reserved identifier +- rule_id: dcl38-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/DCL38-C.+Use+the+correct+syntax+when+declaring+a+flexible+array+member + title: DCL38-C. Use the correct syntax when declaring a flexible array member +- rule_id: dcl39-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/DCL39-C.+Avoid+information+leakage+when+passing+a+structure+across+a+trust+boundary + title: DCL39-C. Avoid information leakage when passing a structure across a trust + boundary +- rule_id: dcl40-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/DCL40-C.+Do+not+create+incompatible+declarations+of+the+same+function+or+object + title: DCL40-C. Do not create incompatible declarations of the same function or + object +- rule_id: dcl41-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/DCL41-C.+Do+not+declare+variables+inside+a+switch+statement+before+the+first+case+label + title: DCL41-C. Do not declare variables inside a switch statement before the first + case label +- rule_id: env30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/ENV30-C.+Do+not+modify+the+object+referenced+by+the+return+value+of+certain+functions + title: ENV30-C. Do not modify the object referenced by the return value of certain + functions +- rule_id: env31-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/ENV31-C.+Do+not+rely+on+an+environment+pointer+following+an+operation+that+may+invalidate+it + title: ENV31-C. Do not rely on an environment pointer following an operation that + may invalidate it +- rule_id: env32-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/ENV32-C.+All+exit+handlers+must+return+normally + title: ENV32-C. All exit handlers must return normally +- rule_id: env33-c + rule_url: https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152177 + title: ENV33-C. Do not call system() +- rule_id: env34-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/ENV34-C.+Do+not+store+pointers+returned+by+certain+functions + title: ENV34-C. Do not store pointers returned by certain functions +- rule_id: err30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/ERR30-C.+Take+care+when+reading+errno + title: ERR30-C. Take care when reading errno +- rule_id: err32-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/ERR32-C.+Do+not+rely+on+indeterminate+values+of+errno + title: ERR32-C. Do not rely on indeterminate values of errno +- rule_id: err33-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/ERR33-C.+Detect+and+handle+standard+library+errors + title: ERR33-C. Detect and handle standard library errors +- rule_id: err34-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/ERR34-C.+Detect+errors+when+converting+a+string+to+a+number + title: ERR34-C. Detect errors when converting a string to a number +- rule_id: exp30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/EXP30-C.+Do+not+depend+on+the+order+of+evaluation+for+side+effects + title: EXP30-C. Do not depend on the order of evaluation for side effects +- rule_id: exp32-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/EXP32-C.+Do+not+access+a+volatile+object+through+a+nonvolatile+reference + title: EXP32-C. Do not access a volatile object through a nonvolatile reference +- rule_id: exp33-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/EXP33-C.+Do+not+read+uninitialized+memory + title: EXP33-C. Do not read uninitialized memory +- rule_id: exp34-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/EXP34-C.+Do+not+dereference+null+pointers + title: EXP34-C. Do not dereference null pointers +- rule_id: exp35-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/EXP35-C.+Do+not+modify+objects+with+temporary+lifetime + title: EXP35-C. Do not modify objects with temporary lifetime +- rule_id: exp36-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/EXP36-C.+Do+not+cast+pointers+into+more+strictly+aligned+pointer+types + title: EXP36-C. Do not cast pointers into more strictly aligned pointer types +- rule_id: exp37-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/EXP37-C.+Call+functions+with+the+correct+number+and+type+of+arguments + title: EXP37-C. Call functions with the correct number and type of arguments +- rule_id: exp39-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/EXP39-C.+Do+not+access+a+variable+through+a+pointer+of+an+incompatible+type + title: EXP39-C. Do not access a variable through a pointer of an incompatible type +- rule_id: exp40-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/EXP40-C.+Do+not+modify+constant+objects + title: EXP40-C. Do not modify constant objects +- rule_id: exp42-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/EXP42-C.+Do+not+compare+padding+data + title: EXP42-C. Do not compare padding data +- rule_id: exp43-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/EXP43-C.+Avoid+undefined+behavior+when+using+restrict-qualified+pointers + title: EXP43-C. Avoid undefined behavior when using restrict-qualified pointers +- rule_id: exp44-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/EXP44-C.+Do+not+rely+on+side+effects+in+operands+to+sizeof%2C+_Alignof%2C+or+_Generic + title: EXP44-C. Do not rely on side effects in operands to sizeof, _Alignof, or + _Generic +- rule_id: exp45-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/EXP45-C.+Do+not+perform+assignments+in+selection+statements + title: EXP45-C. Do not perform assignments in selection statements +- rule_id: exp46-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/EXP46-C.+Do+not+use+a+bitwise+operator+with+a+Boolean-like+operand + title: EXP46-C. Do not use a bitwise operator with a Boolean-like operand +- rule_id: exp47-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/EXP47-C.+Do+not+call+va_arg+with+an+argument+of+the+incorrect+type + title: EXP47-C. Do not call va_arg with an argument of the incorrect type +- rule_id: fio30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FIO30-C.+Exclude+user+input+from+format+strings + title: FIO30-C. Exclude user input from format strings +- rule_id: fio32-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FIO32-C.+Do+not+perform+operations+on+devices+that+are+only+appropriate+for+files + title: FIO32-C. Do not perform operations on devices that are only appropriate for + files +- rule_id: fio34-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FIO34-C.+Distinguish+between+characters+read+from+a+file+and+EOF+or+WEOF + title: FIO34-C. Distinguish between characters read from a file and EOF or WEOF +- rule_id: fio37-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FIO37-C.+Do+not+assume+that+fgets%28%29+or+fgetws%28%29+returns+a+nonempty+string+when+successful + title: FIO37-C. Do not assume that fgets() or fgetws() returns a nonempty string + when successful +- rule_id: fio38-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FIO38-C.+Do+not+copy+a+FILE+object + title: FIO38-C. Do not copy a FILE object +- rule_id: fio39-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FIO39-C.+Do+not+alternately+input+and+output+from+a+stream+without+an+intervening+flush+or+positioning+call + title: FIO39-C. Do not alternately input and output from a stream without an intervening + flush or positioning call +- rule_id: fio40-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FIO40-C.+Reset+strings+on+fgets%28%29++or+fgetws%28%29+failure + title: FIO40-C. Reset strings on fgets() or fgetws() failure +- rule_id: fio41-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FIO41-C.+Do+not+call+getc%28%29%2C+putc%28%29%2C+getwc%28%29%2C+or+putwc%28%29+with+a+stream+argument+that+has+side+effects + title: FIO41-C. Do not call getc(), putc(), getwc(), or putwc() with a stream argument + that has side effects +- rule_id: fio42-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FIO42-C.+Close+files+when+they+are+no+longer+needed + title: FIO42-C. Close files when they are no longer needed +- rule_id: fio44-c + rule_url: https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152071 + title: FIO44-C. Only use values for fsetpos() that are returned from fgetpos() +- rule_id: fio45-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FIO45-C.+Avoid+TOCTOU+race+conditions+while+accessing+files + title: FIO45-C. Avoid TOCTOU race conditions while accessing files +- rule_id: fio46-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FIO46-C.+Do+not+access+a+closed+file + title: FIO46-C. Do not access a closed file +- rule_id: fio47-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FIO47-C.+Use+valid+format+strings + title: FIO47-C. Use valid format strings +- rule_id: flp30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FLP30-C.+Do+not+use+floating-point+variables+as+loop+counters + title: FLP30-C. Do not use floating-point variables as loop counters +- rule_id: flp32-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FLP32-C.+Prevent+or+detect+domain+and+range+errors+in+math+functions + title: FLP32-C. Prevent or detect domain and range errors in math functions +- rule_id: flp34-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FLP34-C.+Ensure+that+floating-point+conversions+are+within+range+of+the+new+type + title: FLP34-C. Ensure that floating-point conversions are within range of the new + type +- rule_id: flp36-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FLP36-C.+Preserve+precision+when+converting+integral+values+to+floating-point+type + title: FLP36-C. Preserve precision when converting integral values to floating-point + type +- rule_id: flp37-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/FLP37-C.+Do+not+use+object+representations+to+compare+floating-point+values + title: FLP37-C. Do not use object representations to compare floating-point values +- rule_id: int30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/INT30-C.+Ensure+that+unsigned+integer+operations+do+not+wrap + title: INT30-C. Ensure that unsigned integer operations do not wrap +- rule_id: int31-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/INT31-C.+Ensure+that+integer+conversions+do+not+result+in+lost+or+misinterpreted+data + title: INT31-C. Ensure that integer conversions do not result in lost or misinterpreted + data +- rule_id: int32-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/INT32-C.+Ensure+that+operations+on+signed+integers+do+not+result+in+overflow + title: INT32-C. Ensure that operations on signed integers do not result in overflow +- rule_id: int33-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/INT33-C.+Ensure+that+division+and+remainder+operations+do+not+result+in+divide-by-zero+errors + title: INT33-C. Ensure that division and remainder operations do not result in divide-by-zero + errors +- rule_id: int34-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/INT34-C.+Do+not+shift+an+expression+by+a+negative+number+of+bits+or+by+greater+than+or+equal+to+the+number+of+bits+that+exist+in+the+operand + title: INT34-C. Do not shift an expression by a negative number of bits or by greater + than or equal to the number of bits that exist in the operand +- rule_id: int35-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/INT35-C.+Use+correct+integer+precisions + title: INT35-C. Use correct integer precisions +- rule_id: int36-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/INT36-C.+Converting+a+pointer+to+integer+or+integer+to+pointer + title: INT36-C. Converting a pointer to integer or integer to pointer +- rule_id: mem30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/MEM30-C.+Do+not+access+freed+memory + title: MEM30-C. Do not access freed memory +- rule_id: mem31-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/MEM31-C.+Free+dynamically+allocated+memory+when+no+longer+needed + title: MEM31-C. Free dynamically allocated memory when no longer needed +- rule_id: mem33-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/MEM33-C.++Allocate+and+copy+structures+containing+a+flexible+array+member+dynamically + title: MEM33-C. Allocate and copy structures containing a flexible array member + dynamically +- rule_id: mem34-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/MEM34-C.+Only+free+memory+allocated+dynamically + title: MEM34-C. Only free memory allocated dynamically +- rule_id: mem35-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/MEM35-C.+Allocate+sufficient+memory+for+an+object + title: MEM35-C. Allocate sufficient memory for an object +- rule_id: mem36-c + rule_url: https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152255 + title: MEM36-C. Do not modify the alignment of objects by calling realloc() +- rule_id: msc30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/MSC30-C.+Do+not+use+the+rand%28%29+function+for+generating+pseudorandom+numbers + title: MSC30-C. Do not use the rand() function for generating pseudorandom numbers +- rule_id: msc32-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/MSC32-C.+Properly+seed+pseudorandom+number+generators + title: MSC32-C. Properly seed pseudorandom number generators +- rule_id: msc33-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/MSC33-C.+Do+not+pass+invalid+data+to+the+asctime%28%29+function + title: MSC33-C. Do not pass invalid data to the asctime() function +- rule_id: msc37-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/MSC37-C.+Ensure+that+control+never+reaches+the+end+of+a+non-void+function + title: MSC37-C. Ensure that control never reaches the end of a non-void function +- rule_id: msc38-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/MSC38-C.+Do+not+treat+a+predefined+identifier+as+an+object+if+it+might+only+be+implemented+as+a+macro + title: MSC38-C. Do not treat a predefined identifier as an object if it might only + be implemented as a macro +- rule_id: msc39-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/MSC39-C.+Do+not+call+va_arg%28%29+on+a+va_list+that+has+an+indeterminate+value + title: MSC39-C. Do not call va_arg() on a va_list that has an indeterminate value +- rule_id: msc40-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/MSC40-C.+Do+not+violate+constraints + title: MSC40-C. Do not violate constraints +- rule_id: msc41-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/MSC41-C.+Never+hard+code+sensitive+information + title: MSC41-C. Never hard code sensitive information +- rule_id: pos30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS30-C.+Use+the+readlink%28%29+function+properly + title: POS30-C. Use the readlink() function properly +- rule_id: pos34-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS34-C.+Do+not+call+putenv%28%29+with+a+pointer+to+an+automatic+variable+as+the+argument + title: POS34-C. Do not call putenv() with a pointer to an automatic variable as + the argument +- rule_id: pos35-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS35-C.+Avoid+race+conditions+while+checking+for+the+existence+of+a+symbolic+link + title: POS35-C. Avoid race conditions while checking for the existence of a symbolic + link +- rule_id: pos36-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS36-C.+Observe+correct+revocation+order+while+relinquishing+privileges + title: POS36-C. Observe correct revocation order while relinquishing privileges +- rule_id: pos37-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS37-C.+Ensure+that+privilege+relinquishment+is+successful + title: POS37-C. Ensure that privilege relinquishment is successful +- rule_id: pos38-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS38-C.+Beware+of+race+conditions+when+using+fork+and+file+descriptors + title: POS38-C. Beware of race conditions when using fork and file descriptors +- rule_id: pos39-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS39-C.+Use+the+correct+byte+ordering+when+transferring+data+between+systems + title: POS39-C. Use the correct byte ordering when transferring data between systems +- rule_id: pos44-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS44-C.+Do+not+use+signals+to+terminate+threads + title: POS44-C. Do not use signals to terminate threads +- rule_id: pos47-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS47-C.+Do+not+use+threads+that+can+be+canceled+asynchronously + title: POS47-C. Do not use threads that can be canceled asynchronously +- rule_id: pos48-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS48-C.+Do+not+unlock+or+destroy+another+POSIX+thread%27s+mutex + title: POS48-C. Do not unlock or destroy another POSIX thread's mutex +- rule_id: pos49-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS49-C.+When+data+must+be+accessed+by+multiple+threads%2C+provide+a+mutex+and+guarantee+no+adjacent+data+is+also+accessed + title: POS49-C. When data must be accessed by multiple threads, provide a mutex + and guarantee no adjacent data is also accessed +- rule_id: pos50-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS50-C.+Declare+objects+shared+between+POSIX+threads+with+appropriate+storage+durations + title: POS50-C. Declare objects shared between POSIX threads with appropriate storage + durations +- rule_id: pos51-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS51-C.+Avoid+deadlock+with+POSIX+threads+by+locking+in+predefined+order + title: POS51-C. Avoid deadlock with POSIX threads by locking in predefined order +- rule_id: pos52-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS52-C.+Do+not+perform+operations+that+can+block+while+holding+a+POSIX+lock + title: POS52-C. Do not perform operations that can block while holding a POSIX lock +- rule_id: pos53-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS53-C.+Do+not+use+more+than+one+mutex+for+concurrent+waiting+operations+on+a+condition+variable + title: POS53-C. Do not use more than one mutex for concurrent waiting operations + on a condition variable +- rule_id: pos54-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/POS54-C.+Detect+and+handle+POSIX+library+errors + title: POS54-C. Detect and handle POSIX library errors +- rule_id: pre30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/PRE30-C.+Do+not+create+a+universal+character+name+through+concatenation + title: PRE30-C. Do not create a universal character name through concatenation +- rule_id: pre31-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/PRE31-C.+Avoid+side+effects+in+arguments+to+unsafe+macros + title: PRE31-C. Avoid side effects in arguments to unsafe macros +- rule_id: pre32-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/PRE32-C.+Do+not+use+preprocessor+directives+in+invocations+of+function-like+macros + title: PRE32-C. Do not use preprocessor directives in invocations of function-like + macros +- rule_id: sig30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers + title: SIG30-C. Call only asynchronous-safe functions within signal handlers +- rule_id: sig31-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/SIG31-C.+Do+not+access+shared+objects+in+signal+handlers + title: SIG31-C. Do not access shared objects in signal handlers +- rule_id: sig34-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/SIG34-C.+Do+not+call+signal%28%29+from+within+interruptible+signal+handlers + title: SIG34-C. Do not call signal() from within interruptible signal handlers +- rule_id: sig35-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/SIG35-C.+Do+not+return+from+a+computational+exception+signal+handler + title: SIG35-C. Do not return from a computational exception signal handler +- rule_id: str30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/STR30-C.+Do+not+attempt+to+modify+string+literals + title: STR30-C. Do not attempt to modify string literals +- rule_id: str31-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/STR31-C.+Guarantee+that+storage+for+strings+has+sufficient+space+for+character+data+and+the+null+terminator + title: STR31-C. Guarantee that storage for strings has sufficient space for character + data and the null terminator +- rule_id: str32-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/STR32-C.+Do+not+pass+a+non-null-terminated+character+sequence+to+a+library+function+that+expects+a+string + title: STR32-C. Do not pass a non-null-terminated character sequence to a library + function that expects a string +- rule_id: str34-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/STR34-C.+Cast+characters+to+unsigned+char+before+converting+to+larger+integer+sizes + title: STR34-C. Cast characters to unsigned char before converting to larger integer + sizes +- rule_id: str37-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/STR37-C.+Arguments+to+character-handling+functions+must+be+representable+as+an+unsigned+char + title: STR37-C. Arguments to character-handling functions must be representable + as an unsigned char +- rule_id: str38-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/STR38-C.+Do+not+confuse+narrow+and+wide+character+strings+and+functions + title: STR38-C. Do not confuse narrow and wide character strings and functions +- rule_id: win30-c + rule_url: https://wiki.sei.cmu.edu/confluence/display/c/WIN30-C.+Properly+pair+allocation+and+deallocation+functions + title: WIN30-C. Properly pair allocation and deallocation functions + \ No newline at end of file diff --git a/web/api/js/codechecker-api-node/dist/codechecker-api-6.58.0.tgz b/web/api/js/codechecker-api-node/dist/codechecker-api-6.58.0.tgz deleted file mode 100644 index a8cf8ab10b..0000000000 Binary files a/web/api/js/codechecker-api-node/dist/codechecker-api-6.58.0.tgz and /dev/null differ diff --git a/web/api/js/codechecker-api-node/dist/codechecker-api-6.59.0.tgz b/web/api/js/codechecker-api-node/dist/codechecker-api-6.59.0.tgz new file mode 100644 index 0000000000..57e11499f8 Binary files /dev/null and b/web/api/js/codechecker-api-node/dist/codechecker-api-6.59.0.tgz differ diff --git a/web/api/js/codechecker-api-node/package.json b/web/api/js/codechecker-api-node/package.json index 0bfd792add..86e4a596e9 100644 --- a/web/api/js/codechecker-api-node/package.json +++ b/web/api/js/codechecker-api-node/package.json @@ -1,6 +1,6 @@ { "name": "codechecker-api", - "version": "6.58.0", + "version": "6.59.0", "description": "Generated node.js compatible API stubs for CodeChecker server.", "main": "lib", "homepage": "https://github.com/Ericsson/codechecker", diff --git a/web/api/py/codechecker_api/dist/codechecker_api.tar.gz b/web/api/py/codechecker_api/dist/codechecker_api.tar.gz index 3875d3ef7f..b1c9b6429b 100644 Binary files a/web/api/py/codechecker_api/dist/codechecker_api.tar.gz and b/web/api/py/codechecker_api/dist/codechecker_api.tar.gz differ diff --git a/web/api/py/codechecker_api/setup.py b/web/api/py/codechecker_api/setup.py index b369453448..fc9d400def 100644 --- a/web/api/py/codechecker_api/setup.py +++ b/web/api/py/codechecker_api/setup.py @@ -8,7 +8,7 @@ with open('README.md', encoding='utf-8', errors="ignore") as f: long_description = f.read() -api_version = '6.58.0' +api_version = '6.59.0' setup( name='codechecker_api', diff --git a/web/api/py/codechecker_api_shared/dist/codechecker_api_shared.tar.gz b/web/api/py/codechecker_api_shared/dist/codechecker_api_shared.tar.gz index 4d607e2b2f..ae4d38a141 100644 Binary files a/web/api/py/codechecker_api_shared/dist/codechecker_api_shared.tar.gz and b/web/api/py/codechecker_api_shared/dist/codechecker_api_shared.tar.gz differ diff --git a/web/api/py/codechecker_api_shared/setup.py b/web/api/py/codechecker_api_shared/setup.py index a4c2e70d02..90f09bf34e 100644 --- a/web/api/py/codechecker_api_shared/setup.py +++ b/web/api/py/codechecker_api_shared/setup.py @@ -8,7 +8,7 @@ with open('README.md', encoding='utf-8', errors="ignore") as f: long_description = f.read() -api_version = '6.58.0' +api_version = '6.59.0' setup( name='codechecker_api_shared', diff --git a/web/api/report_server.thrift b/web/api/report_server.thrift index 359372e28a..46448ca5a6 100644 --- a/web/api/report_server.thrift +++ b/web/api/report_server.thrift @@ -548,6 +548,18 @@ struct Checker { 2: string checkerId, } +struct Guideline { + 1: string guidelineName +} + +struct Rule { + 1: string ruleId, // The identifier of the rule. + 2: string title, // The rule summary. + 3: string url, // The link of the rule page. + 4: list> checkers // List of checker names +} +typedef map> GuidelineRules + service codeCheckerDBAccess { // Gives back all analyzed runs. @@ -779,6 +791,10 @@ service codeCheckerDBAccess { // 'label1:value2', 'label2:value3']. list> getCheckerLabels(1: list checkers) + // Return the list of rules to each guideline that given. + // If the guidelines param is empty, returning with all guideline rules. + GuidelineRules getGuidelineRules(1: list guidelines) + // returns the CodeChecker version that is running on the server // !DEPRECATED Use ServerInfo API to get the package version. string getPackageVersion(); diff --git a/web/codechecker_web/shared/version.py b/web/codechecker_web/shared/version.py index e5d544a750..2ac2d84ae7 100644 --- a/web/codechecker_web/shared/version.py +++ b/web/codechecker_web/shared/version.py @@ -18,7 +18,7 @@ # The newest supported minor version (value) for each supported major version # (key) in this particular build. SUPPORTED_VERSIONS = { - 6: 58 + 6: 59 } # Used by the client to automatically identify the latest major and minor diff --git a/web/codechecker_web/shared/webserver_context.py b/web/codechecker_web/shared/webserver_context.py index 0945443366..992ddb6c59 100644 --- a/web/codechecker_web/shared/webserver_context.py +++ b/web/codechecker_web/shared/webserver_context.py @@ -17,6 +17,7 @@ from codechecker_common import logger from codechecker_common.checker_labels import CheckerLabels +from codechecker_common.guidelines import Guidelines from codechecker_common.singleton import Singleton from codechecker_common.util import load_json @@ -70,7 +71,11 @@ def __init__(self): if 'CC_TEST_LABELS_DIR' in os.environ: labels_dir = os.environ['CC_TEST_LABELS_DIR'] + guidelines_dir = os.path.join(self._data_files_dir_path, + 'config', 'guidelines') + self._checker_labels = CheckerLabels(labels_dir) + self._guidelines = Guidelines(guidelines_dir) self.__system_comment_map = load_json(self.system_comment_map_file, {}) self.__git_commit_urls = self.__get_git_commit_urls() self.__package_version = None @@ -222,6 +227,10 @@ def config_migration_root(self): def checker_labels(self): return self._checker_labels + @property + def guideline(self): + return self._guidelines + def get_context(): try: diff --git a/web/server/codechecker_server/api/report_server.py b/web/server/codechecker_server/api/report_server.py index f3e2a7a6b5..08b47592f4 100644 --- a/web/server/codechecker_server/api/report_server.py +++ b/web/server/codechecker_server/api/report_server.py @@ -41,7 +41,7 @@ Order, \ ReportData, ReportDetails, ReportStatus, ReviewData, ReviewStatusRule, \ ReviewStatusRuleFilter, ReviewStatusRuleSortMode, \ - ReviewStatusRuleSortType, RunData, RunFilter, RunHistoryData, \ + ReviewStatusRuleSortType, Rule, RunData, RunFilter, RunHistoryData, \ RunReportCount, RunSortType, RunTagCount, \ ReviewStatus as API_ReviewStatus, \ SourceComponentData, SourceFileData, SortMode, SortType @@ -2771,6 +2771,41 @@ def getCheckerLabels( return labels + @exc_to_thrift_reqfail + @timeit + def getGuidelineRules( + self, + guidelines: List[ttypes.Guideline] + ): + """ Return the list of rules to each guideline that given. """ + guideline_rules = defaultdict(list) + for guideline in guidelines: + rules = self._context.guideline.rules_of_guideline( + guideline.guidelineName) + if not rules: + guideline_rules[guideline.guidelineName] = [] + continue + for rule in rules: + checkers = [{ + "checkerName": checker_name, + "severity": self._context.checker_labels.severity( + checker_name).lower() + } for checker_name in + self._context.checker_labels.checkers_by_labels( + [f"{guideline.guidelineName}: \ + {rule['rule_id']}"])] + + guideline_rules[guideline.guidelineName].append( + Rule( + ruleId=rule["rule_id"].lower(), + title=rule["title"], + url=rule["rule_url"], + checkers=checkers + ) + ) + + return guideline_rules + @exc_to_thrift_reqfail @timeit def getSourceFileData(self, fileId, fileContent, encoding): diff --git a/web/server/vue-cli/package-lock.json b/web/server/vue-cli/package-lock.json index 56acd84f72..e9120cf833 100644 --- a/web/server/vue-cli/package-lock.json +++ b/web/server/vue-cli/package-lock.json @@ -11,7 +11,7 @@ "@mdi/font": "^6.5.95", "chart.js": "^2.9.4", "chartjs-plugin-datalabels": "^0.7.0", - "codechecker-api": "file:../../api/js/codechecker-api-node/dist/codechecker-api-6.58.0.tgz", + "codechecker-api": "file:../../api/js/codechecker-api-node/dist/codechecker-api-6.59.0.tgz", "codemirror": "^5.65.0", "date-fns": "^2.28.0", "js-cookie": "^3.0.1", @@ -5103,9 +5103,9 @@ } }, "node_modules/codechecker-api": { - "version": "6.58.0", - "resolved": "file:../../api/js/codechecker-api-node/dist/codechecker-api-6.58.0.tgz", - "integrity": "sha512-N6qK5cnLt32jnJlSyyGMmW6FCzybDljyH1RrGOZ1Gk9n1vV7WluJbC9InYWsZ5lbK7xVyIrphTKXhqC4ARKF6g==", + "version": "6.59.0", + "resolved": "file:../../api/js/codechecker-api-node/dist/codechecker-api-6.59.0.tgz", + "integrity": "sha512-uLd4IqBeA+5iKVLVGkgJ8qSb+qB9OZxbTn8UawLv/MrGSj4O4FWDXEdjrxzofi8KMjXTd8IWhkAUVTDaHdOu7g==", "license": "SEE LICENSE IN LICENSE", "dependencies": { "thrift": "0.13.0-hotfix.1" @@ -21124,8 +21124,8 @@ "dev": true }, "codechecker-api": { - "version": "file:../../api/js/codechecker-api-node/dist/codechecker-api-6.58.0.tgz", - "integrity": "sha512-N6qK5cnLt32jnJlSyyGMmW6FCzybDljyH1RrGOZ1Gk9n1vV7WluJbC9InYWsZ5lbK7xVyIrphTKXhqC4ARKF6g==", + "version": "file:../../api/js/codechecker-api-node/dist/codechecker-api-6.59.0.tgz", + "integrity": "sha512-uLd4IqBeA+5iKVLVGkgJ8qSb+qB9OZxbTn8UawLv/MrGSj4O4FWDXEdjrxzofi8KMjXTd8IWhkAUVTDaHdOu7g==", "requires": { "thrift": "0.13.0-hotfix.1" } diff --git a/web/server/vue-cli/package.json b/web/server/vue-cli/package.json index 719f039497..db8c1d9b92 100644 --- a/web/server/vue-cli/package.json +++ b/web/server/vue-cli/package.json @@ -27,7 +27,7 @@ }, "dependencies": { "@mdi/font": "^6.5.95", - "codechecker-api": "file:../../api/js/codechecker-api-node/dist/codechecker-api-6.58.0.tgz", + "codechecker-api": "file:../../api/js/codechecker-api-node/dist/codechecker-api-6.59.0.tgz", "chart.js": "^2.9.4", "chartjs-plugin-datalabels": "^0.7.0", "codemirror": "^5.65.0", diff --git a/web/server/vue-cli/src/components/CountChips.vue b/web/server/vue-cli/src/components/CountChips.vue index 4f976f613c..3fade6ebfe 100644 --- a/web/server/vue-cli/src/components/CountChips.vue +++ b/web/server/vue-cli/src/components/CountChips.vue @@ -89,7 +89,7 @@ export default { }, props: { tag: { type: String, default: "span" }, - numGood: { type: Number, required: true }, + numGood: { type: Number, default: 0 }, numBad: { type: Number, default: 0 }, numTotal: { type: Number, default: 0 }, goodText: { type: String, default: "" }, diff --git a/web/server/vue-cli/src/components/Report/ReportFilter/ReportFilter.vue b/web/server/vue-cli/src/components/Report/ReportFilter/ReportFilter.vue index 1a6abbde29..2490d3cb49 100644 --- a/web/server/vue-cli/src/components/Report/ReportFilter/ReportFilter.vue +++ b/web/server/vue-cli/src/components/Report/ReportFilter/ReportFilter.vue @@ -390,7 +390,8 @@ export default { showReviewStatus: { type: Boolean, default: true }, showRemoveFilteredReports: { type: Boolean, default: true }, showDiffType: { type: Boolean, default: true }, - reportCount: { type: Number, required: true } + reportCount: { type: Number, required: true }, + refreshFilter: { type: Boolean, default: false } }, data() { @@ -412,6 +413,15 @@ export default { }), }, + watch: { + refreshFilter(state) { + if (!state) return; + + this.initByUrl(); + this.$emit("set-refresh-filter-state", false); + } + }, + mounted() { this.initByUrl(); }, diff --git a/web/server/vue-cli/src/components/Statistics/BaseStatisticsTable.vue b/web/server/vue-cli/src/components/Statistics/BaseStatisticsTable.vue index 30c0870797..820ed46dd4 100644 --- a/web/server/vue-cli/src/components/Statistics/BaseStatisticsTable.vue +++ b/web/server/vue-cli/src/components/Statistics/BaseStatisticsTable.vue @@ -2,6 +2,7 @@ + + + + + + + + + + + +