Python-based putty trusted software testing method and system

By using Python automated testing methods, the problems of low efficiency and large errors in traditional manual testing methods are solved, enabling rapid, stable, and full-scale testing of SIS secure and trusted infrastructure, generating structured reports, and improving testing efficiency and quality.

CN122152699APending Publication Date: 2026-06-05HUANENG POWER INT CO LTD RIZHAO POWER PLANT +2
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUANENG POWER INT CO LTD RIZHAO POWER PLANT
Filing Date
2026-02-28
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Traditional manual testing methods are slow, have limited coverage, and are prone to omissions and human error after the release of SIS secure and trusted infrastructure versions, making them unable to meet the testing requirements of high-frequency version upgrades.

Method used

The automated testing method based on Python's PuTTY is adopted. By connecting to the SIS security and trust underlying layer, test cases are preset and parsed into commands, which are then automatically executed, output information is matched, and test reports are generated, thereby achieving full-scale automation and standardization of testing.

Benefits of technology

It improves testing efficiency, reduces human error, ensures test consistency and accuracy, generates structured reports, significantly improves testing speed and quality, and reduces labor costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122152699A_ABST
    Figure CN122152699A_ABST
Patent Text Reader

Abstract

The application belongs to the field of trusted software security testing, and discloses a putty trusted software testing method and system based on Python. The application replaces traditional manual operation with an automatic control mode taking Python as the core, so that the full test process of the SIS (Supervisory Information System) safety and trusted infrastructure can be quickly carried out after the version is released. The application automatically processes test case analysis, command execution, output collection, matching judgment, screenshot recording and report generation, thereby avoiding the cumbersome process of manually executing test instructions, manually comparing outputs, manually taking screenshots and manually arranging test documents.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of trusted software security testing, specifically involving a trusted software testing method and system based on Python's PuTTY. Background Technology

[0002] As a crucial security foundation in the industrial control field, the core mission of the SIS (Safety Instrumented System) secure and trusted infrastructure is to provide a trusted, controllable, and traceable operating environment for SIS. Currently, with the increasing demands for security and independent controllability across industries, system architecture is gradually evolving from traditional general-purpose hardware and commercial software systems to domestically produced hardware and software platforms with "end-to-end trusted capabilities." This infrastructure comprises trusted computer hardware, domestically developed operating systems, and domestically developed trusted computing software. By constructing a complete trusted system from the "hardware root of trust" to the "system-level trusted execution environment," it provides robust security guarantees for the operation of the upper-layer SIS secure and trusted system.

[0003] At the hardware level, the system adopts domestically produced trusted servers and trusted interface machines. The underlying chips, motherboards, and interface modules are all independently controllable, meeting the trustworthiness requirements throughout the entire process from startup to operation. Both the upper and lower level hardware and software are 100% domestically produced to meet the higher requirements of key industries for supply chain security, equipment trustworthiness, and controllability and maintainability. Through encryption, authentication, and protection mechanisms based on national cryptographic algorithms (such as SM2, SM3, and SM4), the system achieves local trusted data acquisition, secure link-level transmission, and integrity and confidentiality verification during cross-module interactions, ensuring that production control data is not tampered with or leaked throughout its entire lifecycle.

[0004] At the software and system functionality level, the SIS secure and trusted infrastructure integrates several core trusted computing functions, including trusted boot, static trusted verification, dynamic trusted verification, a trusted whitelist mechanism, process protection, and application access control. Trusted boot implements layer-by-layer verification from BIOS and Bootloader to the operating system, ensuring the system is protected from malicious tampering at its most basic stage. Static trusted verification performs regular integrity checks on critical system files, configurations, and drivers; dynamic trusted verification further identifies abnormal processes, illegal behaviors, and malicious code injection during system operation. The trusted whitelist mechanism ensures that only certified processes and programs are allowed to run, fundamentally blocking the startup paths of unknown programs. Process protection and access control construct runtime behavior auditing, protection boundaries, and permission isolation, forming a multi-layered, multi-level, interconnected system protection system.

