DOI QR코드

DOI QR Code

Detecting Common Weakness Enumeration(CWE) Based on the Transfer Learning of CodeBERT Model

CodeBERT 모델의 전이 학습 기반 코드 공통 취약점 탐색

  • 박찬솔 (홍익대학교 소프트웨어융합학과) ;
  • 문소영 (홍익대학교 소프트웨어융합학과) ;
  • 김영철 (홍익대학교 소프트웨어융합학과)
  • Received : 2023.05.04
  • Accepted : 2023.08.22
  • Published : 2023.10.31

Abstract

Recently the incorporation of artificial intelligence approaches in the field of software engineering has been one of the big topics. In the world, there are actively studying in two directions: 1) software engineering for artificial intelligence and 2) artificial intelligence for software engineering. We attempt to apply artificial intelligence to software engineering to identify and refactor bad code module areas. To learn the patterns of bad code elements well, we must have many datasets with bad code elements labeled correctly for artificial intelligence in this task. The current problems have insufficient datasets for learning and can not guarantee the accuracy of the datasets that we collected. To solve this problem, when collecting code data, bad code data is collected only for code module areas with high-complexity, not the entire code. We propose a method for exploring common weakness enumeration by learning the collected dataset based on transfer learning of the CodeBERT model. The CodeBERT model learns the corresponding dataset more about common weakness patterns in code. With this approach, we expect to identify common weakness patterns more accurately better than one in traditional software engineering.

소프트웨어 공학 영역에 인공지능의 접목은 큰 화두 중 하나이다. 전 세계적으로 1) 인공지능을 통한 소프트웨어 공학, 2) 소프트웨어 공학을 통한 인공지능 두 가지 방향으로 활발히 연구되고 있다. 그 중 소프트웨어 공학에 인공지능을 접목하여 나쁜 코드 영역을 식별하고 해당 부분을 리팩토링하는 연구가 진행되고 있다. 해당 연구에서 인공지능이 나쁜 코드 요소의 패턴을 잘 학습하기 위해서는 학습하려는 나쁜 코드 요소가 라벨링 된 데이터셋이 필요하다. 문제는 데이터셋이 부족할뿐더러, 자체적으로 수집한 데이터셋의 정확도는 신뢰할 수 없다. 이를 해결하기 위해 코드 데이터 수집 시 전체 코드가 아닌 높은 복잡도를 가진 코드 모듈 영역을 대상으로만 나쁜 코드 데이터를 수집한다. 이후 수집한 데이터셋을 CodeBERT 모델의 전이 학습하여 코드 공통 취약점을 탐색하는 방법을 제안한다. 해당 데이터셋을 통해 CodeBERT 모델이 코드의 공통 취약점 패턴을 더 잘 학습할 수 있다. 이를 통해 전통적인 방법보다 인공지능 모델을 이용해 코드를 분석하고 공통 취약점 패턴을 더 정확하게 식별할 수 있을 것으로 기대한다.

Keywords

Acknowledgement

본 연구는 2023년도 문화체육관광부의 재원으로 한국콘텐츠진흥원(과제명: 인공지능 기반 사용자 대화형 멀티모달 인터랙티브 스토리텔링 3D장면 저작 기술 개발, 과제번호: RS-2023-00227917,기여율:50%) 지원과 2023년도 정부(교육부)의 재원으로 한국연구재단 기초연구사업(과제명: NLP BERT Model 기반 자동 리팩토링을 통한 무결점 코드화 연구, 과제번호: No.2021R1I1A3050407,기여율:40%)의 지원과 2022년도 정부(교육부)의 재원으로 한국연구재단 기초연구사업(과제명: 비정형 요구사항 명세서 기반 자동 비용 예측 및 역공학을 통한 검증 연구, 과제번호: No.2021R1I1 A1A01044060,기여율:10%)의 지원을 받아 수행된 연구임.

