Search

CN-121996523-A - Generating offence exemption terms for static LINT inspection

CN121996523ACN 121996523 ACN121996523 ACN 121996523ACN-121996523-A

Abstract

The present disclosure relates to generating offending exemption terms for static lint inspection. In one example, a method includes converting source code for a register transfer level design into a directed graph, obtaining a first violation generated by analyzing the source code, identifying a violation statement sub-graph in the directed graph associated with the first violation, extracting a reduced sub-graph from the directed graph that represents the first violation, wherein the violation statement sub-graph includes a starting point of the reduced sub-graph, converting the reduced sub-graph into a first vector, calculating a graph similarity between the first vector and a second vector representing a second violation of the source code for which an existing exemption term has been generated, determining, by a processing device, that the graph similarity satisfies a threshold similarity, and generating an exemption term for the first violation in response to the determining.

Inventors

  • T. Aneja
  • M. Mangal
  • S. V. Venkatesh
  • H. Carter Yuria
  • R. K. Olayan
  • P. M. Jia Yin

Assignees

  • 新思科技有限公司

Dates

Publication Date
20260508
Application Date
20251105
Priority Date
20241105

Claims (20)

  1. 1. A method, comprising: Converting source code for a register transfer level design into a directed graph; acquiring a first violation generated by analyzing the source code; Identifying a violation sentence subgraph in the directed graph associated with the first violation; Extracting a reduced subgraph representing the first violation from the directed graph, wherein the violation statement subgraph includes a starting point of the reduced subgraph; converting the reduced sub-graph into a first vector; Calculating a graph similarity between the first vector and a second vector representing a second violation of the source code for which an existing exemption term has been generated; determining, by the processing device, that the graph similarity satisfies a threshold similarity, and An exemption term is generated for the first violation in response to the determination.
  2. 2. The method of claim 1, wherein the converting comprises using an abstract syntax tree parser to perform top-down register transfer level code decompilation of converting the source code for the register transfer level design into the directed graph.
  3. 3. The method of claim 1, wherein the extracting the reduced subgraph comprises: Extracting a violation sentence subgraph from the directed graph based on a tag that marks a starting point of the violation sentence subgraph from the directed graph, wherein the violation sentence subgraph includes the starting point and a portion of the directed graph below the starting point; Augmenting the offending statement subgraph with a subgraph of a block statement to generate an augmented offending statement subgraph, wherein an offending statement associated with the violation is part of the block statement; The expanded offending statement subgraph is expanded with a variable subgraph of a code statement that is computationally dependent on any variable of the directed graph of the variable of the expanded offending statement subgraph.
  4. 4. The method of claim 1, wherein the first vector comprises an embedding vector of attributes of nodes embedding the reduced subgraph.
  5. 5. The method of claim 1, wherein the graph similarity is cosine similarity.
  6. 6. The method of claim 1, wherein the second vector is one of a plurality of vectors, wherein each vector of the plurality of vectors corresponds to one exemption item or one violation that has been identified for the source code.
  7. 7. The method as recited in claim 6, further comprising: Calculating a plurality of graph similarities between a third vector converted from a reduced sub-graph representing a third violation generated by analyzing the source code and each of the plurality of vectors; Determining that all of the plurality of graph similarities are below the threshold similarity, and In response to the determining that all of the plurality of graph similarities are below the threshold similarity, the third violation is added to a set of existing violations of the source code.
  8. 8.A method, comprising: Converting source code for a register transfer level design into a directed graph; Acquiring a first violation generated by a static line inspection tool that analyzes source code; Identifying a violation sentence subgraph in the directed graph associated with the first violation; Extracting a minimum subgraph representing the first violation from the directed graph, wherein the violation statement subgraph includes a starting point of the minimum subgraph; executing a machine learning model that predicts a probability of the minimum subgraph matching a second offending minimum subgraph of different source code for which an exemption term has been generated; determining, by the processing device, that the probability is at least equal to a threshold probability, and An exemption term is generated for the first violation in response to the determination.
  9. 9. The method of claim 8, wherein the converting comprises using an abstract syntax tree parser to perform top-down register transfer level code decompilation of converting the source code for the register transfer level design into the directed graph.
  10. 10. The method of claim 8, wherein the extracting comprises: Extracting a violation sentence subgraph from the directed graph based on a tag that marks a starting point of the violation sentence subgraph from the directed graph, wherein the violation sentence subgraph includes the starting point and a portion of the directed graph below the starting point; Augmenting the offending statement subgraph with a subgraph of a block statement to generate an augmented offending statement subgraph, wherein an offending statement associated with the violation is part of the block statement; The expanded offending statement subgraph is expanded with a variable subgraph of a code statement that is computationally dependent on any variable of the directed graph of the variable of the expanded offending statement subgraph.
  11. 11. The method of claim 8, wherein the machine learning model comprises a graph rolling network that has been trained using a set of labeled minimal subgraphs from violations and exemptions of multiple historical instances of source code that do not include the source code.
  12. 12. The method of claim 8, wherein the machine learning model is trained as a binary classification model that takes as input the minimum subgraph and generates as output a classification indicating whether the minimum subgraph indicates an exempt term or a true violation.
  13. 13. The method of claim 8, further comprising adding the minimum subgraph to a set of minimum subgraphs for determining whether a third violation generated by a static lin inspection tool analyzing source code should be exempted in response to a human operator verifying that the exemption term is valid, wherein each minimum subgraph in the set of minimum subgraphs represents an existing exemption term previously generated for a previously analyzed violation generated by a static lin inspection tool analyzing source code.
  14. 14. The method as recited in claim 13, further comprising: converting the third violation into a new directed graph; extracting a new minimum subgraph from the new directed graph representing the third violation; converting the new minimum sub-graph into a first vector; Calculating a plurality of graph similarities, wherein each graph similarity of the plurality of graph similarities represents a similarity of the first vector to one of a set of vectors, wherein each vector of the set of vectors is transformed from a minimum subgraph of the set of minimum subgraphs; Determining that a graph similarity of the plurality of graph similarities is at least equal to a threshold similarity, and And generating an exemption term for the third violation in response to the determining that a graph similarity of the plurality of graph similarities is at least equal to a threshold similarity.
  15. 15. The method as recited in claim 13, further comprising: converting the third violation into a new directed graph; Extracting a new minimal reduction subgraph from the new directed graph representing the third violation; Converting the new minimum reduced sub-graph into a first vector; Calculating a plurality of graph similarities, wherein each graph similarity of the plurality of graph similarities represents a similarity of the first vector to one of a set of vectors, wherein each vector of the set of vectors is transformed from a minimum reduced subgraph of the set of minimum reduced subgraphs; determining that none of the plurality of graph similarities is at least equal to a threshold similarity, and In response to the determining that none of the plurality of graph similarities is at least equal to a threshold similarity, the third violation is added to a set of existing violations of the source code.
  16. 16. A non-transitory computer-readable medium comprising stored instructions that, when executed by a processor, cause the processor to: Converting source code for a register transfer level design into a directed graph; Obtaining a first violation generated by a static line inspection tool that analyzes the source code; Identifying a violation sentence subgraph in the directed graph associated with the first violation; Extracting a minimum subgraph representing the first violation from the directed graph, wherein the violation statement subgraph includes a starting point of the minimum subgraph; converting the minimum sub-graph into a first vector; Calculating a graph similarity between the first vector and a second vector representing a second violation of the source code for which an existing exemption term has been generated; Determining that the graph similarity is less than a threshold similarity; In response to the graph similarity being less than the threshold similarity, executing a machine learning model that predicts a probability of the smallest subgraph matching a second offending smallest subgraph of a different source code for which an exemption term has been generated; determining that the probability is at least equal to a threshold probability, and An exemption term is generated for the first violation in response to the determination.
  17. 17. The non-transitory computer-readable medium of claim 16, wherein converting the minimum subgraph to the first vector comprises using an abstract syntax tree parser to perform top-down register transfer level code decompilation that converts each register transfer level module of the first violation to the directed graph.
  18. 18. The non-transitory computer-readable medium of claim 16, wherein extracting a minimum subgraph from the directed graph representing the first violation further causes the processor to: extracting the offending sentence subgraph from the directed graph based on a tag that marks a starting point of the offending sentence subgraph from the directed graph; Augmenting the offending statement subgraph with a subgraph of a block statement to generate an augmented offending statement subgraph, wherein an offending statement associated with the violation is part of the block statement; The expanded offending statement subgraph is expanded with a variable subgraph of a code statement that is computationally dependent on any variable of the directed graph of the variable of the expanded offending statement subgraph.
  19. 19. The non-transitory computer-readable medium of claim 16, wherein the graph similarity is a cosine similarity.
  20. 20. The non-transitory computer-readable medium of claim 16, wherein the machine learning model comprises a graph rolling network that has been trained using a set of labeled minimal subgraphs from a plurality of historical examples of source code that does not include the source code.

Description

Generating offence exemption terms for static LINT inspection Technical Field The present disclosure relates generally to Register Transfer Level (RTL) designs, and more particularly to generating offending exemptions for static lint checks. Background The static link inspection tool is used for detecting programming errors, loopholes, style errors and suspicious structures in the source code. When an error or vulnerability is detected, many static lint inspection tools generate an alarm or violation. Disclosure of Invention Thus, in one example, a method according to the present disclosure includes converting source code for a register transfer level design into a directed graph, obtaining a first violation generated by analyzing the source code, identifying a violation sentence sub-graph in the directed graph associated with the first violation, extracting a reduced sub-graph from the directed graph representing the first violation, wherein the violation sentence sub-graph includes a starting point of the reduced sub-graph, converting the reduced sub-graph into a first vector, calculating a graph similarity between the first vector and a second vector representing a second violation of the source code for which an existing exemption item has been generated, determining, by a processing device, that the graph similarity meets a threshold similarity, and generating an exemption item for the first violation in response to the determining. In another example according to the present disclosure, a method includes converting source code for a register transfer level design into a directed graph, obtaining a first violation generated by a static line inspection tool that analyzes the source code, identifying a violation sentence subgraph in the directed graph that is associated with the first violation, extracting a minimum subgraph from the directed graph that represents the first violation, wherein the violation sentence subgraph includes a starting point of the minimum subgraph, executing a machine learning model that predicts a probability that the minimum subgraph matches a minimum subgraph of a second violation of a different source code for which an exemption term has been generated, determining, by a processing device, that the probability is at least equal to a threshold probability, and generating an exemption term for the first violation in response to the determination. In another example, a non-transitory computer-readable medium according to the present disclosure stores instructions that, when executed by a processor, cause the processor to convert source code for a register transfer level design into a directed graph, obtain a first violation generated by a static line inspection tool that analyzes the source code, identify a violation statement sub-graph in the directed graph that is associated with the first violation, extract a minimum sub-graph from the directed graph that represents the first violation, convert the minimum sub-graph into a first vector, wherein the violation statement sub-graph includes a starting point of the minimum sub-graph, calculate a graph similarity between the first vector and a second vector that represents a second violation of the source code for which an existing exempt term has been generated, determine that the graph similarity is less than a threshold similarity, execute a machine learning model that predicts a probability of the minimum and a different source code for which an exempt term has been generated in response to the graph is less than the threshold similarity, and determine that the probability of the minimum rule of the violation term has been generated to be equal to at least a threshold. Drawings The present disclosure will be understood more fully from the detailed description given below and from the accompanying drawings of embodiments of the disclosure. The drawings are intended to provide a knowledge and understanding of embodiments of the present disclosure and are not intended to limit the scope of the present disclosure to these particular embodiments. Moreover, the drawings are not necessarily drawn to scale. FIG. 1 is a flow chart illustrating one example of a method for automatically generating offending exemptions for static lint inspection. FIG. 2 illustrates an example minimal subgraph that may be generated during the method illustrated in FIG. 1. FIG. 3 illustrates a graphical representation of a method for comparing existing exemptions that have been generated for the same source code for which the violation was generated. FIG. 4 illustrates a graphical representation of a method for predicting new exemptions of source code that differ from existing source code from which existing exemptions were generated using a machine learning model that was trained using existing exemptions. Fig. 5A-5D illustrate graphical representations of systems that may be used to perform at least some of the steps of the method illustrated in fig. 1. F