Skip to content

Commit 142ee3f

Browse files
committed
cwe-mapper: do not assign CWE to unknown events of Cppcheck
Reported-by: Steve Grubb
1 parent 9ef50a2 commit 142ee3f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cwe-mapper.cc

+8-1
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,25 @@ bool CweMap::assignCwe(Defect &def) const {
128128
}
129129

130130
// lookup by event
131+
int &cweDst = def.cwe;
131132
const Private::TNumByEvent &row = rowIt->second;
132133
const DefEvent &evt = def.events[def.keyEventIdx];
133134
Private::TNumByEvent::const_iterator cweIt = row.find(evt.event);
134135
if (row.end() == cweIt) {
135136
if (!d->silent)
136137
std::cerr << "warning: CWE not found: checker = " << def.checker
137138
<< ", event = " << evt.event << "\n";
139+
140+
if (def.checker == "CPPCHECK_WARNING") {
141+
// we cannot fallback to a random CWE that Cppcheck has mapping for
142+
cweDst = 0;
143+
return false;
144+
}
145+
138146
cweIt = row.begin();
139147
}
140148

141149
const int cweSrc = cweIt->second;
142-
int &cweDst = def.cwe;
143150
if (cweSrc == cweDst)
144151
// already assigned
145152
return true;

0 commit comments

Comments
 (0)