Safety examination method and device for numerical control program

文档序号:700992 发布日期:2021-04-13 浏览:4次 中文

阅读说明:本技术 数控程序的安全审查方法及装置 (Safety examination method and device for numerical control program ) 是由 许欣 江勇 侯方圆 李宁 杨森 李云峰 赵世杰 王湖 于 2020-12-25 设计创作,主要内容包括:本公开涉及一种数控程序的安全审查方法及装置,包括:获取第一数据文件;根据确定的预设编码规则对第一数据文件的当前编码方式进行编码方式审查,在当前编码方式与预设编码规则一致的情况下,对第一数据文件进行解析,生成第二数据文件;根据知识库中的格式规则对第二数据文件进行格式审查,得到第一审查结果;在第一审查结果正确的情况下,根据知识库中的逻辑规则对第二数据文件进行逻辑审查,得到第二审查结果;在第二审查结果正确的情况下,将第一数据文件发送至目标设备,使目标设备执行与第一数据文件相对应的操作,确保第一数据文件的规范性,提高工业控制系统的安全性,避免对目标设备造成损坏。(The disclosure relates to a method and a device for safety examination of a numerical control program, comprising the following steps: acquiring a first data file; examining a coding mode of the current coding mode of the first data file according to the determined preset coding rule, and analyzing the first data file to generate a second data file under the condition that the current coding mode is consistent with the preset coding rule; format examination is carried out on the second data file according to format rules in the knowledge base, and a first examination result is obtained; under the condition that the first examination result is correct, carrying out logic examination on the second data file according to logic rules in the knowledge base to obtain a second examination result; and under the condition that the second examination result is correct, the first data file is sent to the target equipment, so that the target equipment executes the operation corresponding to the first data file, the normalization of the first data file is ensured, the safety of the industrial control system is improved, and the target equipment is prevented from being damaged.)

1. A security examination method of a numerical control program is characterized by comprising the following steps:

acquiring a first data file;

examining a coding mode of the current coding mode of the first data file according to a determined preset coding rule, and analyzing the first data file to generate a second data file under the condition that the current coding mode is consistent with the preset coding rule;

performing format examination on the second data file according to format rules in a knowledge base to obtain a first examination result;

under the condition that the first examination result is correct, carrying out logic examination on the second data file according to a logic rule in the knowledge base to obtain a second examination result;

and under the condition that the second examination result is correct, sending the first data file to target equipment, and enabling the target equipment to execute the operation corresponding to the first data file.

2. The method of claim 1, further comprising:

compiling format rules and logic rules in the file according to the equipment standard, and generating a lexical analyzer and a syntactic analyzer;

and obtaining an abstract syntax tree according to the lexical analyzer and the syntax analyzer, wherein the abstract syntax tree is the knowledge base.

3. The method of claim 1, further comprising: when the alarm condition is met, an alarm prompt is sent out,

wherein the alarm condition comprises at least one of:

the current coding mode is inconsistent with the preset coding rule;

the first examination result has errors;

and the second examination result has errors.

4. The method of claim 1, wherein the format rule comprises at least one of:

whether the second data file begins with an illegal code, the illegal code comprising a digital code;

whether the second data file comprises a program number instruction word;

whether the second data file comprises legal starting instruction words and ending instruction words or not;

whether a semicolon follows the end instruction word in the second data file;

whether a preparation function instruction word is included after the instruction word is numbered in the second data file and before the instruction word for realizing the processing function;

whether the address symbol of each instruction word in the second data file conforms to the corresponding address symbol rule or not;

whether a numeric code is missing in a numbered instruction word of the plurality of instruction words of the second data file;

whether a signed instruction word of a plurality of instruction words of the second data file is followed by a non-numeric code;

whether the numerical value type of the numerical code in the numerical instruction word among the plurality of instruction words in the second data file is correct.

5. The method of claim 1, wherein the second data file comprises a plurality of program segments, and wherein the logic rules comprise at least one of:

whether the ready function instruction words belonging to the same group appear only once in each program segment;

whether the auxiliary function instruction words belonging to the same group appear only once in each program segment;

whether the processing function instruction words with the same processing function appear only once in each program segment;

whether a numeric code in a numbered instruction word of the plurality of instruction words of each program segment is in a corresponding threshold range determined from an address threshold table corresponding to the numbered instruction word.

6. The method according to claim 1, wherein the preset encoding rule comprises any one of the following modes: ASCII encoding, Unicode encoding.

7. The method of claim 3, wherein the manner of issuing the alert prompt includes at least one of:

displaying a first alarm prompt;