[0005] However, as SIS (Security and Trusted Infrastructure) security infrastructure releases new versions and iterates on demand, the workload of comprehensive testing after deployment has also increased significantly. Traditional manual testing, relying on human intervention, is not only slow and has limited coverage, but also involves a large number of repetitive testing tasks that are extremely time-consuming, prone to omissions, inconsistencies in operation, and human error, thus affecting the testing cycle and quality and failing to meet the requirements of high-frequency version upgrades. In particular, trusted link verification, whitelist rule checks, and security policy effectiveness testing all require a large number of command executions and log comparisons, which are difficult to achieve efficiently and stably using manual methods. Summary of the Invention

[0006] The purpose of this invention is to quickly and stably complete the full-scale testing of SIS secure and trusted infrastructure through automated means after version release, and to provide a Python-based PuTTY trusted software testing method and system.

[0007] To achieve the above objectives, the present invention adopts the following technical solution: In a first aspect, the present invention provides a trusted software testing method based on Python's PuTTY, comprising the following steps: Access the secure and trusted underlying layer of SIS; Pre-set test cases, parse the test cases into test case commands, and execute the test case commands sequentially; Obtain the output information when executing test case commands; The output information is matched with the test cases, and screenshots are taken based on the SIS security and trust underlying layer according to the matching results. The matching results and screenshots are translated into a test report and output.

[0008] A further improvement of this invention is that, when accessing the SIS secure and trusted underlying layer, the PuTTY program is used to connect to the SIS secure and trusted underlying layer via SSH or Telnet, according to the configuration required for the test.

[0009] A further improvement of this invention lies in the following method for pre-setting test cases, parsing the test cases into test case commands, and executing the test case commands sequentially: Pre-set test cases, each consisting of several columns of test case content, are used to parse the test cases into test case commands based on the test case content. Enter the test case command into the SIS secure and trusted underlying layer for execution.

[0010] A further improvement of this invention is that the test cases include column F for command line input, column G for expected command output, column H for expected log results, column I for waiting time, column K for whether to use full screen / whether to take a screenshot, and other auxiliary fields.

[0011] A further improvement of this invention lies in the following specific method for obtaining the output information when executing test case commands: Execute the test case commands and generate the corresponding information. After the test case commands have been executed, enter the first command; When the first command is detected, the generated content information is mapped to the target location and a separator is added.

[0012] A further improvement of this invention lies in matching the output information with test cases, and taking screenshots based on the SIS security and trust underlying layer according to the matching results, as follows: Obtain the output information and compare it with the expected results in the corresponding columns of the preset test cases; If the output information matches the expected result, the matching result is marked in the corresponding position of the test result; otherwise, the matching result is marked in the corresponding position of the test result, and a screenshot of the current window is taken based on the information in the preset test case and the SIS security and trust underlying layer.

[0013] A further improvement of this invention lies in the following method for translating the matching results and screenshots into a test report and outputting it: Get the screenshot and store it in the corresponding location in the test results; Obtain the matching results and screenshots from the test results, translate the matching results and screenshots into a test report, and output it.

[0014] Secondly, this invention provides a Python-based PuTTY-based trusted software testing system, comprising: The communication module is used to access the SIS secure and trusted underlying layer; The command generation module is used to preset test cases and parse the test cases into test case commands, which are then executed sequentially. The information acquisition module is used to acquire the output information when executing test case commands; The information matching module is used to match the output information with the test cases, and take screenshots based on the SIS security and trust underlying layer according to the matching results; The translation module is used to translate the matching results and screenshots into a test report for output.

[0015] Thirdly, the present invention provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of a Python-based PuTTY trusted software testing method.

[0016] Fourthly, the present invention provides a storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the steps of a Python-based PuTTY trusted software testing method.

