WO2021187743A1 - 전자 장치 및 이의 제어 방법 - Google Patents

전자 장치 및 이의 제어 방법 Download PDF

Info

Publication number
WO2021187743A1
WO2021187743A1 PCT/KR2021/000884 KR2021000884W WO2021187743A1 WO 2021187743 A1 WO2021187743 A1 WO 2021187743A1 KR 2021000884 W KR2021000884 W KR 2021000884W WO 2021187743 A1 WO2021187743 A1 WO 2021187743A1
Authority
WO
WIPO (PCT)
Prior art keywords
function
parameter
code
processor
fuzzing
Prior art date
Application number
PCT/KR2021/000884
Other languages
English (en)
French (fr)
Inventor
정성욱
고경준
김무상
Original Assignee
삼성전자주식회사
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 삼성전자주식회사 filed Critical 삼성전자주식회사
Publication of WO2021187743A1 publication Critical patent/WO2021187743A1/ko

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3624Software debugging by performing operations on the source code, e.g. via a compiler
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3696Methods or tools to render software testable

Definitions

  • the present disclosure relates to an electronic device and a control method thereof, and more particularly, to an electronic device providing a fuzzing code (or fuzzer code) for a test code and a control method thereof.
  • Fuzzing is one of the software testing techniques, and it is performed to verify that the software operates without defects by inputting valid and unexpected random data into a computer program.
  • An object of the present disclosure is to solve the above problems, and specifically, to provide an electronic device for automatically generating a fuzzing code for software developed by a software developer and a control method thereof.
  • An electronic device includes: a memory for storing a test code for calling a function and a library code for the at least one function; and a parameter for a function called by the test code is identified using a library code for the function, and a fuzzing source code for the called function is provided based on the identified parameter.
  • a control method of an electronic device may include: identifying a parameter for a function called by a test code using a library code for the function; and providing a fuzzing source code for the called function based on the parameter.
  • FIG. 1 is a block diagram illustrating a configuration of an electronic device according to various embodiments of the present disclosure
  • FIG. 2 is a view for explaining a fuzzer generating system according to an embodiment of the present disclosure
  • FIG. 3 is a view for explaining a function analysis module according to an embodiment of the present disclosure.
  • FIG. 8 is a flowchart illustrating a method of controlling an electronic device according to various embodiments of the present disclosure.
  • expressions such as “have,” “may have,” “include,” or “may include” indicate the presence of a corresponding characteristic (eg, a numerical value, function, operation, or component such as a part). and does not exclude the presence of additional features.
  • expressions such as “A or B,” “at least one of A and/and B,” or “one or more of A or/and B” may include all possible combinations of the items listed together.
  • “A or B,” “at least one of A and B,” or “at least one of A or B” means (1) includes at least one A, (2) includes at least one B; Or (3) it may refer to all cases including both at least one A and at least one B.
  • a component eg, a first component is "coupled with/to (operatively or communicatively)" to another component (eg, a second component)
  • another component eg, a second component
  • the certain element may be directly connected to the other element or may be connected through another element (eg, a third element).
  • a component eg, a first component
  • another component eg, a second component
  • a device configured to may mean that the device is “capable of” with other devices or parts.
  • a coprocessor configured (or configured to perform) A, B, and C may include a processor dedicated to performing the operations (eg, an embedded processor), or executing one or more software programs stored in a memory device. By doing so, it may mean a generic-purpose processor (eg, a central processing unit (CPU) or an application processor) capable of performing corresponding operations.
  • the electronic device may include, for example, at least one of a desktop PC, a laptop PC, a netbook computer, a workstation, a server, a smart phone, a tablet PC, a mobile phone, a video phone, and a wearable device.
  • a desktop PC a laptop PC
  • a netbook computer a workstation
  • a server a smart phone
  • a tablet PC a mobile phone
  • a video phone a wearable device.
  • the term user may refer to a person who uses an electronic device or a device (eg, an artificial intelligence electronic device) using the electronic device.
  • a device eg, an artificial intelligence electronic device
  • a function represents a part of a code that performs a specific operation or service in software, and not only functions included in a program, but also subroutines, routines, methods, procedures ( procedure) may refer to a program unit.
  • FIG. 1 is a block diagram illustrating a configuration of an electronic device according to various embodiments of the present disclosure. As shown in FIG. 1 , the electronic device 100 includes a memory 110 and a processor 120 .
  • the memory 110 is a component for storing various programs and data necessary for the operation of the electronic device 100 .
  • the memory 110 may be implemented as a non-volatile memory, a volatile memory, a flash-memory, a hard disk drive (HDD), or a solid state drive (SSD).
  • the memory 110 is accessed by the processor 120 , and reading/writing/modification/deletion/update of data by the processor 120 may be performed.
  • the term "memory” refers to the memory 110, a ROM (not shown) in the processor 120, a RAM (not shown), or a memory card (not shown) mounted in the electronic device 100 (eg, micro SD). card, memory stick).
  • the memory 110 may store a test code for calling at least one function and a library code for at least one function called from the test code.
  • the test code represents a code for testing whether each module of the program written by the user operates correctly as intended by the user.
  • the test code may mean a unit test source code.
  • the test code may call at least one function to test the program module.
  • the test code may access a specific function using an application programming interface (API).
  • API application programming interface
  • API information may be stored in the memory 110 .
  • the memory 110 may include a fuzzer generating system that generates a fuzzing source code for a function call in the test code. This will be described later with reference to FIG. 2 .
  • the processor 120 may be electrically connected to a memory (not shown) to control overall operations and functions of the electronic device 100 .
  • the processor 120 may control hardware or software components connected to the processor 120 by driving an operating system or an application program, and may perform various data processing and operations.
  • the processor 120 may load and process commands or data received from at least one of the other components into the volatile memory, and store various data in the non-volatile memory.
  • the processor 120 executes a dedicated processor (eg, an embedded processor) or one or more software programs stored in a memory device for performing the corresponding operation, and thus a general-purpose processor (eg, CPU (Central) Processing Unit) or application processor).
  • a dedicated processor eg, an embedded processor
  • a general-purpose processor eg, CPU (Central) Processing Unit) or application processor.
  • the processor 120 may be implemented as a digital signal processor (DSP), a microprocessor, or a time controller (TCON) that processes a digital signal, but is not limited thereto, central processing unit (CPU), micro controller unit (MCU), micro processing unit (MPU), controller, application processor (AP), graphics-processing unit (GPU) or communication
  • the processor 120 may include one or more of a communication processor (CP) and an ARM processor, or may be defined as a corresponding term
  • the processor 120 is a SoC (System on Chip), LSI (large) processor in which a processing algorithm is embedded. scale integration) or implemented in the form of a field programmable gate array (FPGA).
  • SoC System on Chip
  • LSI large
  • FPGA field programmable gate array
  • the processor 120 may identify a parameter for the function called by the test code using the library code for the called function, and provide a fuzzing source code related to the function call based on the identified parameter.
  • the fuzzing source code related to the function call means inputting various values to the parameters of the called function while repeating the function call included in the test code multiple times, and testing based on the output values according to the various input values. It refers to the source code that determines whether errors or defects exist in the code.
  • the fuzzing source code may be described in a programming language. In this case, the programming language is not limited to a specific language, and may be various types of languages such as C, C++, JAVA, Python, and Visual Basic.
  • the processor 120 may analyze the test code using the spread generation system.
  • the processor 120 may determine the configuration of the test code and identify a function call in the test code. In this case, the processor 120 may identify a function call in the test code based on the API information.
  • the processor 120 uses the library code of the called function based on the spread generation system to determine the type and size of the parameter of the called function, whether variable values are assigned to the parameters, and parameters such as correlation between a plurality of parameters. characteristics can be identified.
  • the parameter represents data provided as an input to the function.
  • the processor 120 may provide a fuzzing source code based on an analysis result of the test code and a parameter identified using the library code. Specifically, the processor 120 may control a display (not shown) to display the fuzzing source code. However, this is only an example, and the processor 120 may transmit the fuzzing source code to a display device (not shown) through a communication interface (not shown).
  • the user may receive the fuzzing code for the test code in the form of a source code
  • the user may provide feedback on the fuzzing source code to the electronic device 100 .
  • the user may analyze the fuzzing source code and modify parameters or select a function in the test code to be fuzzed.
  • the processor 120 generates the fuzzing source code by using the spread generation system, and therefore, the spread generation system of the present disclosure will be described first.
  • FIG. 2 is a view for explaining a spread generation system according to an embodiment of the present disclosure.
  • the fuzz generation system 200 may include a test code analysis module 210 , a function analysis module 220 , and a fuzzing code generation module 230 .
  • the test code analysis module 210 may analyze the structure of the test code and identify a function call in the test code.
  • test code analysis module 210 may search for a function call that is a target of fuzzing (hereinafter referred to as a target function call) and a code related thereto among function calls within the test code.
  • a target function call a target of fuzzing
  • the test code analysis module 210 may determine whether a variable corresponding to an argument passed to a parameter of the called function and a return value obtained as a result of the function call are declared or referenced in the test code. have. At this time, if a variable corresponding to an argument passed to a parameter of the called function and a return value obtained as a result of calling the function is declared or referenced in the test code, the test code analysis module 210 calls the function It can be determined that purging is possible. On the other hand, if the variable corresponding to the argument passed to the parameter of the called function and the return value obtained as a result of the function call is not declared or referenced in the test code, the test code analysis module 210 determines the function of the function. It may be determined that fuzzing is impossible for a call.
  • the test code analysis module 210 may analyze a pattern of a function call in the test code and determine whether the target function call is repeatedly executed. Specifically, the test code analysis module 210 may determine whether the target function call is two or more times. When the target function call is two or more times, the test code analysis module 210 identifies a first function call called before the target function call and a second function call called after the target function call, and the first function call within the test code When the function call, the target function call, and the second function call are repeated, it may be determined that the target function call has been repeatedly performed.
  • the test code analysis module 210 may determine whether a target function call is made within a loop of the test code. Specifically, when a target function call is made within a loop of the test code, the test code analysis module 210 may determine that the target function call is repeatedly executed.
  • the loop means a programming phrase that allows a part of the code to be called repeatedly, such as a for statement and a while statement in C language.
  • the loop statement is not limited to the for statement and the while statement, and depending on the programming language, a phrase set to repeat a specific code may correspond to this.
  • the fuzzing code generation module 230 may generate the fuzzing source code so that the target function call is executed only once.
  • the test code analysis module 210 may set the range of the target function call. Specifically, when the target function call is made multiple times in the test code, the test code analysis module 210 may set the range of the target function call from the point where the target function call is executed until the next time the target function call is made. .
  • the test code analysis module 210 determines the first function call before the target function call and the second function call after the target function call, and the first function call and The scope of the target function call can be set by using the second function call. This will be described later in detail with reference to FIGS. 5 and 6 .
  • the fuzzing code generation module 230 may generate a fuzzing source code based on the set range of the target function call. Specifically, the fuzzing code generation module 230 may generate a fuzzing source code for the target function call by removing a code that is not in the range of the target function call from within the test code.
  • the function analysis module 220 may analyze the parameters of the called function by using the library code of the function called from the test code.
  • the function analysis module 220 may include a type identification module 221 , a parameter association determination module 222 , a property analysis module 223 , and a size determination module 224 .
  • the type identification module 221 may identify the type of the parameter by analyzing the library code of the function. Specifically, the type identification module 221 may identify a value input to a parameter within a function to determine the attribute of the parameter.
  • the parameter correlation determination module 222 may determine a relationship between the plurality of parameters through analysis of the function.
  • the parameter association determination module 222 configures the first parameter and the second parameter relationship between them can be determined.
  • the fuzzing code generation module 230 may generate a fuzzing source code in which a plurality of parameters related to each other are fuzzed together based on the relationship between the plurality of parameters determined through the parameter association determination module 222 .
  • the property analysis module 223 may determine whether a variable can be assigned to a parameter of a function. Variables here contain numbers or characters that can be read directly from the parameter or as a result of dereferencing the parameter.
  • the fuzzing code generation module 230 may generate a fuzzing source code for allocating a variable value to a parameter from which a variable value is read, based on the analysis result of the property analysis module 223 .
  • the fuzzing code generation module 230 may determine the range of variable values assignable to the parameter based on the determination result of the size determination module 224 , and generate the fuzzing source code based on the determined result.
  • the property analysis module 223 determines whether a variable is read for each field included in the structure, and the field from which the variable is read and the variable are not read. Fields that are not can be identified.
  • the fuzzing code generation module 230 may generate a fuzzing source code for allocating a variable value to a field from which a variable is read among a plurality of fields of the structure.
  • the size determination module 224 may determine the size of the parameter. As described above, the size determination module 224 may operate together with the type identification module 221 , the parameter association determination module 222 , and the property analysis module 223 . On the other hand, it goes without saying that the type identification module 221 , the parameter correlation determination module 222 , the property analysis module 223 and the size determination module 224 may operate together.
  • the function analysis module 220 is illustrated as including a Type identification module 221 , a Parameter association determination module 222 , a Property analysis module 223 , and a Size determination module 224 , but the function analysis module 220 may not necessarily include the Type identification module 221, the Parameter association determination module 222, the Property analysis module 223 and the Size determination module 224, and some components may be omitted or merged. . In addition, the function analysis module 220 may be configured by adding additional modules to the Type identification module 221 , the Parameter association determination module 222 , the Property analysis module 223 and the Size determination module 224 of FIG. 3 . .
  • the fuzzing code generation module 230 may generate a fuzzing code using the test code analysis module 210 and the function analysis module 220 . Specifically, the fuzzing code generation module 230 may generate the fuzzing code based on the determination result of the test code analysis module 210 and the determination result of the function analysis module 220 . In this case, the generated fuzzing code may include not only the fuzzing source code but also the binary test code written in machine language.
  • the processor 120 identifies a parameter for a function called by the test code based on the spread generation system described above in FIGS. 2 and 3 , and based on the identified parameter, calling the function and A related fuzzing source code can be provided. That is, the processor 120 may use the test code analysis module 210, the function analysis module 220, and the fuzzing code generation module 230 described above, the processor 120 includes the test code analysis module 210, All operations of the function analysis module 220 and the fuzzing code generation module 230 may be performed.
  • the processor 120 may identify a function call in the test code based on the test code analysis module 210 .
  • the processor 120 may identify a parameter for the called function using the function analysis module 220 and the library code for the called function.
  • the processor 120 may determine whether a variable can be assigned to a parameter of a function by using the property analysis module 223 .
  • Variables here contain numbers or letters that can be read directly from the parameter or as a result of dereferencing the parameter.
  • the processor 120 may determine a parameter to which a variable value is assigned among parameters of a function, and set a range of values assignable to the determined parameter to generate the fuzzing source code. Specifically, the processor 120 may identify a parameter from which a variable value is read among parameters included in the function by using the property analysis module 223 , and determine a value assignable to the identified parameter.
  • the processor 120 may identify a parameter from which a variable value is read (or read). For example, when the parameter of the function is int A, since an integer is assigned to A, the processor 120 may determine A as a parameter from which a variable value is read. In addition, when the parameter of the function is char*A, if a character can be read from A as a result of dereferencing A, the processor 120 may determine A as a parameter from which a variable value is read. As such, when the parameter is of a pointer type, the processor 120 may determine whether an actual number or character can be read as a result of dereferencing the parameter.
  • the processor 120 may identify a parameter whose variable is not read. For example, if the parameter is int*B and B performs only null pointer check, the processor 120 may determine that the variable cannot be assigned to B because B cannot read the variable value. Also, in the case of the output parameter, the processor 120 may determine that the variable cannot be assigned to the output parameter because the variable value is written instead of being read.
  • the processor 120 determines a field to which a variable value is assigned among a plurality of fields included in the structure, and sets a range of assignable values for each determined field. can Specifically, the processor 120 may determine whether a variable is read for each field included in the structure, and may distinguish a field from which a variable is read and a field from which a variable is not read. In addition, the processor 120 may set a range of allocable values for a field from which a variable is read.
  • the processor 120 may identify the type of the parameter by analyzing the library code of the function based on the type identification module 221 . Specifically, the processor 120 may identify a value input to a parameter within the function to determine the parameter's properties.
  • the processor 120 may analyze the library code to determine whether the parameter uses a single pointer or multiple pointers. In addition, when the parameter is in the form of a pointer, the processor 120 may analyze the library code to determine whether the parameter represents an array or is intended to point to a specific variable. In addition, when the parameter is in the form of an array, the processor 120 may obtain information about the size of the parameter, that is, the size of the array, from the size determination module 224 , and identify the parameter type based on the obtained information.
  • the processor 120 may identify the type of the parameter based on type casting for the pointer parameter in the library function. For example, when the type casting for a point parameter in the library function is (int *), the Type identification module 221 may identify that the parameter points to an int type variable based on the type casting.
  • the processor 120 may determine the type of each of a plurality of fields included in the structure parameter. Specifically, the processor 120 may recursively repeat the operation of identifying the type of one field in the structure by viewing the structure as a set of parameters.
  • the processor 120 may determine a relationship between the plurality of parameters based on the library code for the function.
  • the processor 120 determines the relationship between the first parameter and the second parameter.
  • the second parameter (ie, int len) among the plurality of parameters exists as a loop condition (i ⁇ len) of a variable (eg, i) functioning as an array index of the first parameter in the function, and the array length
  • a predetermined condition eg, len is 10 or less
  • the processor 120 may determine that the first parameter is a parameter indicating an array and the second parameter is a parameter indicating the size of the array.
  • the processor ( 120) may determine that the first parameter is a parameter indicating an array, and the second parameter is a parameter indicating the size of the array.
  • the processor 120 analyzes the operation of the function F3 so that the first parameter (ie, int* a) is a parameter indicating an array, and the second parameter (ie, int i) indicates an index of the array parameters can be determined.
  • the processor 120 may determine the size of the first parameter indicating the arrangement of the above-described functions F1, F2, and F3 using the size determination module 224 .
  • the processor 120 may set a range of values assignable to each of the plurality of parameters based on the relationship between the plurality of parameters determined as described above. Also, the processor 120 may generate a fuzzing source code in which a plurality of parameters related to each other are purged together based on the relationship between the plurality of parameters.
  • FIG. 4 is a diagram for describing an electronic device according to an embodiment of the present disclosure. Specifically, FIG. 4 shows test codes executed in an electronic device according to an embodiment of the present disclosure.
  • the processor 120 may analyze the test code using the test code analysis module 210 described above with reference to FIG. 2 and identify a function call in the test code. In addition, the processor 120 may identify a fuzzable function call among function calls in the test code.
  • the processor 120 may determine whether a variable corresponding to an argument passed to a parameter of the called function and a return value obtained as a result of the function call are declared or referenced in the test code. At this time, when a variable corresponding to an argument passed to a parameter of the called function and a variable corresponding to a return value obtained as a result of calling the function is declared or referenced in the test code, the test code analysis module 210 calls the function It can be determined that purging is possible.
  • the processor 120 determines whether a code region to which the global variable is referenced exists in the test code and fuzzes the function call. It can be judged whether it is possible or not. Specifically, when it is determined that the code region to which the global variable is referenced exists in the test code, the processor 120 may determine that the function call can be fuzzed.
  • the processor 120 identifies a function call (Line 8, Line 12) that calls the function set_id, and the parameters (char* i, char* n, and char of the function set_id). * You can identify the argument id, name, address, and the return value result of the function set_id passed to ad ).
  • the processor 120 may search an area in which the transfer factors id, name, address, and return value result are declared or referenced in the test code.
  • the processor 120 declares the transfer factors name, address, and return value result, that is, variable declarations are made in Lines 4,5,6, and the transfer factors id, name, address and return value result are Lines 8, 9,10 , 12, 13, 14 can be identified.
  • the processor 120 can identify only the region to which the id is referenced, as it is assumed that the id is declared as a global variable.
  • the processor 120 may determine that fuzzing is possible for the function call set_id as a result of searching the area in which the transfer factors id, name, address, and return value result are declared or referenced.
  • test code analysis module 210 may determine that fuzzing is not possible with respect to the call of the corresponding function.
  • the processor 120 may determine the scope of the function call.
  • FIGS. 5 to 7 are diagrams for explaining an electronic device according to an embodiment of the present disclosure. Specifically, a range of a function call is determined and the function call is performed only once when the function is called a plurality of times. It is a diagram for explaining an electronic device.
  • FIG. 5 is a diagram illustrating a case in which one function is repeatedly called within a test code.
  • the fuzzing source code is to input various values to the parameters of the called function while repeating the function call executed in the test code a plurality of times, when the function call is duplicated in the test code, the processor 120 is You can generate fuzzing source code so that the function is called only once.
  • the processor 120 must determine the range of each function call made in the test code.
  • the processor 120 sets a range related to the call of each function in the test code, and generates a fuzzing source code for the called function based on the set range. can do.
  • the processor 120 may use the test code analysis module 210 to classify a range related to a function call in the test code.
  • the processor 120 may determine a range related to the call of the function while searching for the test code while searching for the code above or below the point where the function is called.
  • the processor 120 may determine the range from the start point to the end point as the range of the first function call, using the point where the function is first called in the test code as the starting point and the point before the point where the function is called second as the ending point. Similarly, the processor 120 can determine the range of the second function call from the start point to the end point, using the point at which the function is called the second time in the test code as the starting point, and the point before the point where the function is called for the third time as the ending point. have.
  • the processor 120 sets Line 8, which is the point at which the function is first called, as a starting point, and Line 10, which is before the point where the function is called for the second time. As the end point, Line 8 to Line 10 can be determined as the range of the first function call. Similarly, the processor 120 determines that the range of the second function call is from Line 12 to Line 15, using Line 12, the point at which the function is called second, as the starting point, and Line 16, the point at which the function ends, as the ending point. can do.
  • the processor 120 may determine that the part where the variable is declared in the test code is the scope of all function calls. For example, the processor 120 may determine a range from Line 4 to Line 6 where a variable is declared as the range of the first function call and the second function call.
  • the processor 120 may determine that the range of the first function call is from Line 4 to Line 6 510 and from Line 8 to Line 10 520 . Then, the processor 120 may determine the range of the second function call to be from Line 4 to Line 6 510 and from Line 12 to Line 15 530 .
  • the processor 120 may delete the call of the second function that is duplicated in the test code, and generate a fuzzing source code that repeats the call of the first function by using the fuzzing code generation module 230 .
  • the processor 120 may determine the range of the target function call even when calls of different functions are repeated a plurality of times.
  • FIG. 6 is a diagram for describing an electronic device that determines a range of a target function call when calls of different functions are repeated a plurality of times.
  • the target function call indicates a function call that is a target of fuzzing.
  • the processor 120 may determine the order of all function calls in the test code by using the test code analysis module 210 , and identify a target function call and a function call before or after the target function call.
  • the function call performed before the target function call is called the preAction function call
  • the function call performed after the target function call is called the postAction function call
  • the function call that the target function call requires in common is called the common function call. lets do it.
  • the processor 120 may determine a function call found before searching for a first target function call in the test code as a preAction function call.
  • the processor 120 searches for a second target function call after the first target function call, from the point where the first target function is called to before the second target function is called can be set as the scope of the first target function.
  • the processor 120 may determine whether the function call after the target function call is the postAction function call of the first target function call or the preAction function call of the second target function call. Specifically, when the function call after the first target function call is a preAction function call called before the first target function call, the function call after the first target function call is a preAction function call after the second target function call. can judge Conversely, if the function call after the first target function call is not a preAction function call called before the first target function call, the function call after the first target function call is a postAction function call after the first target function call. can judge
  • the processor 120 may determine that a function call that is called before the first target function call and has never been called since then is a common function call commonly required by each target function call.
  • the processor 120 searches from the beginning to the end of the test code in the above manner, and may determine the range of each target function.
  • the target function call is create_ui(input). It can be seen from the test code of FIG. 6 that the target function call is performed on lines 6, 10, 14, and 18.
  • the processor 120 may determine whether a function call called before the target function call exists while sequentially searching the test code. In the case of FIG. 6 , since the first function call in the test code is create_ui (input), the processor 120 may determine that the preAction function call of the target function call does not exist.
  • the processor 120 may determine whether the function call after the first target function call is a postAction function call of the first target function call or a preAction function call of the second target function call. Since the preAction function call of the first target function does not exist, the processor 120 may determine that the function call after the first target function call is the postAction function call of the first target function call.
  • the processor 120 may perform a search from the beginning to the end of the test code in this way, and as a result of performing the search from the beginning to the end of the test code, the first target function call is Line 6, and the postAction function call of the first target function call is Line 8, the range of the first target function call is Line 6 to Line 8, the second target function call is Line 10, the postAction function call of the second target function call is Line 12, the range of the second target function call is Line 10 to Line 12, the third target function call The function call is Line 14, the postAction function call of the third target function call is Line 16, the range of the third target function call is Line 14 to Line 16, and the fourth target function call is Line 18, the postAction function call of the fourth target function call is Line 20 , it can be determined that the range of the fourth target function call is from Line 18 to Line 20.
  • the processor 120 may remove the second, third, and fourth function call ranges except for the first function call range by using the fuzzing code generation module 230 and generate a fuzzing code that repeatedly executes the test code.
  • the processor 120 may identify a first function that is called before the function is called in the test code and a second function that is called after the function is called. In addition, when the calling patterns of the first function, the called function, and the second function are repeated in the test code, the processor 120 may determine that the called function is repeatedly called in the test code.
  • the processor 120 may generate the fuzzing source code such that the first function, the called function, and the second function are called only once.
  • FIG. 7 shows a test code in which a function call exists in a loop and the function call is made a plurality of times by the loop.
  • the processor 120 may identify a function call existing in the loop and determine the scope of the function call in the loop. At this time, when one function call exists in the loop, the processor 120 functions from the start position of the loop (eg, the position where the loop is declared) to the end position of the loop (eg, curly braces (' ⁇ ')). It can be judged by the scope of the call. Meanwhile, the start position or end position of the loop may vary depending on the programming language. For example, in the case of C language, the end position of the loop may be curly braces (' ⁇ '), but in other programming languages, the end position of the loop may be END.
  • the processor 120 may generate the source code for executing the loop only once so that the function call can be made only once. For example, the processor 120 may execute 'break;' immediately before the end position of the loop. By inserting a command, it is possible to generate a fuzzing source code in which the loop is executed only once and the function call is made only once.
  • the processor 120 may determine that the range of the function is from Line 5, which is the start position of the iteration, to Line 8, which is the end position of the iteration. In this case, the processor 120 may insert a 'break;' just before the curly braces (' ⁇ ') of the loop of Line 8 so that the function can be called only once. Meanwhile, the command indicating the end of the loop is not necessarily limited to 'break;' in that it varies depending on the type of programming language.
  • FIG. 8 is a flowchart illustrating a method of controlling an electronic device according to various embodiments of the present disclosure.
  • the test code stored in the electronic device 100 may be analyzed. Specifically, it is possible to determine the configuration of the test code, and identify a function call within the test code.
  • a parameter for a function called by the test code may be identified using the library code for the function (S801). Specifically, it is possible to identify characteristics of parameters, such as the type and size of the parameter of the called function, whether a variable value is assigned to the parameter, and association between a plurality of parameters.
  • the parameter represents data provided as an input to the function.
  • a fuzzing source code can be generated by determining a field to which a variable value is assigned among a plurality of fields included in the structure type, and setting the range of assignable values for each determined field. have.
  • the fuzzing source code may be generated by determining the type of the identified parameter using the library code for the function, and setting a range of values corresponding to the parameter type based on the determined parameter type.
  • a function has a plurality of parameters
  • at least one parameter to which an input value is assigned among the plurality of parameters is identified, and a range of values assignable to the identified at least one parameter is set to generate a fuzzing source code.
  • computer instructions for performing a processing operation in the electronic device 100 may be stored in a non-transitory computer-readable medium.
  • the specific device When the computer instructions stored in the non-transitory computer-readable medium are executed by the processor of the specific device, the specific device performs the processing operation of the electronic device 100 according to the various embodiments described above.
  • the non-transitory readable medium refers to a medium that stores data semi-permanently, rather than a medium that stores data for a short moment, such as a register, cache, memory, etc., and can be read by a device.
  • a non-transitory readable medium such as a CD, DVD, hard disk, Blu-ray disk, USB, memory card, ROM, and the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