sending a first instruction to a terminal sending the first data file, wherein the first instruction is used for controlling a first alarm module of the terminal sending the first data file to send a second alarm prompt;

sending a second instruction to the target device, wherein the second instruction is used for controlling a second alarm module of the target device to send out a third alarm prompt;

writing a fourth alarm prompt in the first data file;

controls the third alarm module to send out a fifth alarm prompt,

the first alarm module comprises at least one of an indicator light, a vibration motor and a buzzer, the second alarm module comprises at least one of an indicator light, a vibration motor and a buzzer, and the third alarm module comprises at least one of an indicator light, a vibration motor and a buzzer.

8. A security audit device for a numerical control program, comprising:

the acquisition module is used for acquiring a first data file;

the first processing module is used for examining the current coding mode of the first data file according to a determined preset coding rule, and analyzing the first data file to generate a second data file under the condition that the current coding mode is consistent with the preset coding rule;

the second processing module is used for carrying out format examination on the second data file according to format rules in a knowledge base to obtain a first examination result;

the third processing module is used for carrying out logic examination on the second data file according to the logic rules in the knowledge base under the condition that the first examination result is correct to obtain a second examination result;

and the output module is used for sending the first data file to target equipment under the condition that the second examination result is correct, so that the target equipment executes the operation corresponding to the first data file.

9. A security audit device for a numerical control program, comprising:

a processor;

a memory for storing processor-executable instructions;

wherein the processor is configured to perform the method of any one of claims 1 to 7.

10. A non-transitory computer readable storage medium having computer program instructions stored thereon, wherein the computer program instructions, when executed by a processor, implement the method of any of claims 1 to 7.

Technical Field

The present disclosure relates to the field of security control, and in particular, to a method and an apparatus for security review of a numerical control program.

Background

In recent years, information technology, which is centered on computer technology, communication technology, and control technology, has been rapidly developed and widely applied, and has a great influence on the development of industrial control systems. The industrial control system covers national key infrastructures such as a smart power grid, intelligent transportation, a water conservancy system and an aviation system, once the infrastructures are damaged by attackers, huge economic loss and casualties can be caused, even the national security is damaged, and therefore, the research on the safety problem of the industrial control system is very important to strengthen.

Currently, the research on the safety protection technology of the industrial control system mainly includes: industrial firewalls, intrusion detection, security audits, vulnerability scanning and mining, and the like. The industrial firewall is added with an industrial protocol filtering function on the basis of the traditional network firewall and is used for analyzing, identifying and controlling all data flow passing through the industrial control network, thereby resisting the attack of internal and external networks on industrial control equipment. The intrusion detection technology is mainly used for judging whether behaviors violating data security policies or physical operation flows and attacked objects exist in an industrial control system or not by collecting and analyzing information of equipment, a system, a physical world and the like. The safety audit is to audit the behaviors and flow in the industrial control network in real time, and quickly identify abnormal behaviors such as illegal operation, abnormal events, external attacks and the like in the industrial control system network through a specific safety strategy. Vulnerability scanning is to automatically match information such as model numbers of a host and equipment, firmware version information, communication protocols and the like according to known rules by using a scanning tool so as to detect whether known vulnerabilities exist. And the vulnerability mining is to detect unknown vulnerabilities by adopting a static analysis and dynamic test method. However, the industrial control system security protection technology in the related art mainly aims at the security protection of the network and the device, and it is difficult to review the security of the file transmitted to the device.

Disclosure of Invention

In view of this, the present disclosure provides a security review method and device for a numerical control program.

According to an aspect of the present disclosure, there is provided a security audit method of a numerical control program, including:

acquiring a first data file;

examining a coding mode of the current coding mode of the first data file according to a determined preset coding rule, and analyzing the first data file to generate a second data file under the condition that the current coding mode is consistent with the preset coding rule;

performing format examination on the second data file according to format rules in a knowledge base to obtain a first examination result;

under the condition that the first examination result is correct, carrying out logic examination on the second data file according to a logic rule in the knowledge base to obtain a second examination result;

and under the condition that the second examination result is correct, sending the first data file to target equipment, and enabling the target equipment to execute the operation corresponding to the first data file.

In one possible embodiment, the method further comprises:

generating a lexical analyzer and a syntactic analyzer according to format rules and logic rules in the equipment standard compilation file;

and obtaining an abstract syntax tree according to the lexical analyzer and the syntax analyzer, wherein the abstract syntax tree is the knowledge base.

In one possible embodiment, the method further comprises: when the alarm condition is met, an alarm prompt is sent out,

wherein the alarm condition comprises at least one of:

the current coding mode is inconsistent with the preset coding rule;

the first examination result has errors;

and the second examination result has errors.

In one possible embodiment, the format rule includes at least one of:

whether the second data file begins with an illegal code, the illegal code comprising a digital code;

whether the second data file comprises a program number instruction word;

whether the second data file comprises legal starting instruction words and ending instruction words or not;

whether a semicolon follows the end instruction word in the second data file;

whether a preparation function instruction word is included after the instruction word is numbered in the second data file and before the instruction word for realizing the processing function;

whether the address symbol of each instruction word in the second data file conforms to the corresponding address symbol rule or not;

whether a numeric code is missing in a numbered instruction word of the plurality of instruction words of the second data file;

whether a signed instruction word of a plurality of instruction words of the second data file is followed by a non-numeric code;

whether the numerical value type of the numerical code in the numerical instruction word among the plurality of instruction words in the second data file is correct.

In one possible embodiment, the second data file includes a plurality of program segments, and the logic rules include at least one of:

whether the ready function instruction words belonging to the same group appear only once in each program segment;

whether the auxiliary function instruction words belonging to the same group appear only once in each program segment;

whether the processing function instruction words with the same processing function appear only once in each program segment;

whether a numeric code in a numbered instruction word of the plurality of instruction words of each program segment is in a corresponding threshold range determined from an address threshold table corresponding to the numbered instruction word.

In a possible embodiment, the preset encoding rule includes any one of the following modes: ASCII encoding, Unicode encoding.

In a possible embodiment, the manner of sending out the alarm prompt includes at least one of the following:

displaying a first alarm prompt;

sending a first instruction to a terminal sending the first data file, wherein the first instruction is used for controlling a first alarm module of the terminal sending the first data file to send a second alarm prompt;

sending a second instruction to the target device, wherein the second instruction is used for controlling a second alarm module of the target device to send out a third alarm prompt;

writing a fourth alarm prompt in the first data file;

controls the third alarm module to send out a fifth alarm prompt,

the first alarm module comprises at least one of an indicator light, a vibration motor and a buzzer, the second alarm module comprises at least one of an indicator light, a vibration motor and a buzzer, and the third alarm module comprises at least one of an indicator light, a vibration motor and a buzzer.

According to an embodiment of the present disclosure, there is provided a security audit device for a numerical control program, including:

the acquisition module is used for acquiring a first data file;

the first processing module is used for examining the current coding mode of the first data file according to a determined preset coding rule, and analyzing the first data file to generate a second data file under the condition that the current coding mode is consistent with the preset coding rule;

the second processing module is used for carrying out format examination on the second data file according to format rules in a knowledge base to obtain a first examination result;

the third processing module is used for carrying out logic examination on the second data file according to the logic rules in the knowledge base under the condition that the first examination result is correct to obtain a second examination result;

and the output module is used for sending the first data file to target equipment under the condition that the second examination result is correct, so that the target equipment executes the operation corresponding to the first data file.

According to another aspect of the present disclosure, there is provided a security audit device for a numerical control program, including:

a processor;

a memory for storing processor-executable instructions;

wherein the processor is configured to perform the above method.

According to another aspect of the present disclosure, there is provided a non-transitory computer readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the above-described method.

According to the technical scheme provided by the aspects of the disclosure, the first data file is acquired, after the current coding mode of the first data file is determined to be consistent with the preset coding rule, the first data file is analyzed to obtain the second data file, the format of the second data file is checked, the second data file is logically checked under the condition that the format checking result is correct, and the first data file is sent to the target equipment under the condition that the logical checking result is correct, so that the target equipment executes the operation corresponding to the first data file, the normalization of the first data file is ensured, the safety of an industrial control system is improved, and the target equipment is prevented from being damaged.

Other features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments, which proceeds with reference to the accompanying drawings.

Drawings

The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate exemplary embodiments, features, and aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure.

Fig. 1 shows a flowchart of a security audit method of a numerical control program provided according to an embodiment of the present disclosure.

Fig. 2 shows another flowchart of a security review method of a numerical control program provided according to an embodiment of the present disclosure.

FIG. 3 illustrates a schematic diagram of an alert prompt provided in accordance with an embodiment of the present disclosure.

Fig. 4 shows a configuration diagram of a security audit device of a numerical control program provided according to an embodiment of the present disclosure.

Detailed Description

Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. In the drawings, like reference numbers can indicate functionally identical or similar elements. While the various aspects of the embodiments are presented in drawings, the drawings are not necessarily drawn to scale unless specifically indicated.

