CN115481023A - Interface data checking method and device, computer equipment and readable storage medium - Google Patents

Interface data checking method and device, computer equipment and readable storage medium Download PDF

Info

Publication number
CN115481023A
CN115481023A CN202211114477.3A CN202211114477A CN115481023A CN 115481023 A CN115481023 A CN 115481023A CN 202211114477 A CN202211114477 A CN 202211114477A CN 115481023 A CN115481023 A CN 115481023A
Authority
CN
China
Prior art keywords
target
verification
parameter
verified
annotation
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.)
Pending
Application number
CN202211114477.3A
Other languages
Chinese (zh)
Inventor
张德雷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Pingan Payment Technology Service Co Ltd
Original Assignee
Pingan Payment Technology Service Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Pingan Payment Technology Service Co Ltd filed Critical Pingan Payment Technology Service Co Ltd
Priority to CN202211114477.3A priority Critical patent/CN115481023A/en
Publication of CN115481023A publication Critical patent/CN115481023A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs

Abstract

The application discloses an interface data checking method, an interface data checking device, computer equipment and a readable storage medium, which relate to the field of internet technology and data processing. The method comprises the following steps: adding a check annotation to an additional flow method of a target interface, wherein the check annotation comprises target check logic and a target processing mode; receiving a parameter to be verified, verifying the parameter to be verified by adopting target verification logic according to a target processing mode to obtain a verification result; intercepting the parameter to be verified when the verification result indicates that the parameter to be verified is an abnormal parameter; and generating a verification failure prompt, and sending the verification failure prompt to the target terminal indicated by the target interface.

Description

