CROSS REFERENCE TO RELATED APPLICATIONS

This application claims priority under 35 U.S.C. § 119(b) to European Patent Application No. 20157492.8, filed on Feb. 14, 2020, the contents of which are hereby incorporated by reference.

TECHNICAL FIELD

The present invention generally relates to technical provisions for assessing operational stability of computer systems. More particularly, the present invention generally relates to a computer-implemented method for checking the integrity of a target computer program to be executed in a computer system, the target computer program having a target source code. The invention also relates to an associated apparatus for checking the integrity of a target computer program to be executed in such a computer system, to an associated computer program product and to an associated computer readable medium.

BACKGROUND

Computer systems are used virtually everywhere in modern society. As is well known, a general computer system comprises at least one processing device which is configured to execute at least one computer program being defined by at least one source code. The source code defines computer program code instructions, that may be run by the processing device to perform certain intended functionality.

Our daily lives strongly depend on computer systems being operationally stable in the sense that they must both function flawlessly (i.e., perform the intended functionality without malfunctions) and remain operational for long periods of time without interruptions. Since the source code in effect controls the behavior of the computer system, it is of paramount importance that it contains the correct computer program code instructions. New source code can however be written in different ways by different software developers, and existing source code can be subjected to code modifications, partial code deletions, code rearrangements, code mergers, etc. Over time, therefore, the source code may have undergone substantial changes.

To an operator, host or user of a computer system, the integrity of the computer program as defined by the source code may be fundamentally important for ensuring operational stability of the computer system. It may, however, be a far from easy task for the operator, host or user to know whether and to what extent the integrity of the computer program is satisfactory.

In light of the observations above, the present inventor has realized that there is room for improvements when it comes to technical provisions for assessing operational stability of computer systems.

SUMMARY

It is accordingly an object of the invention to eliminate or alleviate at least some of the problems or drawbacks referred to above.

One aspect of the present invention therefore is a computer-implemented method for checking the integrity of a target computer program to be executed in a computer system. The target computer program has a target source code, and the method involves:

A) obtaining a plurality of reference source code segments which are considered critical to the integrity of the target computer program;

B) for each reference source code segment in said plurality of reference source code segments:

i) processing the reference source code segment to derive tokens therein and their respective offsets in the segment;

ii) for each n-gram of tokens in the reference source code segment, creating a hash and a list of the offsets of the tokens in the n-gram;

iii) generating a reference hash set for the reference source code segment, the reference hash set comprising the hashes as keys and the respective lists of offsets as values;

C) processing the target source code to derive tokens therein and their respective offsets in the target source code;

D) for each n-gram of tokens in the target source code, creating a hash and a list of the offsets of the tokens in the n-gram;

E) generating a target hash set for the target source code, the target hash set comprising the hashes from step D) as keys and the respective lists of offsets from step D) as values;

F) for each reference source code segment in said plurality of reference source code segments:

i) comparing the hashes in the reference hash set to the hashes in the target hash set to do at least one of the following:

a) calculate a score reflecting a degree of match between the reference hash set and the target hash set; and

b) create a hit list comprising offsets of hashes in the reference hash set that match any of the hashes in the target hash set; and

G) making a decision about the integrity of the target computer program by assessing, based on the calculated score and/or the created hit list of at least one of said plurality of reference source code segments, whether or not, or to what extent, said at least one of said plurality of reference source code segments is included in the target source code.

As used herein, “target computer program” refers to an arbitrary computer program, the integrity of which is to be checked by means of the present invention, and “target source code” accordingly refers to the source code of that computer program.

“Token” refers to a sequence of characters in the source code that has recognizable first and last characters with intermediate characters in between, the sequence of characters typically being separated from the rest of the source code by certain special characters like space, comma, semicolon, period, etc., and the sequence of characters typically having a semantical meaning. A word in a text is the most typical example of a token.

The term “n-gram” refers to a contiguous sequence of tokens. The value of n may be 3, or 2 or 4, or another integer value, preferably >1.

A second aspect of the invention is an apparatus for checking the integrity of a target computer program to be executed in a computer system, the target computer program having a target source code, the apparatus comprising a processing device configured for:

