A static measurement method and system for urban rail interlocking software code
By identifying and shielding protective codes in urban rail interlocking software and using regular matching replacement technology, the problem of protective codes affecting static testing is solved, and accurate security assessment of urban rail interlocking software codes is achieved.
Patent Information
- Application Number
- CN202010876151.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-25
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2040-08-25
AI Technical Summary
When the existing technology performs static testing on urban rail interlocking software, protective code is regarded as unreachable code, which affects the static measurement results and makes developers unable to clearly evaluate the security of the code.
By identifying and shielding different types of protective code, using regular matching replacement to convert them into comments that can be recognized by static measurement tools, thereby eliminating their impact during static testing, and judging based on the number and proportion of protective code Safety of function,tuning static metrics.
It achieves more accurate static measurement of urban rail interlocking software code, helps developers more clearly evaluate the security of the code, and avoids the problem of untrustworthy test results caused by protective code interference.
Smart Images

Figure CN112182572B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and system for static measurement of urban rail interlocking software codes. Background Art
[0002] In the current urban rail interlocking software, for safety reasons, protective codes are often written in the code. These protective codes do not affect the normal use of the software, but are mainly used to prevent parameter transmission errors or other possible small probability errors during the use of the software.
[0003] Since these protective codes are often regarded as unreachable codes in normal software static testing, they will affect the static measurement results of normal codes when performing regular software code static testing. In addition, testers often regard the above protective codes as errors in the writing of the code itself, and thus cannot clearly understand the product security related to the test code.
[0004] For urban rail interlocking code, every time a static measurement analysis is performed, a large number of redundant codes for protection and safety will appear, which will affect the results. There is an urgent need to provide a more accurate static measurement method for urban rail interlocking software code. Summary of the invention
[0005] The embodiment of the present invention provides a method and system for static measurement of urban rail interlocking software code, which is used to solve the defect in the prior art that when analyzing the code, the protective code is regarded as an unreachable code, thereby causing the static measurement result to be unreliable, so that developers and development verification personnel can more clearly and intuitively understand the security of the code when evaluating the test code.
[0006] In a first aspect, an embodiment of the present invention provides a method for static measurement of urban rail interlocking software code, mainly comprising: obtaining the type of each protective code in the urban rail interlocking software; shielding the protective code according to the type of the protective code; and statically measuring the shielded urban rail interlocking software.
[0007] Optionally, the above-mentioned shielding processing of the defensive code according to the type of the defensive code mainly includes: using a regular matching replacement method, according to the different types of the defensive code, replacing the defensive code with different annotations that can be recognized by the static measurement tool to achieve shielding processing of the defensive code.
[0008] Optionally, after static measurement is performed on the shielded urban rail interlocking software, the method may further include: obtaining the number of each type of protective code contained in each function in the urban rail interlocking software according to the result of the static measurement; determining the proportion of each type of protective code according to the number of each type of protective code contained in each function in the urban rail interlocking software; judging whether the function meets the preset conditions according to the proportion of each type of protective code contained in each function and in combination with the static measurement result; if the function meets the preset conditions, lowering the standard of the static measurement, and re-statically measuring the shielded urban rail interlocking software; if the result of the static measurement is still unqualified, modifying the protective code in the function.
[0009] Optionally, the above static measurement results mainly include: the total number of lines of code, the number of functions, branch complexity, cyclomatic complexity, fan-out number, fan-in number and code depth.
[0010] Optionally, judging whether the function meets the preset condition according to the proportion of each type of protective code contained in each function and in combination with the static measurement result mainly includes: comparing the proportion of each type of protective code contained in each function with a first threshold; comparing the cyclomatic complexity in the static measurement result with a second threshold; comparing the fan-out number in the static measurement result with a third threshold; on the basis that the proportion is greater than the first threshold, if the cyclomatic complexity is greater than the second threshold or the fan-out number is greater than the third threshold, judging that the function does not meet the preset condition; otherwise, judging that the function meets the preset condition.
[0011] Optionally, if the proportion is not greater than the first threshold, the judgment function meets the preset conditions; or on the basis that the proportion is greater than the first threshold, if the cyclomatic complexity is not greater than the second threshold or the fan-out number is not greater than the third threshold, the judgment function meets the preset conditions.
[0012] Optionally, the defensive code comprises interlock assertion guard code.
[0013] In a second aspect, an embodiment of the present invention further provides a static measurement system for urban rail interlocking software code, comprising: a code identification unit for obtaining the type of each protective code in the urban rail interlocking software; a shielding processing unit for shielding the protective code according to the type of the protective code; and a static measurement unit for statically measuring the urban rail interlocking software after shielding.
[0014] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the static measurement method for the urban rail interlocking software code as described in any one of the above are implemented.
[0015] In a fourth aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above-described methods for static measurement of urban rail interlocking software codes.
[0016] The urban rail interlocking software code static measurement method and system provided in the embodiment of the present invention identify the type of protective codes that have to be written for some reasons, shield the protective codes that do not affect the normal use of the software during static testing, so as to achieve the test of the normal execution code, and visualize the number and proportion of protective codes as a metric, so that developers and development verification personnel can more clearly and intuitively obtain the security of the code when evaluating the software code. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 It is a flow chart of a static measurement method of urban rail interlocking software code provided by an embodiment of the present invention;
[0019] Figure 2 It is a flow chart of another method for static measurement of urban rail interlocking software code provided by an embodiment of the present invention;
[0020] Figure 3 A schematic diagram of the structure of a static measurement system for urban rail interlocking software code provided by an embodiment of the present invention;
[0021] Figure 4 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0023] Static testing of software code includes code checking, static structure analysis, code quality measurement, etc. It can be performed manually to give full play to the advantages of human logical thinking, or it can be performed automatically with the help of software tools. The static measurement method of urban rail interlocking software code proposed in the embodiment of the present invention is mainly performed with the help of relevant software measurement tools.
[0024] Among them, code inspection includes code walkthrough, desktop inspection, code review, etc., mainly checking the consistency of code and design, code compliance with standards, readability, correctness of code logic expression, rationality of code structure, etc., which can find problems that violate program writing standards, unsafe, unclear and ambiguous parts of the program, find out the non-portable parts of the program, and problems that violate the programming style of the program, including variable inspection, naming and type review, program logic review, program syntax inspection and program structure inspection. Static structure analysis will describe the static relationship between objects and classes, and simulate the static structure of objective things by establishing various static connections between objects and classes.
[0025] Static analysis tools are generally divided into static measurement tools and static inspection tools. Among them, static inspection tools mainly discover potential faults hidden in the code through scanning, while the purpose of static measurement is mainly to measure the static complexity of the code, generally including obtaining the number of code lines, the number of functions, etc., and can also include obtaining branch complexity, cyclomatic complexity, code depth, etc. By obtaining these data, the current code size and complexity can be intuitively obtained; and the complexity measurement results can provide visual data for code analysis and provide guidance for code refactoring; the complexity measurement results can also be used to measure the refactoring effect of the code.
[0026] The embodiment of the present invention provides a method for static measurement of urban rail interlocking software code, such as Figure 1 As shown, including but not limited to the following steps:
[0027] Step S1: Obtain the type of each protective code in the urban rail interlocking software;
[0028] Step S2: shielding the protective code according to the type of the protective code;
[0029] Step S3: statically measure the urban rail interlocking software after the shielding process.
[0030] In view of the existing technology, during each static measurement of the urban rail interlocking code, a large number of redundant codes for protection and security that affect the measurement results appear, which are regarded as errors in the writing of the code itself, resulting in the inability to carry out static testing of the software code normally, or the test results are far from achieving the expected effect, increasing the investment in manpower and material resources.
[0031] In an embodiment of the present invention, the tester can record the common protective codes and redundant code formats before the first static code measurement of the interlocking software, and input them during the static measurement. During the specific test, the protective codes and redundant codes are first recorded, and the number of codes of each type and the proportion of protective codes to the total codes are analyzed. Then, each protective code is shielded according to the different types of protective codes. Finally, the shielded urban rail interlocking software can continue to detect other subsequent static measurement items.
[0032] For example, interlock assertion protection code is a common protective code. Its function is to throw an error when the judgment condition is wrong, causing the interlock to crash or power on and lock. This assertion protection is often written in a judgment branch or as the beginning parameter check and the ending condition check. The running judgment conditions of these assertions are often impossible to meet, so unreachable code will appear during static measurement.
[0033] In order to overcome the influence of protective codes such as unreachable codes on static metrics, in an embodiment of the present invention, according to different types of protective codes, corresponding shielding processing methods are adopted for each type of code to achieve shielding processing of each protective code. The embodiment of the present invention does not specifically limit the specific shielding processing tools and processing methods used.
[0034] Finally, code static measurement tools such as Findbugs or Checkstyle are used to perform static measurement on the shielded urban rail interlocking software.
[0035] The urban rail interlocking software code static measurement method provided by the embodiment of the present invention identifies the type of protective codes that have to be written for some reasons, shields the protective codes that do not affect the normal use of the software during static testing, so as to achieve the test of the normal execution code, and visualizes the number and proportion of protective codes as a metric, so that developers and development verifiers can more clearly and intuitively obtain the security of the code when evaluating the software code.
[0036] Based on the content of the above embodiment, as an optional embodiment, the shielding processing of the protective code according to the type of the protective code described in the above step S2 may include: using a regular matching replacement method, according to different types of protective codes, replacing the protective code with different annotations that can be recognized by static measurement tools, so as to achieve shielding processing of the protective code.
[0037] Regular expression is a logical formula for string operation, which is to use some pre-defined specific characters and the combination of these specific characters to form a regular string. This regular string is used to express a filtering logic for the string. It is a shielding processing method that can be used for searching, matching, processing, replacing and converting strings, input and output operations, etc. And various languages support regular expressions, such as .NET regular library, JDK regular package, Perl, JavaScript and other scripting languages.
[0038] Specifically, in the embodiment of the present invention, after the protective codes in the urban rail interlocking software are marked by type in step 1, in step S2, according to different types, regular matching and replacement are adopted to shield each protective code using different annotation strings that can be recognized by the static measurement tool. Finally, static measurement is performed on the shielded urban rail interlocking software.
[0039] The urban rail interlocking software code static measurement method provided in the embodiment of the present invention adopts a method of shielding different types of protective codes using different annotations that can be recognized by static measurement tools to achieve the test of the shielded execution code, so that developers and development verification personnel can more clearly and intuitively obtain the security of the code when evaluating the software code.
[0040] Based on the content of the above embodiments, as an optional embodiment, after static measurement is performed on the urban rail interlocking software after the shielding process, it can also include: according to the result of the static measurement, obtaining the number of each type of protective code contained in each function in the urban rail interlocking software; according to the number of each type of protective code contained in each function in the urban rail interlocking software, determining the proportion of each type of protective code; according to the proportion of each type of protective code contained in each function, and in combination with the static measurement result, judging whether the function meets the preset conditions; if the function meets the preset conditions, lowering the standard of static measurement, and re-statically measuring the urban rail interlocking software after the shielding process; if the result of the static measurement is still unqualified, modifying the protective code in the function.
[0041] Since the defensive code is in a fixed format, the number of defensive codes contained in each function in this measurement can be matched using a method similar to regular expression matching, and the proportion of defensive code in this function can be calculated by comparing the number of code lines occupied after expansion with the total number of code lines.
[0042] However, in the urban rail interlocking software, there may be some functions that do not meet the requirements in the static measurement results due to problems such as high branch complexity, and need to be modified. However, considering its safety nature, it is not recommended to make excessive modifications. At this time, if the proportion of protective code is combined, the code security can be estimated, thereby evaluating the difficulty of code reconstruction. The preset conditions for judging whether the modification is safe can be preset. The preset conditions are set by combining the proportion of each type of protective code contained in the function with static measurement results such as branch complexity. When the function meets the preset conditions, the requirements for other measurement judgment results such as cyclomatic complexity are appropriately relaxed, and the urban rail interlocking software after shielding is re-measured statically. Because other measurement results, especially cyclomatic complexity and fan-in fan-out, are the main aspects of judging code quality, but if the function is considered to have reached a certain standard of security after judging the number or proportion of protective codes, it means that this function should not be modified, and the standards for static measurement of other codes are relaxed. If it is still not satisfied, the code body is modified. Furthermore, if the function does not meet the preset condition, modification of the protective code in the function is not allowed, or modification can be made after further security assessment by R&D personnel.
[0043] The static measurement method for urban rail interlocking software code provided by the embodiment of the present invention distinguishes the protective nature code and includes it in the static measurement range, so as to make a rough assessment of the safety of the code-related products according to the number of protective codes. For the urban rail interlocking code, after each static measurement analysis, for a large number of protective and safety redundant codes that affect the results, appropriate modifications are made according to the safety evaluation results, without affecting the safety of the product, so that developers and development verification personnel can more clearly and intuitively understand the safety of the code when performing static evaluation on the code.
[0044] Based on the content of the above embodiment, as an optional embodiment, the static measurement results described in step S3 may include but are not limited to: the total number of lines of code, the number of functions, branch complexity, cyclomatic complexity, fan-out number, fan-in number and code depth.
[0045] The same problem can be solved by different algorithms, and the quality of an algorithm will affect the efficiency of the algorithm and even the program. Branch complexity is a parameter used to measure the difficulty of testing and maintaining software programs based on the number of layers of software code branches. Branch complexity indicates that program code testing and maintenance are difficult.
[0046] Among them, cyclomatic complexity is a measure of code complexity. In the concept of software testing, cyclomatic complexity is used to measure the complexity of a module's judgment structure. It is quantitatively expressed as the number of linearly independent paths, that is, the minimum number of paths required for reasonable error prevention. A high cyclomatic complexity indicates that the program code may be of low quality and difficult to test and maintain.
[0047] The urban rail interlocking software code static measurement method provided in the embodiment of the present invention performs static testing on the shielded urban rail interlocking software execution code by reasonably setting static measurement objects, so that developers and development verification personnel can more clearly and intuitively obtain the security of the code when evaluating the software code.
[0048] Based on the content of the above embodiment, as an optional embodiment, judging whether a function meets the preset condition according to the proportion of each type of defensive code contained in each function and in combination with the static measurement result may include: comparing the proportion of each type of defensive code contained in each function with a first threshold; comparing the cyclomatic complexity in the static measurement result with a second threshold; comparing the fan-out number in the static measurement result with a third threshold; on the basis that the proportion is greater than the first threshold, if the cyclomatic complexity is greater than the second threshold or the fan-out number is greater than the third threshold, judging that the function does not meet the preset condition; otherwise, judging that the function meets the preset condition. .
[0049] Further, if the proportion is less than the first threshold, the judgment function meets the preset conditions; or on the basis that the proportion is greater than the first threshold, if the cyclomatic complexity is not greater than the second threshold or the fan-out number is not greater than the third threshold, the judgment function meets the preset conditions.
[0050] As an optional embodiment, the embodiment of the present invention provides a method for static measurement of urban rail interlocking software code, such as Figure 2 As shown, including but not limited to the following steps:
[0051] Step Q1: The tester determines and obtains the type of protective code in each function in the urban rail interlocking software through the software developer.
[0052] Step Q2: Calculate the number of defensive codes contained in each function in this measurement, and the proportion of defensive codes in the function.
[0053] Step Q3: According to the different types of each protective code, a corresponding shielding processing method is adopted to complete the shielding processing of the protective code.
[0054] Step Q4: Perform static measurement on the shielded urban rail interlocking software to obtain the cyclomatic complexity, number of nested conditions (branch complexity), total number of code lines, number of comment lines (or number of protective code lines), comment code ratio (or protective code ratio), fan-in and fan-out, etc. of the urban rail interlocking software code.
[0055] Furthermore, it is possible to determine whether each function in the rail interlocking software code satisfies a preset modification condition according to a preset condition.
[0056] For example, if the first threshold is 10%, the second threshold is 25, and the third threshold is 15, then: on the basis that the proportion of defensive code is greater than 10%, if the cyclomatic complexity does not exceed 25 (normally 20), and the fan-out does not exceed 15, the code can be modified without modification considering the impact on security. Even if it exceeds the limit, it needs to be evaluated based on R&D before modification.
[0057] Optionally, it also includes:
[0058] Step Q5: When the proportion of protective codes is less than 10%, the impact of modifying the code on security is small, and it is determined that the function does not meet the preset condition.
[0059] Step Q6: If the proportion of defensive code exceeds 10%, if the cyclomatic complexity does not exceed 25 (normal is 20) and the fan-out does not exceed 15, the code can be left unchanged considering the impact on security. Even if it exceeds this, it needs to be evaluated based on R&D before making any changes.
[0060] Based on the content of the above embodiment, as an optional embodiment, the protective code may include an interlock assertion protection code.
[0061] As an optional embodiment, the role of the interlock assertion protection code is to throw an error when the judgment condition is wrong, causing the interlock to shut down or power on. This assertion protection code is often written in a judgment branch or as a beginning parameter check and an ending condition check, and the running judgment conditions of these assertions are often impossible to be established, so unreachable code may appear in the static measurement process, so it needs to be shielded.
[0062] Since the interlock assertion protection codes are all in a fixed format, the number of protective codes contained in each function in this measurement can be matched using a method similar to regular expression matching, and the proportion of protective codes in this function can be calculated based on the ratio of the number of code lines occupied after expansion to the total number of code lines.
[0063] Finally, the defensive code can be masked by using regular expression matching replacement, for example, temporarily replacing it with comments that can be recognized by static measurement tools and then performing subsequent static measurement.
[0064] Figure 3 A schematic diagram of the structure of a static measurement system for urban rail interlocking software code provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, it includes but is not limited to: a code recognition unit 1, a shielding processing unit 2 and a static measurement unit 3. Among them, the code recognition unit 1 is mainly used to obtain the type of each protective code in the urban rail interlocking software; the shielding processing unit 2 is mainly used to shield the protective code according to the type of the protective code; the static measurement unit 3 is mainly used to perform static measurement on the urban rail interlocking software after shielding processing.
[0065] Specifically, before the first static code measurement of the interlocking software is performed, the code recognition unit 1 can be used to record common protective codes and redundant code formats, and input them during the static measurement.
[0066] During the specific test, the shielding processing unit 2 is used to record the protective codes and redundant codes, and analyze the number of codes of each type and the proportion of protective codes to the total codes. Then, shielding processing is performed on each protective code according to the different types of protective codes. Finally, the shielded urban rail interlocking software can continue to detect other static measurement items.
[0067] Finally, the static measurement unit 3 is used to call the code static measurement tool to perform static measurement on the shielded urban rail interlocking software.
[0068] The urban rail interlocking software code static measurement system provided by the embodiment of the present invention identifies the type of protective codes that have to be written for some reasons, shields the protective codes that do not affect the normal use of the software during static testing, so as to achieve the test of the normal execution code, and visualizes the number and proportion of protective codes as a metric, so that developers and development verifiers can more clearly and intuitively obtain the security of the code when evaluating the software code.
[0069] It should be noted that the urban rail interlocking software code static measurement system provided in the embodiment of the present invention can be implemented based on the urban rail interlocking software code static measurement method described in any of the above embodiments during specific execution, which will not be elaborated in this embodiment.
[0070] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the static measurement method of the urban rail interlocking software code, which mainly includes: obtaining the type of each protective code in the urban rail interlocking software; shielding the protective code according to the type of the protective code; and statically measuring the shielded urban rail interlocking software.
[0071] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0072] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0073] On the other hand, an embodiment of the present invention further provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the urban rail interlocking software code static measurement method provided by the above-mentioned method embodiments, which mainly includes: obtaining the type of each protective code in the urban rail interlocking software; shielding the protective code according to the type of the protective code; and statically measuring the shielded urban rail interlocking software.
[0074] On the other hand, an embodiment of the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for statically measuring the urban rail interlocking software code provided in the above embodiments is implemented, mainly including: obtaining the type of each protective code in the urban rail interlocking software; shielding the protective code according to the type of the protective code; and statically measuring the shielded urban rail interlocking software.
[0075] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0076] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0077] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A static measurement method for urban rail interlocking software code, characterized in that: include: Obtain the types of each protective code in the urban rail interlocking software; shielding the protective code according to the type of the protective code; Conduct static measurement on the urban rail interlocking software after shielding; Also includes: According to the result of the static measurement, the number of each type of protective code contained in each function in the urban rail interlocking software is obtained; Determining the proportion of each type of protective code according to the number of each type of protective code contained in each function in the urban rail interlocking software; According to the proportion of each type of protective code contained in each function and in combination with the static measurement result, it is determined whether the function meets the preset conditions; If the function satisfies the preset condition, the standard of the static measurement is lowered, and the lowered standard of the static measurement is used to re-perform static measurement on the shielded urban rail interlocking software; If the result of the static measurement is still unqualified, the protective code in the function is modified.
2. The urban rail interlocking software code static measurement method according to claim 1 is characterized in that: The shielding process of the protective code according to the type of the protective code includes: By using a regular matching replacement method, the defensive code is replaced with different annotations that can be recognized by a static measurement tool according to different types of the defensive code, so as to achieve shielding processing of the defensive code.
3. The urban rail interlocking software code static measurement method according to claim 1 is characterized in that: The static measurement results include: the total number of lines of code, the number of functions, branch complexity, cyclomatic complexity, fan-out number, fan-in number and code depth.
4. The urban rail interlocking software code static measurement method according to claim 3 is characterized in that: According to the proportion of each type of protective code contained in each function, combined with the static measurement results, it is judged whether the function meets the preset conditions, including: Compare the proportion of each type of defensive code contained in each of the functions with a first threshold; Comparing the cyclomatic complexity in the static measurement result with a second threshold; Compare the fan-out number in the static measurement result with a third threshold; On the basis that the proportion is greater than the first threshold, if the cyclomatic complexity is greater than the second threshold or the fan-out number is greater than the third threshold, it is determined that the function does not meet the preset condition; otherwise, it is determined that the function meets the preset condition.
5. The urban rail interlocking software code static measurement method according to claim 4 is characterized in that: If the proportion is not greater than the first threshold, it is determined that the function meets the preset condition; Alternatively, on the basis that the proportion is greater than the first threshold, if the cyclomatic complexity is not greater than the second threshold and the fan-out number is not greater than the third threshold, it is determined that the function meets the preset condition.
6. The urban rail interlocking software code static measurement method according to claim 1, characterized in that: The protective code includes an interlock assertion protective code.
7. A static measurement system for urban rail interlocking software code, characterized in that: include: A code identification unit, used to obtain the type of each protective code in the urban rail interlocking software; a shielding processing unit, configured to perform shielding processing on the protective code according to the type of the protective code; The static measurement unit is used to perform static measurement on the urban rail interlocking software after shielding, and also includes: According to the result of the static measurement, the number of each type of protective code contained in each function in the urban rail interlocking software is obtained; Determining the proportion of each type of protective code according to the number of each type of protective code contained in each function in the urban rail interlocking software; According to the proportion of each type of protective code contained in each function and in combination with the static measurement result, it is determined whether the function meets the preset conditions; If the function satisfies the preset condition, the standard of the static measurement is lowered, and the lowered standard of the static measurement is used to re-perform static measurement on the shielded urban rail interlocking software; If the result of the static measurement is still unqualified, the protective code in the function is modified.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the urban rail interlocking software code static measurement method as described in any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the urban rail interlocking software code static measurement method as claimed in any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Test code qualitative evaluation
CN102147764A
Parallelization security hole detecting method based on function call graph
CN102567200A
Early warning method for contract-type software fault based on program invariants
CN103294596A
Code testing method and device, storage medium and electronic device
CN109446078A
An urban rail transit signal system software buffer area checking method
CN109799992A
