Intel has released version 1.2 of the ControlFlag toolkit, which allows for the detection of errors and anomalies in source code using a machine learning system trained on a large volume of existing code. Unlike traditional static analyzers, ControlFlag does not apply predefined rules that struggle to account for all possible variations, but instead relies on the statistics of language constructs used across numerous existing projects. The ControlFlag code is written in C++ and is open-sourced under the MIT license.
The new release is notable for its complete support for anomaly detection and training based on typical code patterns for the C++ language. Previous versions provided such support for C and PHP languages. The system is suitable for identifying various types of issues in the code, from spotting typos and incorrect type combinations to detecting anomalies in 'if' conditional expressions and missed NULL checks in pointers. The system learns by building a statistical model of the existing code from open projects in C, C++, and PHP published on GitHub and similar public repositories.
During the training phase, the system identifies typical patterns for constructing code constructs and builds a syntactic tree of relationships between these patterns, reflecting the execution flow of the code in the program. As a result, a reference decision tree is formed, encompassing the development experience of all analyzed source texts. A similar pattern recognition process is applied to the code being checked, comparing it with the reference decision tree. Significant discrepancies with neighboring branches indicate anomalies in the checked pattern.

Source: opennet.ru
