NCI configuration file processing method and device, electronic equipment and storage medium
The white list-based NCI configuration file handling method enhances security and efficiency by parsing only allowed parameters, improving flexibility and maintainability in NCI configuration management.
Patent Information
- Application Number
- CN202510462917.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-14
- Publication Date
- 2025-07-15
AI Technical Summary
The parsing and management of existing NCI configuration files has problems such as poor security, low efficiency, insufficient flexibility and scalability, limited processing of complex data types such as arrays, weak fault tolerance, and lack of unified management interfaces.
The whitelist mechanism is adopted, and the configuration parameter range that allows parsing and management is clearly defined by parsing the parameter whitelist, so as to decouple the definition of configuration parameters and parsing logic, dynamically adjust the storage space, provide a unified configuration management interface, and is compatible with multi-line array configuration items and common newline formats.
It improves the security capabilities of the NFC protocol stack system, improves analysis efficiency and flexibility, enhances system stability and maintainability, simplifies configuration management processes, and improves the overall performance and reliability of configuration management.
Smart Images

Figure CN120321614A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of Near Field Communication (NFC), and particularly to a method, apparatus, electronic device, and storage medium for processing an NCI profile. Background Art
[0002] NCI (NFC Control Interface) is a standardized interface protocol that defines the communication method between an NFC controller and other system components, including host applications, smart card reader applications, etc.
[0003] Currently, in the related art, the parsing and management of NCI profiles are usually implemented by directly parsing and storing key-value pairs. Its working principle is to read the content of the NCI profile, extract parameter values using string matching or preset parsing rules, and perform assignment or storage. However, this direct parsing method is difficult to effectively defend against illegal configurations, and has problems of poor security and low efficiency. Summary of the Invention
[0004] To solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a method, apparatus, electronic device, and storage medium for processing an NCI profile.
[0005] In a first aspect, an embodiment of the present disclosure provides a method for processing an NCI profile, including:
[0006] Upon receiving an NCI configuration parameter acquisition request, acquire an NCI profile;
[0007] Obtain a parsing parameter whitelist, where the parsing parameter whitelist includes at least one parameter entry, and the attributes corresponding to each parameter entry are stored in the form of a structure array;
[0008] Based on the parsing parameter whitelist, parse the target parameters in the NCI profile that match the parameters in the parsing parameter whitelist, and store the parsing results in a configuration parameter storage structure;
[0009] Upon completion of parsing the NCI profile, return the configuration parameter storage structure.
[0010] In a second aspect, an embodiment of the present disclosure provides a device for processing an NCI profile, including:
[0011] A first acquisition module, configured to acquire an NCI profile upon receiving an NCI configuration parameter acquisition request;
[0012] A second acquisition module, configured to acquire a parsing parameter whitelist, where the parsing parameter whitelist includes at least one parameter entry, and the attributes corresponding to each parameter entry are stored in the form of a structure array;
[0013] A parsing and storage module, configured to parse target parameters in the NCI configuration file that match the parameters in the parsing parameter whitelist based on the parsing parameter whitelist, and store the parsing results in a configuration parameter storage structure;
[0014] A return module, configured to return the configuration parameter storage structure in response to the completion of the parsing of the NCI configuration file.
[0015] In a third aspect, an embodiment of the present disclosure provides an electronic device, where the electronic device includes: a processor; a memory for storing executable instructions executable by the processor; the processor is configured to read the executable instructions from the memory and execute the executable instructions to implement the method for processing an NCI configuration file as described in the first aspect.
[0016] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, where the storage medium stores a computer program, and the computer program is used to implement the method for processing an NCI configuration file as described in the first aspect.
[0017] The technical solution provided by the embodiment of the present disclosure has the following advantages compared with the prior art:
[0018] The processing solution for the NCI configuration file provided by the embodiment of the present disclosure, in response to receiving an NCI configuration parameter acquisition request, acquires the NCI configuration file; acquires a parsing parameter whitelist, where the parsing parameter whitelist includes at least one parameter entry, and the attributes corresponding to each parameter entry are stored in the form of a structure array; based on the parsing parameter whitelist, parses target parameters in the NCI configuration file that match the parameters in the parsing parameter whitelist, and stores the parsing results in a configuration parameter storage structure; in response to the completion of the parsing of the NCI configuration file, returns the configuration parameter storage structure. By adopting the solution of the present disclosure, through the parsing parameter whitelist mechanism, only the parameters existing in the parsing parameter whitelist in the NCI configuration file are parsed, which clearly defines the range of configuration parameters allowed to be parsed and managed, effectively preventing the injection and tampering of illegal parameters, thereby improving the security capability of the NFC protocol stack system. At the same time, since the parsing parameter whitelist limits the parsing range, it is not necessary to parse the entire NCI configuration file, which improves the parsing efficiency to a certain extent; and, through the parsing parameter whitelist mechanism, the decoupling of the definition of configuration parameters and the parsing logic is also achieved, and the parameters allowed to be parsed can be flexibly adjusted through the parsing parameter whitelist, improving the flexibility and scalability of parameter parsing. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In conjunction with the accompanying drawings and with reference to the following specific embodiments, the above and other features, advantages, and aspects of the embodiments of the present disclosure will become more apparent. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the original and elements are not necessarily drawn to scale.
[0020] Figure 1 It is a schematic flowchart of a method for processing an NCI configuration file provided by an exemplary embodiment of the present disclosure;
[0021] Figure 2 It is a schematic flowchart of a method for processing an NCI configuration file provided by another exemplary embodiment of the present disclosure;
[0022] Figure 3 It is a schematic flowchart of a method for processing an NCI configuration file provided by yet another exemplary embodiment of the present disclosure;
[0023] Figure 4 It shows a schematic diagram of the processing architecture of an NCI configuration file according to an exemplary embodiment of the present disclosure;
[0024] Figure 5 It shows a schematic flowchart of the parsing process of an NCI configuration file according to an exemplary embodiment of the present disclosure;
[0025] Figure 6 It is a schematic diagram of the structure of a processing device for an NCI configuration file provided by an embodiment of the present disclosure. Specific Embodiments
[0026] The embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. On the contrary, these embodiments are provided to more thoroughly and completely understand the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not used to limit the protection scope of the present disclosure.
[0027] It should be understood that the various steps recited in the method embodiments of the present disclosure can be executed in a different order and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this regard.
[0028] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0029] It should be noted that the concepts such as "first", "second", etc. mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0030] It should be noted that the modification of "one" and "multiple" mentioned in this disclosure is illustrative rather than restrictive. Those skilled in the art should understand that unless clearly specified otherwise in the context, it should be understood as "one or more".
[0031] The names of the messages or information exchanged between multiple devices in the embodiments of this disclosure are only for illustrative purposes and are not used to limit the scope of these messages or information.
[0032] In the related art, the NCI configuration file parsing and management methods are mainly full parsing or hard coding. Although full parsing can read the content in a preset format, its security and configuration item management efficiency are insufficient, and it is difficult to effectively defend against illegal configurations; the hard coding method lacks flexibility because the parameters are directly embedded in the code, and any modification requires recompilation, resulting in low maintenance efficiency. In addition, when processing array parameters, the static array storage cannot be dynamically adjusted due to its fixed size, which is likely to cause space waste and potential overflow risks, and is not conducive to the stability of the system.
[0033] It can be seen that the existing parsing methods generally have disadvantages such as poor security, insufficient flexibility and scalability, limited processing of complex data types such as arrays, weak fault tolerance, and lack of a unified management interface. They are not only vulnerable to malicious configurations, but also have relatively fixed usage and are not easy to expand. When facing new requirements, certain modifications are often required, which limits their application scenarios and life cycles and is not conducive to code maintenance.
[0034] The purpose of this disclosure is to make up for the deficiencies in aspects such as security, flexibility, scalability, complex data type processing ability, fault tolerance, and unified management interface existing in the prior art solutions, and provides a parsing and management solution for NCI configuration files, aiming to provide a more secure, reliable, flexible and efficient configuration management mechanism for the NFC protocol stack system. The purpose and corresponding technical means of the solution of this disclosure are mainly reflected in the following aspects:
[0035] a) Enhance system security: The prior art lacks an effective configuration verification mechanism, which may pose a potential threat to the NCI protocol stack system. This disclosure introduces a whitelist mechanism, which precisely defines the parameter names, types, verification flags, and memory address mapping relationships. By parsing the parameter whitelist, the range of configuration parameters allowed to be parsed and managed is clearly defined. Based on the parsed parameter whitelist, the configuration file is parsed directionally, and only the parameter items specifically specified in the parsed parameter whitelist are processed, effectively preventing illegal parameter injection and tampering, solving the security risks of malicious configuration injection, enhancing the security of configuration parsing, improving the security capabilities of the NFC protocol stack system, and avoiding risks such as system crashes or function abnormalities caused by illegal configurations. At the same time, since the parsing scope is limited by the parsed parameter whitelist, especially when faced with large and complex configuration files, a certain parsing efficiency can also be improved.
[0036] b) Enhance configuration flexibility and scalability: There is a certain coupling between the parsing and configuration parameters in the prior art. When new configuration attributes need to be extended, the code often needs to be modified significantly, resulting in poor flexibility and scalability. This disclosure innovatively adopts the design idea based on the whitelist structure array, realizing the decoupling of the configuration parameter definition and the parsing logic; the configuration parameters are clearly defined by predefining the structure array, and the parameter type mapping union design is used to achieve stronger generality, flexibly supporting multiple configuration parameter types, and using the predefined macro wrapper to encapsulate the parameter entries in the parsed parameter whitelist, simplifying the configuration process of the parsed parameter whitelist. To add new parameters, only the structure array needs to be extended, without modifying the core code, greatly enhancing the flexibility and scalability of configuration management, improving the development efficiency, being able to reduce the later maintenance cost, and being able to quickly respond to the changing configuration requirements.
[0037] c) Optimize the processing method of array type parameters: When dealing with array type parameters in the prior art, problems such as static size limitations are usually faced, and the operations are relatively cumbersome. This disclosure identifies the array type from the parsed parameter whitelist and dynamically allocates or adjusts the storage space according to the actual parameter value size after parsing during the parsing process, reducing the risk of memory waste or overflow, optimizing the memory utilization, overcoming the limitation of the fixed static array size, realizing the on-demand allocation of the storage space for array parameters, and also avoiding some memory problems, enhancing the system operation stability.
[0038] d) Improving the fault tolerance of the NCI protocol stack: When some key parameters are missing in the configuration file of the prior art, the protocol stack may not be able to start or run properly, and the fault tolerance is poor. Before parsing the NCI configuration file, the present disclosure will pre-initialize the default values of the configuration parameter storage structure to ensure that even if some parameters are missing in the configuration file, the system can still start and run normally based on the preset default values, and can mark the missing parameters to avoid system exceptions that may occur when necessary parameters are missing, significantly improving the system stability and fault tolerance, thereby effectively enhancing the reliability of the NFC protocol stack system and improving the user experience.
[0039] e) Building a unified configuration management interface: In the prior art solutions, the acquisition methods of configuration parameters are scattered, lacking a unified management entry, which is not conducive to the centralized management and maintenance of configuration parameters by the protocol stack, reducing the maintainability and readability of the code. This solution provides a unified configuration parameter acquisition interface, facilitating the protocol stack to access and manage configuration parameters conveniently, simplifying the configuration management process, and improving the maintainability and readability of the code.
[0040] f) Enhancing the compatibility of the configuration file format: To enhance the versatility and application scope of this solution and considering the diversity of application scenarios, this solution is fully compatible with multi-line array configuration items and common line break formats, including common line break formats such as LF, CR, and CRLF, and can adapt to different operating systems and text editor environments, improving versatility and convenience, enhancing compatibility, flexibly processing NCI configuration files in different source formats, and implementing the parsing of multi-line configuration items, expanding the application scenarios, and improving the efficiency of configuration processing and the user experience.
[0041] The above innovative technical means work together to provide a safer, more flexible, efficient, and reliable NCI configuration file parsing and management solution, which can effectively reduce configuration risks, improve configuration management efficiency and flexibility, enhance system stability and maintainability, and thus significantly improve the overall performance and reliability of NCI configuration management. Compared with the existing NCI configuration parsing and management methods, it has achieved improvements in terms of security, flexibility, efficiency, and reliability, and is applicable to most Unix-like systems.
[0042] The following will explain in detail the processing method, device, electronic device, and storage medium of the NCI configuration file provided by the present disclosure with reference to the accompanying drawings.
[0043] Figure 1 FIG. is a schematic flowchart of the processing method of the NCI configuration file provided by an exemplary embodiment of the present disclosure. This method can be executed by the processing device of the NCI configuration file provided by the embodiments of the present disclosure. The device can be implemented in software and / or hardware and can be integrated in an electronic device.
[0044] As Figure 1As shown in the figure, the processing method of the NCI configuration file may include the following steps:
[0045] Step 101, in response to receiving an NCI configuration parameter acquisition request, obtain the NCI configuration file.
[0046] In this embodiment, when receiving an NCI configuration parameter acquisition request, the corresponding NCI configuration file may be obtained first.
[0047] As an example, the NCI configuration parameter acquisition request may carry the file name and storage path of the NCI configuration file. In response to receiving the NCI configuration parameter acquisition request, obtain the NCI configuration file that matches the file name from the storage path carried in the NCI configuration parameter acquisition request.
[0048] As another example, the storage path of the NCI configuration file may be pre-configured. The NCI configuration parameter acquisition request carries the file name of the NCI configuration file. When receiving the NCI configuration parameter acquisition request, determine the storage path where the NCI configuration file is located according to the file name, and obtain the NCI configuration file that matches the file name from this storage path.
[0049] Step 102, obtain the parsing parameter whitelist. The parsing parameter whitelist includes at least one parameter entry, and the attributes corresponding to each parameter entry are stored in the form of a structure array.
[0050] Among them, the parsing parameter whitelist can be configured by the user according to actual needs. The parsing parameter whitelist includes at least one parameter entry, and the attributes corresponding to each parameter entry are stored in the form of a structure array. That is to say, the parsing parameter whitelist is stored in the form of a data set of variable-type structures. A structure array corresponds to a parameter (i.e., a parameter entry) in the parsing parameter whitelist. Each element in the structure array describes an allowable configuration parameter item (i.e., the attribute of the parameter) for the parameter entry. The attributes of the parameter entry stored in a structure array may include but are not limited to the parameter name, parameter value type, parameter value storage location mapping (pointing to the corresponding element in the configuration parameter storage structure), parameter parsing status flag (initially "unparsed"), etc., and can be extended according to actual needs.
[0051] Step 103, based on the parsing parameter whitelist, parse the target parameters in the NCI configuration file that match the parameters in the parsing parameter whitelist, and store the parsing results in the configuration parameter storage structure.
[0052] In this embodiment, the NCI configuration file can be parsed based on the obtained parsing parameter whitelist. During parsing, only the parameters in the NCI configuration file that exist in the parsing parameter whitelist are parsed. For example, if the parameter name of a parameter in the NCI configuration file is the same as the parameter name in a certain parameter entry in the parsing parameter whitelist, then the parameter in the NCI configuration file is parsed to obtain a parsing result, and the parsing result is stored in the configuration parameter storage structure.
[0053] Among them, the configuration parameter storage structure is predefined according to the configuration requirements of the NFC protocol stack, and includes the required configuration parameters (such as log level, card reading / listening technical parameters, etc.) and their value types. An element in the configuration parameter storage structure is a structure for storing the relevant information of the parameter that has a mapping relationship with the element position of the element, including the parsing result. That is to say, in this embodiment, for the parameters allowed to be parsed in the NCI configuration file, the obtained parsing results are mapped and stored in the corresponding elements of the configuration parameter storage structure according to the parameter value storage positions corresponding to the parameters stored in the parsing parameter whitelist.
[0054] Step 104, in response to the completion of the parsing of the NCI configuration file, return the configuration parameter storage structure.
[0055] In this embodiment, after the parsing of the NCI configuration file is completed, the configuration parameter storage structure is returned, and the parsing results of all the parameters allowed to be parsed in the parsing parameter whitelist are stored in the configuration parameter storage structure.
[0056] In an alternative embodiment of the present disclosure, for the obtained parsing parameter whitelist, the number of parameter entries in the parsing parameter whitelist can be counted, and the number of parameters that have been parsed can be counted during the process of parsing the NCI configuration file. When the number of parameters that have been parsed is the same as the number of parameter entries in the parsing parameter whitelist, it is determined that the parsing of the NCI configuration file is completed.
[0057] The method for processing the NCI configuration file provided by the embodiments of the present disclosure obtains the NCI configuration file in response to receiving an NCI configuration parameter acquisition request; obtains a parsing parameter whitelist, where the parsing parameter whitelist includes at least one parameter entry, and the attributes corresponding to each parameter entry are stored in the form of a structure array; based on the parsing parameter whitelist, parses the target parameters in the NCI configuration file that match the parameters in the parsing parameter whitelist, and stores the parsing results in a configuration parameter storage structure; in response to the completion of the parsing of the NCI configuration file, returns the configuration parameter storage structure. By adopting the solution of the present disclosure, through the parsing parameter whitelist mechanism, only the parameters existing in the parsing parameter whitelist in the NCI configuration file are parsed, clearly defining the range of configuration parameters allowed to be parsed and managed, effectively preventing the injection and tampering of illegal parameters, thereby improving the security capabilities of the NFC protocol stack system. At the same time, since the parsing parameter whitelist limits the parsing scope, there is no need to parse the entire NCI configuration file, which improves the parsing efficiency to a certain extent; moreover, through the parsing parameter whitelist mechanism, the decoupling of the definition of configuration parameters and the parsing logic is also achieved, and the parameters allowed to be parsed can be flexibly adjusted through the parsing parameter whitelist, enhancing the flexibility and scalability of parameter parsing.
[0058] In an alternative embodiment of the present disclosure, as Figure 2 shown, on the basis of the embodiment shown in Figure 1 step 102 may include the following sub-steps:
[0059] Step 201, determine a target wrapper macro that matches the parameter value type according to the parameter value type selected by the user.
[0060] In this embodiment, wrapper macros can be created in advance for different parameter value types. Some attribute values are pre-configured in the wrapper macros, and some attributes are reserved for the user to configure according to needs. For example, the values of the two attributes of the parameter value type and the parameter parsing status flag of the parameter in the wrapper macro are pre-configured, and the two attributes of the parameter name and the storage location of the parameter value are reserved for the user to configure. When the user needs to create a parsing parameter whitelist, the user can select the required parameter value type according to the parameter value type corresponding to the parameter to be configured, so that the electronic device determines a wrapper macro that matches the parameter value type according to the parameter value type selected by the user (for the convenience of description and distinction, it is called the target wrapper macro).
[0061] Step 202, receive the parameter name and storage location input by the user, where the storage location is the element location in the configuration parameter storage structure.
[0062] Step 203, fill the parameter name into the parameter name attribute in the target wrapper macro, and fill the storage location into the parameter value storage location attribute in the target wrapper macro to obtain a parameter entry.
[0063] In this embodiment, when the user creates a whitelist of parsing parameters, after selecting a suitable target wrapper macro, only the corresponding parameter name and the storage location of the parameter value need to be input. Among them, the storage location represents the element location of the parameter value in the configuration parameter storage structure. The electronic device fills the received parameter name into the parameter name attribute in the target wrapper macro, and fills the storage location into the parameter value storage location attribute in the target wrapper macro to obtain a parameter entry.
[0064] In this embodiment, by pre-configuring wrapper macros that implement different attribute configurations corresponding to different parameter value types, the creation of parameter entries in the whitelist of parsing parameters is simplified. It is possible to only receive the mapping of the parameter name and the element location in the configuration parameter storage structure, and other information is automatically filled, which is simple, efficient and convenient.
[0065] Step 204: Construct a whitelist of parsing parameters based on the obtained parameter entries.
[0066] In this embodiment, when the user creates the parameter entries of the required parsing parameters, based on the constructed parameter entries, a whitelist of parsing parameters can be obtained, and then the parsing of the NCI configuration file can be controlled based on the whitelist of parsing parameters.
[0067] The method for processing the NCI configuration file according to the embodiments of the present disclosure determines a target wrapper macro that matches the parameter value type according to the parameter value type selected by the user, receives the parameter name and the storage location input by the user, and the storage location is the element location in the configuration parameter storage structure. Then, the parameter name is filled into the parameter name attribute in the target wrapper macro, and the storage location is filled into the parameter value storage location attribute in the target wrapper macro to obtain a parameter entry. Finally, a whitelist of parsing parameters is constructed based on the obtained parameter entries. Thus, through the wrapper macro, the automation of parameter entry configuration is realized, the configuration process is simplified, the code is concise and easy to understand. The user only needs to focus on the mapping between the parameter name and the element location in the configuration parameter storage structure, so as to avoid possible errors in manual filling, improve the configuration efficiency, code readability and maintainability, and reduce the development difficulty, error rate and maintenance cost.
[0068] Further, in an optional implementation manner of the present disclosure, as Figure 3 shown, on the basis of the foregoing embodiment, step 103 may include the following sub-steps:
[0069] Step 301: Read the NCI configuration file line by line and obtain the parameter name of the target parameter currently read.
[0070] In this embodiment, for the obtained NCI configuration file, the NCI configuration file can be read line by line to obtain the parameter name of the target parameter currently read.
[0071] Optionally, when reading the NCI configuration file, it can automatically process multiple formats (such as multi-line arrays, different line break formats LF, CR, CRLF, etc.), perform key-value pair splitting and parsing after formatting (including removing whitespace and comments), so as to adapt to configuration files edited by different systems and editors, improve generality and convenience, enhance compatibility, and flexibly process configuration files in different source formats.
[0072] Step 302: Match the parameter name in the parsing parameter whitelist to determine whether the parameter name exists in the parsing parameter whitelist.
[0073] In this embodiment, for the parameter name of the currently read target parameter, the parameter name can be matched in the parsing parameter whitelist to determine whether the parameter name exists in the parsing parameter whitelist. If it exists, it is determined that the parameter corresponding to the parameter name in the NCI configuration file is allowed to be parsed, and then step 303 and subsequent steps are executed; if the parameter name does not exist in the parsing parameter whitelist, it is determined that the parameter corresponding to the parameter name in the NCI configuration file is not allowed to be parsed, the parameters related to the parameter name in the NCI configuration file are ignored, and the next line content of the NCI configuration file is continued to be read to obtain the parameter name of the next parameter and continue to match it in the parsing parameter whitelist. The above process is repeated until the NCI configuration file is parsed completely.
[0074] Step 303: If it exists, convert the parameter value of the target parameter to the target parameter value type based on the target parameter value type of the target parameter entry in the parsing parameter whitelist that matches the parameter name.
[0075] In this embodiment, when the currently read parameter name is matched in the parsing parameter whitelist, the target parameter value type of the target parameter entry in the parsing parameter whitelist that matches the parameter name is further obtained, and based on this target parameter value type, the parameter value of the target parameter recorded in the NCI configuration file is converted from the text type to the target parameter value type. For example, if the target parameter value type is an integer type, the parameter value of the target parameter is converted to an integer type.
[0076] Step 304: Obtain the target storage location of the target parameter entry, and assign the parameter value converted to the target parameter value type to the target element position corresponding to the target storage location in the configuration parameter storage structure, where the storage space size of the target element position is the same as the size of the parameter value converted to the target parameter value type.
[0077] Among them, the target storage location is the element position mapped by the target parameter in the configuration parameter storage structure, pointing to the storage location of the parameter value of the target parameter in the configuration parameter storage structure.
[0078] In this embodiment, after converting the parameter value of the target parameter into the target parameter value type, the target storage location can be obtained from the target parameter entry, and then the parameter value converted into the target parameter value type is assigned to the target element location corresponding to the target storage location in the configuration parameter storage structure. Among them, the storage space of each element location in the configuration parameter storage structure is dynamically adjustable, and the storage space can be dynamically allocated or adjusted according to the actual size of the stored parameter value, so that the storage space size of the target element location is consistent with the size of the parameter value converted into the target parameter value type, improving the utilization rate and flexibility of the storage space.
[0079] For the method for processing the NCI configuration file according to the embodiment of the present disclosure, by reading the NCI configuration file line by line, obtaining the parameter name of the target parameter currently read, matching the parameter name in the parsed parameter whitelist, and determining whether there is a parameter name in the parsed parameter whitelist. If there is, based on the target parameter value type of the target parameter entry matching the parameter name in the parsed parameter whitelist, the parameter value of the target parameter is converted into the target parameter value type, and the parameter value converted into the target parameter value type is assigned to the target element location corresponding to the target storage location in the configuration parameter storage structure, and the storage space size of the target element location is consistent with the size of the parameter value converted into the target parameter value type. Thus, by limiting the parsing range and parameter value storage location of the NCI configuration file through the parsed parameter whitelist, the security risk of malicious configuration injection can be effectively solved, and the security of configuration parsing is improved. Moreover, through dynamic storage management of the storage space of the configuration parameter storage structure, precise memory allocation on demand is achieved, reducing the risk of memory waste or overflow.
[0080] Further, in an optional implementation manner of the present disclosure, the attribute corresponding to each parameter entry includes a parameter parsing status flag, and the value of the parameter parsing status flag is defaulted to unparsed. In this embodiment, after the parameter value converted into the target parameter value type is assigned to the target element location corresponding to the target storage location in the configuration parameter storage structure, the value of the parameter parsing status flag in the target parameter entry can be updated to parsed, and it is determined whether the values of the parameter parsing status flags of each parameter entry in the parsed parameter whitelist are all parsed. If so, it is determined that the parsing of the NCI configuration file is completed; if there are still values of the parameter parsing status flags of parameter entries that are unparsed, continue to read the NCI configuration file for parsing. Thus, by setting a parameter parsing status flag for each parameter entry, it can clearly reflect whether each parameter has been parsed, thereby quickly determining whether the parsing of the NCI configuration file is completed and improving the parsing efficiency.
[0081] In an alternative embodiment of the present disclosure, before parsing the target parameters in the NCI configuration file that match the parameters in the parsing parameter whitelist based on the parsing parameter whitelist, default values can also be assigned to each element position in the configuration parameter storage structure. By initializing the default values of the configuration parameter storage structure before parsing, it can ensure that the system can still run when some configurations are missing, avoid system exceptions that may occur when necessary parameters are missing, significantly improve the system stability, fault tolerance and reliability, and enhance the user experience.
[0082] In an alternative embodiment of the present disclosure, the values of each attribute corresponding to each parameter entry are stored in the form of a union in the structure array. That is to say, the various attributes defined in the structure corresponding to the parameter entry are stored through the union to store attribute values of different types. Thus, in parameter management, the structure and the union are used in combination. By using the union to store different types of parameter pointers, code redundancy can be reduced, the maintenance difficulty can be lowered, and with the compatibility of the union, various types of attributes can be efficiently managed without repeated definition, thereby improving the reusability and expandability, simplifying the code structure, reducing the complexity, facilitating subsequent expansion and maintenance, and ensuring the efficiency and flexibility of data access.
[0083] In an alternative embodiment of the present disclosure, the NCI configuration parameter acquisition request is initiated by the user through the configuration management API (Application Programming Interface). The solution of the present disclosure provides a configuration parameter management function through the configuration management API, including initiating an NCI configuration parameter acquisition request, querying the parameter parsing status (checking whether the parameter is successfully parsed through the parameter parsing status flag), querying the corresponding parameter value according to the parameter name input by the user (obtaining a specific type of parameter value by the parameter name and performing information type matching check), constructing or modifying one or more in the parsing parameter whitelist, and new parameters, function interfaces and requirements can also be conveniently extended by expanding the parsing parameter whitelist. This solution provides a unified configuration management API interface, which facilitates the protocol stack to access and manage configuration parameters conveniently, simplifies the configuration management process, and improves the maintainability and readability of the code.
[0084] Figure 4 The figure shows a schematic diagram of the processing architecture of the NCI configuration file according to an exemplary embodiment of the present disclosure, as Figure 4As shown, the solution of the present disclosure is applicable to different types of systems such as Android and Linux. The NCI configuration parameters can be accessed and managed through the provided configuration management API interface. The whitelist module is located within the configuration parsing and control module, collaborating with the configuration management module and the parser. In the whitelist module, a parsed parameter whitelist is stored, which is stored in the form of a data set of variable-type structures. Each element describes a parameter entry in the parsed parameter whitelist that allows a configurable parameter item. The parameter entry is associated and mapped to the corresponding parameter in the configuration parameter storage area, and this mapping is the core of the whitelist mechanism. The configuration management module obtains the configuration file information, and the parser parses the NCI configuration file based on the parsed parameter whitelist stored in the whitelist module. The following combines Figure 5 to explain the parsing process of the NCI configuration file.
[0085] Figure 5 shows a schematic diagram of the parsing process of the NCI configuration file according to an exemplary embodiment of the present disclosure. As Figure 5 shown, it shows the interaction process of the configuration management API interface, the configuration management module, the parser, and the NCI configuration file. Its goal is to parse the parameters from the NCI configuration file and assign them to the configuration parameter storage structure, which specifically includes the following steps:
[0086] (1) Invoke the configuration management API interface: The NCI protocol stack invokes the configuration management API to initiate an NCI configuration parameter acquisition request to the configuration management module.
[0087] (2) Initialize default values: After receiving the request, the configuration management module performs lazy loading processing and assigns default values to all parameters in the configuration parameter storage structure before obtaining the configuration parameter values, so that the system can still start even if the configuration file lacks necessary parameters.
[0088] (3) Open the configuration file: The configuration management module opens the NCI configuration file according to the storage path of the NCI configuration file, obtains the content of the NCI configuration file, and sends it to the parser.
[0089] (4) Read and parse line by line: The parser reads the NCI configuration file line by line, automatically processes multiple formats (multi-line arrays, different line break formats), and performs key-value pair splitting and parsing after formatting (removing whitespace and comments).
[0090] (5) Parameter value parsing and type conversion: The parser matches according to the parameter name in the parsed parameter whitelist, and only the parameters in the parsed parameter whitelist are allowed to be parsed. Based on the parameter types defined in the parsed parameter whitelist, the text value is converted into the corresponding type, and is assigned to the corresponding element in the configuration parameter storage structure through the mapping relationship, and the parameter is marked as "parsed". Among them, for the parameter values read from the NCI configuration file, the parser also checks the parameter format (such as range, length, etc.) to determine whether the parameter values meet the requirements. When they meet the requirements, parsing is performed; when they do not meet the requirements, parsing is not performed. In addition, for data of parameter types such as arrays and strings, dynamic storage management is adopted, and the storage space of the corresponding elements in the configuration parameter storage structure is dynamically allocated / adjusted according to the actual size of the parameter values after type conversion.
[0091] (6) Return the configuration result: After parsing is completed, close the NCI configuration file, and return the configuration parameter storage structure storing the parsed result to the NCI protocol stack.
[0092] Through the solution of the present disclosure, the usage safety and development and maintenance efficiency are greatly improved; through technical means such as dynamic storage, initialization of default values, and multi-format compatibility, the present solution is also superior to the prior art in terms of memory utilization, system fault tolerance, and versatility.
[0093] In order to implement the above embodiments, the present disclosure also provides a processing device for an NCI configuration file.
[0094] Figure 6 FIG. is a schematic structural diagram of a processing device for an NCI configuration file provided by an embodiment of the present disclosure. The device is implemented in a software and / or hardware manner and can be integrated in an electronic device.
[0095] As Figure 6 shown, the processing device 50 for the NCI configuration file may include: a first acquisition module 510, a second acquisition module 520, a parsing and storage module 530, and a return module 540.
[0096] Among them, the first acquisition module 510 is configured to acquire the NCI configuration file in response to receiving an NCI configuration parameter acquisition request;
[0097] The second acquisition module 520 is configured to acquire a parsed parameter whitelist, and the parsed parameter whitelist includes at least one parameter entry, and the attributes corresponding to each parameter entry are stored in the form of a structure array;
[0098] The parsing and storage module 530 is configured to parse the target parameters in the NCI configuration file that match the parameters in the parsed parameter whitelist based on the parsed parameter whitelist, and store the parsing results in the configuration parameter storage structure;
[0099] A return module 540, configured to return a configuration parameter storage structure in response to completion of parsing of the NCI configuration file.
[0100] Optionally, the second acquisition module 520 is further configured to:
[0101] Determine a target wrapping macro that matches the parameter value type according to the parameter value type selected by the user;
[0102] Receive the parameter name and storage location input by the user, where the storage location is the element location in the configuration parameter storage structure;
[0103] Fill the parameter name into the parameter name attribute in the target wrapping macro, and fill the storage location into the parameter value storage location attribute in the target wrapping macro to obtain a parameter entry;
[0104] Construct a parsed parameter whitelist based on the obtained parameter entry.
[0105] Further optionally, the parsing storage module 530 is further configured to:
[0106] Read the NCI configuration file line by line to obtain the parameter name of the currently read target parameter;
[0107] Match the parameter name in the parsed parameter whitelist to determine whether the parameter name exists in the parsed parameter whitelist;
[0108] If it exists, convert the parameter value of the target parameter to the target parameter value type based on the target parameter value type of the target parameter entry that matches the parameter name in the parsed parameter whitelist;
[0109] Obtain the target storage location of the target parameter entry, and assign the parameter value converted to the target parameter value type to the target element location corresponding to the target storage location in the configuration parameter storage structure, where the storage space size of the target element location is the same as the size of the parameter value converted to the target parameter value type.
[0110] Further optionally, the attribute corresponding to each parameter entry includes a parameter parsing status flag, and the value of the parameter parsing status flag defaults to unparsed; the processing device 50 for the NCI configuration file further includes:
[0111] A status update module, configured to update the value of the parameter parsing status flag in the target parameter entry to parsed;
[0112] A judgment module, configured to judge whether the values of the parameter parsing status flags of each parameter entry in the parsed parameter whitelist are all parsed;
[0113] A determination module, configured to determine that the parsing of the NCI configuration file is completed when the values of the parameter parsing status flags of each parameter entry in the parsed parameter whitelist are all parsed.
[0114] Optionally, the processing device 50 for the NCI configuration file further includes:
[0115] An initialization module, configured to assign default values to each element position in the configuration parameter storage structure before parsing the target parameters in the NCI configuration file that match the parameters in the parsed parameter whitelist based on the parsed parameter whitelist.
[0116] Optionally, the values of each attribute corresponding to each parameter entry are stored in the form of a union in the structure array.
[0117] Optionally, the NCI configuration parameter acquisition request is initiated by the user through the configuration management API; the configuration management API further includes at least one of the following functions:
[0118] Query the parameter parsing status;
[0119] Query the corresponding parameter value according to the parameter name input by the user;
[0120] Construct or modify the parsed parameter whitelist.
[0121] The processing device for the NCI configuration file applied to the electronic device provided by the embodiments of the present disclosure can execute the NCI configuration file processing method provided by the embodiments of the present disclosure, and has the corresponding functional modules and beneficial effects for executing the method. The content not described in detail in the device embodiments of the present disclosure can be referred to the description in any method embodiment of the present disclosure.
[0122] The embodiments of the present disclosure also provide a computer program product, including computer programs / instructions, which when executed by a processor, implement the NCI configuration file processing method provided by any embodiment of the present disclosure.
[0123] According to one or more embodiments of the present disclosure, the present disclosure provides an electronic device, including:
[0124] A processor;
[0125] A memory for storing executable instructions of the processor;
[0126] The processor is configured to read the executable instructions from the memory and execute the executable instructions to implement the NCI configuration file processing method provided by any embodiment of the present disclosure.
[0127] According to one or more embodiments of the present disclosure, the present disclosure provides a computer-readable storage medium storing a computer program for implementing the method for processing an NCI configuration file provided in any embodiment of the present disclosure.
[0128] It should be noted that the computer-readable medium in the present disclosure may be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present disclosure, the computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0129] The above computer-readable medium may be included in the above electronic device; or it may exist separately and not be assembled into the electronic device.
[0130] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a segment of code, or a portion thereof that contains one or more executable instructions for implementing a specified logical function. It should also be noted that, in some alternative implementations, the functions noted in the blocks may occur in a different order than that noted in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or by a combination of dedicated hardware and computer instructions.
[0131] The units involved in the embodiments described in the present disclosure can be implemented in software or in hardware. In some cases, the name of the unit does not constitute a limitation on the unit itself.
[0132] The functions described above herein can be performed, at least in part, by one or more hardware logic components. By way of example, and not limitation, the types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system on a chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0133] In the context of the present disclosure, a machine-readable medium may be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0134] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, the technical solutions formed by mutually replacing the above features with the technical features (but not limited to) having similar functions disclosed in the present disclosure.
[0135] In addition, although the operations are depicted in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or in sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features described in the context of separate embodiments may also be implemented combinatorially in a single embodiment. Conversely, the various features described in the context of a single embodiment may also be implemented separately or in any suitable sub-combination in multiple embodiments.
[0136] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms for implementing the claims.
Claims
1. A method for processing an NCI configuration file, characterized in that, The method includes: Upon receiving an NCI configuration parameter acquisition request, acquiring an NCI configuration file; Acquiring a parsing parameter whitelist, where the parsing parameter whitelist includes at least one parameter entry, and the attributes corresponding to each parameter entry are stored in the form of a structure array; Based on the parsing parameter whitelist, parsing the target parameters in the NCI configuration file that match the parameters in the parsing parameter whitelist, and storing the parsing results in a configuration parameter storage structure; Upon completion of parsing the NCI configuration file, returning the configuration parameter storage structure.
2. The method according to claim 1, characterized in that, The acquiring the parsing parameter whitelist includes: Determining a target wrapper macro that matches the parameter value type according to the parameter value type selected by the user; Receiving the parameter name and storage location input by the user, where the storage location is the element location in the configuration parameter storage structure; Filling the parameter name into the parameter name attribute in the target wrapper macro, and filling the storage location into the parameter value storage location attribute in the target wrapper macro to obtain a parameter entry; Constructing the parsing parameter whitelist based on the obtained parameter entry.
3. The method according to claim 2, wherein The parsing, based on the parsing parameter whitelist, of the target parameters in the NCI configuration file that match the parameters in the parsing parameter whitelist, and storing the parsing results in a configuration parameter storage structure includes: Reading the NCI configuration file line by line to obtain the parameter name of the currently read target parameter; Matching the parameter name in the parsing parameter whitelist to determine whether the parameter name exists in the parsing parameter whitelist; If it exists, converting the parameter value of the target parameter to the target parameter value type based on the target parameter value type of the target parameter entry in the parsing parameter whitelist that matches the parameter name; Obtaining the target storage location of the target parameter entry, and assigning the parameter value converted to the target parameter value type to the target element location corresponding to the target storage location in the configuration parameter storage structure, where the storage space size of the target element location is the same as the size of the parameter value converted to the target parameter value type.
4. The method according to claim 3, wherein The attributes corresponding to each parameter entry include a parameter parsing status flag, and the value of the parameter parsing status flag is defaulted to unparsed; After assigning the parameter value converted to the target parameter value type to the target element location corresponding to the target storage location in the configuration parameter storage structure, the method further includes: Updating the value of the parameter parsing status flag in the target parameter entry to parsed; Judging whether the values of the parameter parsing status flags of each parameter entry in the parsing parameter whitelist are all parsed; If so, determining that the parsing of the NCI configuration file is completed.
5. The method according to claim 1, wherein Before the parsing, based on the parsing parameter whitelist, of the target parameters in the NCI configuration file that match the parameters in the parsing parameter whitelist, the method further includes: Assigning default values to each element location in the configuration parameter storage structure.
6. The method according to any one of claims 1-5, characterized in that The value of each attribute corresponding to each parameter entry is stored in the form of a union in the structure array.
7. The method according to any one of claims 1-5, characterized in that, The NCI configuration parameter acquisition request is initiated by the user through the configuration management API; The configuration management API further includes at least one of the following functions: Query the parameter parsing status; Query the corresponding parameter value according to the parameter name input by the user; Construct or modify the parsing parameter whitelist.
8. A processing device for an NCI configuration file, characterized in that The device includes: A first acquisition module, configured to acquire an NCI configuration file in response to receiving an NCI configuration parameter acquisition request; A second acquisition module, configured to acquire a parsing parameter whitelist, where the parsing parameter whitelist includes at least one parameter entry, and the attributes corresponding to each parameter entry are stored in the form of a structure array; A parsing and storage module, configured to parse the target parameters in the NCI configuration file that match the parameters in the parsing parameter whitelist based on the parsing parameter whitelist, and store the parsing results in a configuration parameter storage structure; A return module, configured to return the configuration parameter storage structure in response to the completion of the parsing of the NCI configuration file.
9. An electronic device, characterized in that, The electronic device includes: A processor; A memory for storing executable instructions executable by the processor; The processor is configured to read the executable instructions from the memory and execute the executable instructions to implement the method for processing the NCI configuration file according to any one of claims 1-7 above.
10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, and the computer program is used to implement the method for processing the NCI configuration file according to any one of claims 1-7 above.
Citation Information
Cited By
Reserved structural body determination method and device, terminal and medium
CN120743339A