[0017] Compared with the prior art, the present invention has the following beneficial effects: This invention replaces traditional manual operations with an automated control method based on Python, enabling rapid deployment of full-scale testing of the SIS (Security and Trusted Infrastructure) infrastructure after version release. It automates all processes, including test case parsing, command execution, output collection, matching and judgment, screenshot recording, and report generation, avoiding the tedious process of manually executing test commands, manually comparing outputs, manually taking screenshots, and manually compiling test documentation. This invention can stably connect to the underlying SIS security and trust infrastructure, automatically executing a large number of repetitive command operations, ensuring consistency in the execution of test steps, improving testing efficiency, and reducing human error. By automatically matching the execution output with the preset expected results, the system can simultaneously complete result verification at the command and log levels, making test judgments more accurate and reliable. Simultaneously, it automatically controls screenshot behavior based on the matching results, ensuring sufficient execution records are generated in critical, abnormal, or evidence-gathering steps, providing effective evidence for problem localization and test tracing. Finally, the matching results and screenshots are automatically translated into a structured test report, significantly reducing the time spent on manual document compilation and ensuring the standardization and readability of the report content. In summary, this invention automates, standardizes, and improves the efficiency of full-scale testing after version release, significantly increasing test execution speed, reducing labor costs, minimizing the risk of missed or false positives caused by human interference, and enhancing test coverage and execution quality. This ensures the rapid verification and stable delivery of the SIS secure and trusted infrastructure after each version update. Attached Figure Description

[0018] Figure 1 This is a flowchart of the present invention; Figure 2 This is a system diagram of the present invention; Figure 3 This is a flowchart of Example 4; Figure 4 This is a system diagram of Example 5. Detailed Implementation

[0019] To further understand the content of this invention, the invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the embodiments are merely illustrative and not limiting of the invention.

[0020] Example 1: See Figure 1A trusted software testing method based on Python's PuTTY includes the following steps: S1 connects to the secure and trusted underlying layer of SIS.

[0021] S2 sets up test cases and parses them into test case commands, then executes the test case commands sequentially.

[0022] S3 retrieves the output information when executing test case commands.

[0023] S4 matches the output information with the test cases, and takes screenshots based on the SIS security and trust underlying layer according to the matching results.

[0024] S5 translates the matching results and screenshots into a test report and outputs it.

[0025] Example 2: A Python-based PuTTY-based trusted software testing system, including: The communication module is used to access the SIS secure and trusted underlying layer.

[0026] The command generation module is used to preset test cases and parse the test cases into test case commands, which are then executed sequentially.

[0027] The information acquisition module is used to acquire the output information when executing test case commands.

[0028] The information matching module is used to match the output information with the test cases, and take screenshots based on the SIS security and trust underlying layer according to the matching results.

[0029] The translation module is used to translate the matching results and screenshots into a test report for output.

[0030] Example 3: This embodiment uses an automated tool to call the PuTTY program to access the SIS secure and trusted underlying layer via SSH or Telnet, and automatically executes the test process according to the command content in the preset test cases, thereby achieving rapid and stable full-scale testing of the SIS secure and trusted infrastructure.

[0031] The program parses the preset test cases, reads the command line inputs in column F of the test cases, and sequentially inputs these commands into the SIS secure and trusted underlying layer for execution. After each command is executed, the program automatically inputs the `clear` command to trigger the collection of output information. When the `clear` command is detected, the automation tool completely maps the content currently displayed in the PuTTY window to a TXT file in the current path, inserting an asterisk (*) as a separator between adjacent mappings to distinguish the output results of different commands.

[0032] The program identifies the content between two asterisks (*) in the TXT file as the actual output of the command and compares it with the expected result preset in column G of the test case. If the expected log result is filled in column H of the test case, and the command generates underlying logs, the program will automatically execute the command to retrieve the logs in PuTTY, map the returned log content to the TXT file, and match and verify it with the expected log result in column H.

[0033] The window display mode during command execution is set according to column K of the test case: when column K is "Yes", "No", or empty, the PuTTY window maintains its default size; when column K is "Full Screen", the program automatically maximizes the window. When column K is "Yes" or "Full Screen", the program waits for three seconds after command execution and takes a screenshot of the current window. The screenshot file's storage path will be recorded in column N of the Excel format test report. If the command to retrieve logs is executed, due to the large amount of log content, the system will force a full-screen screenshot to ensure complete log display. For commands with a large amount of output and a long execution time, a waiting time can be set through column I of the test case. The program will pause according to this waiting time after command execution to ensure complete collection of output content.