전자 장치가 개시된다. 본 개시에 따른 전자 장치는, 적어도 하나의 함수를 호출하는 테스트 코드(code) 및 적어도 하나의 함수에 대한 라이브러리 코드를 저장하는 메모리 및 테스트 코드가 호출하는 함수에 대한 파라미터(parameter)를 함수에 대한 라이브러리 코드를 이용하여 식별하고, 식별된 파라미터를 기초로 함수의 호출과 관련된 퍼징 소스 코드(Fuzzing source code)를 제공하는 프로세서를 포함한다.

Description

전자 장치 및 이의 제어 방법
본 개시는 전자 장치 및 이의 제어 방법에 관한 것으로, 구체적으로는 테스트 코드에 대한 퍼징 코드(fuzzing code)(또는 퍼저 코드(fuzzer code))를 제공하는 전자 장치 및 이의 제어 방법에 관한 것이다.
소프트웨어 개발자는 자신이 개발한 소프트웨어에 대하여 보안 테스트를 하고자 할 때, 다양한 테스트 방법 중에서 퍼징(fuzzing) 또는 퍼즈 테스트(fuzz test)(이하, 퍼징)를 수행할 수 있다. 퍼징은 소프트웨어 테스트 기법 중 하나로, 컴퓨터 프로그램에 유효하면서도 예상치 않은 무작위의 데이터를 입력하여 소프트웨어가 결함 없이 동작하는지 입증하기 위하여 수행된다.
소프트웨어 개발에 있어서 보안 테스트는 중요한 과정이지만, 소프트웨어 개발자가 퍼징을 수행하기 위해서는, 퍼징 프레임워크(fuzzing framework)에 대한 이해를 필요로 하고, 퍼징 코드(fuzzing code)를 직접 작성해야 하는 부담이 존재하였다.
본 개시는 상술한 문제점을 해결하기 위한 것으로, 구체적으로 소프트웨어 개발자가 개발한 소프트웨어에 대한 퍼징 코드(fuzzing code)를 자동으로 생성하는 전자 장치 및 이의 제어 방법을 제공함에 있다.
본 개시의 일 실시 예에 따른 전자 장치는, 함수를 호출하는 테스트 코드(code) 및 상기 적어도 하나의 함수에 대한 라이브러리 코드를 저장하는 메모리; 및 상기 테스트 코드가 호출하는 함수에 대한 파라미터(parameter)를 상기 함수에 대한 라이브러리 코드를 이용하여 식별하고, 상기 식별된 파라미터를 기초로 상기 호출된 함수에 대한 퍼징 소스 코드(Fuzzing source code)를 제공하는 프로세서를 포함한다.
한편, 본 개시의 또 다른 일 실시 예에 따른 전자 장치의 제어 방법은, 테스트 코드(code)가 호출하는 함수에 대한 파라미터(parameter)를 상기 함수에 대한 라이브러리 코드를 이용하여 식별하는 단계; 및 상기 파라미터를 기초로 상기 호출된 함수에 대한 퍼징 소스 코드(Fuzzing source code)를 제공하는 단계를 포함한다.
도 1은 본 개시의 다양한 실시 예에 따른 전자 장치의 구성을 설명하기 위한 블록도,
도 2는 본 개시의 일 실시 예에 따른 퍼져(fuzzer) 생성 시스템을 설명하기 위한 도면,
도 3은 본 개시의 일 실시 예에 따른 함수 분석 모듈을 설명하기 위한 도면,
도 4 내지 도 7은 본 개시의 일 실시 예에 따른 전자 장치를 설명하기 위한 도면, 및
도 8은 본 개시의 다양한 실시 예에 따른 전자 장치의 제어 방법을 설명하기 위한 흐름도이다.
이하, 본 개시의 다양한 실시 예가 첨부된 도면을 참조하여 기재된다. 그러나, 이는 본 개시에 기재된 기술을 특정한 실시 형태에 대해 한정하려는 것이 아니며, 본 개시의 실시 예의 다양한 변경(modifications), 균등물(equivalents), 및/또는 대체물(alternatives)을 포함하는 것으로 이해되어야 한다. 도면의 설명과 관련하여, 유사한 구성요소에 대해서는 유사한 참조 부호가 사용될 수 있다.
본 개시에서, "가진다," "가질 수 있다," "포함한다," 또는 "포함할 수 있다" 등의 표현은 해당 특징(예: 수치, 기능, 동작, 또는 부품 등의 구성요소)의 존재를 가리키며, 추가적인 특징의 존재를 배제하지 않는다.
본 개시에서, "A 또는 B," "A 또는/및 B 중 적어도 하나," 또는 "A 또는/및 B 중 하나 또는 그 이상"등의 표현은 함께 나열된 항목들의 모든 가능한 조합을 포함할 수 있다. 예를 들면, "A 또는 B," "A 및 B 중 적어도 하나," 또는 "A 또는 B 중 적어도 하나"는, (1) 적어도 하나의 A를 포함, (2) 적어도 하나의 B를 포함, 또는 (3) 적어도 하나의 A 및 적어도 하나의 B 모두를 포함하는 경우를 모두 지칭할 수 있다.
본 개시에서 사용된 "제1," "제2," "첫째," 또는 "둘째,"등의 표현들은 다양한 구성요소들을, 순서 및/또는 중요도에 상관없이 수식할 수 있고, 한 구성요소를 다른 구성요소와 구분하기 위해 사용될 뿐 해당 구성요소들을 한정하지 않는다.
어떤 구성요소(예: 제1 구성요소)가 다른 구성요소(예: 제2 구성요소)에 "(기능적으로 또는 통신적으로) 연결되어((operatively or communicatively) coupled with/to)" 있다거나 "접속되어(connected to)" 있다고 언급된 때에는, 상기 어떤 구성요소가 상기 다른 구성요소에 직접적으로 연결되거나, 다른 구성요소(예: 제3 구성요소)를 통하여 연결될 수 있다고 이해되어야 할 것이다. 반면에, 어떤 구성요소(예: 제1 구성요소)가 다른 구성요소(예: 제2 구성요소)에 "직접 연결되어" 있다거나 "직접 접속되어" 있다고 언급된 때에는, 상기 어떤 구성요소와 상기 다른 구성요소 사이에 다른 구성요소(예: 제 3 구성요소)가 존재하지 않은 것으로 이해될 수 있다.
본 개시에서 사용된 표현 "~하도록 구성된(또는 설정된)(configured to)"은 상황에 따라, 예를 들면, "~에 적합한(suitable for)," "~하는 능력을 가지는(having the capacity to)," "~하도록 설계된(designed to)," "~하도록 변경된(adapted to)," "~하도록 만들어진(made to)," 또는 "~를 할 수 있는(capable of)"과 바꾸어 사용될 수 있다. 용어 "~하도록 구성된(또는 설정된)"은 하드웨어적으로 "특별히 설계된(specifically designed to)" 것만을 반드시 의미하지 않을 수 있다. 대신, 어떤 상황에서는, "~하도록 구성된 장치"라는 표현은, 그 장치가 다른 장치 또는 부품들과 함께 "~할 수 있는" 것을 의미할 수 있다. 예를 들면, 문구 "A, B, 및 C를 수행하도록 구성된(또는 설정된) 부프로세서"는 해당 동작을 수행하기 위한 전용 프로세서(예: 임베디드 프로세서), 또는 메모리 장치에 저장된 하나 이상의 소프트웨어 프로그램들을 실행함으로써, 해당 동작들을 수행할 수 있는 범용 프로세서(generic-purpose processor)(예: CPU(Central Processing Unit) 또는 application processor)를 의미할 수 있다.
본 개시의 다양한 실시 예에 따른 전자 장치는, 예를 들면, 데스크탑 PC, 랩탑 PC, 넷북 컴퓨터, 워크 스테이션, 서버, 스마트폰, 태블릿 PC, 이동 전화기, 영상 전화기, 웨어러블 장치 중 적어도 하나를 포함할 수 있다.
한편, 본 개시에서, 사용자라는 용어는 전자 장치를 사용하는 사람 또는 전자 장치를 사용하는 장치(예: 인공지능 전자 장치)를 지칭할 수 있다.
또한, 본 개시에서 함수는 소프트웨어에서 특정 동작이나 서비스를 수행하는 일정 코드 부분을 나타내는 것으로, 프로그램에 포함되는 함수뿐만 아니라, 서브루틴(subroutine), 루틴(routine), 메소드(method), 프로시저(procedure)와 같은 프로그램 단위를 지칭할 수 있다.
이하에서는 도면을 참조하여 본 개시에 대해 상세히 설명하기로 한다.
도 1은 본 개시의 다양한 실시 예에 따른 전자 장치의 구성을 설명하기 위한 블록도이다. 도 1에 도시된 바와 같이, 전자 장치(100)는 메모리(110) 및 프로세서(120)를 포함한다.
메모리(110)는 전자 장치(100)의 동작에 필요한 각종 프로그램 및 데이터 등을 저장하기 위한 구성요소이다. 메모리(110)는 비휘발성 메모리, 휘발성 메모리, 플래시메모리(flash-memory), 하드디스크 드라이브(HDD) 또는 솔리드 스테이트 드라이브(SSD) 등으로 구현될 수 있다. 메모리(110)는 프로세서(120)에 의해 액세스되며, 프로세서(120)에 의한 데이터의 독취/기록/수정/삭제/갱신 등이 수행될 수 있다. 본 개시에서 메모리라는 용어는 메모리(110), 프로세서(120) 내 롬(미도시), 램(미도시) 또는 전자 장치(100)에 장착되는 메모리 카드(미도시)(예를 들어, micro SD 카드, 메모리 스틱)를 포함할 수 있다.
메모리(110)에는 적어도 하나의 함수를 호출하는 테스트 코드(code) 및 테스트 코드에서 호출되는 적어도 하나의 함수에 대한 라이브러리 코드가 저장될 수 있다. 여기에서, 테스트 코드는 사용자가 작성한 프로그램의 각각의 모듈들이 사용자의 의도대로 정확하게 작동하는지 테스트하기 위한 코드를 나타낸다. 본 개시에서 테스트 코드는 유닛 테스트(unit test) 소스 코드를 의미할 수 있다. 테스트 코드는 프로그램 모듈을 테스트하기 위하여 적어도 하나의 함수를 호출할 수 있다. 이때, 테스트 코드는 API(application programming interface)를 이용하여 특정 함수에 접근할 수 있다. 이를 위하여, 메모리(110)에는 API 정보가 저장되어 있을 수 있다.
그리고, 메모리(110)에는 테스트 코드 내 함수 호출에 대한 퍼징 소스 코드(Fuzzing source code)를 생성하는 퍼져(fuzzer) 생성 시스템을 포함할 수 있다. 이에 대해서는 도 2에서 후술하기로 한다.
프로세서(120)는 메모리(미도시)와 전기적으로 연결되어 전자 장치(100)의 전반적인 동작 및 기능을 제어할 수 있다. 예를 들어, 프로세서(120)는 운영 체제 또는 응용 프로그램을 구동하여 프로세서(120)에 연결된 하드웨어 또는 소프트웨어 구성요소들을 제어할 수 있고, 각종 데이터 처리 및 연산을 수행할 수 있다. 또한, 프로세서(120)는 다른 구성요소들 중 적어도 하나로부터 수신된 명령 또는 데이터를 휘발성 메모리에 로드하여 처리하고, 다양한 데이터를 비휘발성 메모리에 저장할 수 있다.
이를 위해, 프로세서(120)는 해당 동작을 수행하기 위한 전용 프로세서(예, 임베디드 프로세서) 또는 메모리 디바이스에 저장된 하나 이상의 소프트웨어 프로그램을 실행함으로써, 해당 동작들을 수행할 수 있는 범용 프로세서(예: CPU (Central Processing Unit) 또는 application processor)로 구현될 수 있다.
본 개시에서, 프로세서(120)는 디지털 신호를 처리하는 디지털 시그널 프로세서(digital signal processor(DSP), 마이크로프로세서(microprocessor), TCON(Time controller)으로 구현될 수 있다. 다만, 이에 한정되는 것은 아니며, 중앙처리장치(central processing unit(CPU)), MCU(Micro Controller Unit), MPU(micro processing unit), 컨트롤러(controller), 어플리케이션 프로세서(application processor(AP)), GPU(graphics-processing unit) 또는 커뮤니케이션 프로세서(communication processor(CP)), ARM 프로세서 중 하나 또는 그 이상을 포함하거나, 해당 용어로 정의될 수 있다. 또한, 프로세서(120)는 프로세싱 알고리즘이 내장된 SoC(System on Chip), LSI(large scale integration)로 구현될 수도 있고, FPGA(Field Programmable gate array) 형태로 구현될 수도 있다.
프로세서(120)는 테스트 코드가 호출하는 함수에 대한 파라미터(parameter)를 호출된 함수에 대한 라이브러리 코드를 이용하여 식별하고, 식별된 파라미터를 기초로 함수의 호출과 관련된 퍼징 소스 코드를 제공할 수 있다. 여기에서, 함수의 호출과 관련된 퍼징 소스 코드라 함은, 테스트 코드에 포함된 함수 호출을 복수 회 반복하면서 호출되는 함수의 파라미터에 다양한 값을 입력하고, 다양한 입력 값에 따른 출력 값을 기초로 테스트 코드에 오류나 결함이 존재하는지 판단하는 소스 코드를 의미한다. 퍼징 소스 코드는 프로그래밍 언어로 기술될 수 있다. 이때 프로그래밍 언어는 특정 언어에 한정되지 않으며, C, C++, JAVA, Python, Visual Basic 과 같은 다양한 형태의 언어가 될 수 있다.
프로세서(120)는 퍼져 생성 시스템을 이용하여 테스트 코드를 분석할 수 있다. 프로세서(120)는 테스트 코드의 구성을 판단하고, 테스트 코드 내의 함수 호출을 식별할 수 있다. 이때, 프로세서(120)는 API 정보를 기초로 테스트 코드 내의 함수 호출을 식별할 수 있다.
그리고, 프로세서(120)는 퍼져 생성 시스템을 기초로 호출된 함수의 라이브러리 코드를 이용하여 호출된 함수의 파라미터의 타입, 사이즈, 파라미터에 변수 값이 할당되었는지 여부, 복수의 파라미터 간의 연관성과 같은 파라미터의 특징을 식별할 수 있다. 여기에서, 파라미터는 함수의 입력으로 제공되는 데이터를 나타낸다.
프로세서(120) 테스트 코드의 분석 결과 및 라이브러리 코드를 이용하여 식별된 파라미터를 기초로 퍼징 소스 코드를 제공할 수 있다. 구체적으로, 프로세서(120)는 퍼징 소스 코드를 표시하도록 디스플레이(미도시)를 제어할 수 있다. 다만, 이는 일 실시 예일 뿐이며, 프로세서(120)는 통신 인터페이스(미도시)를 통하여 퍼징 소스 코드를 디스플레이 장치(미도시)에 전송할 수도 있다.
사용자는 테스트 코드에 대한 퍼징 코드를 소스 코드 형태로 제공받을 수 있다는 점에서, 사용자는 퍼징 소스 코드에 대한 피드백을 전자 장치(100)에 제공할 수도 있다. 가령, 사용자는 퍼징 소스 코드를 분석하여 파라미터를 수정하거나, 퍼징의 대상이 되는, 테스트 코드 내의 함수를 선택할 수도 있다.
이와 같이, 프로세서(120)는 퍼져 생성 시스템을 이용하여 퍼징 소스 코드를 생성하는바, 본 개시의 퍼져 생성 시스템에 관하여 우선적으로 설명하기로 한다.
도 2는 본 개시의 일 실시 예에 따른 퍼져 생성 시스템을 설명하기 위한 도면이다.
도 2에 도시된 바와 같이, 퍼져 생성 시스템(200)은 테스트 코드 분석 모듈(210), 함수 분석 모듈(220) 및 퍼징 코드 생성 모듈(230)을 포함할 수 있다.
테스트 코드 분석 모듈(210)은 테스트 코드의 구조를 분석하고, 테스트 코드 내 함수 호출을 식별할 수 있다.
구체적으로, 테스트 코드 분석 모듈(210)은 테스트 코드 내 함수 호출 중 퍼징의 대상이 되는 함수 호출(이하, 타겟 함수 호출) 및 이와 연관되는 코드를 검색할 수 있다.
더욱 구체적으로, 테스트 코드 분석 모듈(210)은 호출된 함수의 파라미터에 전달되는 전달 인자(argument) 및 함수 호출 결과 획득되는 리턴 값에 대응되는 변수가 테스트 코드 내에서 선언되거나 참조되었는지를 판단할 수 있다. 이때, 호출된 함수의 파라미터에 전달되는 전달 인자(argument) 및 함수 호출 결과 획득되는 리턴 값에 대응되는 변수가 테스트 코드 내에서 선언되거나 참조된 경우, 테스트 코드 분석 모듈(210)은 해당 함수의 호출에 대하여 퍼징 가능하다고 판단할 수 있다. 반면, 호출된 함수의 파라미터에 전달되는 전달 인자(argument) 및 함수 호출 결과 획득되는 리턴 값에 대응되는 변수가 테스트 코드 내에서 선언되거나 참조된 바 없다면, 테스트 코드 분석 모듈(210)은 해당 함수의 호출에 대하여 퍼징이 불가능하다고 판단할 수 있다.
테스트 코드 분석 모듈(210)은 테스트 코드 내에서 함수 호출의 패턴을 분석하고, 타겟 함수 호출이 반복적으로 실행되는지 판단할 수 있다. 구체적으로, 테스트 코드 분석 모듈(210)은 타겟 함수 호출이 2번 이상인지 판단할 수 있다. 타겟 함수 호출이 2번 이상인 경우, 테스트 코드 분석 모듈(210)은 타겟 함수 호출 이전에 호출되는 제1 함수 호출 및 타겟 함수 호출 이후에 호출되는 제2 함수 호출을 식별하고, 테스트 코드 내에서 제1 함수 호출, 타겟 함수 호출, 및 제2 함수 호출이 반복되는 경우, 타겟 함수 호출이 반복적으로 행해진 것으로 판단할 수 있다.
그리고, 테스트 코드 분석 모듈(210)은 테스트 코드의 반복문 내에서 타겟 함수 호출이 이뤄지는지 판단할 수 있다. 구체적으로, 테스트 코드 분석 모듈(210)은 테스트 코드의 반복문 내에서 타겟 함수 호출이 이뤄지는 경우, 타겟 함수 호출이 반복적으로 실행되는 것으로 판단할 수 있다. 여기에서, 반복문은 C언어의 for문, while문과 같이, 코드의 일부가 반복하여 호출되도록 하는 프로그래밍 문구를 의미한다. 다만, 반복문은 for문, while문에 한정되는 것은 아니며, 프로그래밍 언어에 따라 특정 코드를 반복하도록 설정된 문구가 이에 해당될 수 있다.
테스트 코드 분석 모듈(210)을 통한 분석 결과 타겟 함수 호출이 반복적으로 실행된 것으로 판단된 경우, 퍼징 코드 생성 모듈(230)은 타겟 함수 호출이 1회만 실행되도록 퍼징 소스 코드를 생성할 수 있다.
테스트 코드 분석 모듈(210)은 타겟 함수 호출의 범위를 설정할 수 있다. 구체적으로, 테스트 코드 분석 모듈(210)은 테스트 코드에서 타겟 함수 호출이 복수 회 이뤄지는 경우, 타겟 함수 호출이 실행된 지점부터 다음 회 타겟 함수 호출이 이뤄지기 전까지를 타겟 함수 호출의 범위로 설정할 수 있다.
또한, 테스트 코드에서 타겟 함수 호출이 복수 회 이뤄지는 경우, 테스트 코드 분석 모듈(210)은 타겟 함수 호출 이전의 제1 함수 호출 및 타겟 함수 호출 이후의 제2 함수 호출을 판단하고, 제1 함수 호출 및 제2 함수 호출을 이용하여 타겟 함수 호출의 범위를 설정할 수 있다. 이에 대하여는 도 5 및 도 6에서 구체적으로 후술하기로 한다.
테스트 코드 분석 모듈(210)을 이용하여 타겟 함수 호출의 범위가 설정된 경우, 퍼징 코드 생성 모듈(230)은 설정된 타겟 함수 호출의 범위를 기초로 퍼징 소스 코드를 생성할 수 있다. 구체적으로, 퍼징 코드 생성 모듈(230)은 테스트 코드 내에서 타겟 함수 호출의 범위가 아닌 코드를 제거하여 타겟 함수 호출에 대한 퍼징 소스 코드를 생성할 수 있다.
함수 분석 모듈(220)은 테스트 코드에서 호출된 함수의 라이브러리 코드를 이용하여 호출된 함수의 파라미터를 분석할 수 있다.
도 3은 본 개시의 일 실시 예에 따른 함수 분석 모듈(220)을 설명하기 위한 도면이다. 도 3에 도시된 바와 같이, 함수 분석 모듈(220)은 Type 식별 모듈(221), Parameter 연관성 판단 모듈(222), Property 분석 모듈(223) 및 Size 판단 모듈(224)을 포함할 수 있다.
Type 식별 모듈(221)은 함수의 라이브러리 코드를 분석하여 파라미터의 타입(type)을 식별할 수 있다. 구체적으로, Type 식별 모듈(221)은 함수 내에서 파라미터에 입력되는 값을 식별하여, 파라미터의 속성을 파악할 수 있다.
Parameter 연관성 판단 모듈(222)은 함수가 복수의 파라미터를 포함하는 경우, 함수의 분석을 통하여 복수의 파라미터 간의 관계를 파악할 수 있다.
가령, 복수의 파라미터 중 제1 파라미터가 배열을 할당받는 파라미터이고, 제2 파라미터가 제1 파라미터의 배열의 길이를 할당받는 파라미터인 경우, Parameter 연관성 판단 모듈(222)은 제1 파라미터 및 제2 파라미터 간의 관계를 판단할 수 있다.
이때, 퍼징 코드 생성 모듈(230)은 Parameter 연관성 판단 모듈(222)을 통하여 판단된 복수의 파라미터 간의 관계를 기초로, 서로 연관되는 복수의 파라미터가 함께 퍼징되는 퍼징 소스 코드를 생성할 수 있다.
Property 분석 모듈(223)은 함수의 파라미터에 변수를 할당할 수 있는지 여부를 판단할 수 있다. 여기에서 변수는 파라미터로부터 직접 읽혀지거나 파라미터를 역참조한 결과 읽혀질 있는 숫자 또는 문자를 포함한다.
퍼징 코드 생성 모듈(230)은 Property 분석 모듈(223)의 분석 결과를 기초로, 변수 값이 읽혀지는 파라미터에 변수 값을 할당하는 퍼징 소스 코드를 생성할 수 있다. 이때, 퍼징 코드 생성 모듈(230)은 Size 판단 모듈(224)의 판단 결과를 기초로 파라미터에 할당 가능한 변수 값의 범위를 판단하고, 판단된 결과를 기초로 퍼징 소스 코드를 생성할 수 있다.
한편, Property 분석 모듈(223)은 파라미터가 복수의 필드(field)를 포함하는 구조체인 경우, 구조체에 포함된 각각의 필드에 대하여 변수가 읽혀지는지 판단하고, 변수가 읽혀지는 필드 및 변수가 읽혀지지 않는 필드를 구분할 수 있다. 그리고, 퍼징 코드 생성 모듈(230)은 구조체의 복수의 필드 중 변수가 읽혀지는 필드에 변수 값을 할당하는 퍼징 소스 코드를 생성할 수 있다.
Size 판단 모듈(224)은 파라미터의 크기를 판단할 수 있다. 상술한 바와 같이, Size 판단 모듈(224)은 Type 식별 모듈(221), Parameter 연관성 판단 모듈(222) 및 Property 분석 모듈(223)과 함께 동작할 수 있다. 한편, Type 식별 모듈(221), Parameter 연관성 판단 모듈(222), Property 분석 모듈(223) 및 Size 판단 모듈(224)이 함께 동작할 수 있음은 물론이다.
한편, 도 3에서는 함수 분석 모듈(220)이 Type 식별 모듈(221), Parameter 연관성 판단 모듈(222), Property 분석 모듈(223) 및 Size 판단 모듈(224)을 포함하는 것으로 도시하였으나, 함수 분석 모듈(220)이 반드시 Type 식별 모듈(221), Parameter 연관성 판단 모듈(222), Property 분석 모듈(223) 및 Size 판단 모듈(224)을 포함하지 않을 수도 있으며, 일부 구성 요소는 생략하거나 병합할 수도 있다. 또한, 도 3의 Type 식별 모듈(221), Parameter 연관성 판단 모듈(222), Property 분석 모듈(223) 및 Size 판단 모듈(224)에 추가적으로 모듈을 부가하여 함수 분석 모듈(220)을 구성할 수도 있다.
다시 도 2를 참조하면, 퍼징 코드 생성 모듈(230)은 테스트 코드 분석 모듈(210) 및 함수 분석 모듈(220)을 이용하여 퍼징 코드를 생성할 수 있다. 구체적으로, 퍼징 코드 생성 모듈(230)은 테스트 코드 분석 모듈(210)의 판단 결과 및 함수 분석 모듈(220)의 판단 결과를 기초로 퍼징 코드를 생성할 수 있다. 이때, 생성되는 퍼징 코드는 퍼징 소스 코드 뿐 만 아니라, 기계어로 작성된 바이너리 테스트 코드를 포함할 수도 있다.
다시 도 1을 참조하면, 프로세서(120)는 도 2 및 도 3에서 상술한 퍼져 생성 시스템을 기초로, 테스트 코드가 호출하는 함수에 대한 파라미터를 식별하고, 식별된 파라미터를 기초로 함수의 호출과 관련된 퍼징 소스 코드를 제공할 수 있다. 즉, 프로세서(120)는 상술한 테스트 코드 분석 모듈(210), 함수 분석 모듈(220) 및 퍼징 코드 생성 모듈(230)을 이용할 수 있는 바, 프로세서(120)는 테스트 코드 분석 모듈(210), 함수 분석 모듈(220) 및 퍼징 코드 생성 모듈(230)의 모든 동작을 수행할 수 있다.
가령, 프로세서(120)는 테스트 코드 분석 모듈(210)을 기초로, 테스트 코드에서의 함수 호출을 식별할 수 있다.
그리고, 프로세서(120)는 함수 분석 모듈(220) 및 호출된 함수에 대한 라이브러리 코드를 이용하여 호출되는 함수에 대한 파라미터를 식별할 수 있다.
프로세서(120)는 Property 분석 모듈(223)을 이용하여 함수의 파라미터에 변수를 할당할 수 있는지 여부를 판단할 수 있다. 여기에서 변수는 파라미터로부터 직접 읽을 수 있거나 파라미터를 역참조한 결과 읽을 수 있는 숫자 또는 문자를 포함한다.
구체적으로, 프로세서(120)는 함수의 파라미터 중 변수 값이 할당되는 파라미터를 판단하고, 판단된 파라미터에 할당 가능한 값의 범위를 설정하여 퍼징 소스 코드를 생성할 수 있다. 구체적으로, 프로세서(120)는 Property 분석 모듈(223)을 이용하여 함수에 포함된 파라미터 중 변수 값이 읽혀지는 파라미터를 식별하고, 식별된 파라미터에 할당 가능한 값을 판단할 수 있다.
프로세서(120)는 변수 값이 읽혀지는(또는 read 되는) 파라미터를 식별할 수 있다. 가령, 함수의 파라미터가 int A인 경우, A에는 정수가 할당된다는 점에서, 프로세서(120)는 A를 변수 값이 읽혀지는 파라미터로 판단할 수 있다. 또한, 함수의 파라미터가 char* A 인 경우, A를 역참조한 결과 A로부터 문자를 읽을 수 있다면, 프로세서(120)는 A를 변수 값이 읽혀지는 파라미터로 판단할 수 있다. 이와 같이, 프로세서(120)는 파라미터가 포인터(pointer) 형인 경우, 파라미터를 역참조 한 결과 실제 숫자 또는 문자를 읽을 수 있는지 여부를 판단할 수 있다.
그리고, 프로세서(120)는 변수가 읽혀지지 않은 파라미터를 식별할 수도 있다. 가령, 파라미터가 int* B이고 B가 Null 포인터 체크만 수행한다면, 프로세서(120)는 B는 변수 값을 읽을 수 없다는 점에서 B에 변수를 할당할 수 없다고 판단할 수 있다. 또한, 프로세서(120)는 출력 파라미터의 경우 변수 값이 읽혀지지 않고 써진다는(write된다는) 점에서, 출력 파라미터에 변수를 할당할 수 없다고 판단할 수 있다.
프로세서(120)는 파라미터가 복수의 필드(field)를 포함하는 구조체인 경우, 구조체에 포함된 복수의 필드 중 변수 값이 할당되는 필드를 판단하고, 판단된 필드 각각의 할당 가능한 값의 범위를 설정할 수 있다. 구체적으로, 프로세서(120)는 구조체에 포함된 각각의 필드에 대하여 변수가 읽혀지는지 판단하고, 변수가 읽혀지는 필드 및 변수가 읽혀지지 않는 필드를 구분할 수 있다. 그리고, 프로세서(120)는 변수가 읽혀지는 필드에 대하여 할당 가능한 값의 범위를 설정할 수 있다.
한편, 프로세서(120)는 Type 식별 모듈(221)을 기초로, 함수의 라이브러리 코드를 분석하여 파라미터의 타입(type)을 식별할 수 있다. 구체적으로, 프로세서(120)는 함수 내에서 파라미터에 입력되는 값을 식별하여, 파라미터의 속성을 파악할 수 있다.
가령, 파라미터가 배열(array) 형태인 경우, 프로세서(120)는 라이브러리 코드를 분석하여 파라미터가 단일 포인터를 이용하는지, 다중 포인터를 이용하는지 여부를 판단할 수 있다. 또한, 파라미터가 포인터(pointer) 형태인 경우, 프로세서(120)는 라이브러리 코드를 분석하여 파라미터가 배열을 나타내는 것인지, 특정 변수를 포인터하기 위한 것인지 판단할 수 있다. 또한, 프로세서(120)는 파라미터가 배열 형태인 경우, Size 판단 모듈(224)로부터 파라미터의 사이즈, 즉 배열의 크기 정보를 획득하고, 획득한 정보를 기초로 파라미터의 타입을 식별할 수도 있다.
그리고, 프로세서(120)는 라이브러리 함수 내에서 포인터 파라미터에 대한 타입 캐스팅(type casting)을 기초로, 파라미터의 type을 식별할 수 있다. 가령, 라이브러리 함수 내에서 포인트 파라미터에 대한 타입 캐스팅이 (int *)인 경우, Type 식별 모듈(221)은 타입 캐스팅을 기초로, 파라미터가 int 형 변수를 포인트 하는 것임을 식별할 수 있다.
프로세서(120)는 파라미터가 구조체 형태인 경우, 구조체 파라미터에 포함된 복수의 필드 각각의 타입을 판단할 수 있다. 구체적으로, 프로세서(120)는 구조체를 파라미터의 집합으로 보아, 구조체 내 하나의 필드에 대한 타입을 식별하는 동작을 재귀적으로 반복할 수 있다.
한편, 프로세서(120)는 호출된 함수의 파라미터가 복수 개인 경우, 함수에 대한 라이브러리 코드를 기초로 복수의 파라미터 간의 관계를 판단할 수 있다.
복수의 파라미터 중 제1 파라미터가 배열을 할당 받는 파라미터이고, 제2 파라미터가 제1 파라미터의 배열의 길이를 할당받는 파라미터인 경우, 프로세서(120)는 제1 파라미터 및 제2 파라미터 간의 관계를 판단할 수 있다.
가령, 아래의 함수 F1을 가정하여 설명하도록 한다.
Line 1 void F1(int* a, int len) {
Line 2 int i;
Line 3 for(i=0; i<len; i++)
Line 4 a[i]= i;
Line 5 }
상기 예시와 같이 복수의 파라미터 중 제2 파라미터(즉, int len)가 함수 내에서 제1 파라미터의 배열 인덱스로 기능하는 변수(가령, i)의 반복문 조건(i<len)으로 존재하고, 배열 길이의 기설정된 조건(가령, len은 10 이하)을 만족하는 경우, 프로세서(120)는 제1 파라미터는 배열을 나타내는 파라미터, 제2 파라미터는 배열의 크기를 나타내는 파라미터임을 판단할 수 있다.
한편, 또 다른 실시 예로 아래의 함수 F2를 가정하여 설명하도록 한다.
Line 1 void F2 (int* a, int len) {
Line 2 int k = 10;
Line 3 while(len >= 0)
Line 4 a[--len] = K--;
Line 5 }
상기 예시와 같이, 복수의 파라미터 중 제2 파라미터(int len)가 제1 파라미터의 배열 인덱스로 기능하는 변수이고, 배열 길이의 기설정된 조건(가령, len은 10 이하)을 만족하는 경우, 프로세서(120)는 제1 파라미터는 배열을 나타내는 파라미터, 제2 파라미터는 배열의 크기를 나타내는 파라미터임을 판단할 수 있다.
또 다른 예로, 아래의 함수 F3를 가정하여 설명하도록 한다.
Line 1 void F1(int* a, int i) {
Line 2 int i;
Line 3 for(i=0; i<len; i++)
Line 4 a[i]= i;
Line 5 }
상기 F3와 같은 경우, 프로세서(120)는 함수 F3의 동작을 분석하여 제1 파라미터(즉, int* a)는 배열을 나타내는 파라미터이고, 제2 파라미터(즉, int i)는 배열의 인덱스를 나타내는 파라미터임을 판단할 수 있다.
이때, 프로세서(120)는 Size 판단 모듈(224)을 이용하여 상술한 함수 F1, F2, F3의 배열을 나타내는 제1 파라미터의 크기를 판단할 수도 있다.
그리고, 프로세서(120)는 이와 같이 판단된 복수의 파라미터 간의 관계를 기초로, 복수의 파라미터 각각에 할당 가능한 값의 범위를 설정할 수 있다. 또한, 프로세서(120)는 복수의 파라미터 간의 관계를 기초로, 서로 연관되는 복수의 파라미터가 함께 퍼징되는 퍼징 소스 코드를 생성할 수 있다.
도 4는 본 개시의 일 실시 예에 따른 전자 장치를 설명하기 위한 도면이다. 구체적으로, 도 4는 본 개시의 일 실시 예에 따른 전자 장치에서 실행되는 테스트 코드를 나타낸다.
프로세서(120)는 도 2에서 상술한 테스트 코드 분석 모듈(210)을 이용하여 테스트 코드를 분석하고 테스트 코드 내 함수 호출을 식별할 수 있다. 더불어, 프로세서(120)는 테스트 코드 내의 함수 호출 중 퍼징 가능한 함수 호출을 식별할 수 있다.
구체적으로, 프로세서(120)는 호출된 함수의 파라미터에 전달되는 전달 인자(argument) 및 함수 호출 결과 획득되는 리턴 값에 대응되는 변수가 테스트 코드 내에서 선언되거나 참조되었는지를 판단할 수 있다. 이때, 호출된 함수의 파라미터에 전달되는 전달 인자(argument) 및 함수 호출 결과 획득되는 리턴 값에 대응되는 변수가 테스트 코드 내에서 선언되거나 참조된 경우, 테스트 코드 분석 모듈(210)은 해당 함수의 호출에 대하여 퍼징 가능하다고 판단할 수 있다.
한편, 전달인자 및 리턴 값에 대한 변수 선언 중 테스트 코드 외부에 전역으로 선언된 것이 존재하는 경우, 프로세서(120)는 전역 변수가 참조되는 코드 영역이 테스트 코드 내에 존재하는지 판단하여 함수 호출에 대한 퍼징 가능 여부를 판단할 수 있다. 구체적으로, 프로세서(120)는 전역 변수가 참조되는 코드 영역이 테스트 코드 내에 존재하는 것으로 판단되면, 함수 호출에 대한 퍼징을 할 수 있다고 판단할 수 있다.
예를 들어, 도 4의 테스트 코드를 참조하면, 프로세서(120)는 함수 set_id를 호출하는 함수 호출(Line 8, Line 12)을 식별하고, 함수 set_id의 파라미터(char* i, char* n 및 char* ad )에 전달되는 전달인자 id, name, address 및 함수 set_id의 리턴 값 result를 식별할 수 있다. 그리고, 프로세서(120)는 테스트 코드 내에서 전달인자 id, name, address 및 리턴 값 result가 선언되거나 참조된 영역을 탐색할 수 있다. 프로세서(120)는 전달인자 name, address및 리턴 값 result의 선언, 즉, 변수 선언이 Line 4,5,6 에서 이루어지고, 전달인자 id, name, address 및 리턴 값 result가 Line 8,9,10,12,13,14에서 참조된 것을 식별할 수 있다. 한편, 전달인자 id의 경우 테스트 코드 내에서 변수 선언이 없으므로 프로세서(120)는 id가 전역 변수로 선언된 것으로 보아 id가 참조된 영역만을 식별할 수 있다.
이와 같이, 프로세서(120)는 전달인자 id, name, address및 리턴 값 result가 선언되거나 참조된 영역을 탐색한 결과, 함수 호출 set_id에 대해 퍼징이 가능하다고 판단할 수 있다.
한편, 도 4에 도시된 바와 달리, 함수 호출에서 호출된 함수의 파라미터에 전달되는 전달 인자(argument) 및 함수 호출 결과 획득되는 리턴 값에 대응되는 변수가 테스트 코드 내에서 선언되지 않고 참조되지 않은 경우, 테스트 코드 분석 모듈(210)은 해당 함수의 호출에 대하여 퍼징 불가능하다고 판단할 수 있다.
프로세서(120)는 테스트 코드 내 함수 호출에 대하여 퍼징 가능하다고 판단된 경우, 함수 호출의 범위를 판단할 수 있다.
이와 관련하여, 도 5 내지 도 7은 본 개시의 일 실시 예에 따른 전자 장치를 설명하기 위한 도면으로, 구체적으로 함수 호출의 범위를 판단하고 함수가 복수회 호출되는 경우 함수 호출이 1회만 수행되도록 하는 전자 장치를 설명하기 위한 도면이다.
도 5는 테스트 코드 내에서 하나의 함수가 중복되어 호출되는 경우를 나타낸 도면이다. 상술한 바와 같이, 퍼징 소스 코드는 테스트 코드에서 실행되는 함수 호출을 복수 회 반복하면서 호출되는 함수의 파라미터에 다양한 값을 입력하는 것이기 때문에, 테스트 코드 내에 함수 호출이 중복되는 경우, 프로세서(120)는 함수가 1회만 호출되도록 퍼징 소스 코드를 생성할 수 있다.
이를 위하여, 우선 프로세서(120)는 테스트 코드 내에서 이뤄지는 각 함수 호출의 범위를 판단하여야 한다.
이와 관련하여, 프로세서(120)는 테스트 코드에서 함수가 반복적으로 호출되는 경우, 테스트 코드 내에서 각 함수의 호출과 관련된 범위를 설정하고, 설정된 범위를 기초로 호출된 함수에 대한 퍼징 소스 코드를 생성할 수 있다.
구체적으로, 프로세서(120)는 테스트 코드 분석 모듈(210)을 이용하여 테스트 코드에서 함수의 호출과 관련 있는 범위를 구분할 수 있다. 프로세서(120)는 테스트 코드를 탐색하면서 함수 호출된 지점의 위 또는 아래로 코드를 탐색하면서 함수의 호출과 관련된 범위를 판단할 수 있다.
프로세서(120)는 테스트 코드 내에서 함수가 첫번째로 호출된 지점을 시작점으로 하고, 함수가 두번째로 호출된 지점 이전을 종료점으로 하여, 시작점에서부터 종료점까지를 첫번째 함수 호출의 범위로 판단할 수 있다. 마찬가지로, 프로세서(120)는 테스트 코드 내에서 함수가 두번째로 호출된 지점을 시작점으로 하고, 함수가 세번째로 호출된 지점 이전을 종료점으로 하여, 시작점에서부터 종료점까지를 두번째 함수 호출의 범위로 판단할 수 있다.
가령, 도 5에 도시된 바와 같이, set_id 함수가 반복적으로 호출된 경우, 프로세서(120)는 함수가 첫번째로 호출된 지점인 Line 8을 시작점으로 하고, 함수가 두번째로 호출된 지점 이전인 Line 10을 종료점으로 하여, Line 8에서부터 Line 10까지를 첫번째 함수 호출의 범위로 판단할 수 있다. 마찬가지로, 프로세서(120)는 함수가 두번째로 호출된 지점인 Line 12를 시작점으로 하고, 함수가 종료되는 지점인 Line 16을 종료점으로 하여, Line 12에서부터 Line 15까지를 두 번째 함수 호출의 범위로 판단할 수 있다.
또한, 프로세서(120)는 테스트 코드 내에서 변수가 선언되는 부분은 모든 함수 호출의 범위로 판단할 수 있다. 예를 들어, 프로세서(120)는 변수가 선언되는 부분인 Line 4에서부터 Line 6 까지를 첫번째 함수 호출 및 두번째 함수 호출의 범위로 판단할 수 있다.
즉, 프로세서(120)는 첫번째 함수 호출의 범위를 Line 4에서부터 Line 6 까지(510) 및 Line 8에서부터 Line 10까지(520)로 판단할 수 있다. 그리고, 프로세서(120)는 두번째 함수 호출의 범위를 Line 4에서부터 Line 6 까지(510) 및 Line 12에서부터 Line 15까지(530)로 판단할 수 있다.
그리고, 프로세서(120)는 퍼징 코드 생성 모듈(230)을 이용하여, 테스트 코드에서 중복되는 두번째 함수의 호출을 삭제하고, 첫번째 함수의 호출을 반복하는 퍼징 소스 코드를 생성할 수 있다.
한편, 프로세서(120)는 서로 다른 함수의 호출이 복수 회 반복되는 경우에도, 타겟 함수 호출의 범위를 판단할 수 있다.
도 6은 서로 다른 함수의 호출이 복수 회 반복되는 경우 타겟 함수 호출의 범위를 판단하는 전자 장치를 설명하기 위한 도면이다. 여기에서 타겟 함수 호출은 퍼징의 대상이 되는 함수 호출을 나타낸다.
프로세서(120)는 테스트 코드 분석 모듈(210)을 이용하여 테스트 코드 내의 모든 함수 호출의 순서를 판단하고, 타겟 함수 호출 및 타겟 함수 호출의 이전 또는 이후에 있는 함수 호출을 식별할 수 있다.
먼저, 타겟 함수 호출이 되기 이전에 수행되는 함수 호출을 preAction 함수 호출, 타겟 함수 호출이 된 이후에 수행되는 함수 호출을 postAction 함수 호출, 타겟 함수 호출이 공통으로 필요로 하는 함수 호출을 common 함수 호출이라 하자.
프로세서(120)는 테스트 코드에서 첫번째 타겟 함수 호출을 탐색하기 이전에 탐색되는 함수 호출을 preAction 함수 호출로 판단할 수 있다.
한편, 테스트 코드에서 타겟 함수 호출이 복수 회 반복되는 경우, 프로세서(120)는 첫번째 타겟 함수 호출 이후의 두번째 타겟 함수 호출을 탐색하고, 첫번째 타겟 함수가 호출된 지점부터 두번째 타겟 함수가 호출되기 이전까지를 첫번째 타겟 함수의 범위로 설정할 수 있다.
이와 관련하여, 프로세서(120)는 타겟 함수 호출 이후의 함수 호출이 첫번째 타겟 함수 호출의 postAction 함수 호출인지, 두번째 타겟 함수 호출의 preAction 함수 호출인지 판단할 수 있다. 구체적으로, 프로세서(120)는 첫번째 타겟 함수 호출 이후의 함수 호출이 첫번째 타겟 함수 호출 이전에 호출된 preAction 함수 호출인 경우, 첫번째 타겟 함수 호출 이후의 함수 호출은 두번째 타겟 함수 호출 이후의 preAction 함수 호출로 판단할 수 있다. 반대로, 프로세서(120)는 첫번째 타겟 함수 호출 이후의 함수 호출이 첫번째 타겟 함수 호출 이전에 호출된 preAction 함수 호출이 아닌 경우, 첫번째 타겟 함수 호출 이후의 함수 호출은 첫번째 타겟 함수 호출 이후의 postAction 함수 호출로 판단할 수 있다.
한편, 첫번째 타겟 함수 호출 이전에 호출되고 그 이후로 한번도 호출되지 않은 함수 호출이 존재할 수 있다. 이 경우 프로세서(120)는 첫번째 타겟 함수 호출 이전에 호출되고 그 이후로 한번도 호출되지 않은 함수 호출을 각각의 타켓 함수 호출들이 공통으로 필요로 하는common 함수 호출로 판단할 수 있다.
프로세서(120)는 위와 같은 방식으로 테스트 코드의 처음부터 끝까지 탐색하며, 각각의 타겟 함수의 범위를 판단할 수 있다.
가령, 도 6을 참조하면, 타겟 함수 호출이 create_ui(input)이라고 가정하자. 도 6의 테스트 코드에서 타겟 함수 호출은 Line 6, 10, 14 및 18에서 수행되는 것을 알 수 있다.
프로세서(120)는 테스트 코드를 순차적으로 탐색하면서 타겟 함수 호출 이전에 호출되는 함수 호출이 존재하는지 판단할 수 있다. 도 6의 경우, 테스트 코드에서의 첫번째 함수 호출이 create_ui (input)인 바, 프로세서(120)는 타겟 함수 호출의 preAction 함수 호출은 존재하지 않는 것으로 판단할 수 있다.
그리고, 프로세서(120)는 첫번째 타겟 함수 호출 이후의 함수 호출이 첫번째 타겟 함수 호출의 postAction 함수 호출인지, 두번째 타겟 함수 호출의 preAction 함수 호출인지 판단할 수 있다. 첫번째 타겟 함수의 preAction 함수 호출이 존재하지 않기 때문에, 프로세서(120)는 첫번째 타겟 함수 호출 이후의 함수 호출이 첫번째 타겟 함수 호출의 postAction 함수 호출인 것으로 판단할 수 있다.
프로세서(120)는 이와 같이 테스트 코드의 처음부터 끝까지 탐색을 수행할 수 있으며, 테스트 코드의 처음부터 끝까지 탐색을 수행할 결과, 첫번째 타겟 함수 호출은 Line 6, 첫번째 타겟 함수 호출의 postAction 함수 호출은 Line 8, 첫번째 타겟 함수 호출의 범위는 Line 6 에서 Line 8, 두번째 타겟 함수 호출은 Line 10, 두번째 타겟 함수 호출의 postAction 함수 호출은 Line 12, 두번째 타겟 함수 호출의 범위는 Line 10 에서 Line 12, 세번째 타겟 함수 호출은 Line 14, 세번째 타겟 함수 호출의 postAction 함수 호출은 Line 16, 세번째 타겟 함수 호출의 범위는 Line 14 에서 Line 16 및 네번째 타겟 함수 호출은 Line 18, 네번째 타겟 함수 호출의 postAction 함수 호출은 Line 20, 네번째 타겟 함수 호출의 범위는 Line 18 에서 Line 20임을 판단할 수 있다.
그리고, 프로세서(120)는 퍼징 코드 생성 모듈(230)을 이용하여 첫번째 함수 호출 범위를 제외한 두번째, 세번째 및 네번째의 함수 호출 범위를 제거하고 테스트 코드를 반복 실행하는 퍼징 코드를 생성할 수 있다.
한편, 또 다른 일 실시 예에 따라, 프로세서(120)는 테스트 코드에서 함수가 호출되기 이전에 호출되는 제1 함수 및 함수가 호출된 이후에 호출되는 제2 함수를 식별할 수 있다. 그리고, 프로세서(120)는 테스트 코드 내에서 제1 함수, 호출된 함수 및 제2 함수의 호출 패턴이 반복되는 경우, 호출된 함수가 테스트 코드 내에서 반복적으로 호출된 것으로 판단할 수 있다.
이 경우에도 프로세서(120)는 제1 함수, 호출된 함수 및 제2 함수가 1회만 호출되도록 하는 퍼징 소스 코드를 생성할 수 있다.
한편, 도 7은 반복문 내에서 함수 호출이 존재하여 반복문에 의하여 함수 호출이 복수회 이루어지는 테스트 코드를 나타낸다.
프로세서(120)는 반복문 내에 존재하는 함수 호출을 식별하고, 반복문 내에서의 함수 호출의 범위를 판단할 수 있다. 이때, 프로세서(120)는 반복문 내에 하나의 함수 호출이 존재하는 경우, 반복문의 시작 위치(가령, 반복문 선언된 위치)부터 반복문의 끝 위치(가령, 중괄호('}'))가 표시된 위치를 함수 호출의 범위로 판단할 수 있다. 한편, 반복문의 시작 위치 또는 끝 위치는 프로그래밍 언어에 따라 달라질 수 있다. 가령, C 언어의 경우 반복문의 끝 위치는 중괄호('}')일 수 있지만, 다른 프로그래밍 언어의 경우 반복문의 끝 위치는 END가 될 수도 있다.
이와 같이 반복문 내에 함수 호출이 존재하는 경우, 프로세서(120)는 함수 호출이 1번만 이뤄질 수 있도록 반복문이 한번만 실행되도록 하는 소스 코드를 생성할 수 있다. 가령, 프로세서(120)는 반복문의 끝 위치 바로 이전에 'break;' 명령어를 삽입하여 반복문이 1회만 실행되면서 함수 호출이 한번만 이뤄지는 퍼징 소스 코드를 생성할 수 있다.
가령, 도 7에서 프로세서(120)는 함수의 범위가 반복문의 시작 위치인 Line 5부터 반복문의 끝 위치인 Line 8까지라고 판단할 수 있다. 이때, 프로세서(120)는 함수가 1회만 호출될 수 있도록 Line 8의 반복문의 중괄호('}') 바로 이전에 'break;'를 삽입할 수 있다. 한편, 반복문의 종료를 나타내는 명령어는 프로그래밍 언어의 종류에 따라 다양하다는 점에서, 반드시 'break;'에 한정되는 것만은 아니다.
한편, 도 8은 본 개시의 다양한 실시 예에 따른 전자 장치의 제어 방법을 설명하기 위한 흐름도이다.
우선, 전자 장치(100)에 저장된 테스트 코드를 분석할 수 있다. 구체적으로, 테스트 코드의 구성을 판단하고, 테스트 코드 내의 함수 호출을 식별할 수 있다.
테스트 코드가 호출하는 함수에 대한 파라미터를 함수에 대한 라이브러리 코드를 이용하여 식별할 수 있다(S801). 구체적으로, 호출된 함수의 파라미터의 타입, 사이즈, 파라미터에 변수 값이 할당되었는지 여부, 복수의 파라미터 간의 연관성과 같은 파라미터의 특징을 식별할 수 있다. 여기에서, 파라미터는 함수의 입력으로 제공되는 데이터를 나타낸다.
그리고, 식별된 파라미터를 기초로 함수에 대한 퍼징 소스 코드를 제공할 수 있다(S820).
구체적으로, 함수의 파라미터 중 변수 값이 할당되는 파라미터를 판단할 수 있으며, 판단된 파라미터에 할당 가능한 값의 범위를 설정하여 퍼징 소스 코드를 생성할 수 있다.
이때, 함수의 파라미터가 구조체 타입인 경우, 구조체 타입에 포함된 복수의 필드 중 변수 값이 할당되는 필드를 판단하고, 판단된 필드 각각의 할당 가능한 값의 범위를 설정하여 퍼징 소스 코드를 생성할 수 있다.
또한, 함수에 대한 라이브러리 코드를 이용하여 식별된 파라미터의 타입을 판단하고, 판단된 파라미터의 타입을 기초로 파라미터의 타입에 대응되는 값의 범위를 설정하여 퍼징 소스 코드를 생성할 수 있다.
그리고, 함수의 파라미터가 복수 개인 경우, 복수의 파라미터 중 입력 값이 할당되는 적어도 하나의 파라미터를 식별하고, 식별된 적어도 하나의 파라미터에 할당 가능한 값의 범위를 설정하여 퍼징 소스 코드를 생성할 수 있다.
한편, 함수가 테스트 코드에서 반복적으로 호출되는지 판단할 수 있다. 함수가 반복적으로 호출되는 경우, 호출된 함수가 1회만 호출되도록 하는 퍼징 소스 코드를 생성할 수 있다.
구체적으로, 테스트 코드에서 함수가 호출되기 이전에 호출되는 제1 함수 및 함수가 호출된 후에 호출되는 제2 함수를 식별하고, 테스트 코드 내 제1 함수, 함수 및 제2 함수의 호출이 반복된 경우, 함수가 테스트 코드에서 반복적으로 호출된 것으로 판단할 수 있다.
또한, 함수가 호출된 이후에 호출되는 함수를 식별하고, 함수가 호출된 지점부터 식별된 함수가 호출되기 이전까지를 호출된 함수의 범위로 설정하며, 설정된 함수의 범위를 기초로, 함수에 대한 퍼징 소스 코드를 생성할 수 있다.
한편, 상술한 본 개시의 다양한 실시 예들에 따른 전자 장치(100)에서의 처리동작을 수행하기 위한 컴퓨터 명령어(computer instructions)는 비일시적 컴퓨터 판독 가능 매체(non-transitory computer-readable medium)에 저장될 수 있다. 이러한 비일시적 컴퓨터 판독 가능 매체에 저장된 컴퓨터 명령어는 특정 기기의 프로세서에 의해 실행되었을 때 상술한 다양한 실시 예에 따른 전자 장치(100)의 처리 동작을 상술한 특정 기기가 수행하도록 한다.
비일시적 판독 가능 매체란 레지스터, 캐쉬, 메모리 등과 같이 짧은 순간 동안 데이터를 저장하는 매체가 아니라 반영구적으로 데이터를 저장하며, 기기에 의해 판독(reading)이 가능한 매체를 의미한다. 구체적으로는, 상술한 다양한 어플리케이션 또는 프로그램들은 CD, DVD, 하드 디스크, 블루레이 디스크, USB, 메모리카드, ROM 등과 같은 비일시적 판독 가능 매체에 저장되어 제공될 수 있다.
또한, 이상에서는 본 개시의 바람직한 실시 예에 대하여 도시하고 설명하였지만, 본 개시는 상술한 특정의 실시 예에 한정되지 아니하며, 청구범위에서 청구하는 본 개시의 요지를 벗어남이 없이 당해 개시가 속하는 기술분야에서 통상의 지식을 가진 자에 의해 다양한 변형 실시가 가능한 것은 물론이고, 이러한 변형실시들은 본 개시의 기술적 사상이나 전망으로부터 개별적으로 이해돼서는 안 될 것이다.

Claims (15)

  1. 전자 장치에 있어서,
    적어도 하나의 함수를 호출하는 테스트 코드(code) 및 상기 적어도 하나의 함수에 대한 라이브러리 코드를 저장하는 메모리; 및
    상기 테스트 코드가 호출하는 함수에 대한 파라미터(parameter)를 상기 함수에 대한 라이브러리 코드를 이용하여 식별하고, 상기 식별된 파라미터를 기초로 상기 함수의 호출과 관련된 퍼징 소스 코드(Fuzzing source code)를 제공하는 프로세서;를 포함하는 전자 장치.
  2. 제1항에 있어서,
    상기 프로세서는,
    상기 함수의 파라미터 중 변수 값이 할당되는 파라미터를 판단하고,
    상기 판단된 파라미터에 할당 가능한 값의 범위를 설정하여 퍼징 소스 코드를 생성하는, 전자 장치.
  3. 제2항에 있어서,
    상기 프로세서는,
    상기 함수의 파라미터가 구조체 타입인 경우, 상기 구조체 타입에 포함된 복수의 필드(field) 중 변수 값이 할당되는 필드를 판단하고, 상기 판단된 필드 각각의 할당 가능한 값의 범위를 설정하여 퍼징 소스 코드를 생성하는, 전자 장치.
  4. 제1항에 있어서,
    상기 프로세서는,
    상기 함수에 대한 라이브러리 코드를 이용하여 상기 식별된 파라미터의 타입(type)을 판단하고, 상기 판단된 파라미터의 타입을 기초로 상기 파라미터의 타입에 대응되는 값의 범위를 설정하여 퍼징 소스 코드를 생성하는, 전자 장치.
  5. 제1항에 있어서,
    상기 프로세서는,
    상기 함수의 파라미터가 복수 개인 경우, 상기 함수에 대한 라이브러리 코드를 기초로 상기 복수의 파라미터 간의 관계를 판단하고, 상기 판단된 복수의 파라미터 간의 관계를 기초로, 상기 복수의 파라미터 각각에 할당 가능한 값의 범위를 설정하여 퍼징 소스 코드를 생성하는, 전자 장치.
  6. 제1항에 있어서,
    상기 프로세서는,
    상기 함수의 파라미터가 복수 개인 경우, 상기 복수의 파라미터 중 입력 값이 할당되는 적어도 하나의 파라미터를 식별하고, 상기 식별된 적어도 하나의 파라미터에 할당 가능한 값의 범위를 설정하여 퍼징 소스 코드를 생성하는, 전자 장치.
  7. 제1항에 있어서,
    상기 프로세서는,
    상기 함수가 상기 테스트 코드에서 반복적으로 호출되는지 판단하고, 상기 함수가 반복적으로 호출되는 경우, 상기 함수가 1회만 호출되도록 하는 퍼징 소스 코드를 생성하는, 전자 장치.
  8. 제7항에 있어서,
    상기 프로세서는,
    상기 테스트 코드에서 상기 함수가 호출되기 이전에 호출되는 제1 함수 및 상기 함수가 호출된 후에 호출되는 제2 함수를 식별하고, 상기 테스트 코드 내 상기 제1 함수, 상기 함수 및 상기 제2 함수의 호출이 반복된 경우, 상기 함수가 상기 테스트 코드에서 반복적으로 호출된 것으로 판단하는, 전자 장치.
  9. 제7항에 있어서,
    상기 프로세서는,
    상기 함수가 반복적으로 호출되는 경우, 상기 테스트 코드 내에서 상기 함수의 호출과 관련된 범위를 설정하고,
    상기 설정된 범위를 기초로 상기 호출된 함수에 대한 퍼징 소스 코드를 생성하는, 전자 장치.
  10. 제1항에 있어서,
    상기 프로세서는,
    상기 함수의 파라미터에 전달되는 전달인자(argument) 및 상기 함수의 리턴 값에 대한 변수 선언(variable declaration)이 상기 테스트 코드에 존재하는지 판단하고, 상기 변수 선언이 존재하는 경우, 상기 함수 호출에 대한 퍼징이 가능하다고 판단하는, 전자 장치.
  11. 전자 장치의 제어 방법에 있어서,
    테스트 코드(code)가 호출하는 함수에 대한 파라미터(parameter)를 상기 함수에 대한 라이브러리 코드를 이용하여 식별하는 단계; 및
    상기 식별된 파라미터를 기초로 상기 함수에 대한 퍼징 소스 코드(Fuzzing source code)를 제공하는 단계;를 포함하는, 제어 방법.
  12. 제11항에 있어서,
    상기 함수의 파라미터 중 변수 값이 할당되는 파라미터를 판단하는 단계;
    상기 판단된 파라미터에 할당 가능한 값의 범위를 설정하여 퍼징 소스 코드를 생성하는 단계;
    상기 함수의 파라미터가 구조체 타입인 경우, 상기 구조체 타입에 포함된 복수의 필드(field) 중 변수 값이 할당되는 필드를 판단하는 단계; 및
    상기 판단된 필드 각각의 할당 가능한 값의 범위를 설정하여 퍼징 소스 코드를 생성하는 단계;를 더 포함하는, 제어 방법.
  13. 제11항에 있어서,
    상기 함수에 대한 라이브러리 코드를 이용하여 상기 식별된 파라미터의 타입(type)을 판단하는 단계; 및
    상기 판단된 파라미터의 타입을 기초로 상기 파라미터의 타입에 대응되는 값의 범위를 설정하여 퍼징 소스 코드를 생성하는 단계;를 더 포함하는, 제어 방법.
  14. 제11항에 있어서,
    상기 함수의 파라미터가 복수 개인 경우, 상기 함수에 대한 라이브러리 코드를 기초로 상기 복수의 파라미터 간의 관계를 판단하는 단계; 및
    상기 판단된 복수의 파라미터 간의 관계를 기초로, 상기 복수의 파라미터 각각에 할당 가능한 값의 범위를 설정하여 퍼징 소스 코드를 생성하는 단계;를 더 포함하는, 제어 방법.
  15. 전자 장치의 제어 방법을 실행하기 위한 프로그램을 포함하는 컴퓨터 판독가능 기록매체 있어서,
    테스트 코드(code)가 호출하는 함수에 대한 파라미터(parameter)를 상기 함수에 대한 라이브러리 코드를 이용하여 식별하는 단계; 및
    상기 파라미터를 기초로 상기 함수에 대한 퍼징 소스 코드(Fuzzing source code)를 제공하는 단계;를 포함하는, 기록 매체.
PCT/KR2021/000884 2020-03-16 2021-01-22 전자 장치 및 이의 제어 방법 WO2021187743A1 (ko)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
KR1020200031929A KR20210115728A (ko) 2020-03-16 2020-03-16 전자 장치 및 이의 제어 방법
KR10-2020-0031929 2020-03-16

Publications (1)

Publication Number Publication Date
WO2021187743A1 true WO2021187743A1 (ko) 2021-09-23

Family

ID=77771096

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/KR2021/000884 WO2021187743A1 (ko) 2020-03-16 2021-01-22 전자 장치 및 이의 제어 방법

Country Status (2)

Country Link
KR (1) KR20210115728A (ko)
WO (1) WO2021187743A1 (ko)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20180076550A (ko) * 2016-12-28 2018-07-06 충남대학교산학협력단 다중 함수 정적 분석 장치 및 방법
KR20180105688A (ko) * 2016-01-24 2018-09-28 사이드 캄란 하산 인공 지능을 기반으로 한 컴퓨터 보안

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20180105688A (ko) * 2016-01-24 2018-09-28 사이드 캄란 하산 인공 지능을 기반으로 한 컴퓨터 보안
KR20180076550A (ko) * 2016-12-28 2018-07-06 충남대학교산학협력단 다중 함수 정적 분석 장치 및 방법

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
JANG JOON UN, HUY KANG KIM: "Automated Applying Greybox Fuzzing to C/C++ Library Using Unit Test", JOURNAL OF THE KOREA INSTITUTE OF INFORMATION SECURITY & CRYPTOLOGY, 1 August 2019 (2019-08-01), pages 807 - 819, XP055851820, Retrieved from the Internet <URL:http://koreascience.or.kr/article/JAKO201926072346451.pdf> DOI: 10.13089/JKIISC.2019.29.4.807 *
KELLY MATTHEW; TREUDE CHRISTOPH; MURRAY ALEX: "A Case Study on Automated Fuzz Target Generation for Large Codebases", 2019 ACM/IEEE INTERNATIONAL SYMPOSIUM ON EMPIRICAL SOFTWARE ENGINEERING AND MEASUREMENT (ESEM), IEEE, 19 September 2019 (2019-09-19), pages 1 - 6, XP033635350, DOI: 10.1109/ESEM.2019.8870150 *
KIM MINHO, PARK SEONGBIN, YOON JINO, KIM MINSOO, NOH BONG-NAM: "File Analysis Data Auto-Creation Model For Peach Fuzzing", JOURNAL OF THE KOREA INSTITUTE OF INFORMATION SECURITY AND CRYPTOLOGY, vol. 24, no. 2, 30 April 2014 (2014-04-30), pages 327 - 333, XP055851821, ISSN: 1598-3986, DOI: 10.13089/JKIISC.2014.24.2.327 *

Also Published As

Publication number Publication date
KR20210115728A (ko) 2021-09-27

Similar Documents

Publication Publication Date Title
WO2014035043A1 (ko) 악성 애플리케이션 진단 장치 및 방법
US7275239B2 (en) Run-time wait tracing using byte code insertion
WO2020253034A1 (zh) 客户端埋点测试方法、装置、设备及存储介质
WO2017213400A1 (en) Malware detection by exploiting malware re-composition variations
US11989292B2 (en) Analysis function imparting device, analysis function imparting method, and recording medium
WO2020253112A1 (zh) 测试策略的获取方法、装置、终端及可读存储介质
WO2013191458A1 (en) License verification method and apparatus, and computer readable storage medium storing program therefor
WO2022260254A1 (ko) 전이학습을 통한 적응형 모델 기반의 온 디바이스 안드로이드 악성코드 탐지 방법, 이를 수행하기 위한 기록 매체 및 장치
WO2019231194A1 (ko) 메모리 오류를 검출하는 방법 및 시스템
WO2021045428A1 (en) Method and apparatus for improving runtime performance after application update in electronic device
WO2017126786A1 (ko) 악성 코드 분석을 위한 전자 장치 및 이의 방법
WO2022114392A1 (ko) 특성 선택에 기반한 모바일 악성 코드 분류 방법, 이를 수행하기 위한 기록 매체 및 장치
WO2016085272A1 (ko) 소스 코드의 오류 검출에 있어서 오경보 저감 방법, 이를 위한 컴퓨터 프로그램, 그 기록매체
WO2018236141A1 (ko) 크래시 리포트 그룹핑 방법, 서버 및 컴퓨터 프로그램
WO2021187743A1 (ko) 전자 장치 및 이의 제어 방법
WO2020050455A1 (ko) 시그니처 추출을 이용한 분석회피기법 자동 인식 장치 및 그 방법
EP3570173B1 (en) Equivalence verification apparatus and equivalence verification program
WO2022163908A1 (ko) 애플리케이션 내부의 데이터 유출 위험성 평가 방법, 이를 수행하기 위한 기록 매체 및 장치
WO2023229065A1 (ko) 리버싱 엔진과 cdr 엔진을 활용한 악성 비실행 파일 차단 방법 및 장치
WO2023282500A1 (ko) 슬라이드 스캔 데이터의 자동 레이블링 방법, 장치 및 프로그램
WO2022145723A1 (en) Method and apparatus for detecting layout
US6611924B1 (en) Reducing code size of debug output statements
WO2018043885A1 (ko) 악성코드탐지시스템 및 악성코드 탐지 방법
WO2022097799A1 (ko) 함수 요약 정보를 생성하는 보안 취약점 분석 방법 및 이를 포함하는 전자 장치{security vulnerability analysis method for generating function abstract information and electronic device including the same}
WO2016108677A1 (ko) 웹 컨텐츠 출력 장치 및 방법

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21771087

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21771087

Country of ref document: EP

Kind code of ref document: A1