Interface data checking method and device, computer equipment and readable storage medium
Technical Field
The present application relates to the field of internet technology and data processing, and in particular, to a method and an apparatus for checking interface data, a computer device, and a readable storage medium.
Background
With the continuous development of internet technology, an interface becomes an important component in an engineering system, the input parameter data and the output parameter data of the interface determine the safety of the interface and the stability of the system, and the wrong interface data may cause the crash of an application system, so that the verification of the interface data is of great importance.
In the related art, the common checks of the interface data check system include parameter basis check (parameter cannot be null, parameter length control, etc.), user authentication, user data authentication, service logic check, user current limit, log record, etc., and a related engineer adds a data check code before a service logic code, so that before the input parameter data is injected into the service logic code, data check is performed on the parameter.
In carrying out the present application, the applicant has found that the related art has at least the following problems:
the data verification code and the service logic code are mixed together, so that the code structure is disordered, the repeatability of the data verification code is caused, and the interface data verification speed is low and the efficiency is low.
Disclosure of Invention
In view of this, the present application provides an interface data verification method, an apparatus, a computer device and a readable storage medium, and mainly aims to solve the problems that the existing data verification code and a service logic code are mixed together, which may cause a code structure to be confused, and may cause the repeatability of the data verification code, thereby resulting in a slow speed and low efficiency of interface data verification.
According to a first aspect of the present application, there is provided an interface data verification method, including:
adding a check annotation to an additional flow method of a target interface, wherein the check annotation comprises target check logic and a target processing mode, and the target processing mode is used for indicating one of synchronous processing, asynchronous processing and fragment processing;
receiving a parameter to be verified, and verifying the parameter to be verified by adopting the target verification logic according to the target processing mode to obtain a verification result;
intercepting the parameter to be checked when the checking result indicates that the parameter to be checked is an abnormal parameter;
and generating a verification failure prompt, and sending the verification failure prompt to a target terminal indicated by the target interface, wherein the verification failure prompt is used for triggering the target terminal to upload the parameters to be verified again.
According to a second aspect of the present application, there is provided an interface data verification apparatus, the apparatus including:
the annotation module is used for adding check annotation to the additional flow method of the target interface, wherein the check annotation comprises target check logic and a target processing mode, and the target processing mode is used for indicating one of synchronous processing, asynchronous processing and fragment processing;
the receiving module is used for receiving the parameters to be verified, and verifying the parameters to be verified by adopting the target verification logic according to the target processing mode to obtain a verification result;
the interception module is used for intercepting the parameter to be checked when the checking result indicates that the parameter to be checked is an abnormal parameter;
and the generating module is used for generating a verification failure prompt and sending the verification failure prompt to the target terminal indicated by the target interface, wherein the verification failure prompt is used for triggering the target terminal to upload the parameters to be verified again.
According to a third aspect of the present application, there is provided a computer device comprising a memory storing a computer program and a processor implementing the steps of the method of any of the first aspects when the computer program is executed.
According to a fourth aspect of the present application, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the method of any of the first aspects described above.
By means of the technical scheme, the interface data verification method, the device, the computer equipment and the readable storage medium are provided. And then, receiving the parameters to be verified, and verifying the parameters to be verified by adopting target verification logic according to a target processing mode to obtain a verification result. And intercepting the parameter to be verified when the verification result indicates that the parameter to be verified is an abnormal parameter, generating a verification failure prompt, and sending the verification failure prompt to a target terminal indicated by a target interface. The method adopts an annotation mode to check the interface parameters, has no invasion to normal codes, increases the target processing modes of asynchronous processing and fragment processing, and performs multi-thread processing when the number of parameters to be processed is large, thereby improving the checking speed and the checking efficiency of parameter checking.
The foregoing description is only an overview of the technical solutions of the present application, and the present application can be implemented according to the content of the description in order to make the technical means of the present application more clearly understood, and the following detailed description of the present application is given in order to make the above and other objects, features, and advantages of the present application more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the application. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 shows a schematic flowchart of an interface data verification method provided in an embodiment of the present application;
fig. 2A shows a schematic flowchart of an interface data verification method provided in an embodiment of the present application;
fig. 2B shows a schematic flowchart of an interface data verification method provided in the embodiment of the present application;
fig. 3A illustrates a schematic structural diagram of an interface data verification apparatus according to an embodiment of the present application;
fig. 3B shows a schematic structural diagram of an interface data verification apparatus according to an embodiment of the present application;
fig. 3C shows a schematic structural diagram of an interface data checking apparatus according to an embodiment of the present application;
fig. 4 shows a schematic device structure diagram of a computer apparatus according to an embodiment of the present application.
Detailed Description
Exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
An embodiment of the present application provides an interface data verification method, as shown in fig. 1, the method includes:
101. and adding a check annotation to the additional flow method of the target interface, wherein the check annotation comprises target check logic and a target processing mode, and the target processing mode is used for indicating one of synchronous processing, asynchronous processing and fragmentation processing.
The method is suitable for the interface data verification plug-in of the micro service application system, and the plug-in is simple and convenient to use, can be introduced quickly and is convenient to use. In actual operation, one-key verification of interface data is realized through the plug-in, and the normal business logic code is not invasive. Related technicians can utilize the interface data to verify the plug-in according to actual operation requirements, and add notes on the additional flow method with frequent parameter entering errors, so that parameter verification is facilitated. Specifically, a related technician may define a list of methods to be verified, and add an additional flow method that requires interface data verification to the list. Next, considering that different additional deduction methods require different types of parameters to be checked, a related technician may identify the additional flow methods in the list in advance, and determine a target check logic corresponding to each additional flow method. It should be noted that, in fact, an additional process method does not only use one parameter to be verified, that is, one process method does not only need to verify one parameter to be verified, and the parameter to be verified used by the same additional process method does not always use the same verification logic, so that the verification annotation needs to note the specific verification logic corresponding to each parameter to be verified. For example, if the interface a calls the method 01, three uploaded parameters are respectively a parameter a, a parameter B and a parameter C, and the annotation of the method 01 indicates that the uploaded user identifier parameter a is verified by user authentication, and after the parameter a is verified, the remaining uploaded parameters and the parameter C are verified by parameter basis.
In the actual operation process, when a user starts the application service based on the target terminal, the target terminal calls the corresponding interface and the micro-service application system to transmit background data, and the interface is the target interface. That is, the interface is used as the target interface by checking the data uploaded by the interface. It should be noted that the verification annotation includes a target verification logic and a target processing mode, where the target processing mode may be one of synchronous processing, asynchronous processing, or fragment processing, when the to-be-verified parameter is too large, asynchronous processing may be used to increase the processing speed, and when the to-be-verified parameter data volume is large, a fragment processing mode may be used to split the to-be-verified parameter for synchronous processing. The verification problem is solved through an annotation mode, and therefore non-invasion to normal business logic codes is achieved.
102. And receiving the parameters to be verified, and verifying the parameters to be verified by adopting target verification logic according to a target processing mode to obtain a verification result.
In this embodiment of the application, the interface data verification plug-in may intercept the transferred parameter to be verified before the additional flow method is executed, and verify the parameter to be verified according to the annotation information on the additional flow method. In the actual operation process, a plurality of annotation file templates can be attached to the interface data verification plug-in, and corresponding target verification logic and a target processing mode are stored on the annotation file templates. According to the additional flow method, related workers designate a target annotation file corresponding to the additional flow method in a plurality of annotation file templates, and then an interface data verification plug-in introduces the target annotation file into the additional flow method. And then, checking the parameters to be checked by adopting target checking logic to obtain a corresponding checking result.
103. And intercepting the parameter to be verified when the verification result indicates that the parameter to be verified is the abnormal parameter.
When the verification result shows that the parameter to be verified is an abnormal parameter, it indicates that the parameter to be verified cannot be injected into the additional flow method to execute the normal service logic, and therefore the parameter to be verified needs to be intercepted and is prohibited from being injected into the normal service logic code.
104. And generating a verification failure prompt, and sending the verification failure prompt to a target terminal indicated by a target interface, wherein the verification failure prompt is used for triggering the target terminal to upload the parameters to be verified again.
Further, the verification plug-in generates a verification failure prompt and returns the verification failure prompt to the corresponding target terminal through the target interface. In consideration of actual operation, there may be a plurality of terminal devices that simultaneously call the additional flow method to upload the parameters to be verified, so that the target interface may add a terminal identifier to the parameters to be verified when receiving the parameters to be verified, so as to indicate the corresponding target terminal. Further, when the verification plug-in generates the verification failure prompt, the terminal identifier corresponding to the parameter to be verified can be added into the prompt, and then the terminal identifier is returned to the target interface, so that the verification failure prompt is sent to the target terminal corresponding to the terminal identifier through the target interface for displaying.
The user can check the verification failure prompt on the target terminal, the verification failure prompt can pop up on the target terminal in a text popup mode or in a picture mode, and the content and the mode of the verification failure prompt are not specifically limited by the application. After receiving the verification failure prompt, the user can modify the parameter content according to the prompt information and upload the parameters to be verified through the target interface again based on the target terminal.
According to the method provided by the embodiment of the application, firstly, the verification annotation is added to the additional flow method of the target interface, and the verification annotation comprises target verification logic and a target processing mode. And then, receiving the parameters to be verified, and verifying the parameters to be verified by adopting target verification logic according to a target processing mode to obtain a verification result. And intercepting the parameter to be verified when the verification result indicates that the parameter to be verified is an abnormal parameter, generating a verification failure prompt, and sending the verification failure prompt to a target terminal indicated by a target interface. The method adopts an annotation mode to verify the interface parameters, has no invasion to normal codes, increases the target processing modes of asynchronous processing and fragment processing, and performs multi-thread processing when the parameters to be processed are more, thereby improving the verification speed and the verification efficiency of parameter verification.
An embodiment of the present application provides an interface data verification method, as shown in fig. 2A, the method includes:
201. introducing related files of the spring framework, starting declarative service, introducing a target annotation file, adding verification annotation for the additional flow method according to annotation content indicated in the target annotation file, and packaging the additional flow method added with the annotation in the section programming of the spring framework.
With the continuous development of internet technology, an interface becomes an important component in an engineering system, the input parameter data and the output parameter data of the interface determine the safety of the interface and the stability of the system, and the wrong interface data may cause the crash of an application system, so that the verification of the interface data is of great importance. At present, the common checks of the interface data check system include parameter basic check (parameters can not be empty, parameter length control, etc.), user authentication, user data authentication, service logic check, user current limit, log record, etc., and a relevant engineer adds a data check code before a service logic code, so that data check is performed on parameters before the input parameter data is injected into the service logic code. Applicants have recognized, however, that the intermingling of data verification code and business logic code can confuse the code structure and cause repeatability of the data verification code, resulting in slow and inefficient interface data verification.
Therefore, the application provides an interface data verification method, an interface data verification device, computer equipment and a readable storage medium. And then, receiving the parameters to be verified, and verifying the parameters to be verified by adopting target verification logic according to a target processing mode to obtain a verification result. And intercepting the parameter to be verified when the verification result indicates that the parameter to be verified is an abnormal parameter, generating a verification failure prompt, and sending the verification failure prompt to a target terminal indicated by a target interface. The method adopts an annotation mode to check the interface parameters, has no invasion to normal codes, increases the target processing modes of asynchronous processing and fragment processing, and performs multi-thread processing when the number of parameters to be processed is large, thereby improving the checking speed and the checking efficiency of parameter checking.
In the embodiment of the application, the micro-service application system must introduce spring-related jar and open the declarative service. jar file is an archive file, constructed in ZIP format, with jar as the file extension. Are commonly used to aggregate large numbers of Java class files, associated metadata and resource (text, pictures, etc.) files into one file in order to develop Java platform applications or libraries. Spring is an open source framework that uses the basic JavaBean to do what could previously only be done by an EJB, a lightweight control inversion (IoC) and facet oriented (AOP) container framework.
Specifically, code is written
Figure BDA0003844937390000071
Figure BDA0003844937390000072
Introducing spring related jar and writing codes
Figure BDA0003844937390000073
Figure BDA0003844937390000074
Figure BDA0003844937390000075
Transactions are enabled, i.e. declarative services are started.
Furthermore, the microservice application system refers to a self-developed interface data verification plug-in validatdate, and adds annotations on the specified additional flow method by adopting a target annotation file in the interface data verification plug-in. The target annotation file stores target verification logic and a target processing mode, wherein the target verification logic comprises a parameter basic verification annotation @ paramValidated annotation, a current limiting verification annotation @ SentielValidated annotation, a user authentication annotation @ UserValidated annotation, and judges whether a current user has authority access and a user data authentication annotation @ UserDataValidated annotation.
And then, adding a check annotation for the additional flow method according to the annotation content indicated in the target annotation file, and packaging the additional flow method added with the annotation in the section programming of the spring frame. Specifically, when the application service is started, an AOP (Aspect organized Programming) is generated. AOP is a technology for realizing unified maintenance of program functions through a pre-compiling mode and a dynamic proxy during running, is an important content in a Spring framework, and is a derivative paradigm of functional programming. By utilizing the AOP, all parts of the business logic can be isolated, so that the coupling degree between all parts of the business logic is reduced, the reusability of a program is improved, and the development efficiency is improved. And introducing an additional flow method into the section logic for logic processing by taking the verification annotation as an entry point, and analyzing the target verification logic in the section.
In addition, the method also supports user-defined annotation to facilitate user extension, related technicians can write a specified annotation file with combined annotation BaseValidated annotation instead of adopting an annotation file template in the interface data verification plug-in, and the interface data verification plug-in identifies the specified annotation file. When the combined annotation BaseValidated annotation is detected in the specified annotation file, the specified annotation file is scanned, and the self-defined check logic and the self-defined processing mode are determined. And finally, according to a user-defined processing mode, carrying out parameter verification on the parameters to be verified by adopting user-defined verification logic. It should be noted that the combined annotation basevalid is an annotation that allows the plug-in to scan the custom annotation.
202. And responding to the application service to call the target interface to upload the parameters to be verified, intercepting the target interface, receiving the parameters to be verified uploaded by the target terminal, verifying the parameters to be verified by adopting target verification logic according to a target processing mode, and obtaining a verification result.
In the embodiment of the application, the annotation plug-in utilizes the principle of Spring's Aop (tangent plane programming), when the application service is started, generates a proxy class on the class method with the annotation, and processes the additional flow method of the annotation through the proxy class. In addition, the asynchronous processing is started according to the annotated asynchronous synchronous setting asyn, whether the efficiency is improved by the fragmentation processing of the data is determined according to annotated fragmentation parameters, and the like. And then normal business logic processing is carried out.
Specifically, the parameters to be verified are uploaded in response to the application service calling target interface, and the parameters to be verified are intercepted. And simultaneously, generating an agent class in the additional flow method, and injecting parameters to be verified into the agent class by adopting param parameters in the verification annotation to perform automatic verification. And calling the proxy class, and verifying the parameters to be verified according to the target processing mode and the target verification logic stored in the verification annotation to obtain a verification result. Specifically, when the target processing mode is synchronous processing, the target verification logic is adopted, and the single thread verifies the parameters to be verified to obtain a verification result. When asyn is set to be equal to true in the annotation, the target processing mode is asynchronous processing, and at the moment, the thread pool is started to carry out asynchronous verification on a plurality of sub-parameters in the parameters to be verified, so that a verification result is obtained. Originally, one thread is started for five seconds to complete five verifications, and after the asynchronization, five threads can be started for one second to complete five verifications, so that the data verification efficiency is improved. When the sharing fragment is set in the annotation, the target processing mode is the fragment processing, the to-be-verified parameter is segmented to obtain a plurality of fragment data, the plurality of fragment data are set in a key value pair mode, for example, a =1, b =2 and the like, then the plurality of fragment data are synchronously processed in a multi-thread mode in the tangent plane to obtain a plurality of sub-verification results, and the plurality of sub-verification results are combined to obtain the verification result. For example, the data to be checked is divided into 2 pieces of sliced data, and the two pieces of data are executed separately in the section, so that the condition that single check is overtime due to the data volume problem is prevented, the data can be synchronously processed in multiple threads after being divided into pieces, the sub-check results are finally merged, and the check result is returned.
Finally, the verification result is identified, when the verification result indicates that the parameter to be verified is a normal parameter, the parameter to be verified is injected into the service logic code to perform logic processing of the service function, that is, the following step 203 is executed, and when the verification result indicates that the parameter to be verified is an abnormal parameter, the parameter to be verified is intercepted, that is, the following step 204 is executed.
203. And when the verification result indicates that the parameter to be verified is a normal parameter, injecting the parameter to be verified into a service logic code to perform logic processing of a service function, obtaining parameter data, and sending the parameter data to a terminal corresponding to the target interface for displaying.
In the embodiment of the application, when the verification result indicates that the parameter to be verified is a normal parameter, it indicates that the verification is passed, and the parameter to be verified can be injected into the additional flow method to perform logic processing of the service function. After the additional flow method is executed, parameter data is generated, and the parameter data can also be sent to a terminal corresponding to the target interface through a plug-in for displaying. It should be noted that, in an optional execution scenario, after obtaining the parameter data, the interface data verification plug-in may continue to perform parameter verification on the parameter data, and after checking that no error exists, return to the corresponding target terminal through the target interface.
204. And intercepting the parameter to be verified when the verification result indicates that the parameter to be verified is the abnormal parameter.
When the verification result shows that the parameter to be verified is an abnormal parameter, it indicates that the parameter to be verified cannot be injected into the additional flow method to execute the normal service logic, and therefore the parameter to be verified needs to be intercepted and is prohibited from being injected into the normal service logic code.
205. And generating a verification failure prompt, and sending the verification failure prompt to the target terminal indicated by the target interface, wherein the verification failure prompt is used for triggering the target terminal to upload the parameters to be verified again.
Further, the verification plug-in generates a verification failure prompt and returns the verification failure prompt to the corresponding target terminal through the target interface. In consideration of actual operation, there may be a plurality of terminal devices that simultaneously call the additional flow method to upload the parameters to be verified, so that the target interface may add a terminal identifier to the parameters to be verified when receiving the parameters to be verified, so as to indicate the corresponding target terminal. Further, when the verification plug-in generates the verification failure prompt, the terminal identifier corresponding to the parameter to be verified can be added into the prompt, and then the terminal identifier is returned to the target interface, so that the verification failure prompt is sent to the target terminal corresponding to the terminal identifier through the target interface for displaying.
The user can check the verification failure prompt on the target terminal, the verification failure prompt can pop up on the target terminal in a text popup mode or in a picture mode, and the content and the mode of the verification failure prompt are not specifically limited by the application. After receiving the verification failure prompt, the user can modify the parameter content according to the prompt information, and upload the parameters to be verified again through the target interface based on the target terminal.
In summary, as shown in fig. 2B, the user starts the application service based on the target terminal and uploads the parameter to be verified through the target interface, the interface data verification plug-in the background intercepts the parameter to be verified for verification, and when the verification result indicates that the parameter is normal, the parameter to be verified is injected into the additional flow method to execute the normal business logic. And when the verification result indicates that the parameters are abnormal, intercepting the parameters to be verified, prohibiting the parameters to be verified from being injected into normal service logic, generating a verification failure prompt, and returning the verification failure prompt to the target terminal through the target interface.
According to the method provided by the embodiment of the application, firstly, the verification annotation is added to the additional flow method of the target interface, and the verification annotation comprises target verification logic and a target processing mode. And then, receiving the parameters to be verified, and verifying the parameters to be verified by adopting target verification logic according to a target processing mode to obtain a verification result. And when the verification result indicates that the to-be-verified parameters are abnormal parameters, intercepting the to-be-verified parameters, generating verification failure prompts, and sending the verification failure prompts to a target terminal indicated by a target interface. The method adopts an annotation mode to verify the interface parameters, has no invasion to normal codes, increases the target processing modes of asynchronous processing and fragment processing, and performs multi-thread processing when the parameters to be processed are more, thereby improving the verification speed and the verification efficiency of parameter verification.
Further, as a specific implementation of the method shown in fig. 1, an embodiment of the present application provides an interface data checking apparatus, and as shown in fig. 3A, the apparatus includes: an annotation module 301, a verification module 302, an interception module 303, and a generation module 304.
The annotation module 301 is configured to add a check annotation to an additional flow method of a target interface, where the check annotation includes a target check logic and a target processing mode, where the target processing mode is used to indicate one of synchronous processing, asynchronous processing, and fragment processing;
the checking module 302 is configured to receive a parameter to be checked, and check the parameter to be checked by using the target checking logic according to the target processing manner to obtain a checking result;
the intercepting module 303 is configured to intercept the parameter to be verified when the verification result indicates that the parameter to be verified is an abnormal parameter;
the generating module 304 is configured to generate a verification failure prompt, and send the verification failure prompt to the target terminal indicated by the target interface, where the verification failure prompt is used to trigger the target terminal to upload the parameters to be verified again.
In a specific application scenario, the annotation module 301 is configured to introduce a related file of a spring framework and start a declarative service; introducing a target annotation file, wherein the target annotation file stores the target verification logic and a target processing mode, and the target verification logic comprises a parameter basic verification annotation, a current limiting verification annotation, a user authentication annotation and a user data authentication annotation; and adding the verification annotation for the additional flow method according to the annotation content indicated in the target annotation file, and packaging the additional flow method added with the annotation in the section programming of the spring frame.
In a specific application scenario, the annotation module 301 is configured to introduce the additional flow method into a tangent plane logic for logic processing with the check annotation as an entry point, and analyze the target check logic in the tangent plane.
In a specific application scenario, the verification module 302 is configured to invoke the target interface to upload the parameter to be verified in response to an application service, intercept the target interface, and receive the parameter to be verified uploaded by the target terminal; generating an agent class on the additional flow method, and injecting the parameters to be verified into the agent class by adopting param parameters in the verification annotation; and calling the proxy class, identifying a target processing mode and the target verification logic stored in the verification annotation, and verifying the parameter to be verified by adopting the target verification logic according to the target processing mode to obtain a verification result.
In a specific application scenario, the checking module 302 is configured to check, by using the target checking logic and by using a single thread, the parameter to be checked when the target processing manner is the synchronous processing, so as to obtain the checking result; when the target processing mode is the asynchronous processing mode, starting a thread pool, and performing asynchronous verification on the parameter to be verified by adopting the target verification logic to obtain a verification result; when the target processing mode is the slicing processing, the parameters to be verified are sliced to obtain a plurality of sliced data, the sliced data are set in a key value pair mode, the sliced data are processed in a multithreading mode synchronously to obtain a plurality of sub-verification results, and the sub-verification results are combined to obtain the verification result.
In a specific application scenario, as shown in fig. 3B, the apparatus further includes: an acquisition module 305 and a presentation module 306.
The obtaining module 305 is configured to, when the verification result indicates that the parameter to be verified is a normal parameter, inject the parameter to be verified into a service logic code to perform logic processing of a service function, and obtain parameter data;
the displaying module 306 is configured to send the parameter data to the terminal corresponding to the target interface for displaying.
In a specific application scenario, as shown in fig. 3C, the apparatus further includes: an identification module 307, a scanning module 308.
The identification module 307 is configured to receive a specified annotation file and identify the specified annotation file;
the scanning module 308 is configured to scan the specified annotation file if the specified annotation file includes basevalid annotations of the combinatorial annotation, and determine a custom check logic and a custom processing mode;
the verification module 302 is further configured to perform parameter verification on the parameter to be verified by using the custom verification logic according to the custom processing manner, so as to obtain the verification result.
According to the device provided by the embodiment of the application, firstly, the verification annotation is added to the additional flow method of the target interface, and the verification annotation comprises target verification logic and a target processing mode. And then, receiving the parameters to be verified, and verifying the parameters to be verified by adopting target verification logic according to a target processing mode to obtain a verification result. And intercepting the parameter to be verified when the verification result indicates that the parameter to be verified is an abnormal parameter, generating a verification failure prompt, and sending the verification failure prompt to a target terminal indicated by a target interface. The method adopts an annotation mode to verify the interface parameters, has no invasion to normal codes, increases the target processing modes of asynchronous processing and fragment processing, and performs multi-thread processing when the parameters to be processed are more, thereby improving the verification speed and the verification efficiency of parameter verification.
It should be noted that other corresponding descriptions of the functional units related to the interface data verification apparatus provided in the embodiment of the present application may refer to the corresponding descriptions in fig. 1 and fig. 2, and are not described herein again.
In an exemplary embodiment, referring to fig. 4, there is further provided a device including a communication bus, a processor, a memory, and a communication interface, and further including an input/output interface and a display device, wherein the functional units may communicate with each other through the bus. The memory stores computer programs, and the processor is used for executing the programs stored in the memory and executing the interface data verification method in the embodiment.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the interface data checking method.
Through the above description of the embodiments, those skilled in the art will clearly understand that the present application can be implemented by hardware, and also by software plus a necessary general hardware platform. Based on such understanding, the technical solution of the present application may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.), and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the implementation scenarios of the present application.
Those skilled in the art will appreciate that the figures are merely schematic representations of one preferred implementation scenario and that the blocks or flow diagrams in the figures are not necessarily required to practice the present application.
Those skilled in the art can understand that the modules in the device in the implementation scenario may be distributed in the device in the implementation scenario according to the implementation scenario description, and may also be located in one or more devices different from the present implementation scenario with corresponding changes. The modules of the implementation scenario may be combined into one module, or may be further split into a plurality of sub-modules.
The above application serial number is merely for description and does not represent the superiority and inferiority of the implementation scenario.
The above disclosure is only a few specific implementation scenarios of the present application, but the present application is not limited thereto, and any variations that can be made by those skilled in the art are intended to fall within the scope of the present application.

