Translation of vulnerable code to remediated code
AssigneeAccenture Global Solutions Limited
InventorsKarthik Rajkumar Kannan, Malek Ben Salem
Life of this patent
Estimating the term…
Abstract
A code translation apparatus receives a source code including one or more code vulnerabilities and automatically generates remediated code. The source code provided to the code translation apparatus is converted to a source directional graph. The edges of the source directional graph are augmented with additional edge attributes. The source directional graph thus augmented is further converted into a source graph vector representation. The source graph vector representation is provided to an encoder of a trained code transformer. The remediated code is obtained from the decoder of the trained code transformer.
Claims19
A code translation apparatus, comprising:
- at least one processor;
- a non-transitory, processor-readable medium storing machine-readable instructions that cause the at least one processor to:
- train a code transformer by providing graph vector representations augmented with additional data generated from vulnerable source code samples to an encoder of the code transformer, and the graph vector representations augmented with additional data of corresponding remediated code samples to a decoder of the code transformer,
- wherein the vulnerable source code samples are remediated by the corresponding remediated code samples;
- access a source directional graph generated from a source code that includes at least one code vulnerability;
- augment the source directional graph with additional data from the source code;
- generate a graph vector representation for the source directional graph augmented with the additional data from the source code, wherein the graph vector representation includes neural network encoding data stored in nodes of the source directional graph augmented with the additional data from the source code;
- provide the graph vector representation to the trained code transformer;
- and
- generate via the trained code transformer, a final remediated code including an altered version of the source code,
- wherein the final remediated code remediates the at least one code vulnerability by the altered version of the source code.
A method of obtaining an output remediated code for an input source code comprising:
- generating training data including graph vector representations for a code transformer by:
- accessing source directional graphs and remediated directional graphs generated from sample vulnerable source codes and remediated code samples,
- wherein the remediated code samples remediate a corresponding one of the sample vulnerable source codes;
- augmenting the source directional graphs with additional data from the sample vulnerable source codes, and augmenting the remediated directional graphs with additional data from the remediated code samples;
- generating the graph vector representations for the augmented source directional graphs and for the augmented remediated directional graphs,
- wherein each of the graph vector representations includes neural networks encoding data stored in nodes of the augmented source directional graphs and nodes of the augmented remediated directional graphs;
- training the code transformer on the graph vector representations by providing the graph vector representations for the augmented source directional graphs to an encoder of the code transformer and by providing the graph vector representations for the augmented remediated directional graphs to a decoder of the code transformer;
- and
- generating via the trained code transformer, an output remediated code including an altered version of an input vulnerable source code,
- wherein the output remediated code remediates at least one vulnerability by the altered version of the input vulnerable source code.
A non-transitory processor-readable storage medium comprising machine-readable instructions that cause a processor to:
- train a code transformer by providing graph vector representations augmented with additional data generated from vulnerable source code samples to an encoder of the code transformer and the graph vector representations augmented with the additional data of corresponding remediated code samples to a decoder of the code transformer,
- the vulnerable source code samples are remediated by the corresponding remediated code samples;
- access a source directional graph generated from a source code that includes at least one code vulnerability;
- augment the source directional graph with additional from the source code;
- generate a graph vector representation for the source directional graph augmented with the additional data from the source code,
- wherein the graph vector representation includes neural networks encoding data stored in nodes of the source directional graph augmented with the additional data from the source code;
- provide the graph vector representation to the trained code transformer;
- and
- generate via the trained code transformer, a final remediated code including an altered version of the source code,
- wherein the final remediated code remediates the at least one code vulnerability by the altered version of the source code.
Dependencies are inferred from the claim text.