Code scanning management and control method and system for polyspace license and storage medium
By receiving and analyzing git patch compressed packages, extracting and merging code for Polyspace scanning, it solves the problem of multi-developer code scanning requirements for large companies, and realizes local code scanning for multiple developers, reducing license fees and project development costs.
Patent Information
- Application Number
- CN202411420631.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-02-14
AI Technical Summary
Existing static code scanning tools such as Polyspace have high license fees and can only bind one computer to each license, which is difficult to meet the code scanning needs of hundreds or thousands of developers in large companies.
By receiving git patch compression package, decompressing and analyzing file information, extracting code and finding corresponding project code in the server repository, combining code and running Polyspace code scans, generating TOKEN tokens or scanning failure information, realizing local code scanning for multiple developers .
Only one Polyspace license can complete the code scanning tasks of multiple developers, reducing license fees and project development costs, while ensuring the correctness of the code.
Smart Images

Figure CN119440986A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer software technology, and in particular to a code scanning control method, system and storage medium for a polyspace license. Background Art
[0002] There are many static code scanning tools, but few of them meet the automotive standard ASIL-B. Polyspace is a static code scanning tool that meets ASIL-B. However, the license fee of Polyspace is bound to each user and each computer. For companies with hundreds or thousands of developers, purchasing large quantities of licenses is not in line with corporate strategy. At this time, it is necessary to consider the minimum number of licenses to meet the code scanning tasks of a large number of developers.
[0003] Currently, professional static code scanning tools all require a license. Polyspace is a professional static code scanning tool that requires the purchase of a license. The license fee is relatively expensive, and each license can only be bound to one computer.
[0004] Currently, most network static code scanning is to submit the modified code to the code repository, and then scan it uniformly by the code server to get a report. This method of storing the code first and then scanning is not compatible with real-time, simplicity and security at the same time. Summary of the invention
[0005] To solve the above technical problems, the present application provides a code scanning control method, system and storage medium for a polyspace license.
[0006] In a first aspect, the present application provides a code scanning control method for a polyspace license, the code scanning control method comprising: S1: receiving a git patch compressed package, decompressing and analyzing file information of the git patch compressed package.
[0007] S2: extract the code in the file information, and search in the server warehouse whether there is a corresponding project code. If so, proceed to step S3; if not, determine the code as a project program and proceed to step S4.
[0008] S3: extracting the project code from the server warehouse, and merging the code into the project code to obtain the project program.
[0009] S4: Run the polyspace code to scan the project program and obtain the scanning result.
[0010] S5: If the scanning result is correct, a TOKEN token is generated and fed back to the client; if the scanning result is wrong, a scanning failure message is generated and fed back to the client.
[0011] The present invention only requires one polyspace license and can solve the local code scanning tasks of dozens or hundreds of software developers by sending the modified code to the code scanning and compilation server for scanning.
[0012] The present invention can control the code to be scanned and verified on the local computer of the software developer without submitting the code to the code warehouse.
[0013] Furthermore, before step S1, the method further includes: Pull the project code from the warehouse server and modify it.
[0014] Generate a git patch file based on the modified project code.
[0015] Compress the git patch file to obtain a git patch compressed package.
[0016] Furthermore, before step S1, the step further includes: Design new project code.
[0017] Generate a git patch file based on the new project code.
[0018] Compress the git patch file to obtain a git patch compressed package.
[0019] When designing a new project, you can pull the original project code from the warehouse server and modify it, or you can rewrite the new project code.
[0020] Furthermore, after receiving the TOKEN token, the client uses the git push command to upload the project program to the warehouse server.
[0021] TOKEN is the command token generated when the scanning result is correct. Only with this token can the project code be uploaded to the warehouse server.
[0022] Furthermore, if the scan result is an error, the URL address of the website server is fed back to the client.
[0023] Furthermore, developers can view the project program scanning results at the URL address of the website server.
[0024] If there are problems with project code rules and code defects, the scan results are uploaded to the website server, and a scan failure message and the URL address of the website server are fed back to the client.
[0025] Second invention, the present application also proposes a system for code scanning and control of polyspace licenses, characterized in that the system includes: git repository server, a server used to store the codes of various projects.
[0026] Client, used by developers to modify project code or write new project code.
[0027] The code scanning and compiling server is used to compile and verify the project code.
[0028] and website servers.
[0029] Furthermore, the code scanning and compiling server is configured with a polyspace license.
[0030] Through this inventive design, the present invention only requires one polyspace license, and can solve the local code scanning tasks of dozens or hundreds of software developers by sending the modified code to the code scanning and compilation server for scanning.
[0031] Furthermore, it is characterized in that the website server includes a URL address.
[0032] In summary, the present application proposes a code scanning control method, system and storage medium for polyspace licenses. The method includes: receiving a git patch compressed package, decompressing and analyzing the file information of the git patch compressed package; extracting the code in the file information, and searching in the server warehouse for the corresponding project code; extracting the project code from the server warehouse, and merging the code into the project code to obtain the project program; running the polyspace code to scan the project program to obtain the scanning result; if the scanning result is correct, generating a TOKEN token to feedback to the client; if the scanning result is an error, generating a scanning failure message to the client.
[0033] In a third aspect, the present application proposes a computer-readable storage medium, which stores computer-executable instructions, characterized in that when the computer-executable instructions are executed by a control processor, the code scanning control method of the polyspace license as described in the first aspect is implemented.
[0034] Compared with the prior art, this application has at least the following beneficial effects: The method proposed in this application can not only ensure the correctness of the code, but also complete local code scanning with only one Polyspace license. One Polyspace license can be used to complete code scanning tasks for multiple developers, reducing license fees and project development costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 It is a flow chart of the code scanning control method of the polyspace license shown in the embodiment of the present application.
[0036] Figure 2 It is a structural diagram of the code scanning control system of the polyspace license shown in the embodiment of the present application. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0038] Embodiment 1: The present application provides a code scanning control method for a polyspace license, the code scanning control method comprising: S1: receiving a git patch compressed package, decompressing and analyzing file information of the git patch compressed package.
[0039] S2: extract the code in the file information, and search in the server warehouse whether there is a corresponding project code. If so, proceed to step S3; if not, determine the code as a project program and proceed to step S4.
[0040] S3: extracting the project code from the server warehouse, and merging the code into the project code to obtain the project program.
[0041] S4: Run the polyspace code to scan the project program and obtain the scanning result.
[0042] S5: If the scanning result is correct, a TOKEN token is generated and fed back to the client; if the scanning result is wrong, a scanning failure message is generated and fed back to the client.
[0043] Polyspace is a static code analysis and verification tool provided by MathWorks, mainly for languages such as C, C++, and Ada. It helps developers identify potential code defects, runtime errors, and ensure that the code complies with specific standards (such as MISRA or ISO 26262).
[0044] The main functions of Polyspace are: static analysis: detect potential problems in the code, such as uninitialized variables, array out of bounds, etc.; verification: ensure the safety and reliability of the code under various conditions; code standard compliance: check whether the code complies with industry standards and best practices; integration: can be integrated with MATLAB and Simulink to support model-driven development.
[0045] Polyspace is used in embedded system development, high-security fields such as automotive and aerospace, and projects that require strict compliance with coding standards.
[0046] The present invention only requires one polyspace license and can solve the local code scanning tasks of dozens or hundreds of software developers by sending the modified code to the code scanning and compilation server for scanning.
[0047] The present invention can control the code to be scanned and verified on the local computer of the software developer without submitting the code to the code warehouse.
[0048] In the embodiment of the present invention, optionally, before step S1, the step further includes: Pull the project code from the warehouse server and modify it.
[0049] Generate a git patch file based on the modified project code.
[0050] Compress the git patch file to obtain a git patch compressed package.
[0051] In the embodiment of the present invention, optionally, before step S1, the step further includes: Design new project code.
[0052] Generate a git patch file based on the new project code.
[0053] Compress the git patch file to obtain a git patch compressed package.
[0054] When designing a new project, you can pull the original project code from the warehouse server and modify it, or you can rewrite the new project code.
[0055] git patch is a feature in Git for generating and applying patches, making it easy to share code changes.
[0056] Create a patch: Generate patch file: Use git diff or git format-patch command to generate patch.
[0057] Using git diff: git diff> changes.patch Use git format-patch (usually used to generate patches for submission): git format-patch -n Where -n is the number of the latest commit to generate.
[0058] Specify a range: If you want to generate only patches between certain commits, you can specify the commit hash: git format-patch <commit1> .. <commit2> Apply the patch: Apply patch file: Use the git apply command to apply the patch.
[0059] git apply changes.patch View patch contents: Before applying a patch, you can view the contents of the patch: git apply --stat changes.patch git apply --check changes.patch Apply and create a commit: If you want to create a commit immediately after applying the patch, you can use git am: git am changes.patch In the embodiment of the present invention, optionally, after receiving the TOKEN token, the client uses the git push command to upload the project program to the warehouse server.
[0060] git push is a command used to push changes in a local code base to a remote repository.
[0061] git push <remote> <branch> <remote>Usually origin, which refers to the name of the remote repository.
[0062] <branch>is the name of the local branch you want to push, such as main or master.
[0063] TOKEN is the command token generated when the scanning result is correct. Only with this token can the project code be uploaded to the warehouse server.
[0064] In secure communications, a token may be an encrypted string to ensure the confidentiality and integrity of data.
[0065] In the embodiment of the present invention, optionally, if the scanning result is an error, the URL address of the website server is fed back to the client.
[0066] In the embodiment of the present invention, optionally, the developer can view the project program scanning result at the URL address of the website server.
[0067] If there are problems with project code rules and code defects, the scan results are uploaded to the website server, and a scan failure message and the URL address of the website server are fed back to the client.
[0068] Embodiment 2: The present application also proposes a system for code scanning and control of polyspace licenses, the system comprising: git repository server, a server used to store the codes of various projects.
[0069] Client, used by developers to modify project code or write new project code.
[0070] The code scanning and compiling server is used to compile and verify the project code.
[0071] and website servers.
[0072] In the embodiment of the present invention, optionally, a polyspace license is configured in the code scanning and compiling server.
[0073] Through this inventive design, the present invention only requires one polyspace license, and can solve the local code scanning tasks of dozens or hundreds of software developers by sending the modified code to the code scanning and compilation server for scanning.
[0074] In the embodiment of the present invention, optionally, it is characterized in that the website server includes a URL address.
[0075] Embodiment three: The present application proposes a computer-readable storage medium, which stores computer-executable instructions, characterized in that when the computer-executable instructions are executed by a control processor, the code scanning control method of the polyspace license as described in the first aspect is implemented.
[0076] In the computer-readable storage medium, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk SolidState Disk (SSD)), etc.
[0077] In summary, the present application proposes a code scanning control method, system and storage medium for polyspace licenses. The method includes: receiving a git patch compressed package, decompressing and analyzing the file information of the git patch compressed package; extracting the code in the file information, and searching in the server warehouse for the corresponding project code; extracting the project code from the server warehouse, and merging the code into the project code to obtain the project program; running the polyspace code to scan the project program to obtain the scanning result; if the scanning result is correct, generating a TOKEN token to feedback to the client; if the scanning result is an error, generating a scanning failure message to the client.
[0078] The method proposed in this application can not only ensure the correctness of the code, but also complete local code scanning with only one Polyspace license. One Polyspace license can be used to complete code scanning tasks for multiple developers, reducing license fees and project development costs.
[0079] In several embodiments provided in the present application, it is understood that each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved.
[0080] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially or in other words, the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for an electronic device to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
[0081] The specific embodiments described above further describe the purpose, technical solutions and beneficial effects of the present application in detail. It should be understood that the above description is only a specific embodiment of the present application and is not intended to limit the scope of protection of the present application. It is particularly pointed out that for those skilled in the art, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of protection of the present application.< / branch> < / remote> < / branch> < / remote> < / commit1>
Claims
1. A code scanning control method for polyspace licenses, characterized in that: The code scanning control method specifically includes: S1: receiving a git patch compressed package, decompressing and analyzing file information of the git patch compressed package; S2: extract the code in the file information, and search the server warehouse for the corresponding project code. If it exists, proceed to step S3; if it does not exist, determine the code as a project program, and proceed to step S4; S3: extracting the project code from the server warehouse and merging the code into the project code to obtain a project program; S4: Run the polyspace code to scan the project program and obtain the scanning result; S5: If the scanning result is correct, a TOKEN token is generated and fed back to the client; if the scanning result is wrong, a scanning failure message is generated and fed back to the client.
2. The code scanning control method of polyspace license according to claim 1, characterized in that: Before step S1, the following steps are also included: Pull the project code from the warehouse server and modify it; Generate a git patch file based on the modified project code; Compress the git patch file to obtain a git patch compressed package.
3. The code scanning control method of polyspace license according to claim 1, characterized in that: Before step S1, the following steps are also included: Design new project code; Generate a git patch file based on the new project code; Compress the git patch file to obtain a git patch compressed package.
4. The code scanning control method of polyspace license according to claim 1, characterized in that: After receiving the TOKEN token, the client uses the git push command to upload the project program to the warehouse server.
5. The code scanning control method of polyspace license according to claim 1, characterized in that: If the scan result is an error, the URL address of the website server is fed back to the client.
6. The code scanning control method of polyspace license according to claim 5, characterized in that: Developers can view the project program scanning results at the URL address of the website server.
7. A system for code scanning and control of polyspace licenses, characterized in that: The system comprises: Git repository server, a server used to store the codes of various projects; Client, used by developers to modify project code or write new project code; A code scanning and compiling server, used for compiling and verifying the project code; and website servers.
8. The system according to claim 7, characterized in that The code scanning and compiling server is configured with a polyspace license.
9. The system according to claim 7, characterized in that The website server includes a URL address.
10. A computer-readable storage medium storing computer-executable instructions, characterized in that: When the computer executable instructions are executed by the control processor, the code scanning control method of the polyspace license as described in claims 1-6 is implemented.