Claims (10)

1. An interface data verification method, comprising:
adding a check annotation to an additional flow method of a target interface, wherein the check annotation comprises target check logic and a target processing mode, and the target processing mode is used for indicating one of synchronous processing, asynchronous processing and fragment processing;
receiving a parameter to be verified, and verifying the parameter to be verified by adopting the target verification logic according to the target processing mode to obtain a verification result;
intercepting the parameter to be checked when the checking result indicates that the parameter to be checked is an abnormal parameter;
and generating a verification failure prompt, and sending the verification failure prompt to a target terminal indicated by the target interface, wherein the verification failure prompt is used for triggering the target terminal to upload the parameters to be verified again.
2. The method of claim 1, wherein adding a check annotation to the additional flow method for the target interface comprises:
introducing related files of a spring framework and starting declarative services;
introducing a target annotation file, wherein the target verification logic and a target processing mode are stored in the target annotation file, and the target verification logic comprises parameter basic verification annotations, current limiting verification annotations, user authentication annotations and user data authentication annotations;
and adding the verification annotation for the additional flow method according to the annotation content indicated in the target annotation file, and packaging the additional flow method added with the annotation in the section programming of the spring frame.
3. The method according to claim 2, wherein the packaging of the additional flow method for adding annotation in the section programming of the spring frame comprises: and introducing the additional flow method into a tangent plane logic for logic processing by taking the check annotation as an entry point, and analyzing the target check logic in the tangent plane.
4. The method of claim 1, wherein the receiving the parameter to be verified, and verifying the parameter to be verified by using the target verification logic according to the target processing manner to obtain a verification result comprises:
calling the target interface to upload the parameters to be checked in response to the application service, intercepting the target interface, and receiving the parameters to be checked uploaded by the target terminal;
generating an agent class on the additional flow method, and injecting the parameters to be verified into the agent class by adopting param parameters in the verification annotation;
and calling the proxy class, identifying a target processing mode and the target verification logic stored in the verification annotation, and verifying the parameter to be verified by adopting the target verification logic according to the target processing mode to obtain a verification result.
5. The method according to claim 4, wherein said checking the parameter to be checked with the target checking logic according to the target processing manner to obtain a checking result includes:
when the target processing mode is the synchronous processing, the target verification logic is adopted, and the parameter to be verified is verified by a single thread to obtain the verification result;
when the target processing mode is the asynchronous processing mode, starting a thread pool, and performing asynchronous verification on the parameter to be verified by adopting the target verification logic to obtain a verification result;
when the target processing mode is the slicing processing, the parameters to be verified are sliced to obtain a plurality of sliced data, the sliced data are set in a key value pair mode, the sliced data are processed in a multithreading mode synchronously to obtain a plurality of sub-verification results, and the sub-verification results are combined to obtain the verification result.
6. The method according to claim 1, wherein after the target processing manner is adopted to verify the parameter to be verified by the target verification logic, and a verification result is obtained, the method further comprises:
when the verification result indicates that the parameter to be verified is a normal parameter, injecting the parameter to be verified into a service logic code to perform logic processing of a service function, and obtaining parameter data;
and sending the parameter data to a terminal corresponding to the target interface for displaying.
7. The method of claim 1, further comprising:
receiving a specified annotation file, and identifying the specified annotation file;
if the appointed annotation file contains a combined annotation BaseValidated annotation, scanning the appointed annotation file to determine a self-defined check logic and a self-defined processing mode;
and according to the user-defined processing mode, performing parameter verification on the parameter to be verified by adopting the user-defined verification logic to obtain the verification result.
8. An interface data verification apparatus, comprising:
the annotation module is used for adding check annotation to the additional flow method of the target interface, wherein the check annotation comprises target check logic and a target processing mode, and the target processing mode is used for indicating one of synchronous processing, asynchronous processing and fragment processing;
the verification module is used for receiving the parameters to be verified, verifying the parameters to be verified by adopting the target verification logic according to the target processing mode, and obtaining a verification result;
the interception module is used for intercepting the parameter to be checked when the checking result indicates that the parameter to be checked is an abnormal parameter;
and the generating module is used for generating a verification failure prompt and sending the verification failure prompt to the target terminal indicated by the target interface, wherein the verification failure prompt is used for triggering the target terminal to upload the parameters to be verified again.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor when executing the computer program performs the steps of the method according to any of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202211114477.3A 2022-09-14 2022-09-14 Interface data checking method and device, computer equipment and readable storage medium Pending CN115481023A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211114477.3A CN115481023A (en) 2022-09-14 2022-09-14 Interface data checking method and device, computer equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211114477.3A CN115481023A (en) 2022-09-14 2022-09-14 Interface data checking method and device, computer equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN115481023A true CN115481023A (en) 2022-12-16