[0034] When matching output results, if both command output and log results (if any) match the expected results, column L of the test report will be automatically filled with "OK"; if either one fails to match, "NG" will be filled in, and the specific failure type will be noted in column M, including command output matching failure, log matching failure, or both matching failure.

[0035] After all commands are executed and results are determined, the program automatically converts the Excel-formatted test report into a Word-formatted test report, and appends all screenshots generated during the test process to the corresponding commands in the order of the test cases, thus forming a structured test document with corresponding text and images.

[0036] Example 4: See Figure 3 The steps in this embodiment are as follows: Step 1: According to the designed test cases, manually fill in the following information in the Excel file used for automated testing: Test Case Number, Test Case Name, Test Case Description, Test Type (Preparation or Steps), Test Content (Chinese Description), Test Command (only fill in the command), Expected Output, Expected Log Results, Waiting Time, Expected Results (written in a Word report), and whether to take a screenshot. Step two: Run the PuTTY automated testing tool and fill in the necessary configuration items, such as the client IP and serial port number, username and password, Excel test case file name, log retrieval command, absolute path to the PuTTY program file, and absolute path to save screenshot files. Click the "Save Current Configuration" button. The next time you open the PuTTY automated testing tool, the GUI interface will automatically fill in the saved configuration items for easy access next time.

[0037] Step 3: In the PuTTY automated testing tool GUI interface, click the (Start Execution) button to launch the PuTTY program and execute the commands in column F of the test cases sequentially in the PuTTY window.

[0038] a) After each command returns information, the clear command will be executed. Whenever the clear command appears, the program will automatically map the information in the putty window to the txt file in the current path, separated by a line of asterisks. Then the program will match the content between the two lines of asterisks with the expected result of the output of column G in the command line. b) If the execution of this command generates underlying logs, and the expected log result is also filled in column H of the test case, then the command to retrieve the logs will be executed in the PuTTY window, and the returned log content will also be mapped to the txt file and matched with the expected log result. c) The window size for each command execution is determined by the content entered in column K of the command row, corresponding to whether a screenshot is required. When the content in column K is "yes," "no," or blank, the window is the default size. When the content in column K is "full screen," the PuTTY window will be maximized. If the "screenshot" column is "yes" or "full screen," the window will wait 3 seconds after the command execution is completed before taking a screenshot, and the path to the screenshot file will be entered in column N of the Excel test report. When executing the command to retrieve logs, because the log content is relatively large, a full-screen screenshot must be set in the Excel file, and the PuTTY window will be maximized.

[0039] d) If some commands have a lot of output, you can set a waiting time in column I of the test case. After executing the command, the program will wait for the set waiting time before executing the next action.

[0040] Step 4: When the expected results of the output and log are both successfully matched, column L of the test report in Excel format will be automatically filled with "OK". If any item fails to match, "NG" will be filled in, and the corresponding column M will indicate which item failed to match or whether both items failed to match.

[0041] Step 5: Once all commands in the test case have been executed, an Excel-formatted test report will be generated.

[0042] Step six: If you want to see PuTTY screenshots during the test process in the test report, you can convert the Excel test report to a Word test report. The Word test report will attach the screenshots generated during the test to the corresponding command lines for easy viewing of the detailed test process.

[0043] This method, without affecting normal functionality, quickly and efficiently utilizes the PuTTY automation tool to perform effective automated testing of SIS (Security and Trusted Infrastructure) infrastructures, outputting test reports in various formats. It effectively improves testing speed and quality, saves manual testing time, and allows developers to quickly identify and record issues after release, facilitating rapid problem location and resolution, and significantly reducing testing costs. This method is applicable to all SIS security and trusted infrastructures that can connect to the trusted underlying layer via SSH or Telnet.

[0044] Example 5: Please see Figure 4 As shown, the present invention also provides an electronic device 100 for a trusted software testing method based on Python's PuTTY; the electronic device 100 includes a memory 101, at least one processor 102, a computer program 103 stored in the memory 101 and executable on the at least one processor 102, and at least one communication bus 104.

