CN114115833B - Automatic protocol audit code generation method and device - Google Patents
Automatic protocol audit code generation method and device Download PDFInfo
- Publication number
- CN114115833B CN114115833B CN202210083628.7A CN202210083628A CN114115833B CN 114115833 B CN114115833 B CN 114115833B CN 202210083628 A CN202210083628 A CN 202210083628A CN 114115833 B CN114115833 B CN 114115833B
- Authority
- CN
- China
- Prior art keywords
- protocol
- information
- code
- field
- processing
- Prior art date
- Legal status (The legal status 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 status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/76—Adapting program code to run in a different environment; Porting
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/18—Multiprotocol handlers, e.g. single devices capable of handling multiple protocols
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/22—Parsing or analysis of headers
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Communication Control (AREA)
Abstract
The invention provides a method and a device for automatically generating a protocol audit code, which are based on a graphic information input module and used for receiving the attention information of a current protocol; generating a system configuration file based on the attention information of the current protocol; automatically generating a protocol audit code based on the system configuration file; wherein the graphical information input module is a user interface generated for categorizing based on the protocol-associated key information. The method is characterized in that a graphic information input module is provided for a user, so that the user can conveniently input the attention information of the current protocol, and the computer can conveniently determine which information of the protocol specifically corresponds to the information input by the user according to the attention information of the current protocol; and a corresponding configuration file is generated according to the attention information of the current protocol, so that a computer can automatically generate protocol audit codes based on the configuration file conveniently, and therefore, corresponding modules do not need to be developed manually according to each protocol for processing, and the problems of huge development workload and poor code normalization are solved.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for automatically generating protocol audit codes.
Background
In the prior art, flow audit can be performed by analyzing message data in a network protocol, and analyzing abnormal behaviors existing in a network according to the message data.
Under the normal condition, when analyzing message data, the existing scheme for auditing the flow needs to manually develop a corresponding module according to each protocol for processing, and when facing a new protocol, the scheme needs to be re-developed, so that the problems of huge development workload and poor code normalization exist.
Disclosure of Invention
The invention provides a method and a device for automatically generating protocol audit codes, which are used for solving the defects that in the prior art, when flow audit is carried out, a new protocol needs to be developed again, the development workload is huge, and the code normative is poor, realizing the automatic generation of protocol processing codes for processing the corresponding protocol, and further, not needing to manually develop corresponding modules according to each protocol for processing, and solving the problems of huge development workload and poor code normative.
The invention provides a method for automatically generating a protocol audit code, which comprises the following steps: receiving attention information of a current protocol based on a graphic information input module; generating a system configuration file based on the attention information of the current protocol; automatically generating protocol processing codes based on the system configuration file; the graphical information input module is a user interface generated by classifying based on key information associated with a protocol.
According to the automatic generation method of the protocol audit code provided by the invention, the graphic information input module is as follows:
a graphics input module;
a chart input module; or
And a database input module.
According to the method for automatically generating the protocol audit code provided by the invention, the receiving the attention information of the current protocol further comprises the following steps: receiving a plurality of key word information and configuration rule information included in an input current protocol; wherein the plurality of keyword information at least comprises one of the following: a protocol name; a protocol port number; the number of layers, sequence number and field name of an application layer protocol; the number of the values corresponding to the field names and the field values; the meaning of the field value and the length of the field; and, the configuration rule information includes regular rule information, and irregular rule information.
According to the automatic generation method of the protocol audit code provided by the invention, the automatic generation of the protocol processing code based on the system configuration file comprises the automatic generation of the protocol processing code based on a plurality of keyword information, and at least one of the following is included: generating a basic structure of a processing protocol and registering a processing function name based on the protocol name and the protocol port number; generating a frame code for processing each corresponding layer based on the number of application layer protocol layers; and generating a filling processing function based on the length of the field, the field name, the corresponding value of the field name and the number of the fields.
According to the method for automatically generating the protocol audit code, which is provided by the invention, the automatically generating the protocol processing code based on the system configuration file comprises the step of automatically generating the protocol processing code based on configuration rule information, and the method comprises the following steps: generating a code for processing the jump of the conventional field based on the conventional rule information; and/or generating code for inserting the calling function based on the irregular rule information.
The invention also provides a protocol auditing method, which is used for analyzing the protocol to be audited based on the automatic generation method of the protocol auditing codes and auditing according to the analysis result.
The invention also provides a device for automatically generating the protocol audit code, which comprises:
the receiving module is used for receiving the concerned information of the current protocol based on the graphic information input module; the first generation module is used for generating a system configuration file based on the attention information of the current protocol; the second generation module is used for automatically generating a protocol processing code based on the system configuration file; the graphical information input module is a user interface generated by classifying key information associated with a protocol.
The invention also provides a protocol auditing device, which comprises: and the auditing module is used for analyzing the protocol to be audited based on the protocol auditing code automatic generation method and auditing according to the analysis result.
The invention also provides an electronic device, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the program to realize the steps of the protocol auditing code automatic generation method or the protocol auditing method.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the protocol audit code automatic generation method or the protocol audit method as described in any of the above.
The invention also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the method for automatically generating protocol auditing code or the method for auditing a protocol as described in any of the above.
According to the method and the device for automatically generating the protocol audit code, the user interface generated by classifying the key information based on the protocol association is provided for the user, so that the user can conveniently input the key information associated with the protocol, and the computer can conveniently determine which information of the protocol specifically corresponds to the information input by the user according to the key information associated with the protocol input by the user; and generating a corresponding configuration file according to the key information associated with the protocol, and storing the key information associated with the protocol in a fixed format, thereby laying a foundation for a computer to automatically generate a protocol audit code based on the configuration file, and further automatically generating the protocol audit code for processing the corresponding protocol, thereby not needing to manually develop a corresponding module according to each protocol for processing, and solving the problems of huge development workload and poor code normative.
Drawings
In order to more clearly illustrate the technical solutions of the present invention or the prior art, the drawings needed for the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
FIG. 1 is a schematic flow chart of a protocol audit code automatic generation method provided by the present invention;
FIG. 2 is a second schematic flow chart of the method for automatically generating protocol audit codes according to the present invention;
FIG. 3 is a schematic structural diagram of an automatic protocol audit code generation device provided by the present invention;
fig. 4 is a schematic structural diagram of an electronic device provided in the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The following describes a method and an apparatus for automatically generating a protocol audit code according to the present invention with reference to fig. 1 to 4.
Fig. 1 is a schematic flow diagram of an automatic protocol audit code generation method provided by the present invention. It will be appreciated that the method of figure 1 may be performed by the protocol audit code automatic generation apparatus. As shown in fig. 1, the method for automatically generating a protocol audit code provided by the present invention includes the following steps:
It will be appreciated that the present invention is directed to automatically generating protocol processing code, which for computers requires certain input data and, correspondingly, an interface for providing input data for the input data.
Therefore, the user interface generated by classifying the key information associated with the protocol can be understood by the graphic information input module, so that the computer can determine the content corresponding to the corresponding position according to the information of the corresponding position, and the content is the specific reason.
Wherein, the concerned information of the current protocol can be key information associated with the current protocol.
And 120, generating a system configuration file based on the attention information of the current protocol.
As described above, since the object of the present invention is to automatically generate a protocol processing code, and input data in a specific format is required for automatically generating a code for a computer, it is possible to generate a system configuration file based on the attention information of the current protocol, and to read data in a specific format from the system configuration file to generate a processing code of the current protocol.
And step 130, automatically generating a protocol processing code based on the system configuration file.
It can be understood that, since the key information associated with the current protocol, that is, the attention information of the current protocol is stored in the system configuration file, the function to be implemented in the current protocol can be acquired according to the attention information of the current protocol in the system configuration file, and the protocol processing code is automatically generated according to the function.
According to the automatic generation method of the protocol audit code, the user interface generated by classifying the key information based on protocol association is provided for the user, so that the user can conveniently input the key information of the protocol association, and the computer can conveniently determine which information of the protocol specifically corresponds to the information input by the user according to the key information of the protocol association input by the user; and generating a corresponding configuration file according to the key information associated with the protocol, and storing the key information associated with the protocol in a fixed format, thereby laying a foundation for a computer to automatically generate a protocol processing code based on the configuration file, and automatically generating a protocol auditing code for processing the corresponding protocol, thereby not needing to manually develop a corresponding module according to each protocol for processing, and solving the problems of huge development workload and poor code normative.
Based on any of the above embodiments, in this embodiment, the graphic information input module is:
a graphics input module;
a chart input module; or
And a database input module.
It can be understood that the graphical information input module is mainly a user interface generated for classifying the key information based on the association of the protocols, and is mainly used for facilitating a computer to determine what information about the protocols the user inputs. Therefore, the graphic information input module may exist in various forms, and this embodiment provides three possible implementation manners, which are in the form of a graph, a chart, and a database, respectively, that is, correspond to the graphic input module, the chart input module, and the database input module. The user is provided with an interface in a graphic form, so that the user can conveniently input key information related to the protocol to corresponding positions of a graphic input interface, and a computer can determine what information about the protocol is contained in data of the corresponding positions. Similarly, the information of interest of the current protocol entered by the user is maintained in the form of tables and databases, which facilitate the computer to determine what information about the protocol the data of the corresponding location pertains to.
The method for automatically generating the protocol audit code is convenient for a computer to determine what information about the protocol is in data at the corresponding position through the graphic information input module, thereby laying a foundation for the computer to automatically generate the protocol processing code according to the input of the graphic input module.
Based on any of the foregoing embodiments, in this embodiment, the receiving the attention information of the current protocol further includes:
receiving a plurality of key word information and configuration rule information included in an input current protocol; wherein the plurality of keyword information includes at least one of:
a protocol name;
a protocol port number;
the number of layers, sequence number and field name of an application layer protocol;
the number of the values corresponding to the field names and the field values;
the meaning of the field value and the length of the field;
and, the configuration rule information includes regular rule information, and irregular rule information.
The key information is some attribute information about the protocol, and it can be determined what protocol the current protocol is specific and attribute information corresponding to each field in the message corresponding to the protocol according to the key information. The configuration rule information is used for configuring the linking processing procedure between the fields in the key word information.
Wherein, the protocol name and the protocol port number are used for determining the function of the protocol, which can make the computer determine the corresponding code frame according to the function. It is understood that there are many application layer protocols, so in practical applications, message data can be transmitted through multiple layers of protocols, such as Domain Name System (DNS), File Transfer Protocol (FTP), Simple Mail Transfer Protocol (SMTP), and HyperText transfer protocol (HTTP). That is, each layer can be considered to correspond to one protocol, so that different layers of protocols can be represented by different application layer protocol layers. Sequence numbers may be understood as identifications corresponding to the fields to facilitate computer recognition of the corresponding fields. The field name, the number of the corresponding value of the field name, the field value, the meaning of the field value and the length of the field can be understood as protocol reservation, and a user needs to configure the protocol reservation, so that the computer automatically generates a protocol processing code according to the information. Wherein, the length of the field is the length occupied by the field.
It can be understood that the field name is a name corresponding to a field in the message data specified in the corresponding protocol.
The regular rule information is jump processing information corresponding to the regular field. The unconventional rule information is jump processing information corresponding to the unconventional field. Wherein, the regular field is a field which needs to be processed separately, and the irregular field is a field which does not need to be processed or needs to be processed jointly with other fields.
It will be appreciated that based on the above key information and configuration rule information, the computer may determine relevant details of the protocol, and thereby progressively generate corresponding portions of the protocol processing code from those details.
The method for automatically generating the protocol audit code provides input data for a computer to automatically generate the protocol processing code corresponding to the information by enabling a user to configure the keyword information and the configuration rule information of the protocol, so that the computer can determine the related detail content of the protocol according to the keyword information and the configuration rule information, and the corresponding part of the protocol processing code is gradually generated according to the content.
Based on any one of the foregoing embodiments, in this embodiment, the automatically generating a protocol processing code based on the system configuration file includes automatically generating a protocol processing code based on a plurality of keyword information, and at least one of the following:
Generating a basic structure of a processing protocol based on the protocol name and the protocol port number, and registering a processing function name;
generating a frame code for processing each corresponding layer based on the number of application layer protocol layers;
and generating a filling processing function based on the length of the field, the field name, the corresponding value of the field name and the number of the fields.
It can be understood that the specific function of the protocol can be determined according to the protocol name and the protocol port number, and therefore, the method can be used for generating a basic structure of a corresponding processing protocol according to the protocol name and the protocol port number, and registering the naming of a processing function.
In addition, as described above, each layer of protocol may be understood as corresponding to a different protocol, and therefore, the corresponding function is also different, and therefore, a corresponding code frame may be generated according to the number of layers of the corresponding application layer protocol to implement the corresponding function.
The length of the field, the field name correspondence value, and the number of fields are used to determine the corresponding fill processing function in the code framework.
Specifically, first, field processing may be performed according to the length of the field, so as to obtain at least one field corresponding to the field name one to one. And then, according to the number of the fields, the name of the fields and the output and analysis of the field values, obtaining the meaning of the fields and determining a corresponding field processing module. And finally, sequentially processing the plurality of fields according to the method until the layer protocol is processed.
The method for automatically generating the protocol audit code ensures that a computer can determine the related detail content of the protocol according to the key word information and the configuration rule information by enabling a user to configure the key word information and the configuration rule information of the protocol, thereby gradually generating the corresponding part of the protocol processing code according to the content.
Based on any one of the foregoing embodiments, in this embodiment, the automatically generating a protocol processing code based on the system configuration file includes automatically generating a protocol processing code based on configuration rule information, and includes:
generating a code for processing the jump of the conventional field based on the conventional rule information;
code inserted into the calling function is generated based on the irregular rule information.
As described above, the regular rule information is the jump processing information corresponding to the regular field. The unconventional rule information is jump processing information corresponding to the unconventional field. Wherein, the regular field is a field which needs to be processed separately, and the irregular field is a field which does not need to be processed or needs to be processed jointly with other fields.
For ease of understanding, the following is illustrated in conjunction with the conventional and non-conventional fields, respectively.
It is understood that some fields in the message structure corresponding to the protocol may be processed individually, some fields may not be processed, or may be processed in combination with other fields. Therefore, for the above case, the fields are divided into regular fields and irregular fields. And different methods are used for processing the two fields. Aiming at the conventional fields, unified jump codes can be adopted for processing; for the unconventional fields, because the fields required to be combined by each unconventional field can be different, a corresponding insert call function can be generated for each unconventional field to realize jump processing after the unconventional fields are processed.
The automatic generation method of the protocol audit code provided by the invention respectively generates different jump codes aiming at the conventional field and the unconventional field, realizes jump processing connection between the fields, and generates partial protocol processing codes.
In addition, the invention also provides a protocol auditing method, which comprises the following steps:
and analyzing the protocol to be audited based on the protocol audit code automatic generation method, and auditing according to the analysis result.
It can be understood that the protocol to be audited can be analyzed according to the method, so as to obtain the message data contained in the protocol, and then audit is performed according to the result obtained by analysis, so as to judge whether the network behavior is abnormal. For ease of understanding, the following is exemplified.
For example, the message data obtained by analyzing the protocol to be audited is mainly used for requesting access to a certain website, and auditing the certain website may be to audit whether the website is an abnormal website.
According to the protocol auditing method provided by the invention, the protocol can be analyzed according to the automatically generated protocol processing code based on the automatically generated protocol auditing code, and then the auditing of the analysis result is completed, so that in the protocol auditing process, corresponding codes do not need to be written for each protocol for analyzing the protocol, the labor cost is saved, and the problems of huge development workload and poor code normalization are solved.
Fig. 2 is a second schematic flowchart of the method for automatically generating the protocol audit code according to the present invention.
And step 220, reading the number of application layer protocol layers 1-n in the attention information of the current protocol, and generating corresponding frame codes aiming at the 1-n layers respectively.
Then step 230 and step 240 are performed for the fields of each layer.
And step 230, generating a filling processing function based on the length, the field name corresponding value and the field number of the field in the attention information of the current protocol.
Specifically, first, field processing may be performed according to the length of the field, so as to obtain at least one field corresponding to the field name one to one. And then, according to the number of the fields, the name of the fields and the output and analysis of the field values, obtaining the meaning of the fields and determining a corresponding field processing module. And finally, sequentially processing the plurality of fields according to the method until the layer of protocol processing is finished.
Step 240, generating a code for processing the jump of the conventional field based on the conventional rule information; code inserted into the calling function is generated based on the irregular rule information.
The following describes the automatic generation device of the protocol audit code provided by the present invention, and the automatic generation device of the protocol audit code described below and the automatic generation method of the protocol audit code described above can be referred to each other correspondingly.
Fig. 3 is a schematic diagram of an automatic protocol audit code generation apparatus provided by the present invention, and as shown in fig. 3, an automatic protocol audit code generation apparatus provided by an embodiment of the present invention includes:
a receiving module 310, configured to receive attention information of a current protocol based on the graphical information input module;
A first generating module 320, configured to generate a system configuration file based on the attention information of the current protocol;
a second generating module 330, configured to automatically generate a protocol processing code based on the system configuration file; wherein
The graphical information input module is a user interface generated by classifying key information based on protocol association.
The protocol audit code automatic generation device provided by the invention provides a user interface generated by classifying the key information based on protocol association for a user, so that the user can conveniently input the key information of the protocol association, and a computer can conveniently determine which information of the protocol specifically corresponds to the information input by the user according to the key information of the protocol association input by the user; and generating a corresponding configuration file according to the key information associated with the protocol, and storing the key information associated with the protocol in a fixed format, thereby laying a foundation for a computer to automatically generate a protocol processing code based on the configuration file, and further automatically generating the protocol processing code for processing the corresponding protocol, thereby not needing to manually develop a corresponding module according to each protocol for processing, and solving the problems of huge development workload and poor code normative.
Based on any of the above embodiments, in this embodiment, the graphic information input module is:
a graphics input module;
a chart input module; or
And a database input module.
The automatic generation device of the protocol audit code provided by the invention is convenient for a computer to determine the data of the corresponding position as the information about the protocol through the graphic information input module, thereby laying a foundation for the computer to automatically generate the protocol processing code according to the input of the graphic input module.
Based on any one of the above embodiments, in this embodiment, the receiving module 310 includes:
the receiving unit is used for receiving a plurality of key word information and configuration rule information which are included in an input current protocol; wherein the plurality of keyword information at least comprises one of the following:
a protocol name;
a protocol port number;
the number of layers, sequence number and field name of an application layer protocol;
the number of the values corresponding to the field names and the field values;
the meaning of the field value and the length of the field;
and, the configuration rule information includes regular rule information, and irregular rule information.
The automatic generation device of the protocol audit code provides input data for a computer to automatically generate the protocol processing code corresponding to the information by enabling a user to configure the keyword information and the configuration rule information of the protocol, so that the computer can determine the related detail content of the protocol according to the keyword information and the configuration rule information, and the corresponding part of the protocol processing code is gradually generated according to the content.
Based on any one of the foregoing embodiments, in this embodiment, the second generating module 330 includes at least one of the following:
a first generating unit, configured to generate a basic structure of a processing protocol and register a processing function name based on the protocol name and the protocol port number;
a second generating unit configured to generate a frame code for processing each corresponding layer based on the number of application layer protocol layers;
and a third generating unit, configured to generate a filling processing function based on the length of the field, the field name correspondence value, and the number of the fields.
The automatic generation device of the protocol audit code provided by the invention enables a user to configure the key word information and the configuration rule information of the protocol, so that a computer can determine the relevant detail content of the protocol according to the key word information and the configuration rule information, and the corresponding part of the protocol processing code is gradually generated according to the content.
Based on any one of the above embodiments, in this embodiment, the second generating module 330 includes:
a fourth generating unit for generating a code for processing a jump of the regular field based on the regular rule information;
and a fifth generating unit for generating the code inserted into the calling function based on the irregular rule information.
The automatic generation device of the protocol audit code provided by the invention respectively generates different jump codes aiming at the conventional field and the unconventional field, realizes jump processing connection between the fields, and generates partial protocol processing codes.
In addition, the invention also provides a protocol auditing device, which comprises:
and the auditing module is used for analyzing the protocol to be audited based on the protocol auditing code automatic generation method and auditing according to the analysis result.
According to the protocol auditing device provided by the invention, the automatic generation method of the code based on the protocol auditing can complete the analysis of the protocol according to the automatically generated protocol processing code, and further complete the auditing of the analysis result, so that in the process of protocol auditing, corresponding codes do not need to be written for each protocol for the analysis of the protocol, the labor cost is saved, and the problems of huge development workload and poor code normalization are solved.
Fig. 4 illustrates a physical structure diagram of an electronic device, which may include, as shown in fig. 4: a processor (processor)410, a communication Interface (Communications Interface)420, a memory (memory)430 and a communication bus 440, wherein the processor 410, the communication Interface 420 and the memory 430 are in communication with each other via the communication bus 440. Processor 410 may invoke logic instructions in memory 430 to perform a protocol audit code auto generation method or a protocol audit method. The automatic generation method of the protocol audit code comprises the following steps: receiving attention information of a current protocol based on a graphic information input module; generating a system configuration file based on the attention information of the current protocol; automatically generating protocol processing codes based on the system configuration file; wherein the graphical information input module is a user interface generated based on categorizing protocol-related key information. The protocol auditing method comprises the following steps: and analyzing the protocol to be audited based on the protocol audit code automatic generation method, and auditing according to the analysis result.
In addition, the logic instructions in the memory 430 may be implemented in the form of software functional units and stored in a computer readable storage medium when the software functional units are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In another aspect, the present invention also provides a computer program product comprising a computer program, the computer program being storable on a non-transitory computer readable storage medium, the computer program, when executed by a processor, being capable of executing the protocol audit code automatic generation method or the protocol audit method provided by the present invention. The automatic generation method of the protocol audit code comprises the following steps: receiving attention information of a current protocol based on a graphic information input module; generating a system configuration file based on the attention information of the current protocol; automatically generating protocol processing codes based on the system configuration file; wherein the graphical information input module is a user interface generated based on categorizing protocol-related key information. The protocol auditing method comprises the following steps: and analyzing the protocol to be audited based on the protocol audit code automatic generation method, and auditing according to the analysis result.
In yet another aspect, the present invention also provides a non-transitory computer-readable storage medium having stored thereon a computer program, which when executed by a processor, is implemented to perform the protocol auditing code automatic generation method or protocol auditing method provided by the present invention. The automatic generation method of the protocol audit code comprises the following steps: receiving attention information of a current protocol based on a graphic information input module; generating a system configuration file based on the attention information of the current protocol; automatically generating protocol processing codes based on the system configuration file; wherein the graphical information input module is a user interface generated based on categorizing protocol-related key information. The protocol auditing method comprises the following steps: and analyzing the protocol to be audited based on the protocol audit code automatic generation method, and auditing according to the analysis result.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment may be implemented by software plus a necessary general hardware platform, and may also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, and not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.
Claims (7)
1. A method for automatically generating protocol audit codes is characterized by comprising the following steps:
receiving attention information of a current protocol based on a graphic information input module;
generating a system configuration file based on the attention information of the current protocol;
automatically generating protocol processing codes based on the system configuration file; wherein
The graphical information input module is a user interface generated by classifying key information based on protocol association;
the graphic information input module is as follows:
a graphics input module;
a chart input module; or
A database input module;
the receiving of the attention information of the current protocol further comprises:
receiving a plurality of key word information and configuration rule information included in an input current protocol; wherein the plurality of keyword information at least comprises one of the following:
a protocol name;
a protocol port number;
the number of layers, sequence number and field name of an application layer protocol;
the number of the values corresponding to the field names and the field values;
the meaning of the field value and the length of the field;
and, the configuration rule information includes regular rule information, and irregular rule information;
the automatically generating protocol processing code based on the system configuration file comprises automatically generating protocol processing code based on a plurality of keyword information, including at least one of:
Generating a basic structure of a processing protocol based on the protocol name and the protocol port number, and registering a processing function name;
generating a frame code for processing each corresponding layer based on the number of application layer protocol layers;
and generating a filling processing function based on the length of the field, the field name corresponding value and the number of the fields.
2. The method of claim 1, wherein automatically generating protocol audit code based on the system configuration file includes automatically generating protocol process code based on configuration rule information, including:
generating a code for processing the jump of the conventional field based on the conventional rule information; and/or
Code inserted into the calling function is generated based on the irregular rule information.
3. A protocol auditing method, characterized in that, the protocol to be audited is analyzed based on the protocol auditing code automatic generation method of any claim 1 to 2, and auditing is performed according to the analysis result.
4. An automatic protocol audit code generation device, comprising:
the receiving module is used for receiving the attention information of the current protocol based on the graphic information input module;
the first generation module is used for generating a system configuration file based on the attention information of the current protocol;
The second generation module is used for automatically generating a protocol processing code based on the system configuration file; wherein
The graphic information input module is a user interface generated by classifying key information based on protocol association;
the graphic information input module is as follows:
a graphic input module;
a chart input module; or
A database input module;
the receiving module includes:
the receiving unit is used for receiving a plurality of key word information and configuration rule information which are included in an input current protocol; wherein the plurality of keyword information at least comprises one of the following:
a protocol name;
a protocol port number;
the number of layers, sequence number and field name of an application layer protocol;
the number of the values corresponding to the field names and the field values;
the meaning of the field value and the length of the field;
the configuration rule information comprises conventional rule information and unconventional rule information;
the second generating module 330 includes at least one of:
a first generating unit, configured to generate a basic structure of a processing protocol and register a processing function name based on the protocol name and the protocol port number;
a second generating unit configured to generate a frame code for processing each corresponding layer based on the number of application layer protocol layers;
And a third generating unit, configured to generate a filling processing function based on the length of the field, the field name correspondence value, and the number of fields.
5. An agreement audit device, comprising:
an auditing module for parsing the protocol to be audited based on the protocol auditing code automatic generation method of any one of claims 1 to 2 and auditing according to the parsing result.
6. An electronic device comprising a memory, a processor and a computer program stored on said memory and executable on said processor, wherein said processor when executing said program implements the steps of the method for automatically generating a protocol auditing code according to any one of claims 1 to 2 or the method for protocol auditing according to claim 3.
7. A non-transitory computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor implements the steps of the protocol auditing code automatic generation method of any one of claims 1 to 2 or the protocol auditing method of claim 3.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210083628.7A CN114115833B (en) | 2022-01-25 | 2022-01-25 | Automatic protocol audit code generation method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210083628.7A CN114115833B (en) | 2022-01-25 | 2022-01-25 | Automatic protocol audit code generation method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114115833A CN114115833A (en) | 2022-03-01 |
CN114115833B true CN114115833B (en) | 2022-06-28 |
Family
ID=80360846
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210083628.7A Active CN114115833B (en) | 2022-01-25 | 2022-01-25 | Automatic protocol audit code generation method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114115833B (en) |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020157041A1 (en) * | 2001-04-23 | 2002-10-24 | Bennett David Charles | Protocol parser-code generator |
CN106412086B (en) * | 2016-10-31 | 2020-01-03 | 武汉斗鱼网络科技有限公司 | Method and system for automatically generating communication code by using protocol description file |
CN108141464B (en) * | 2017-03-15 | 2019-04-05 | 深圳力维智联技术有限公司 | A kind of communication protocol parsing code automatic generation method and system |
CN111338616A (en) * | 2020-03-24 | 2020-06-26 | 北京自如信息科技有限公司 | Protocol analysis code generation method and device and electronic equipment |
CN112165463B (en) * | 2020-09-14 | 2023-04-18 | 杭州安恒信息技术股份有限公司 | Audit data generation method, device, equipment and computer readable storage medium |
-
2022
- 2022-01-25 CN CN202210083628.7A patent/CN114115833B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN114115833A (en) | 2022-03-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2022007434A1 (en) | Visualization method and related device | |
CN113360519B (en) | Data processing method, device, equipment and storage medium | |
CN112346775B (en) | Index data general processing method, electronic device and storage medium | |
CN112084179A (en) | Data processing method, device, equipment and storage medium | |
CN112463261B (en) | Interface calling method, device, electronic equipment, medium and product | |
CN112883088B (en) | Data processing method, device, equipment and storage medium | |
CN110516258B (en) | Data verification method and device, storage medium and electronic device | |
CN114115833B (en) | Automatic protocol audit code generation method and device | |
CN111124883A (en) | Test case library introduction method, system and equipment based on tree form | |
CN116204428A (en) | Test case generation method and device | |
CN116483707A (en) | Test method, test device, test apparatus, test program, and test program | |
CN113672233B (en) | Server out-of-band management method, device and equipment based on Redfish | |
US20200302914A1 (en) | Method, device, computer apparatus, and storage medium of processing claim data | |
CN114817482A (en) | Method, device and equipment for determining product manufacturing program and storage medium | |
CN115033436A (en) | Page testing method and device, electronic equipment and storage medium | |
CN113934526A (en) | Construction method and device of business process | |
CN113342647A (en) | Test data generation method and device | |
US20070240048A1 (en) | A standard communication interface for server-side filter objects | |
CN111209284A (en) | Metadata-based table dividing method and device | |
CN114760365B (en) | Data extraction method and device and electronic equipment | |
CN117032646A (en) | Index configuration method, index execution method and system | |
CN117149541A (en) | Automated testing method, apparatus, electronic device, and readable storage medium | |
CN114119263A (en) | Big data based data checking method and device, electronic equipment and storage medium | |
CN117215541A (en) | Code generation method, system, equipment and storage medium | |
CN115729989A (en) | Offline data conversion method and device, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |