Automatic code generation based on Abstract Syntax-based encoding. Application on malware detection code generation based on MITRE ATT&CK techniques

Alexandru-Gabriel Sîrbu, Gabriela Czibula · Expert Systems with Applications · 2024

In the last decade, the area of code generation based on natural language was one of the most studied machine learning topics. The paper addresses the problem of code generation from natural language, by generating a syntax-error-free generator model, which creates an Syntax-based model, later translated into code, for generating the structure of the code. Two approaches are comparatively investigated for generating the structure of the program. The first approach generates code templates in the form of an Abstract Syntax Tree, while the second generates the code in the form of an Abstract Syntax Graph, a new introduced concept which reduces the initial redundancy of Abstract Syntax Trees and uses it as a new way to generate code. The proposed methodology is tested on two literature data sets and on malware detection code generation based on a real data set containing MITRE ATT&CK techniques. The results outperform the state-of-the-art Abstract Syntax Tree approaches by 2.46% and the plain text-based approaches with more than 12.5%, highlighting that the proposed methodology learns better the structural representation than other literature approaches. • We propose two approaches for generating the structure of the code. • Abstract Syntax Trees and Abstract Syntax Graphs are proposed for code generation. • Experiments are performed on public data and on malware detection code generation. • Our results outperform the state-of-the-art Abstract Syntax Tree approaches by 2.46%. • The results also outperform the plain text-based related work with more than 12.5%.

Read the paper · More papers on PaperTik