diff --git a/src/lib/parser-json-cov.cc b/src/lib/parser-json-cov.cc index 7c2863a4..84adb80b 100644 --- a/src/lib/parser-json-cov.cc +++ b/src/lib/parser-json-cov.cc @@ -50,11 +50,17 @@ bool CovTreeDecoder::readNode(Defect *def) // out of the supported tools, only Coverity produces this data format def->tool = "coverity"; - // read CWE if available + // extract checker properties if available const pt::ptree *checkerProps; - if (findChildOf(&checkerProps, defNode, "checkerProperties")) + if (findChildOf(&checkerProps, defNode, "checkerProperties")) { + // read CWE if available def->cwe = valueOf(*checkerProps, "cweCategory"); + // treat defects with high impact as important + if ("High" == valueOf(*checkerProps, "impact")) + def->imp = 1; + } + // count the events and allocate dst array const pt::ptree &evtList = defNode.get_child("events"); def->events.resize(evtList.size()); diff --git a/tests/csgrep/0061-json-parser-cov-v7-lang-stdout.txt b/tests/csgrep/0061-json-parser-cov-v7-lang-stdout.txt index 76d4c8ad..754a1459 100644 --- a/tests/csgrep/0061-json-parser-cov-v7-lang-stdout.txt +++ b/tests/csgrep/0061-json-parser-cov-v7-lang-stdout.txt @@ -198,6 +198,7 @@ { "checker": "RESOURCE_LEAK", "cwe": 404, + "imp": 1, "function": "bpf::output_probe(bpf::BPF_Output &, bpf::program &, std::__cxx11::basic_string, std::allocator > const &, unsigned int)", "language": "c/c++", "tool": "coverity", @@ -652,6 +653,7 @@ { "checker": "RESOURCE_LEAK", "cwe": 404, + "imp": 1, "function": "sql_stmt(sqlite3 *, char const *)", "language": "c/c++", "tool": "coverity", @@ -810,6 +812,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "location_context::location_context(target_symbol *, expression *)", "language": "c/c++", "tool": "coverity", @@ -1269,6 +1272,7 @@ { "checker": "RESOURCE_LEAK", "cwe": 404, + "imp": 1, "function": "parser::parse_components()", "language": "c/c++", "tool": "coverity", @@ -2546,6 +2550,7 @@ { "checker": "STRING_NULL", "cwe": 170, + "imp": 1, "function": "procfs_write_event_loop(procfsprobe_data *, bpf_transport_context *)", "language": "c/c++", "tool": "coverity", @@ -3813,6 +3818,7 @@ { "checker": "UNINIT", "cwe": 457, + "imp": 1, "function": "stapregex::rebalance_priorities(std::stack > > &, std::stack > > &)", "language": "c/c++", "tool": "coverity", @@ -3844,6 +3850,7 @@ { "checker": "UNINIT", "cwe": 457, + "imp": 1, "function": "stapregex::rebalance_priorities(std::stack > > &, std::stack > > &)", "language": "c/c++", "tool": "coverity", @@ -3889,6 +3896,7 @@ { "checker": "UNINIT", "cwe": 457, + "imp": 1, "function": "stapregex::rebalance_priorities(std::stack > > &, std::stack > > &)", "language": "c/c++", "tool": "coverity", @@ -3993,6 +4001,7 @@ { "checker": "RESOURCE_LEAK", "cwe": 404, + "imp": 1, "function": "parse_args", "language": "c/c++", "tool": "coverity", @@ -4101,6 +4110,7 @@ { "checker": "RESOURCE_LEAK", "cwe": 404, + "imp": 1, "function": "parse_args", "language": "c/c++", "tool": "coverity", @@ -8286,6 +8296,7 @@ { "checker": "RESOURCE_LEAK", "cwe": 404, + "imp": 1, "function": "send_relocation_modules", "language": "c/c++", "tool": "coverity", @@ -8881,6 +8892,7 @@ { "checker": "RESOURCE_LEAK", "cwe": 404, + "imp": 1, "function": "register_tapset_python(systemtap_session &)", "language": "c/c++", "tool": "coverity", @@ -8919,6 +8931,7 @@ { "checker": "RESOURCE_LEAK", "cwe": 404, + "imp": 1, "function": "utrace_var_expanding_visitor::visit_target_symbol_arg(target_symbol *)", "language": "c/c++", "tool": "coverity", @@ -8978,6 +8991,7 @@ { "checker": "RESOURCE_LEAK", "cwe": 404, + "imp": 1, "function": "register_tapset_utrace(systemtap_session &)", "language": "c/c++", "tool": "coverity", @@ -9301,6 +9315,7 @@ { "checker": "RESOURCE_LEAK", "cwe": 404, + "imp": 1, "function": "dwarf_var_expanding_visitor::visit_target_symbol_context(target_symbol *)", "language": "c/c++", "tool": "coverity", @@ -9517,6 +9532,7 @@ { "checker": "RESOURCE_LEAK", "cwe": 404, + "imp": 1, "function": "delete_statement_operand_visitor::visit_arrayindex(arrayindex *)", "language": "c/c++", "tool": "coverity", @@ -10023,6 +10039,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::equal_to, std::allocator > > *>, std::allocator, std::equal_to, std::allocator > > *> >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::tuple<> >(std::__detail::_Hashtable_alloc, std::equal_to, std::allocator > > *>, false> > > *, , std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10061,6 +10078,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable > *>, std::allocator > *> >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::tuple<> >(std::__detail::_Hashtable_alloc > *>, false> > > *, , std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10099,6 +10117,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, int, std::less, std::allocator > >, std::allocator, std::allocator > const, int> > > >, std::allocator, std::allocator >, int, std::less, std::allocator > >, std::allocator, std::allocator > const, int> > > > >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::tuple<> >(std::__detail::_Hashtable_alloc, std::allocator >, int, std::less, std::allocator > >, std::allocator, std::allocator > const, int> > > >, false> > > *, , std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10137,6 +10156,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node >(std::__detail::_Hashtable_alloc, true> > > *, ...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10175,6 +10195,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node >(std::__detail::_Hashtable_alloc, true> > > *, ...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10213,6 +10234,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node >(std::__detail::_Hashtable_alloc, true> > > *, ...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10251,6 +10273,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::tuple<> >(std::__detail::_Hashtable_alloc, true> > > *, , std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10289,6 +10312,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node >(std::__detail::_Hashtable_alloc, false> > > *, ...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10327,6 +10351,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, std::pair, std::allocator > const, Dwarf_Die>, std::allocator, std::allocator > const, Dwarf_Die> >, std::__detail::_Select1st, std::equal_to, std::allocator > >, std::hash, std::allocator > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::allocator > const &>, std::tuple<> >(std::__detail::_Hashtable_alloc, std::allocator > const, Dwarf_Die>, true> > > *, , std::allocator > const &>, std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10365,6 +10390,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, std::pair, std::allocator > const, bpf::value *>, std::allocator, std::allocator > const, bpf::value *> >, std::__detail::_Select1st, std::equal_to, std::allocator > >, std::hash, std::allocator > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::allocator >, bpf::value *> >(std::__detail::_Hashtable_alloc, std::allocator > const, bpf::value *>, true> > > *, , std::allocator >, bpf::value *>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10403,6 +10429,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, std::pair, std::allocator > const, expression *>, std::allocator, std::allocator > const, expression *> >, std::__detail::_Select1st, std::equal_to, std::allocator > >, std::hash, std::allocator > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::allocator > const &>, std::tuple<> >(std::__detail::_Hashtable_alloc, std::allocator > const, expression *>, true> > > *, , std::allocator > const &>, std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10441,6 +10468,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, std::pair, std::allocator > const, std::vector > *>, std::allocator, std::allocator > const, std::vector > *> >, std::__detail::_Select1st, std::equal_to, std::allocator > >, std::hash, std::allocator > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::allocator > &&>, std::tuple<> >(std::__detail::_Hashtable_alloc, std::allocator > const, std::vector > *>, true> > > *, , std::allocator > &&>, std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10479,6 +10507,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node >(std::__detail::_Hashtable_alloc, false> > > *, ...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10517,6 +10546,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node >(std::__detail::_Hashtable_alloc, false> > > *, ...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10555,6 +10585,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node >(std::__detail::_Hashtable_alloc, false> > > *, ...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10593,6 +10624,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::tuple<> >(std::__detail::_Hashtable_alloc, false> > > *, , std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10631,6 +10663,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, int, std::less, std::allocator > >, std::allocator, std::allocator > const, int> > > >, std::allocator, std::allocator >, int, std::less, std::allocator > >, std::allocator, std::allocator > const, int> > > > >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::tuple<> >(std::__detail::_Hashtable_alloc, std::allocator >, int, std::less, std::allocator > >, std::allocator, std::allocator > const, int> > > >, false> > > *, , std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10669,6 +10702,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node >(std::__detail::_Hashtable_alloc, false> > > *, ...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10707,6 +10741,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, Dwarf_Die, std::hash, std::allocator > >, std::equal_to, std::allocator > >, std::allocator, std::allocator > const, Dwarf_Die> > > *>, std::allocator, std::allocator >, Dwarf_Die, std::hash, std::allocator > >, std::equal_to, std::allocator > >, std::allocator, std::allocator > const, Dwarf_Die> > > *> >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::tuple<> >(std::__detail::_Hashtable_alloc, std::allocator >, Dwarf_Die, std::hash, std::allocator > >, std::equal_to, std::allocator > >, std::allocator, std::allocator > const, Dwarf_Die> > > *>, false> > > *, , std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10745,6 +10780,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator >, std::vector > *, std::hash, std::allocator > >, std::equal_to, std::allocator > >, std::allocator, std::allocator > const, std::vector > *> > > *>, std::allocator, std::allocator >, std::vector > *, std::hash, std::allocator > >, std::equal_to, std::allocator > >, std::allocator, std::allocator > const, std::vector > *> > > *> >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::tuple<> >(std::__detail::_Hashtable_alloc, std::allocator >, std::vector > *, std::hash, std::allocator > >, std::equal_to, std::allocator > >, std::allocator, std::allocator > const, std::vector > *> > > *>, false> > > *, , std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10783,6 +10819,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::equal_to, std::allocator > > *>, std::allocator, std::equal_to, std::allocator > > *> >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::tuple<> >(std::__detail::_Hashtable_alloc, std::equal_to, std::allocator > > *>, false> > > *, , std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10821,6 +10858,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::equal_to, std::allocator > > *>, std::allocator, std::equal_to, std::allocator > > *> >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::tuple<> >(std::__detail::_Hashtable_alloc, std::equal_to, std::allocator > > *>, false> > > *, , std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10859,6 +10897,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::equal_to, std::allocator > *>, std::allocator, std::equal_to, std::allocator > *> >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::tuple<> >(std::__detail::_Hashtable_alloc, std::equal_to, std::allocator > *>, false> > > *, , std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10897,6 +10936,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable > *>, std::allocator > *> >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::tuple<> >(std::__detail::_Hashtable_alloc > *>, false> > > *, , std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity", @@ -10935,6 +10975,7 @@ { "checker": "CTOR_DTOR_LEAK", "cwe": 401, + "imp": 1, "function": "std::_Hashtable, std::allocator > > *>, std::allocator, std::allocator > > *> >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >::_Scoped_node::_Scoped_node, std::tuple<> >(std::__detail::_Hashtable_alloc, std::allocator > > *>, false> > > *, , std::tuple<>...> &&...)", "language": "c/c++", "tool": "coverity",