The word "exemplary" is used exclusively herein to mean "serving as an example, embodiment, or illustration. Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments.

Furthermore, in the following detailed description, numerous specific details are set forth in order to provide a better understanding of the present disclosure. It will be understood by those skilled in the art that the present disclosure may be practiced without some of these specific details. In some instances, methods, means, elements and circuits that are well known to those skilled in the art have not been described in detail so as not to obscure the present disclosure.

When a numerical control (numerical control for short) program is written, errors such as lexical, grammatical or logic easily occur, and when the numerical control program is transmitted to a numerical control machine tool through an industrial control system, the numerical control machine tool also has the risk of being maliciously tampered by an attacker, so that the numerical control machine tool receives the numerical control program which is out of specification, accidents such as machine collision and tool collision can occur in the machining process of the numerical control machine tool, equipment of the numerical control machine tool can be seriously damaged, and the production capacity of the numerical control machine tool is reduced. Therefore, how to ensure the safety of the numerical control program in the transmission process of the numerical control program is an urgent technical problem to be solved.

Based on the above, the present disclosure provides a security review method and device for a numerical control program. Fig. 1 is a flowchart illustrating a security inspection method for a numerical control program according to an embodiment of the present disclosure, where the security inspection method for a numerical control program may be used in a security inspection device for a numerical control program, the security inspection device for a numerical control program may be provided independently, or may be provided in a numerically controlled machine tool, and the present disclosure does not limit the installation position of the security inspection device for a numerical control program.

The numerically controlled machine tool is capable of logically processing a program defined by a control code or other symbolic instructions, decoding the program, representing the decoded program by a coded number, and inputting the coded number to the numerical control device through an information carrier. After operation, the numerical control device sends out various control signals to control the action of the machine tool, and the parts are automatically machined according to the shape and the size required by the drawing. It should be understood that the specific functions of the numerically controlled machine tool may be set according to practical circumstances, and the present disclosure is not limited thereto.

As shown in FIG. 1, the method includes steps S11-S15.

In step S11, a first data file is acquired.

In a possible implementation mode, the first data file can be compiled according to the shape and the size of a part to be machined by the numerical control machine tool, and the specific compiling mode can be set according to different numerical control systems, different numerical control types, different system versions and numerical control standards. The first data file may include a numerical control program file written according to a product actual compilation manual of industrial control equipment manufacturers such as Siemens, Fanuc (hairy department), Heidenhain (haidhan), Hass (Hass), and the like.

Wherein the first data file can be written by any one of the following digital control standards: the industrial digital control standard, the digital control standard set by each industrial control equipment manufacturer, or the digital control standard formed by combining the industrial digital control standard and the digital control standard set by each industrial control equipment manufacturer.

The industry digital control standard can be any one of ISO (International Organization for Standardization), EIA (Electronic Industries Association, american society of america), code of preparation function G and auxiliary function M in JB/T3208-.

In a possible implementation manner, the first data file may be directly obtained, or the first data file may be obtained according to an instruction sent by an external device, and the like.

In step S12, a current encoding method of the first data file is examined according to a determined preset encoding rule, and when the current encoding method is consistent with the preset encoding rule, the first data file is parsed to generate a second data file.

In a possible embodiment, the first data file may be encoded by using any one of the following preset encoding rules: ASCII encoding, Unicode encoding.

In a possible implementation, after determining the preset encoding rule, a first data file may be read in a binary manner based on Python (a cross-platform computer programming language), and based on Chardet (a tool that can be used to query an encoding manner) of Python, each instruction word in the first data file is compared with a plurality of "detectors" in the Chardet, and in a case where a certain "detector" can uniquely identify a current encoding manner of each instruction word in the first data file, it is determined that the current encoding manner of the first data file is an encoding manner corresponding to the "detector". Wherein the Chardet comprises a set of "detectors" corresponding to the character set of each encoding rule, each "detector" being capable of uniquely identifying the character set of the encoding rule corresponding thereto. The character set includes an ASCII character set, a GB2312 character set, a BIG5 character set, a GB18030 character set, a Unicode character set, and the like, which is not limited by the present disclosure.

The phrase "when the current encoding mode is consistent with the preset encoding rule" may refer to determining that the current encoding mode of the first data file is consistent with the preset encoding rule when the preset encoding rule is determined, that is, determining that the current encoding mode of each instruction word in the first data file can be uniquely identified by the "detector" corresponding to the character set of the preset encoding rule, and otherwise determining that the current encoding mode of the first data file is inconsistent with the preset encoding rule.

