XML: Ensure file0 info is kept in multithreaded analysis. Write file0 attribute in top <error> element instead of in the <location> elements.
This commit is contained in:
parent
e65ea8575f
commit
161ea81fd8
|
@ -17,20 +17,6 @@
|
||||||
<element name="errors">
|
<element name="errors">
|
||||||
<zeroOrMore>
|
<zeroOrMore>
|
||||||
<element name="error">
|
<element name="error">
|
||||||
<optional>
|
|
||||||
<attribute name="cwe">
|
|
||||||
<data type="integer">
|
|
||||||
<param name="minExclusive">0</param>
|
|
||||||
</data>
|
|
||||||
</attribute>
|
|
||||||
</optional>
|
|
||||||
<optional>
|
|
||||||
<attribute name="hash">
|
|
||||||
<data type="integer">
|
|
||||||
<param name="minExclusive">1</param>
|
|
||||||
</data>
|
|
||||||
</attribute>
|
|
||||||
</optional>
|
|
||||||
<attribute name="id">
|
<attribute name="id">
|
||||||
<data type="NCName"/>
|
<data type="NCName"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
@ -55,13 +41,27 @@
|
||||||
<attribute name="verbose">
|
<attribute name="verbose">
|
||||||
<data type="string"/>
|
<data type="string"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
<zeroOrMore>
|
|
||||||
<element name="location">
|
|
||||||
<optional>
|
<optional>
|
||||||
<attribute name="file0">
|
<attribute name="file0">
|
||||||
<data type="string"/>
|
<data type="string"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<attribute name="cwe">
|
||||||
|
<data type="integer">
|
||||||
|
<param name="minExclusive">0</param>
|
||||||
|
</data>
|
||||||
|
</attribute>
|
||||||
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<attribute name="hash">
|
||||||
|
<data type="integer">
|
||||||
|
<param name="minExclusive">1</param>
|
||||||
|
</data>
|
||||||
|
</attribute>
|
||||||
|
</optional>
|
||||||
|
<zeroOrMore>
|
||||||
|
<element name="location">
|
||||||
<attribute name="file">
|
<attribute name="file">
|
||||||
<data type="string"/>
|
<data type="string"/>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
|
|
@ -123,6 +123,8 @@ void XmlReportV2::writeError(const ErrorItem &error)
|
||||||
mXmlWriter->writeAttribute(CWEAttribute, QString::number(error.cwe));
|
mXmlWriter->writeAttribute(CWEAttribute, QString::number(error.cwe));
|
||||||
if (error.hash > 0)
|
if (error.hash > 0)
|
||||||
mXmlWriter->writeAttribute(HashAttribute, QString::number(error.hash));
|
mXmlWriter->writeAttribute(HashAttribute, QString::number(error.hash));
|
||||||
|
if (!error.file0.isEmpty())
|
||||||
|
mXmlWriter->writeAttribute(IncludedFromFilenameAttribute, quoteMessage(error.file0));
|
||||||
if (!error.sinceDate.isEmpty())
|
if (!error.sinceDate.isEmpty())
|
||||||
mXmlWriter->writeAttribute(SinceDateAttribute, error.sinceDate);
|
mXmlWriter->writeAttribute(SinceDateAttribute, error.sinceDate);
|
||||||
if (!error.tags.isEmpty())
|
if (!error.tags.isEmpty())
|
||||||
|
@ -132,9 +134,6 @@ void XmlReportV2::writeError(const ErrorItem &error)
|
||||||
mXmlWriter->writeStartElement(LocationElementName);
|
mXmlWriter->writeStartElement(LocationElementName);
|
||||||
|
|
||||||
QString file = QDir::toNativeSeparators(error.errorPath[i].file);
|
QString file = QDir::toNativeSeparators(error.errorPath[i].file);
|
||||||
if (!error.file0.isEmpty() && file != error.file0) {
|
|
||||||
mXmlWriter->writeAttribute(IncludedFromFilenameAttribute, quoteMessage(error.file0));
|
|
||||||
}
|
|
||||||
mXmlWriter->writeAttribute(FilenameAttribute, XmlReport::quoteMessage(file));
|
mXmlWriter->writeAttribute(FilenameAttribute, XmlReport::quoteMessage(file));
|
||||||
mXmlWriter->writeAttribute(LineAttribute, QString::number(error.errorPath[i].line));
|
mXmlWriter->writeAttribute(LineAttribute, QString::number(error.errorPath[i].line));
|
||||||
if (error.errorPath[i].column > 0)
|
if (error.errorPath[i].column > 0)
|
||||||
|
@ -218,6 +217,8 @@ ErrorItem XmlReportV2::readError(QXmlStreamReader *reader)
|
||||||
item.cwe = attribs.value(QString(), CWEAttribute).toInt();
|
item.cwe = attribs.value(QString(), CWEAttribute).toInt();
|
||||||
if (attribs.hasAttribute(QString(), HashAttribute))
|
if (attribs.hasAttribute(QString(), HashAttribute))
|
||||||
item.hash = attribs.value(QString(), HashAttribute).toULongLong();
|
item.hash = attribs.value(QString(), HashAttribute).toULongLong();
|
||||||
|
if (attribs.hasAttribute(QString(), IncludedFromFilenameAttribute))
|
||||||
|
item.file0 = attribs.value(QString(), IncludedFromFilenameAttribute).toString();
|
||||||
if (attribs.hasAttribute(QString(), SinceDateAttribute))
|
if (attribs.hasAttribute(QString(), SinceDateAttribute))
|
||||||
item.sinceDate = attribs.value(QString(), SinceDateAttribute).toString();
|
item.sinceDate = attribs.value(QString(), SinceDateAttribute).toString();
|
||||||
if (attribs.hasAttribute(QString(), TagsAttribute))
|
if (attribs.hasAttribute(QString(), TagsAttribute))
|
||||||
|
|
|
@ -270,6 +270,7 @@ std::string ErrorMessage::serialize() const
|
||||||
oss << Severity::toString(severity).length() << " " << Severity::toString(severity);
|
oss << Severity::toString(severity).length() << " " << Severity::toString(severity);
|
||||||
oss << MathLib::toString(cwe.id).length() << " " << MathLib::toString(cwe.id);
|
oss << MathLib::toString(cwe.id).length() << " " << MathLib::toString(cwe.id);
|
||||||
oss << MathLib::toString(hash).length() << " " << MathLib::toString(hash);
|
oss << MathLib::toString(hash).length() << " " << MathLib::toString(hash);
|
||||||
|
oss << file0.size() << " " << file0;
|
||||||
if (certainty == Certainty::inconclusive) {
|
if (certainty == Certainty::inconclusive) {
|
||||||
const std::string text("inconclusive");
|
const std::string text("inconclusive");
|
||||||
oss << text.length() << " " << text;
|
oss << text.length() << " " << text;
|
||||||
|
@ -296,9 +297,9 @@ bool ErrorMessage::deserialize(const std::string &data)
|
||||||
certainty = Certainty::normal;
|
certainty = Certainty::normal;
|
||||||
callStack.clear();
|
callStack.clear();
|
||||||
std::istringstream iss(data);
|
std::istringstream iss(data);
|
||||||
std::array<std::string, 6> results;
|
std::array<std::string, 7> results;
|
||||||
std::size_t elem = 0;
|
std::size_t elem = 0;
|
||||||
while (iss.good() && elem < 6) {
|
while (iss.good() && elem < 7) {
|
||||||
unsigned int len = 0;
|
unsigned int len = 0;
|
||||||
if (!(iss >> len))
|
if (!(iss >> len))
|
||||||
return false;
|
return false;
|
||||||
|
@ -318,15 +319,16 @@ bool ErrorMessage::deserialize(const std::string &data)
|
||||||
results[elem++] = temp;
|
results[elem++] = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem != 6)
|
if (elem != 7)
|
||||||
throw InternalError(nullptr, "Internal Error: Deserialization of error message failed");
|
throw InternalError(nullptr, "Internal Error: Deserialization of error message failed");
|
||||||
|
|
||||||
id = results[0];
|
id = results[0];
|
||||||
severity = Severity::fromString(results[1]);
|
severity = Severity::fromString(results[1]);
|
||||||
std::istringstream(results[2]) >> cwe.id;
|
std::istringstream(results[2]) >> cwe.id;
|
||||||
std::istringstream(results[3]) >> hash;
|
std::istringstream(results[3]) >> hash;
|
||||||
mShortMessage = results[4];
|
std::istringstream(results[4]) >> file0;
|
||||||
mVerboseMessage = results[5];
|
mShortMessage = results[5];
|
||||||
|
mVerboseMessage = results[6];
|
||||||
|
|
||||||
unsigned int stackSize = 0;
|
unsigned int stackSize = 0;
|
||||||
if (!(iss >> stackSize))
|
if (!(iss >> stackSize))
|
||||||
|
@ -438,10 +440,11 @@ std::string ErrorMessage::toXML() const
|
||||||
if (certainty == Certainty::inconclusive)
|
if (certainty == Certainty::inconclusive)
|
||||||
printer.PushAttribute("inconclusive", "true");
|
printer.PushAttribute("inconclusive", "true");
|
||||||
|
|
||||||
|
if (!file0.empty())
|
||||||
|
printer.PushAttribute("file0", file0.c_str());
|
||||||
|
|
||||||
for (std::list<FileLocation>::const_reverse_iterator it = callStack.rbegin(); it != callStack.rend(); ++it) {
|
for (std::list<FileLocation>::const_reverse_iterator it = callStack.rbegin(); it != callStack.rend(); ++it) {
|
||||||
printer.OpenElement("location", false);
|
printer.OpenElement("location", false);
|
||||||
if (!file0.empty() && (*it).getfile() != file0)
|
|
||||||
printer.PushAttribute("file0", Path::toNativeSeparators(file0).c_str());
|
|
||||||
printer.PushAttribute("file", (*it).getfile().c_str());
|
printer.PushAttribute("file", (*it).getfile().c_str());
|
||||||
printer.PushAttribute("line", std::max((*it).line,0));
|
printer.PushAttribute("line", std::max((*it).line,0));
|
||||||
printer.PushAttribute("column", (*it).column);
|
printer.PushAttribute("column", (*it).column);
|
||||||
|
|
Loading…
Reference in New Issue