Adversarial attack method and apparatus
Abstract
The present disclosure relates to an adversarial attack method and apparatus. The adversarial attack method according to an embodiment of the present disclosure may include: selecting vulnerable positions of an original source code; acquiring open source codes based on an open source code set; selecting dissimilar codes among the open source codes based on dissimilarity of the open source codes; acquiring an attention score for each of the dissimilar codes; extracting a snippet from at least one of the dissimilar codes based on the attention scores; and generating an adversarial source code based on the at least one snippet.
Claims
exact text as granted — not AI-modifiedWhat is claimed is:
1 . An adversarial attack method, comprising:
selecting vulnerable positions of an original source code; acquiring open source codes based on an open source code set; selecting dissimilar codes among the open source codes based on dissimilarity of the open source codes; acquiring an attention score for each of the dissimilar codes; extracting a snippet from at least one of the dissimilar codes based on the attention scores; and generating an adversarial source code based on the at least one snippet.
2 . The method of claim 1 , wherein the selection of the dissimilar codes among the open source codes based on dissimilarity of the open source codes comprises:
acquiring similarity between the open source codes; acquiring a dissimilarity score of each of the open source codes based on the similarity; and selecting some of the open sources as the dissimilar codes based on the dissimilarity score.
3 . The method of claim 2 , wherein the acquisition of the similarity between the open source codes comprises acquiring cosine similarity between the open source codes.
4 . The method of claim 1 , wherein the extraction of the snippet from at least one of the dissimilar codes based on the attention scores comprises:
extracting sentences from each of the dissimilar codes; and extracting the sentence extracted from the dissimilar code with the highest attention score among the extracted sentences as the snippet.
5 . The method of claim 1 , wherein the generation of the adversarial source code based on the at least one snippet comprises:
generating a dead code by inserting the at least one snippet into a character string variable name; and generating the adversarial source code by inserting the dead code into the vulnerable positions of the original source code.
6 . An adversarial source code generation apparatus, comprising:
a processor; and a memory storing one or more instructions executed by the processor, wherein the one or more instructions comprises: selecting vulnerable positions of an original source code; acquiring open source codes based on an open source code set; selecting dissimilar codes among the open source codes based on dissimilarity of the open source codes; acquiring an attention score for each of the dissimilar codes; extracting a snippet from at least one of the dissimilar codes based on the attention scores; and generating an adversarial source code based on the at least one snippet.
7 . The apparatus of claim 6 , wherein the selection of the dissimilar codes among the open source codes based on dissimilarity of the open source codes comprises:
acquiring similarity between the open source codes; acquiring a dissimilarity score of each of the open source codes based on the similarity; and selecting some of the open sources as the dissimilar codes based on the dissimilarity score.
8 . The apparatus of claim 7 , wherein the acquisition of the similarity between the open source codes comprises acquiring cosine similarity between the open source codes.
9 . The apparatus of claim 6 , wherein the extraction of the snippet from at least one of the dissimilar codes based on the attention scores comprises:
extracting sentences from each of the dissimilar codes; and extracting the sentence extracted from the dissimilar code with the highest attention score among the extracted sentences as the snippet.
10 . The apparatus of claim 6 , wherein the generation of the adversarial source code based on the at least one snippet comprises:
generating a dead code by inserting the at least one snippet into a character string variable name; and generating the adversarial source code by inserting the dead code into the vulnerable positions of the original source code.
11 . An adversarial attack performance analysis method, comprising:
receiving an original source code from an original source code provision apparatus; receiving an adversarial source code from an adversarial source code generation apparatus; and determining whether an artificial intelligence model has been attacked by the adversarial source code based on the original source code and the adversarial source code, wherein the adversarial source code is generated by: selecting vulnerable positions of an original source code; acquiring open source codes based on an open source code set; selecting dissimilar codes among the open source codes based on dissimilarity of the open source codes; acquiring an attention score for each of the dissimilar codes; extracting a snippet from at least one of the dissimilar codes based on the attention scores; and generating the adversarial source code based on the at least one snippet.
12 . The method of claim 11 , wherein the selection of the dissimilar codes among the open source codes based on dissimilarity of the open source codes comprises:
acquiring similarity between the open source codes; acquiring a dissimilarity score of each of the open source codes based on the similarity; and selecting some of the open sources as the dissimilar codes based on the dissimilarity score.
13 . The method of claim 12 , wherein the acquisition of the similarity between the open source codes comprises acquiring cosine similarity between the open source codes.
14 . The method of claim 11 , wherein the extraction of the snippet from at least one of the dissimilar codes based on the attention scores comprises:
extracting sentences from each of the dissimilar codes; and extracting the sentence extracted from the dissimilar code with the highest attention score among the extracted sentences as the snippet.
15 . The method of claim 11 , wherein the generation of the adversarial source code based on the at least one snippet comprises:
generating a dead code by inserting the at least one snippet into a character string variable name; and generating the adversarial source code by inserting the dead code into the vulnerable positions of the original source code.
16 . A non-transitory computer-readable recording medium recording a program for executing the method of claim 1 on a computer.Join the waitlist — get patent alerts
Track US2025028824A1 — get alerts on status changes and closely related new filings.
We store only your email — no account needed. See our privacy policy.