Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,9 @@ void CppCheck::executeAddons(const std::vector<std::string>& files, const std::s
}
errmsg.file0 = file0;

if (obj.count("cwe")>0)
errmsg.cwe = CWE(obj["cwe"].get<std::int64_t>());

if (obj.count("hash")>0)
errmsg.hash = obj["hash"].get<std::int64_t>();

Expand Down
17 changes: 17 additions & 0 deletions test/cli/premium_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,23 @@ def test_help(tmpdir):
assert 'cppchecksolutions.com' in stdout, stdout # check for premium help link


def test_cwe(tmpdir):
# Trac 14323 - addon warnings with cwe
test_file = os.path.join(tmpdir, 'test.c')
addon_file = os.path.join(tmpdir, 'premiumaddon.py')

with open(test_file, 'wt') as f:
f.write('void foo();\n')

args = [f"--addon={addon_file}", '--xml', test_file]

with open(addon_file, 'wt') as f:
f.write('print(\'{"addon":"a","column":1,"errorId":"id","extra":"","file":"test.c","cwe":123,"linenr":1,"message":"bug","severity":"error"}\')')

_, _, stderr = cppcheck(args)
assert '<error id="a-id" severity="error" msg="bug" verbose="bug" cwe="123" ' in stderr


def test_hash(tmpdir):
# Trac 14225 - warnings with hash
test_file = os.path.join(tmpdir, 'test.c')
Expand Down
Loading