The C/C++ security analyses are regularly evaluated against the SAMATE Juliet tests maintained by the US National Institute of Standards and Technology (NIST). This ensures that the quality and discrimination of the results is maintained as the queries are updated, for example, for changes to the C++ language, or improvements to the CodeQL library, and enhancements to the code extraction process.
Summary of results
The following table summarizes the results for the latest release of the C/C++ security queries run against the SAMATE Juliet 1.3 tests. In the table, each row represents a weakness, and the columns show the following information:
- TP – count of all true positive results: the code has a known security weakness, and the CodeQL analyses correctly identify this defect.
- FP – count of all false positive results: the code has no known security weakness, but the CodeQL analyses are over cautious and suggest a potential problem.
- TN – count of true negative results: the code has no known security weakness, and CodeQL analyses correctly pass the code as secure.
- FN – count of all false negative results: the code has a known security weakness, but CodeQL analyses fail to identify this defect.
In an ideal implementation of the analyses, the number of false positives (FP) and false negatives (FN) would be zero, but that is impossible to achieve by static analysis. The figures for FP and FN show where there are limitations in the present implementation.
Interpreting the results
The report CAS Static Analysis Tool Study – Methodology, by the Center for Assured Software of the National Security Agency of the USA defines four different ways to measure success:
- Precision = TP/ (FP+TP)
- Recall = TP/(TP+FN)
- F-Score = 2*(Precision*Recall)/(Precision+Recall)
- Discrimination rate = #discriminated tests / #tests
For each of these metrics, a higher score is better. There is clearly a trade-off between the precision and recall metrics: increasing the level of precision or recall for any analysis reduces the level of the other metric. The F-score is therefore an attempt to quantify the balance of decision between these two metrics.
The following table shows the results of calculating these metrics for the results shown above. These scores compare very favorably with the sample tools tested by the Center for Assured Software.
The tests suggest judicious choices have been made to balance the number of false positive results (an incorrect warning is issued) and false negative results (a true defect was not identified). Where comparative results are available for other tools, the CodeQL analyses stand out for their exceptional accuracy.