References

  1. A. D. Carleton, E. Harper, T. Menzies, T. Xie, S. Eldh, and M. R. Lyu, "The AI effect: Working at the Intersection of AI and SE," IEEE Software, Vol.37, No.4, pp.26-35, 2020. https://doi.org/10.1109/MS.2020.2987666
  2. G. H. Kang, R. Y. C. Kim, G. S. Yi, Y. S. Kim, Y. B. Park, and H. S. Son, "A study on code static analysis with open source-based tool chainization," KIISE Transactions on Computing Practices, Vol.21, No.2, pp.148-153, 2015. https://doi.org/10.5626/KTCP.2015.21.2.148
  3. H. Kwon and R. Y. C. Kim, "Extracting use case design mechanisms via programming based on reverse engineering," International Journal of Applied Engineering Research, Vol.10, No.90, pp.503-505, 2015.
  4. B. K. Park, G. H. Kang, H. S. Son, B. K. Jeon, and R. Y. C. Kim, "Code visualization for performance improvement of Java code for controlling smart traffic system in the smart city," Applied Sciences, Vol.10, No.8, 2020.
  5. S. J. Jung, J. H. Kim, W. Y. Lee, B. K. Park, H. S. Son, and R. Y. C. Kim, "Automatic UML design extraction with software visualization based on reverse engineering," International Journal of Advanced Smart Convergence, Vol.10, No.3, pp.89-96, 2021. https://doi.org/10.7236/IJASC.2021.10.3.89
  6. W. Y. Lee and R. Y. C. Kim, "Best practices on validation and extraction of object oriented designs with code visualization tool-chain," Journal of Internet Computing and Services, Vol.23, No.2, pp.79-86, 2022.
  7. C. S. Park, S. Y. Moon, and R. Y. C. Kim, "Quality visualization of quality metric indicators based on table normalization of static code building information," KIPS Transactions on Software and Data Engineering, Vol.12, No.5, pp.199-206, 2023.
  8. T. Sharma, M. Kechagia, S. Georgiou, R. Tiwari, I. Vats, H. Moazen, and F. Sarro, "A survey on machine learning techniques for source code analysis," arXiv preprint arXiv: 2110.09610, 2021.
  9. Halstead, Maurice H., "Elements of software science (Operating and programming systems series)," Elsevier Science Inc., 1977.
  10. S. R. Chidamber, C. F. Kemerer, "A metrics suite for object oriented design," IEEE Transactions on Software Engineering, Vol.20, No.6, pp.476-493, 1994. https://doi.org/10.1109/32.295895
  11. T. J. McCabe, "A complexity measure," IEEE Transactions on Software Engineering, Vol.4, pp.308-320, 1976. https://doi.org/10.1109/TSE.1976.233837
  12. M. Fowler, "Refactoring," Addison-Wesley Professional, 2018.
  13. J. Devlin, M. W. Chang, K. Lee, and K. Toutanova, "Bert: Pre-training of deep bidirectional transformers for language understanding," arXiv preprint arXiv:1810.04805, 2018.
  14. A. Vaswani et al., "Attention is all you need," Advances in Neural Information Processing Systems, 30, 2017.
  15. Z. Feng et al., "Codebert: A pre-trained model for programming and natural languages," arXiv preprint arXiv: 2002.08155, 2020.
  16. Common Weakness Enumeration [Internet], http://cwe.mitre.org
  17. PMD [Internet], https://pmd.github.io/
  18. C. S. Park, J. H. Kim, S. Y. Moon, and R. Y. C. Kim, "Applied practice on identifying bad codes through supervised learning with bad code patterns," Proceedings of the 25th Korea Conference on Software Engineering, Vol.25, No.1, pp.119-120, 2023.
  19. C. S. Park, W. S. Jang, and R. Y. C. Kim, "Tool Chain Mechanism with Identifying and Collecting High Quality Data for Learning Bad Code based on Code Visualization," 2023 Conference of KISM, Vol.12, No.1, pp.52-53, 2023.
  20. N. Medeiros, N. Ivaki, P. Costa, and M. Vieira, "Software Metrics as Indicators of Security Vulnerabilities," 2017 IEEE 28th International Symposium on Software Reliability Engineering (ISSRE), Toulouse, France, pp.216-227, 2017.
  21. NSA Center for Assured Software, 2017, "Juliet Java 1.3," [Online].Available:https://samate.nist.gov/SARD/test-suites/111