CN103425571B - A kind of source code integrality detection method and device - Google Patents

A kind of source code integrality detection method and device Download PDF

Info

Publication number
CN103425571B
CN103425571B CN201210161665.1A CN201210161665A CN103425571B CN 103425571 B CN103425571 B CN 103425571B CN 201210161665 A CN201210161665 A CN 201210161665A CN 103425571 B CN103425571 B CN 103425571B
Authority
CN
China
Prior art keywords
source code
feature coding
stake
recorded
code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201210161665.1A
Other languages
Chinese (zh)
Other versions
CN103425571A (en
Inventor
彭成锋
罗慧
徐勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Tencent Cloud Computing Beijing Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201210161665.1A priority Critical patent/CN103425571B/en
Publication of CN103425571A publication Critical patent/CN103425571A/en
Application granted granted Critical
Publication of CN103425571B publication Critical patent/CN103425571B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a kind of source code integrality detection method, be applied to the pitching pile test process of source code, the method comprises: generate the feature coding not carrying out the source code of pitching pile, and is recorded in by described feature coding in the field not affecting source code execution in source code; When carrying out stake operation, the feature coding recorded in extraction source code, and this feature coding is deleted from source code; Generate the feature coding removing the source code after stake, the feature coding recorded in the feature coding removing the source code after stake and the source code extracted is compared, and according to the integrality of comparative result determination source code.Adopt the present invention, can determine whether software source code is changed after pitching pile test, thus can the source code occurring to change be replaced, be published to prevent the source code of mistake.

Description

A kind of source code integrality detection method and device
Technical field
The present invention relates to field of computer technology, particularly a kind of source code integrality detection method and device.
Background technology
Software is being carried out to (such as code coverage test) in the process of pitching pile test, generally need to carry out pitching pile to source code and go the operation of stake, namely pitching pile adds stake code in source code, the work such as Data Collection are completed by stake code, stake is gone to be then removed from source code by stake code, by performing the source code after pitching pile, corresponding test purpose can be reached.
Execute the source code after pitching pile and after obtaining corresponding test data, the source code with stake code cannot run in general operating environment, stake code wherein must be removed.The method of general employing is, adopts predetermined matching inquiry rule in source code, inquire about stake code, deletes the stake code found.
But inventor finds, at least there are the following problems for prior art:
Carry out time; inquire about in source code according to certain matching inquiry rule; often there will be the code segment meeting matching inquiry rule found not is stake code; this deletes the source code content outside stake code by causing; in addition; under also having certain situation; because query script mistake causes the position not inquiring a code; this will cause a code to be removed; above situation all can cause the mistake of source code; and the flow process of prior art can not find the mistake of source code timely, and the source code of mistake can be issued.
Summary of the invention
The object of the present invention is to provide a kind of source code integrality detection method and device, to determine whether software source code is changed after pitching pile test, and for this reason, the embodiment of the present invention adopts following technical scheme:
A kind of source code integrality detection method, is applied to the pitching pile test process of source code, comprises:
Generate the feature coding not carrying out the source code of pitching pile, and described feature coding is recorded in the field not affecting source code execution in source code;
When carrying out stake operation, the feature coding recorded in extraction source code, and this feature coding is deleted from source code;
Generate the feature coding removing the source code after stake, the feature coding recorded in the feature coding removing the source code after stake and the source code extracted is compared, and according to the integrality of comparative result determination source code.
A kind of source code integrity detection device, is applied to the pitching pile test process of source code, comprises:
Generation module, for generating the feature coding of the source code not carrying out pitching pile, and is recorded in the field not affecting source code execution in source code by described feature coding;
Extraction module, for when carrying out stake operation, the feature coding recorded in extraction source code, and this feature coding is deleted from source code;
Comparison module, for generating the feature coding of the source code after stake, compares the feature coding recorded in the feature coding removing the source code after stake and the source code that extracts, and according to the integrality of comparative result determination source code.
The above embodiment of the present invention, generate the feature coding not carrying out the source code of pitching pile, and described feature coding is recorded in the field not affecting source code execution in source code, when carrying out stake operation, the feature coding recorded in extraction source code, and the described feature coding recorded in source code is deleted, generate the feature coding of the source code after going stake, the feature coding recorded in the feature coding removing the source code after stake and the source code that extracts is compared, and according to the integrality of comparative result determination source code.Thus, can determine whether software source code is changed after pitching pile test, and then can the source code occurring to change be replaced, be published to prevent the source code of mistake.
Accompanying drawing explanation
The schematic flow sheet of the source code integrality detection method that Fig. 1 provides for the embodiment of the present invention;
The schematic flow sheet of the source code integrality detection method that Fig. 2 provides for the embodiment of the present invention;
The structural representation of the source code integrity detection device that Fig. 3 provides for the embodiment of the present invention.
Embodiment
Below in conjunction with the accompanying drawing in the present invention, carry out clear, complete description to the technical scheme in the present invention, obviously, described embodiment is a part of embodiment of the present invention, instead of whole embodiments.Based on the embodiment in the present invention, other embodiments all that those of ordinary skill in the art obtain under the prerequisite not making creative work, all belong to the scope of protection of the invention.
Embodiment one
Embodiments provide a kind of source code integrality detection method, be applied to the pitching pile test process of source code.The integrality of detection resources code, namely whether detection resources code there is any change.As shown in Figure 1, be the treatment scheme of the method, can comprise the following steps.
Step 101, generates the feature coding not carrying out the source code of pitching pile, and is recorded in by this feature coding in the field not affecting source code execution in source code.
Wherein, this feature coding is the coding that a section of adopting a kind of irreversible coding rule to be carried out by primary code being converted to is only corresponding with this source code, feature coding can have default regular length, and feature coding also can be called fingerprint or the summary of source code.According to this coding rule, each different source code has each self-corresponding unique features coding, if so feature coding is different, then can illustrate that corresponding source code exists different.Concrete, this feature coding can be MD5(MessageDigestAlgorithm5, Message Digest Algorithm 5) coding, SHA(SecureHashAlgorithm, Secure Hash Algorithm) encode.
Concrete, feature coding is recorded in the process in source code, can carries out before pitching pile operation, can also carry out when pitching pile operates, can certainly carry out after pitching pile operation.Preferably, can when carrying out pitching pile operation, generating feature is encoded, and is recorded in source code by the feature coding of generation.On the one hand, the process of generation and recording feature coding carries out can saving corresponding system resource without the need to cache feature coding simultaneously, on the other hand, the operation of recording feature coding and pitching pile is carried out simultaneously, namely simultaneously by the relevant position in stake code and feature coding write source code, the treatment effeciency of this flow process can be improved.
The process of source code being carried out to pitching pile test is: first, and stake code is written to (i.e. pitching pile) in tested source code, general stake code is written in the forefront of source code; Then, perform the source code after write stake code, first will perform anterior stake code, then perform source code below, to realize the test purpose to source code; Finally, stake code is removed (going stake).Visible, the record position of feature coding in source code, as long as in above-mentioned test process with pitching pile after the irrelevant field of the execution of source code just passable.Preferably, this field can be the field of the annotation information for storing source code, is recorded in the annotation information of source code by feature coding.
Step 102, when carrying out stake operation, the feature coding recorded in extraction source code, and this feature coding is deleted from source code.
Preferably, first the feature coding recorded in source code can be extracted from source code, then the stake code in source code and feature coding be deleted simultaneously, the treatment effeciency of this flow process can be improved like this.
Step 103, generates the feature coding removing the source code after stake, the feature coding recorded is compared in the feature coding removing the source code after stake and the source code extracted, and according to the integrality of comparative result determination source code.
After deleting the stake code and feature coding write in source code, regenerate the feature coding of source code.Here the feature coding generated in step 101 is denoted as feature coding 1, the feature coding regenerated is denoted as feature coding 2.Contrast characteristic encodes 1 and feature coding 2, if identical, then illustrate that the source code of its correspondence is also identical, namely source code through pitching pile, go the operation of stake after do not change, there is integrality, if not identical, then illustrate that the source code of its correspondence is not identical, namely source code through pitching pile, go the operation of stake after change, not there is integrality.
By the above-mentioned flow process of the embodiment of the present invention, can detect the integrality of the source code carried out before and after pitching pile test, if find the source code integrality existing problems after going stake, then can be replaced with correct source code before source code is issued.But, also there is some situation, as script failure etc., cause stake to operate and perform failure, and integrity detection result is made mistakes.For this situation, the embodiment of the present invention also proposed following solution.
When stake code starts to perform, judge whether current execution environment is test environment, if so, then perform stake code, otherwise, skip a code, perform source code.Specifically can add judgement statement at the forefront of stake code, to judge current execution environment.If current execution environment is test environment, then illustrates that the execution environment of stake code is correct, can sequentially perform a code and source code.If current execution environment is operating environment, then illustrate that the source code with stake code is published, because the correct execution environment of stake code should be test environment, so this execution environment mistake, at this moment, if still perform a code, program may be caused to report an error, a code (namely not performing a code) can be skipped, perform source code.
The above embodiment of the present invention, generate the feature coding not carrying out the source code of pitching pile, and described feature coding is recorded in the field not affecting source code execution in source code, when carrying out stake operation, the feature coding recorded in extraction source code, and the described feature coding recorded in source code is deleted, generate the feature coding of the source code after going stake, the feature coding recorded in the feature coding removing the source code after stake and the source code that extracts is compared, and according to the integrality of comparative result determination source code.Thus, can determine whether software source code is changed after pitching pile test, and then can the source code occurring to change be replaced, be published to prevent the source code of mistake.
Embodiment two
As shown in Figure 2, be the treatment scheme of source code integrality detection method in embody rule scene that the embodiment of the present invention provides, can comprise the following steps.
Step 201, generates the MD5 coding not carrying out the source code of pitching pile, is denoted as coding A.
Step 202, is written to coding A in the annotation information of source code, and by stake code insertion in source code.General stake code can write on the forefront of source code.
Step 203, performs the source code after pitching pile, tests source code.
Step 204, extracts coding A from source code.
Step 205, deletes stake code and coding A in source code.
Step 206, generates the MD5 coding of the source code after going stake, is denoted as coding B.
Step 207, judges that whether the coding A extracted from source code is consistent with the value of the coding B going stake to generate afterwards, if so, then determines that source code does not change, otherwise, determine that source code changes.
The above embodiment of the present invention, generate the feature coding not carrying out the source code of pitching pile, and described feature coding is recorded in the field not affecting source code execution in source code, when carrying out stake operation, the feature coding recorded in extraction source code, and the described feature coding recorded in source code is deleted, generate the feature coding of the source code after going stake, the feature coding recorded in the feature coding removing the source code after stake and the source code that extracts is compared, and according to the integrality of comparative result determination source code.Thus, can determine whether software source code is changed after pitching pile test, and then can the source code occurring to change be replaced, be published to prevent the source code of mistake.
Embodiment three
Based on identical technical conceive, the embodiment of the present invention additionally provides a kind of source code integrity detection device, is applied to the pitching pile test process of source code, as shown in Figure 3, comprises:
Generation module 310, for generating the feature coding of the source code not carrying out pitching pile, and is recorded in the field not affecting source code execution in source code by described feature coding;
Extraction module 320, for when carrying out stake operation, the feature coding recorded in extraction source code, and this feature coding is deleted from source code;
Comparison module 330, for generating the feature coding of the source code after stake, compares the feature coding recorded in the feature coding removing the source code after stake and the source code that extracts, and according to the integrality of comparative result determination source code.
Preferably, described generation module 310, specifically for:
When carrying out pitching pile operation, generate the feature coding not carrying out the source code of pitching pile, and described feature coding is recorded in the field not affecting source code execution in source code.
Preferably, described generation module 310, specifically for:
Described feature coding is recorded in the annotation information of source code.
Preferably, described feature coding is specially MD5 coding or SHA coding.
Preferably, also comprise execution module, for:
When stake code starts to perform, judge whether current execution environment is test environment, if so, then perform described stake code, otherwise, skip described stake code, perform source code.
The above embodiment of the present invention, generate the feature coding not carrying out the source code of pitching pile, and described feature coding is recorded in the field not affecting source code execution in source code, when carrying out stake operation, the feature coding recorded in extraction source code, and the described feature coding recorded in source code is deleted, generate the feature coding of the source code after going stake, the feature coding recorded in the feature coding removing the source code after stake and the source code that extracts is compared, and according to the integrality of comparative result determination source code.Thus, can determine whether software source code is changed after pitching pile test, and then can the source code occurring to change be replaced, be published to prevent the source code of mistake.
It will be appreciated by those skilled in the art that the module in the device in embodiment can carry out being distributed in the device of embodiment according to embodiment description, also can carry out respective change and be arranged in the one or more devices being different from the present embodiment.The module of above-described embodiment can merge into a module, also can split into multiple submodule further.
The invention described above embodiment sequence number, just to describing, does not represent the quality of embodiment.
Through the above description of the embodiments, those skilled in the art can be well understood to the mode that the present invention can add required general hardware platform by software and realize, and can certainly pass through hardware, but in a lot of situation, the former is better embodiment.Based on such understanding, technical scheme of the present invention can embody with the form of software product the part that prior art contributes in essence in other words, this computer software product is stored in a storage medium, comprising some instructions in order to make a station terminal equipment (can be mobile phone, personal computer, server, or the network equipment etc.) perform method described in each embodiment of the present invention.
The above is only the preferred embodiment of the present invention; it should be pointed out that for those skilled in the art, under the premise without departing from the principles of the invention; can also make some improvements and modifications, these improvements and modifications also should look protection scope of the present invention.

Claims (10)

1. a kind of source code integrality detection method, is applied to the pitching pile test process of source code, it is characterized in that, comprising:
generate the feature coding not carrying out the source code of pitching pile, and described feature coding is recorded in the field not affecting source code execution in source code;
when carrying out stake operation, the feature coding recorded in extraction source code, and this feature coding is deleted from source code;
generate the feature coding removing the source code after stake, the feature coding recorded in the feature coding removing the source code after stake and the source code extracted is compared, and according to the integrality of comparative result determination source code.
2. the method of claim 1, is characterized in that, the feature coding of the source code of pitching pile is not carried out in described generation, and is recorded in by described feature coding in the field not affecting source code execution in source code, is specially:
when carrying out pitching pile operation, generate the feature coding not carrying out the source code of pitching pile, and described feature coding is recorded in the field not affecting source code execution in source code.
3. the method of claim 1, is characterized in that, in the described field not affecting source code execution be recorded in by described feature coding in source code, is specially:
described feature coding is recorded in the annotation information of source code.
4. the method of claim 1, is characterized in that, described feature coding is specially MD5 coding or SHA coding.
5. the method of claim 1, is characterized in that, also comprises:
when stake code starts to perform, judge whether current execution environment is test environment, if so, then perform described stake code, otherwise, skip described stake code, perform source code.
6. a kind of source code integrity detection device, is applied to the pitching pile test process of source code, it is characterized in that, comprising:
generation module, for generating the feature coding of the source code not carrying out pitching pile, and is recorded in the field not affecting source code execution in source code by described feature coding;
extraction module, for when carrying out stake operation, the feature coding recorded in extraction source code, and this feature coding is deleted from source code;
comparison module, for generating the feature coding of the source code after stake, compares the feature coding recorded in the feature coding removing the source code after stake and the source code that extracts, and according to the integrality of comparative result determination source code.
7. device as claimed in claim 6, is characterized in that, described generation module, specifically for:
when carrying out pitching pile operation, generate the feature coding not carrying out the source code of pitching pile, and described feature coding is recorded in the field not affecting source code execution in source code.
8. device as claimed in claim 6, is characterized in that, described generation module, specifically for:
described feature coding is recorded in the annotation information of source code.
9. device as claimed in claim 6, is characterized in that, described feature coding is specially MD5 coding or SHA coding.
10. device as claimed in claim 6, is characterized in that, also comprises execution module, for:
when stake code starts to perform, judge whether current execution environment is test environment, if so, then perform described stake code, otherwise, skip described stake code, perform source code.
CN201210161665.1A 2012-05-23 2012-05-23 A kind of source code integrality detection method and device Active CN103425571B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210161665.1A CN103425571B (en) 2012-05-23 2012-05-23 A kind of source code integrality detection method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210161665.1A CN103425571B (en) 2012-05-23 2012-05-23 A kind of source code integrality detection method and device

Publications (2)

Publication Number Publication Date
CN103425571A CN103425571A (en) 2013-12-04
CN103425571B true CN103425571B (en) 2016-04-13

Family

ID=49650356

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210161665.1A Active CN103425571B (en) 2012-05-23 2012-05-23 A kind of source code integrality detection method and device

Country Status (1)

Country Link
CN (1) CN103425571B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114089725B (en) * 2021-11-18 2024-03-15 北京晶亦精微科技股份有限公司 Test method and device for control software of chemical mechanical polishing equipment and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1758585A (en) * 2004-10-10 2006-04-12 北京华旗数码影像技术研究院有限责任公司 Method for recogniting seal by digital watermark
CN102214142A (en) * 2011-07-15 2011-10-12 南京大学 Instrumentation method for traceless manageable source code manually-defined mark
CN102222041A (en) * 2011-06-15 2011-10-19 深圳市运通信息技术有限公司 Test analysis system and method based on embedded software

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1758585A (en) * 2004-10-10 2006-04-12 北京华旗数码影像技术研究院有限责任公司 Method for recogniting seal by digital watermark
CN102222041A (en) * 2011-06-15 2011-10-19 深圳市运通信息技术有限公司 Test analysis system and method based on embedded software
CN102214142A (en) * 2011-07-15 2011-10-12 南京大学 Instrumentation method for traceless manageable source code manually-defined mark

Also Published As

Publication number Publication date
CN103425571A (en) 2013-12-04

Similar Documents

Publication Publication Date Title
CN103136243B (en) File system duplicate removal method based on cloud storage and device
CN102937926B (en) Method and device for recovering deleted sqlite files on mobile terminal
CN107229420B (en) Data storage method, reading method, deleting method and data operating system
US20150178170A1 (en) Method and Apparatus for Recovering Data
CN109388556B (en) Method and device for analyzing test process
CN111475324B (en) Log information analysis method, device, computer equipment and storage medium
CN101783955B (en) Data recovering method when data is abnormal and equipment thereof
CN104408154A (en) Repeated data deletion method and device
CN105045676A (en) Device and method for recovering lost data based on SQLite database
CN104965999A (en) Analysis and integration method and device for sequencing of medium-short gene segment
CN104424010A (en) Method and system for detecting and repairing text document messy codes
CN108573172B (en) Data checking and storing method and device
US20140337301A1 (en) Big data extraction system and method
WO2015087509A1 (en) State storage and restoration device, state storage and restoration method, and storage medium
CN113486358B (en) Vulnerability detection method and device
CN104348905A (en) Method and device for pushing message in off-line way
CN108196975B (en) Data verification method and device based on multiple checksums and storage medium
CN106658034A (en) File storage and reading method and device
CN108133026B (en) Multi-data processing method, system and storage medium
CN103425571B (en) A kind of source code integrality detection method and device
CN105468531A (en) Vulnerability mining method and device and electronic equipment
CN103746868A (en) Methods and apparatuses for sending and receiving testing messages, and testing equipment
CN102325171B (en) Data storage method in monitoring system and system
CN107357701B (en) SAS signal testing method and device under distributed scene
CN107783904B (en) Unit test pile de-weighting method, device, computer readable storage medium and equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20190808

Address after: 518000 Nanshan District science and technology zone, Guangdong, Zhejiang Province, science and technology in the Tencent Building on the 1st floor of the 35 layer

Co-patentee after: Tencent cloud computing (Beijing) limited liability company

Patentee after: Tencent Technology (Shenzhen) Co., Ltd.

Address before: Shenzhen Futian District City, Guangdong province 518057 Zhenxing Road, SEG Science Park 2 East Room 403

Patentee before: Tencent Technology (Shenzhen) Co., Ltd.

TR01 Transfer of patent right