[0045] The memory 101 can be used to store the computer program 103. The processor 102 implements the steps of the Python-based PuTTY trusted software testing method described in Embodiment 1 by running or executing the computer program stored in the memory 101 and calling the data stored in the memory 101. The memory 101 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device 100 (such as audio data), etc. In addition, the memory 101 may include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other non-volatile solid-state storage device.

[0046] The at least one processor 102 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 102 may be a microprocessor or any conventional processor. The processor 102 is the control center of the electronic device 100, connecting various parts of the electronic device 100 via various interfaces and lines.

[0047] The memory 101 in the electronic device 100 stores multiple instructions to implement a Python-based PuTTY trusted software testing method, and the processor 102 can execute the multiple instructions to achieve the following: Access the secure and trusted underlying layer of SIS; Pre-set test cases, parse the test cases into test case commands, and execute the test case commands sequentially; Obtain the output information when executing test case commands; The output information is matched with the test cases, and screenshots are taken based on the SIS security and trust underlying layer according to the matching results. The matching results and screenshots are translated into a test report and output.

[0048] Example 5 If the modules / units integrated in the electronic device 100 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).

[0049] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0050] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0051] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0052] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0053] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A trusted software testing method based on Python's PuTTY, characterized in that... Includes the following steps: Access the secure and trusted underlying layer of SIS; Pre-set test cases, parse the test cases into test case commands, and execute the test case commands sequentially; Obtain the output information when executing test case commands; The output information is matched with the test cases, and screenshots are taken based on the SIS security and trust underlying layer according to the matching results. The matching results and screenshots are translated into a test report and output.

2. The trusted software testing method based on Python and PuTTY according to claim 1, characterized in that, When accessing the SIS secure and trusted underlying layer, use the PuTTY program and connect to the SIS secure and trusted underlying layer via SSH or Telnet, depending on the configuration required for the test.

3. The trusted software testing method based on Python and PuTTY according to claim 1, characterized in that, The specific method for pre-setting test cases, parsing them into test case commands, and executing the test case commands sequentially is as follows: Pre-set test cases, each consisting of several columns of test case content, are used to parse the test cases into test case commands based on the test case content. Enter the test case command into the SIS secure and trusted underlying layer for execution.

4. The trusted software testing method based on Python using PuTTY according to claim 1 or 3, characterized in that, The test cases include column F for command line input, column G for expected command output, column H for expected log results, column I for waiting time, column K for whether to use full screen / whether to take a screenshot, and other auxiliary fields.

5. The trusted software testing method based on Python and PuTTY according to claim 1, characterized in that, The specific method for obtaining the output information when executing test case commands is as follows: Execute the test case commands and generate the corresponding information. After the test case commands have been executed, enter the first command; When the first command is detected, the generated content information is mapped to the target location and a separator is added.

6. The trusted software testing method based on Python and PuTTY according to claim 1, characterized in that, The specific method for matching the output information with the test cases and taking screenshots based on the matching results and the SIS security and trust underlying layer is as follows: Obtain the output information and compare it with the expected results in the corresponding columns of the preset test cases; If the output information matches the expected result, the matching result will be marked in the corresponding position of the test result; Otherwise, the matching result will be marked in the corresponding position of the test result, and a screenshot of the current window will be taken based on the information in the preset test case and the SIS security and trust underlying layer.

7. The trusted software testing method based on Python and PuTTY according to claim 1, characterized in that, The specific method for translating the matching results and screenshots into a test report and outputting it is as follows: Get the screenshot and store it in the corresponding location in the test results; Obtain the matching results and screenshots from the test results, translate the matching results and screenshots into a test report, and output it.

8. A trusted software testing system based on Python and PuTTY, characterized in that: include: The communication module is used to access the SIS secure and trusted underlying layer; The command generation module is used to preset test cases and parse the test cases into test case commands, which are then executed sequentially. The information acquisition module is used to acquire the output information when executing test case commands; The information matching module is used to match the output information with the test cases, and take screenshots based on the SIS security and trust underlying layer according to the matching results; The translation module is used to translate the matching results and screenshots into a test report for output.

9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the Python-based PuTTY trusted software testing method as described in any one of claims 1 to 7.

10. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the Python-based PuTTY trusted software testing method as described in any one of claims 1 to 7.