Family

ID=84423250

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211114477.3A Pending CN115481023A (en) 2022-09-14 2022-09-14 Interface data checking method and device, computer equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN115481023A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116600009A (en) * 2023-05-11 2023-08-15 浙江轩毅信息技术有限公司 Interface management method based on collateral file safekeeping cabinet

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116600009A (en) * 2023-05-11 2023-08-15 浙江轩毅信息技术有限公司 Interface management method based on collateral file safekeeping cabinet
CN116600009B (en) * 2023-05-11 2023-11-28 浙江轩毅信息技术有限公司 Interface management method based on collateral file safekeeping cabinet

Similar Documents

Publication Publication Date Title
US20180357154A1 (en) Automatically Running Tests Against WEB APIs Based on Specifications
US11726799B2 (en) Preventing framework conflicts for multi-OS applications
CN111400182B (en) Fault injection method, device, server and computer readable storage medium
US20240121261A1 (en) Automated Security Analysis of Software Libraries
CN111563016B (en) Log collection and analysis method and device, computer system and readable storage medium
AU2021206497B2 (en) Method and apparatus for authority control, computer device and storage medium
WO2022095518A1 (en) Automatic interface test method and apparatus, and computer device and storage medium
CN110851352A (en) Fuzzy test system and terminal equipment
CN115481023A (en) Interface data checking method and device, computer equipment and readable storage medium
CN113330419A (en) Equipment application installation method and device
CN111782526A (en) Interface testing method and device, electronic equipment and storage medium
CN114816993A (en) Full link interface test method, system, medium and electronic equipment
CN111752838A (en) Question checking method and device, server and storage medium
CN108763934B (en) Data processing method and device, storage medium and server
CN116599881A (en) Cloud platform tenant modeling test method, device, equipment and storage medium
CN115904317A (en) Method, device, equipment and storage medium for uniformly calling front-end interface and back-end interface
CN113360172B (en) Application deployment method, device, computer equipment and storage medium
CN115470152A (en) Test code generation method, test code generation device, and storage medium
CN114282221B (en) Injection type vulnerability detection method, system, terminal and storage medium
CN114637672A (en) Automatic data testing method and device, computer equipment and storage medium
CN114676436A (en) Android application multimedia analysis library vulnerability mining system and method based on structural variation
Tasiran et al. Location pairs: a test coverage metric for shared-memory concurrent programs
CN114116509A (en) Program analysis method, program analysis device, electronic device, and storage medium
CN114371866A (en) Version reconfiguration test method, device and equipment of service system
CN113419738A (en) Interface document generation method and device and interface management equipment

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