In a possible implementation manner, under the condition that the coding manner of the first data file is determined to be consistent with the preset coding rule, the first data file, such as the numerical control program file, is analyzed, and a plurality of program segments of the second data file, such as the numerical control program file, are generated. By examining the encoding mode of the current encoding mode of the first data file, whether the first data file is encoded according to the encoding rule or not can be quickly and effectively detected, whether the first data file contains abnormal codes such as malicious codes or not can be judged, the first data file is analyzed under the condition that the encoding mode of the first data file is consistent with the preset encoding rule, messy codes cannot occur in the process of analyzing the first data file, and the accuracy of analysis is improved.

In one possible embodiment, the method further comprises:

compiling format rules and logic rules in the file according to the equipment standard, and generating a lexical analyzer and a syntactic analyzer;

and obtaining an abstract syntax tree according to the lexical analyzer and the syntax analyzer, wherein the abstract syntax tree is the knowledge base.

The equipment standard documentation file can comprise any one of the following digital control standard files: the present disclosure is not limited to the above-mentioned standard files, or the standard files set by the manufacturers of industrial control equipment, or the standard files formed by combining the standard files set by the manufacturers of industrial control equipment and the standard files set by the manufacturers of industrial control equipment.

By generating an abstract syntax tree (i.e., a knowledge base), format examination and logical examination of the second data file can be quickly completed by calling the knowledge base.

In step S13, format examination is performed on the second data file according to the format rule in the knowledge base, so as to obtain a first examination result.

By format examination of the second data file, whether the second data file conforms to the industry digital control standard or the format rule of the digital control standard set by each industrial control equipment manufacturer can be detected, and whether the first data file is safe or not can be further determined.

In step S14, if the first examination result is correct, the second data file is logically examined according to the logic rules in the knowledge base to obtain a second examination result.

By logically examining the second data file, it can be determined whether the second data file conforms to the logic rules, thereby determining whether the first data file is safe.

In step S15, if the second checking result is correct, the first data file is sent to a target device, so that the target device executes an operation corresponding to the first data file. Wherein the target device may be a numerically controlled machine tool, and the operations performed corresponding to the first data file may include: and analyzing the first data file to obtain the shape and the size of the part to be machined, and machining the part according to the shape and the size of the part to be machined.

According to the embodiment of the disclosure, the first data file is acquired, after the current coding mode of the first data file is determined to be consistent with the preset coding rule, the first data file is analyzed to obtain the second data file, the format of the second data file is checked, the second data file is logically checked under the condition that the format checking result is correct, and the first data file is sent to the target equipment under the condition that the logical checking result is correct, so that the target equipment executes the operation corresponding to the first data file, the normalization of the first data file is ensured, the safety of an industrial control system is improved, and the target equipment is prevented from being damaged.

Fig. 2 shows another flowchart of a security review method of a numerical control program provided according to an embodiment of the present disclosure. As shown in fig. 2, the method may include steps S201 to S210.

In step S201, a first data file is acquired, and after step S201 is executed, step S202 is executed.

In step S202, the current encoding method of the first data file is determined, and after step S202 is executed, step S203 is executed.

In step S203, it is determined whether the current encoding mode of the first data file is inconsistent with a preset encoding rule. If the current encoding mode of the first data file is consistent with the preset encoding rule, step S204 is executed. And under the condition that the current coding mode of the first data file is inconsistent with the preset coding rule, judging that the current coding mode of the first data file meets the alarm condition, executing the step S210, and sending an alarm prompt.

In step S204, the first data file is subjected to program analysis to obtain a second data file, and after step S204 is executed, step S205 is executed.

In step S205, the second data file is format checked according to the format rule in the knowledge base to obtain a first checking result, and after step S205 is executed, step S206 is executed.

In step S206, the correctness of the first examination result is determined. In case the first examination result is correct, step S207 is performed. In case of an error in the first examination result, it may be determined that the first examination result satisfies the alarm condition, and step S210 is executed to issue an alarm prompt.

In step S207, the second data file is logically checked according to the logic rules in the knowledge base to obtain a second checking result, and after step S207 is executed, step S208 is executed.

In step S208, the correctness of the second review result is determined. In the case where the second review result is correct, step S209 is executed. In case of an error in the second review result, it may be determined that it satisfies the alarm condition, and step S210 is executed to issue an alarm prompt.

In step S209, the first data file is transmitted to the target device.

In step S210, when the alarm condition is satisfied, an alarm prompt is issued.