A) obtaining a plurality of reference source code segments which are considered critical to the integrity of the target computer program;

B) for each reference source code segment in said plurality of reference source code segments:

i) processing the reference source code segment to derive tokens therein and their respective offsets in the segment;

ii) for each n-gram of tokens in the reference source code segment, creating a hash and a list of the offsets of the tokens in the n-gram;

iii) generating a reference hash set for the reference source code segment, the reference hash set comprising the hashes as keys and the respective lists of offsets as values;

C) processing the target source code to derive tokens therein and their respective offsets in the target source code;

D) for each n-gram of tokens in the target source code, creating a hash and a list of the offsets of the tokens in the n-gram;

E) generating a target hash set for the target source code, the target hash set comprising the hashes from step D) as keys and the respective lists of offsets from step D) as values;

F) for each reference source code segment in said plurality of reference source code segments:

I) comparing the hashes in the reference hash set to the hashes in the target hash set to do at least one of the following:

a) calculate a score reflecting a degree of match between the reference hash set and the target hash set; and

b) create a hit list comprising offsets of hashes in the reference hash set that match any of the hashes in the target hash set; and

G) making a decision about the integrity of the target computer program by assessing, based on the calculated score and/or the created hit list of at least one of said plurality of reference source code segments, whether or not, or to what extent, said at least one of said plurality of reference source code segments is included in the target source code.

A third aspect of the invention is a computer program product comprising computer program code for performing the method according to the first aspect, when the computer program code is executed by a processing device.

A fourth aspect of the invention is a computer readable medium having stored thereon a computer program comprising computer program code for performing the method according to the first aspect when the computer program code is executed by a processing device.

The invention is based on the inventive understanding that the operational stability of a computer system can be assessed by checking the integrity of a target computer program to be executed in the computer system. Embodiments of the invention have the ability to evaluate, quickly and with high confidence, whether or not information which can be considered critical to the integrity of the target computer program is included in a target source code. Embodiments of the invention can do this even when changes have been made to the critical information, for instance change in individual words in the target source code, introduction of special characters in the target source code, or moving of text chunks in the target source code.

Such critical information is handled in the form of a plurality of reference source code segments in the present invention. The reference source code segments may advantageously define critical functions representing key parts of the functionality to be performed by the computer system when the computer program is executed. Alternatively or additionally, the reference source code segments may contain technical background information for future use in modification or development of the target source code, or license statements or copyright notices about the right to use the target source code or respective parts thereof.

Differently put, an understanding that forms the foundation of the present invention is that the presence of critical information in a target source code is important for the integrity or operational stability of a computer system in which the target source code shall execute, and the present invention provides an efficient and accurate way of analyzing whether and to what extent such critical information is in fact contained in the target source code.

In embodiments of the invention, a control signal for the computer system may be generated to prevent execution of the target computer program if the decision in the aforementioned step G) does not indicate integrity of the target computer program. Alternatively or additionally, embodiments of the invention may further involve generating report data based on the aforementioned decision made in step G). Such report data may reflect the decision and, additionally, at least one of the calculated score and an indication of said at least one of said plurality of reference source code segments. The generated report data may be sent or presented to an operator of the computer system, and/or a developer of the target source code.

The provision of a method, apparatus, computer program product and computer readable medium as disclosed herein will solve or at least mitigate one or more of the problems or drawbacks identified in the Background section of this document. These and other aspects, objectives, features and advantages of the invention and its disclosed embodiments will appear from the following detailed disclosure, from the attached dependent claims as well as from the drawings.

Generally, all terms used in the claims are to be interpreted according to their ordinary meaning in the technical field, unless explicitly defined otherwise herein.

All references to “a/an/the [element, device, component, means, step, etc.]” are to be interpreted openly as referring to at least one instance of the element, device, component, means, step, etc., unless explicitly stated otherwise. The steps of any method disclosed herein do not have to be performed in the exact order disclosed, unless explicitly stated.

A reference to an entity being “designed for” doing something, or “capable of” doing something in this document is intended to mean the same as the entity being “arranged for”, “configured for” or “adapted for” doing this very something, and vice versa.

