@@ -274,11 +274,9 @@ std::string ErrorMessage::serialize() const
274274 serializeString (oss, severityToString (severity));
275275 serializeString (oss, std::to_string (cwe.id ));
276276 serializeString (oss, std::to_string (hash));
277+ serializeString (oss, fixInvalidChars (remark));
277278 serializeString (oss, file0);
278- if (certainty == Certainty::inconclusive) {
279- const std::string text (" inconclusive" );
280- serializeString (oss, text);
281- }
279+ serializeString (oss, (certainty == Certainty::inconclusive) ? " 1" : " 0" );
282280
283281 const std::string saneShortMessage = fixInvalidChars (mShortMessage );
284282 const std::string saneVerboseMessage = fixInvalidChars (mVerboseMessage );
@@ -312,9 +310,9 @@ void ErrorMessage::deserialize(const std::string &data)
312310 callStack.clear ();
313311
314312 std::istringstream iss (data);
315- std::array<std::string, 7 > results;
313+ std::array<std::string, 9 > results;
316314 std::size_t elem = 0 ;
317- while (iss.good () && elem < 7 ) {
315+ while (iss.good () && elem < 9 ) {
318316 unsigned int len = 0 ;
319317 if (!(iss >> len))
320318 throw InternalError (nullptr , " Internal Error: Deserialization of error message failed - invalid length" );
@@ -332,11 +330,6 @@ void ErrorMessage::deserialize(const std::string &data)
332330
333331 if (!iss.good ())
334332 throw InternalError (nullptr , " Internal Error: Deserialization of error message failed - premature end of data" );
335-
336- if (temp == " inconclusive" ) {
337- certainty = Certainty::inconclusive;
338- continue ;
339- }
340333 }
341334
342335 results[elem++] = std::move (temp);
@@ -345,7 +338,7 @@ void ErrorMessage::deserialize(const std::string &data)
345338 if (!iss.good ())
346339 throw InternalError (nullptr , " Internal Error: Deserialization of error message failed - premature end of data" );
347340
348- if (elem != 7 )
341+ if (elem != 9 )
349342 throw InternalError (nullptr , " Internal Error: Deserialization of error message failed - insufficient elements" );
350343
351344 id = std::move (results[0 ]);
@@ -362,9 +355,12 @@ void ErrorMessage::deserialize(const std::string &data)
362355 if (!strToInt (results[3 ], hash, &err))
363356 throw InternalError (nullptr , " Internal Error: Deserialization of error message failed - invalid hash - " + err);
364357 }
365- file0 = std::move (results[4 ]);
366- mShortMessage = std::move (results[5 ]);
367- mVerboseMessage = std::move (results[6 ]);
358+ remark = std::move (results[4 ]);
359+ file0 = std::move (results[5 ]);
360+ if (results[6 ] == " 1" )
361+ certainty = Certainty::inconclusive;
362+ mShortMessage = std::move (results[7 ]);
363+ mVerboseMessage = std::move (results[8 ]);
368364
369365 unsigned int stackSize = 0 ;
370366 if (!(iss >> stackSize))
@@ -496,6 +492,9 @@ std::string ErrorMessage::toXML() const
496492 if (!file0.empty ())
497493 printer.PushAttribute (" file0" , file0.c_str ());
498494
495+ if (!remark.empty ())
496+ printer.PushAttribute (" remark" , fixInvalidChars (remark).c_str ());
497+
499498 for (std::list<FileLocation>::const_reverse_iterator it = callStack.crbegin (); it != callStack.crend (); ++it) {
500499 printer.OpenElement (" location" , false );
501500 printer.PushAttribute (" file" , it->getfile ().c_str ());
@@ -641,6 +640,7 @@ std::string ErrorMessage::toString(bool verbose, const std::string &templateForm
641640 findAndReplace (result, " {severity}" , severityToString (severity));
642641 findAndReplace (result, " {cwe}" , std::to_string (cwe.id ));
643642 findAndReplace (result, " {message}" , verbose ? mVerboseMessage : mShortMessage );
643+ findAndReplace (result, " {remark}" , remark);
644644 if (!callStack.empty ()) {
645645 if (result.find (" {callstack}" ) != std::string::npos)
646646 findAndReplace (result, " {callstack}" , ErrorLogger::callStackToString (callStack));
0 commit comments