The method comprises the steps of obtaining a first data file, analyzing the first data file after the current coding mode of the first data file is determined to be consistent with a preset coding rule, obtaining a second data file, carrying out format examination on the second data file, carrying out logic examination on the second data file under the condition that the format examination result is correct, and sending the first data file to target equipment under the condition that the logic examination result is correct, so that the target equipment executes the operation corresponding to the first data file, the standardization of the first data file is ensured, the safety of an industrial control system is improved, and the target equipment is prevented from being damaged by the first data file. And when the alarm condition is met, an alarm prompt is sent out, so that the working personnel can be effectively reminded of processing the first data file in time.

As shown in fig. 2, in step S210, when the alarm condition is satisfied, an alarm prompt is issued.

The alarm prompt may include review time for performing security review, an error type (that is, an alarm condition that is met, such as a first review result error and a second review result error), a detection type (that is, a name of a manufacturer of the industrial control device corresponding to the detected first data file), an error line (that is, a line in the first data file where an error occurs, or a line in the first data file where an alarm prompt is issued), and error information describing which logic rule or format rule the error that occurs in the first data file corresponds to, and other related information.

For example, fig. 3 shows a schematic diagram of an alert prompt provided according to an embodiment of the present disclosure. As shown in fig. 3, an alarm indication is issued by security review of the first data file. The alarm indication may indicate that, in the security inspection of the first data file named Heidenhain of the corresponding industrial control equipment manufacturer, when the inspection time is 20 months, 23 days, 17 hours, 24 minutes and 26 seconds, an error that "the error type is a range error, 16 lines of error behavior, the error information is that the instruction word S exceeds a threshold range", "the error type is a no-program-end flag, 42 lines of error behavior, and the error information is a no-program-end flag" exists in the first data file.

Wherein the alarm condition comprises at least one of: the current coding mode is inconsistent with the preset coding rule; the first examination result has errors; and the second examination result has errors.

When the alarm condition is met, an alarm prompt is sent out, and terminal workers can be effectively reminded to process the first data file in time.

In a possible implementation manner, the manner of sending out the alarm prompt includes at least one of the following manners one to five.

In the first mode, a first alarm prompt is displayed.

The first alarm prompt may be directly displayed through a display panel of the apparatus that executes the method, where the display panel includes an lcd (liquid crystal display) display and a crt (cathode ray tube) display, and this disclosure is not limited in this respect. The first alert prompt may include the satisfied alert condition and/or a location in the second data file (or first data file) that satisfies the alert condition. For example, the first alert can include that the first review result is incorrect and that the fifth program segment in the second data file is incorrect.

And in a second mode, sending a first instruction to the terminal sending the first data file, wherein the first instruction is used for controlling a first alarm module of the terminal sending the first data file to send a second alarm prompt.

The terminal sending the first data file can control the first alarm module to send out a second alarm prompt according to the received first instruction by sending the first instruction to the terminal sending the first data file, wherein the first alarm module can comprise at least one of an indicator light, a vibration motor and a buzzer. The alarm can be given by changing the display mode of the indicator light, controlling the vibration of the vibration motor, controlling the sound production of the buzzer and the like, and the specific alarm mode is not limited by the disclosure. The display mode of the indicator light is changed, wherein the change of the display mode of the indicator light comprises changing the on-off frequency of the indicator light, controlling the indicator light to display different colors and the like.

And in a third mode, sending a second instruction to the target device, wherein the second instruction is used for controlling a second alarm module of the target device to send out a third alarm prompt.

The terminal sending the first data file can control the second alarm module to send a third alarm prompt according to the received first instruction by sending a second instruction to the terminal sending the first data file, wherein the second alarm module comprises at least one of an indicator light, a vibration motor and a buzzer. The alarm can be given by changing the display mode of the indicator light, controlling the vibration of the vibration motor, controlling the sound production of the buzzer and the like, and the specific alarm mode is not limited by the disclosure. The display mode of the indicator light is changed, wherein the change of the display mode of the indicator light comprises changing the on-off frequency of the indicator light, controlling the indicator light to display different colors and the like.

And writing a fourth alarm prompt into the first data file to give an alarm, so that a worker of the control terminal processes the first data file according to the fourth alarm prompt.

And controlling the third alarm module to send a fifth alarm prompt.

The third alarm module of the safety examination device for controlling the numerical control program can send out a fifth alarm prompt, wherein the third alarm module comprises at least one of an indicator light, a vibration motor and a buzzer. The alarm can be given by changing the display mode of the indicator light, controlling the vibration of the vibration motor, controlling the sound production of the buzzer and the like, and the specific alarm mode is not limited by the disclosure. The display mode of the indicator light is changed, wherein the change of the display mode of the indicator light comprises changing the on-off frequency of the indicator light, controlling the indicator light to display different colors and the like.

