The invention relates to a patch
overfitting evaluation method combined with
dual code representation, and belongs to the field of
internet security services. Aiming at an automatic patch generation condition, firstly, a defect
code snippet, a correct
code snippet and CFG and AST of a patch are constructed, and a Word2Vec model is utilized to respectively generate embedded vectors containing structural information and
semantic information; secondly, a Transform model is utilized to
encode an AST embedded vector, a GAT model is utilized to
encode a CFG embedded vector, and a
feature vector is obtained through splicing; then calculating
feature vector distances between the patches and the defect code snippets and between the patches and the correct code snippets, and training to generate a dichotomy model for calculating patch
overfitting confidence; and finally, weighting the confidence coefficient according to the code change degree, and comparing the weighted confidence coefficient with a threshold value to judge whether
overfitting exists. Aiming at the defects in the existing method, the
semantic similarity of correct code snippets is high, and misjudgment is easily caused when the code change degree is large, the code CFG features are increased, the code change degree is calculated, and the patch overfitting evaluation accuracy is improved.