By sending the alarm prompt under the condition of meeting any one of the alarm conditions, the working personnel can be effectively reminded to process the first data file in time.

In one possible embodiment, the format rule may include at least one of:

whether the second data file begins with an illegal code, which may include a digital code;

whether the second data file comprises a program number instruction word;

whether the second data file comprises legal starting instruction words and ending instruction words or not;

whether a semicolon follows the end instruction word in the second data file;

whether a preparation function instruction word is included after the instruction word is numbered in the second data file and before the instruction word for realizing the processing function;

whether the address symbol of each instruction word in the second data file conforms to the corresponding address symbol rule or not;

whether a numeric code is missing in a numbered instruction word of the plurality of instruction words of the second data file;

whether a signed instruction word of a plurality of instruction words of the second data file is followed by a non-numeric code;

whether the numerical value type of the numerical code in the numerical instruction word among the plurality of instruction words in the second data file is correct.

The first examination result of the format examination of the second data file according to the format rule is correct, and the first examination result comprises the following steps:

the second data file is not headed by an illegal code;

the second data file comprises program number instruction words;

the second data file comprises legal starting instruction words and ending instruction words;

a semicolon follows the end instruction word in the second data file;

the second data file comprises preparation function instruction words after the instruction words are numbered by the program and before the instruction words for realizing the processing function;

the address symbol of each instruction word in the second data file conforms to the corresponding address symbol rule;

the digital instruction word in the plurality of instruction words of the second data file contains a digital code;

the sign of a signed instruction word in a plurality of instruction words in the second data file is followed by a digital code;

the numerical type of the numerical code in the plurality of instruction words of the second data file is correct.

Wherein, the first examination result of the format examination of the second data file according to the format rule is incorrect, which comprises any one or more of the following:

the second data file begins with an illegal code;

the second data file does not comprise a program number instruction word;

legal start instruction words and/or end instruction words are not included in the second data file;

no semicolon follows the end instruction word in the second data file;

the preparation function instruction word is not included after the program serial number instruction word in the second data file and before the instruction word for realizing the processing function;

the address symbol of each instruction word in the second data file does not conform to the corresponding address symbol rule;

a digital code is absent from a digital instruction word of the plurality of instruction words of the second data file;

the sign of a signed instruction word in a plurality of instruction words in the second data file is followed by a non-numeric code;

the number type of the number code in the plurality of instruction words of the second data file is incorrect.

By format examination of the second data file, whether the second data file meets the format rules determined by the industry digital control standard or the digital control standard set by each industry control equipment manufacturer or the like can be detected, and whether the first data file is safe or not can be further determined.

In one possible embodiment, the second data file includes a plurality of program segments, and the logic rules include at least one of:

whether the ready function instruction words belonging to the same group appear only once in each program segment;

whether the auxiliary function instruction words belonging to the same group appear only once in each program segment;

whether the processing function instruction words with the same processing function appear only once in each program segment;

whether a numeric code in a numbered instruction word of the plurality of instruction words of each program segment is in a corresponding threshold range determined from an address threshold table corresponding to the numbered instruction word.

Wherein, the second examination result of the logic examination of the second data file according to the logic rule is correct, which comprises the following steps:

the instruction words belonging to the same group of preparation functions only appear once in each program segment;

the instruction words belonging to the same group of auxiliary functions only appear once in each program segment;

the processing instruction words with the same processing function only appear once in each program segment;

the numerical code in the numerical instruction word of the plurality of instruction words of each program segment is in a corresponding threshold range, wherein the threshold range is determined according to the address character threshold table corresponding to the numerical instruction word. The address character threshold value table is determined according to the address character of the instruction word and the value represented by the numerical code corresponding to the instruction word, and the address character of the instruction word and the value represented by the numerical code corresponding to the instruction word are related to the function of the instruction word.

Wherein, the second examination result of the logic examination of the second data file according to the logic rule is incorrect, which comprises any one or more of the following:

the instruction words belonging to the same group of preparation functions appear at least twice in each program segment;

the instruction words belonging to the same group of auxiliary functions appear at least twice in each program segment;

processing instruction words with the same processing function appear at least twice in each program segment;

the digital codes in the numbered instruction words in the plurality of instruction words of each program segment are not in the corresponding threshold ranges.

By performing logic examination on the second data file, whether the instruction words in the second data file conform to the logic rules can be confirmed, and whether the first data file is safe can be further determined.

Fig. 4 shows a configuration diagram of a security audit device of a numerical control program provided according to an embodiment of the present disclosure. As shown in fig. 4, the apparatus includes:

the acquisition module is used for acquiring a first data file;

the first processing module is used for examining the current coding mode of the first data file according to a determined preset coding rule, and analyzing the first data file to generate a second data file under the condition that the current coding mode is consistent with the preset coding rule;

the second processing module is used for carrying out format examination on the second data file according to format rules in a knowledge base to obtain a first examination result;

the third processing module is used for carrying out logic examination on the second data file according to the logic rules in the knowledge base under the condition that the first examination result is correct to obtain a second examination result;

and the output module is used for sending the first data file to target equipment under the condition that the second examination result is correct, so that the target equipment executes the operation corresponding to the first data file.

According to the embodiment of the disclosure, by acquiring a first data file, after the current coding mode of the first data file is determined to be consistent with a preset coding rule, the first data file is analyzed to obtain a second data file, the format of the second data file is checked, the second data file is logically checked under the condition that the format checking result is correct, and the first data file is sent to a target device under the condition that the logical checking result is correct, so that the target device executes the operation corresponding to the first data file, the normalization of the first data file is ensured, the safety of an industrial control system is improved, and the target device is prevented from being damaged.

In one possible implementation, the apparatus further includes a generation module, the generation module including:

the first generation module is used for generating a lexical analyzer and a syntactic analyzer according to format rules and logic rules in the equipment standard compilation file;

and the second generation module is used for obtaining an abstract syntax tree according to the lexical analyzer and the syntax analyzer, wherein the abstract syntax tree is the knowledge base.

In a possible implementation mode, the device further comprises an alarm module, wherein the alarm module is used for sending out an alarm prompt when the alarm condition is met,

wherein the alarm condition comprises at least one of:

the current coding mode is inconsistent with the preset coding rule;

the first examination result has errors;

and the second examination result has errors.

In one possible embodiment, the format rule includes at least one of:

whether the second data file begins with an illegal code, the illegal code comprising a digital code;

whether the second data file comprises a program number instruction word;

whether the second data file comprises legal starting instruction words and ending instruction words or not;

whether a semicolon follows the end instruction word in the second data file;

whether a preparation function instruction word is included after the instruction word is numbered in the second data file and before the instruction word for realizing the processing function;

whether the address symbol of each instruction word in the second data file conforms to the corresponding address symbol rule or not;

whether a numeric code is missing in a numbered instruction word of the plurality of instruction words of the second data file;

whether a signed instruction word of a plurality of instruction words of the second data file is followed by a non-numeric code;

whether the numerical value type of the numerical code in the numerical instruction word among the plurality of instruction words in the second data file is correct.

In one possible embodiment, the second data file includes a plurality of program segments, and the logic rules include at least one of:

whether the ready function instruction words belonging to the same group appear only once in each program segment;

whether the auxiliary function instruction words belonging to the same group appear only once in each program segment;

whether the processing function instruction words with the same processing function appear only once in each program segment;

whether a numeric code in a numbered instruction word of the plurality of instruction words of each program segment is in a corresponding threshold range determined from an address threshold table corresponding to the numbered instruction word.

In a possible embodiment, the preset encoding rule includes any one of the following modes: ASCII encoding, Unicode encoding.

In a possible embodiment, the manner of sending out the alarm prompt by the alarm module includes at least one of the following:

displaying a first alarm prompt;

sending a first instruction to a terminal sending the first data file, wherein the first instruction is used for controlling a first alarm module of the terminal sending the first data file to send a second alarm prompt;

sending a second instruction to the target device, wherein the second instruction is used for controlling a second alarm module of the target device to send out a third alarm prompt;

writing a fourth alarm prompt in the first data file;

controls the third alarm module to send out a fifth alarm prompt,

the first alarm module comprises at least one of an indicator light, a vibration motor and a buzzer, the second alarm module comprises at least one of an indicator light, a vibration motor and a buzzer, and the third alarm module comprises at least one of an indicator light, a vibration motor and a buzzer.

The embodiment of the present disclosure further provides a security audit device of a numerical control program, where the device includes:

a processor;

a memory for storing processor-executable instructions;

wherein the processor is configured to perform the above method.

Embodiments of the present disclosure also provide a non-transitory computer readable storage medium having computer program instructions stored thereon, wherein the computer program instructions, when executed by a processor, implement the above method.

Having described embodiments of the present disclosure, the foregoing description is intended to be exemplary, not exhaustive, and not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terms used herein were chosen in order to best explain the principles of the embodiments, the practical application, or technical improvements to the techniques in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.

16页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:数据表格明文转换为便于程序可读取的二进制密文的方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!