Patent Description:
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 function flawlessly (i.e., perform the intended functionality without malfunctions) while remaining 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. With a massive code quantity in global software archives together with the open-source model for open collaboration between projects, it is becoming increasingly difficult to confirm the true origin of the code.

Software vulnerabilities and toxic code snippets are being discovered and recorded, both constantly and massively, in global software archives. When a vulnerability is found in an application or a software library, the authors of the code are typically responsible for having well-defined processes to share the relevant information to anyone importing and operating on this code. This information needs to be shared immediately, since it may affect critical security flaws of the code. If a code snippet has been imported from a third party source, this source is not necessarily obliged to share the relevant information, and is much less likely to have a well-defined process for communicating information to code importers. Additionally, outdated and license-violating online code clones are much less likely to be communicated.

Hence, as the validity of the author or organization behind the code in operation may not be credible, operational stability may not be ensured for an operator, host or user of a computer system importing this code.

It may, however, be far from trivial for the operator, host or user to correctly monitor, audit or validate the origins of imported files due to a potentially massive project with a large amount of code contributors. If the origin of the code in a program is unknown, security of the program can't be guaranteed. <CIT> discloses a system and method for performing code provenance review in a software due diligence system. Performing code provenance review may include sub-dividing source code under review and third-party source into logical fragments using a language-independent text fracturing algorithm. For example, the fracturing algorithm may include a set of heuristic rules that account for variations in coding style to create logical fragments that are as large as possible without being independently copyrightable. Unique fingerprints are then generated for the logical fragments using a fingerprint algorithm that features arithmetic computation.

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.

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

A first aspect of the present invention therefore is a computer-implemented method for determining an origin of a target source code for a computer program or a part thereof. The method involves:.

As used herein, "target source code" refers to an arbitrary piece or snippet of source code for a computer program or a part thereof, the operational stability of which is to be assessed by means of the present invention. "Computer program" accordingly refers to the computer program executing the target source code and "a part thereof" refers to instructions, libraries or related data of the computer program. "Software archives" refer to publically available open source libraries managing and storing large quantities of computer source code from a code space created and modified by a plurality of e.g. software developers, coders, enthusiasts and other professionals. Software archives typically offer distributed version control of programs and store key information of a program such as for example authors, repository names, filenames and resource locations. The software archives may be stored for online or offline access through a variety of search engines. Additionally, software archives may manage repository licenses and versions.

The invention is based on the inventive understanding that the operational stability of a computer system can be assessed by determining and analyzing the origin of a target source code to be executed in a computer system.

Upon applying the scoring scheme, a score will be calculated which effectively and reliably distinguishes the origin of the target source code from e.g. other third party sources. As a result, code owners, developers, companies and other stakeholders may be assisted in performing key decisions regarding operational stability of the computer program.

According to the invention, the key information of the matching source code files includes at least one of author, repository name, filename or resource location of the matching source code files.

In another embodiment of the invention, applying the scoring scheme to the built frequency map involves:
for each of the matching source code files, calculating a score based on adding the keyword count of the author of the matching source code file with the keyword count of the repository name of the matching source code file, wherein the keyword count values being retrieved from the frequency map.

In another embodiment of the invention, applying the scoring scheme to the built frequency map further involves lowering the score if key information of a matching source code file contains dependent keywords which frequently occurs in dependent software archives.

In another embodiment of the invention, applying the scoring scheme to the built frequency map further involves lowering the score if details are missing in the matching source code file such as one or more key information entries, license number or version number.

The scoring scheme of the present invention provides several advantages regarding accuracy. When assessing the relevancy of the matches, the user may be assured that the score reflects all of the matching source code files. In other words, no potential target origins are overlooked. Additionally, as the scoring scheme in embodiments of the invention takes dependencies and lack of important details into account, the user may therefore assess the operational stability of the computer system credibly.

In another embodiment of the invention, the computer-implemented method further comprising, after said step of selecting and retrieving the origin of the target source code for a computer program or a part thereof, returning at least one of author, repository name, filename or resource location of the matching source code file as a response to the computer-implemented method having determined the origin of the target source code.

A second aspect of the invention is an apparatus for determining an origin of a target source code for a computer program or a part thereof. The apparatus comprises a processing device which is configured for performing the computer-implemented method according to the first aspect of the invention.

A third aspect of the invention is computer program product comprising computer program code for performing the computer-implemented method according to the first aspect of the invention 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 computer-implemented method according to the first aspect of the invention when the computer program code is executed by a processing device.

The provision of a computer-implemented 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.

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.

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.

Embodiments of the invention will now be described with reference to the accompanying drawings. The invention may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art. The terminology used in the detailed description of the particular embodiments illustrated in the accompanying drawings is not intended to be limiting of the invention.

<FIG> illustrates a general computer network <NUM> that comprises various kinds of computing devices <NUM>, <NUM>. The computing devices include typical end-user devices <NUM>, or client devices, such as tablet computers (e.g. surf pads), mobile terminals (e.g. smartphones or personal digital assistants), or personal computers (e.g. laptops, personal computers or workstations). The computing devices also include typical server devices <NUM>, which may be physically separable devices, or distributed (e.g. cloud-based) computing resources, or a combination thereof.

The computing devices <NUM>, <NUM> communicate by wireless and/or wired networked communication, illustrated in a simplified manner in the form of one common communication network <NUM>. The wireless networked communication may include one or more of WIFI, Bluetooth®, W-CDMA, GSM, UTRAN, HSPA, LTE and LTE Advanced, to name a few. The wired networked communication may include one or more of USB, Ethernet or TCP/ IP, to name a few. The communication network <NUM> may be the Internet or a part thereof.

<FIG> is a schematic block diagram of some typical components of a general computer system <NUM>. The computer system <NUM> may, for instance, be any of the types of computing devices <NUM>, <NUM> shown in <FIG>. As seen in <FIG>, the computer system <NUM> comprises a processing device <NUM> (or a cooperative plurality of such processing devices) and a memory <NUM> (or a cooperative plurality of such memories).

The processing device <NUM> is responsible for the overall operation of the computer system <NUM> and is preferably implemented by any commercially available CPU ("Central Processing Unit"), DSP ("Digital Signal Processor") or any other electronic programmable logic device. The processing device <NUM> is configured to read instructions from the memory <NUM> and execute these instructions to control the operation of the computer system <NUM>. The memory <NUM> may be implemented using any commonly known technology for computer-readable memories such as ROM, RAM, SRAM, DRAM, CMOS, FLASH, DDR, EEPROM memory, flash memory, hard drive, optical storage or any combination thereof.

The processing device <NUM> and the memory <NUM> can be seen as a hardware layer <NUM> of the computer system <NUM>. The computer system <NUM> further has a software architecture which includes an operating system layer <NUM> and an application program layer <NUM>. The operating system layer <NUM> includes an operating system (OS) kernel <NUM>, various code libraries <NUM>, and a runtime <NUM>. The application program layer <NUM> comprises an application framework <NUM> that supports various application programs <NUM>-<NUM>. For exemplifying purposes in the present description, it is assumed that the application program <NUM> is the target computer program. The origin <NUM> of the source code being executed from the application program <NUM> by the processing device <NUM> of the computer system <NUM> is determined by means of the present invention. The operating system may, for instance, be Apple OSX, Microsoft Windows, Unix, Android or Apple iOS.

The application program <NUM> is defined by source code <NUM>. As seen at <NUM>, compilation or interpretation will generate executable code <NUM> from the source code. The executable code will contain sets of instructions that when executed by the processing device <NUM> will control the operation of the computer system <NUM> by performing the functionality intended by the application program <NUM>.

Needless to say, the computer system <NUM> may typically comprise user interface devices (particularly when the computer system <NUM> is an end-user (client device like <NUM> in <FIG>), and communication interface devices being adapted to allow the computer system <NUM> to communicate with other devices through the use wired or wireless communication, for instance as described above for <FIG>. Moreover, the components of the computer system <NUM> may be distributed over more than one physical device, such as in a client-server or cloud computing architecture. Accordingly, the computer system is not limited to being merely a single physical device.

<FIG> is a schematic illustration of a computer system <NUM> that comprises a processing device <NUM> being adapted to execute a target computer program <NUM> having a target source code <NUM>. One possible task of the computer system <NUM> when executing the target computer program <NUM> may be to control an external system <NUM> by generating control signals <NUM>. The external system <NUM> may, for instance, be an industrial process or plant, or technical equipment in a private home or a public building, etc. As already discussed in the background section of this document, the computer system needs to be operationally stable by functioning flawlessly while remaining operational for long periods of time without interruptions. This requires the target computer program <NUM> to perform the intended functionality without malfunctions, bugs or malicious activity, i.e. to have operational stability. Since it is the target source code <NUM> that defines the target computer program <NUM> and therefore in effect controls the behavior of the computer system <NUM>, the target source code <NUM> must contain the correct computer program code instructions and nothing else. As was explained in the background section, however, the target source code <NUM> may be written in different ways by different software developers, and it may undergo code modifications, partial code deletions, code rearrangements, code mergers, etc., over time.

Another possible task of the computer system <NUM> when executing the target computer program <NUM> may be to generate output data <NUM> by generating control signals <NUM>. The output data may represent key information for use by other technical systems or human readers. For similar reasons as were given above, it is typically quite important that the generated output data <NUM> is correct and free from errors. Again, the target computer program <NUM> should perform the intended functionality without malfunctions, bugs or malicious activity, i.e. have operational stability.

<FIG> is a schematic illustration of an apparatus <NUM> for determining an origin <NUM> of a target source code <NUM> for the computer program <NUM>. The apparatus <NUM> comprises a processing device <NUM> which is configured for performing functionality of a computer-implemented method <NUM>. The method <NUM> is illustrated in more detail as a flowchart diagram in <FIG>.

In some embodiments, the processing device <NUM> of the apparatus <NUM> is implemented by customized hardware (such as, for instance, an ASIC or FPGA). In other embodiments it may be implemented by a general-purpose processor (such as, for instance, a CPU or DSP) being programmed by software customized to perform the functionality of the method <NUM> as described herein.

The processing device <NUM> takes the target source code <NUM> as input and determines the origin <NUM> of the target source code <NUM> for the computer program <NUM> in accordance with the computer-implemented method <NUM> in <FIG>, a detailed explanation of which will follow in subsequent passages of this document.

The apparatus <NUM> may be used for assessing operational stability of the computer system <NUM>. After the processing device <NUM> of the apparatus <NUM> has determined the origin of the target source code, the processing device <NUM> may generate a control signal <NUM> for the computer system <NUM> to prevent execution of the target computer program <NUM> if operational stability can't be guaranteed for the target computer program <NUM>. This is advantageous since it may prevent hazards from occurring at the controlled external system <NUM> as a result of the origin <NUM> of the target source code <NUM> being untrusted.

<FIG> cover a preferred embodiment of the methodology of how the origin <NUM> of the target source code <NUM> may be determined by inputting the target source code <NUM>, finding target source code occurrences in software archives <NUM> in the form of matching source code files, building a frequency map <NUM> of the found occurrences, applying a scoring scheme <NUM> to the matching source code files based on the built frequency map <NUM>, and returning information about the origin <NUM> of the target source code <NUM> to, for example, an end-user device <NUM>, a user or operator <NUM> of the computer system <NUM> in <FIG>, or a developer <NUM> of the target source code <NUM> (also see <FIG>).

<FIG> is a general block diagram schematic illustration of the primary inventive aspects of the invention including computer system input and output with a plurality of responsible computer components. A target source code <NUM>, typically comprising one or more code files, code pieces or code snippets, is provided for a search engine <NUM> by e.g. an end-user device <NUM>, user <NUM> or developer <NUM>. In some embodiments, the search engine <NUM> is designed to carry out web searches in a systematic way to obtain particular information specified in a web search query. The search engine <NUM> may for example be a crawler based search engine such as Google, Bing or Yahoo!, or human powered directories such as Yahoo! Directory or DMOZ. The search engine <NUM> is responsible for searching through a large number of software files in a large number of software archives <NUM> in a global computerized network, for example the network as explained in <FIG>. Alternatively or additionally, the search engine <NUM> may also operate offline on massive software archives which have been collected and downloaded in advance and stored in a local data repository.

Searching through software archives <NUM> may be executed efficiently by having a search engine <NUM> capable of performing distributed searches simultaneously to a plurality of software archives <NUM> from different sources in order to quickly locate important information in a large search space. When target source code occurrences have been found <NUM>, the search engine <NUM> collects key information about the matching source code files <NUM>; <NUM>; <NUM>; <NUM>, and a frequency map <NUM> is built based on the collected key information. The frequency map <NUM> calculates a keyword count value, indicative of the number of times the keyword occurs in the key information of each matching source code file <NUM>; <NUM>; <NUM>; <NUM>. The key information is collected as one or more keywords from a plurality of attributes of the matching source code file and/or the software archive <NUM> in which it was found. For instance, the key information may comprise at least one of author, repository name, filename or resource location of the matching source code file <NUM>; <NUM>; <NUM>; <NUM>. A resource location may for instance comprise a path to where the resource resides in public or private clouds, branch offices, data storages, data centers or other virtual locations.

Subsequently, once the frequency map <NUM> has been built, a scoring scheme <NUM> is applied to the matching source code files based on the frequency map <NUM>. The scoring scheme <NUM> involves:
For each of the matching source code files <NUM>; <NUM>; <NUM>; <NUM> in the frequency map <NUM>, calculating a score V1; V2; V3; V4 based on adding the keyword count of the author of the matching source code file <NUM>; <NUM>; <NUM>; <NUM> and the keyword count of the repository name of the same matching source code file <NUM>; <NUM>; <NUM>; <NUM>, wherein the keyword count values being retrieved from the frequency map <NUM>.

Additionally, the score V1; V2; V3; V4 may be lowered if key information of a matching source code file <NUM>; <NUM>; <NUM>; <NUM> contains dependent keywords which frequently occurs in dependent software archives. These words may for example be, but not limited to being, one of "deps", "thirdparty", "external", or the like.

The score V1; V2; V3; V4 may also be lowered if details are missing in the matching source code file <NUM>; <NUM>; <NUM>; <NUM> such as one or more key information entries, license number or version number.

Finally, once the scoring scheme <NUM> has been applied, the origin <NUM> of the target source code <NUM> representing the highest score Vmax of the entries in the frequency map <NUM> will be returned by the computer system. At least one of author, repository name, filename or resource location of the origin <NUM> of the target source code <NUM> is to be returned.

<FIG> is a schematic illustration of how a frequency map <NUM> is built from the matching source code files <NUM>; <NUM>; <NUM>; <NUM> in the software archives <NUM>. It should be clear that the embodiment shown in <FIG> and <FIG> is just one example of a method for determining an origin of a target source code where specific example data have been used. In practice, the search engine <NUM> may find an arbitrary number of found occurrences among the software archives <NUM>. In the example provided, the end-user device <NUM> wants to discover the origin <NUM> of the target source code <NUM>: "d1_pkt. The search engine <NUM> finds four matching source code files <NUM>; <NUM>; <NUM>; <NUM>, and a frequency map <NUM> is built comprising the count of each relevant keyword.

In order for the frequency map <NUM> to make sense of the data given by the matching source code files <NUM>; <NUM>; <NUM>; <NUM>, the retrieved data are expected to go through a pipeline of text processing modules, as a way to prepare the data for keyword frequency calculation. Herein, a variety of data preprocessing techniques may be performed. The different fields of each found source code file <NUM>; <NUM>; <NUM>; <NUM> are processed by e.g. a data parser, wherein all relevant keywords are being retrieved and data noise and inconsistencies are filtered. Given the example shown in <FIG>, instructions given to the parser may for example be to eliminate cardinal numbers, punctuations, multiple whitespaces as well as other regular expressions (regex) not contributing to any meaningful information such as e.g. slashes, underscores or asterisks.

The data preprocessing can be done in different ways. For instance, an algorithm may have been developed for iterating a global archive of found file occurrences, which may be based on set instructions made by the programmer or a human user. Additionally, a software program based on unsupervised learning algorithms looking for hidden structures behind the data may have been implemented.

In this example, the keyword "archive" has been found four times, the keyword "ssl" has been found four times, and the keyword "openssl" has been found <NUM> times. The frequency map also contains additional words such as "github", "tar", "gz" not shown in the example. These words typically contribute to data inconsistencies, and have therefore been filtered by the parser using techniques for e.g. removing stop words and frequently occurring words, or similar data preprocessing technology.

Given the keyword count from the frequency map <NUM> in <FIG>, <FIG> is a schematic illustration of how a scoring scheme <NUM> is applied to the frequency map <NUM>. Herein, a score is calculated for each matching source code files <NUM>; <NUM>; <NUM>; <NUM>, and a highest score Vmax is determined. In the example provided, the fourth matching source code file <NUM> will be given the highest score, since both the name of the author and the name of the repository is "openssl". Thus, the score V4 and consequently the highest score Vmax will be calculated as <NUM> + <NUM> = <NUM>. Finally, the at least author, repository name, filename or resource location of the matching source code file <NUM> corresponding to the highest score Vmax is determined from the software archives <NUM> and returned to the end-user device <NUM>.

<FIG> is a flowchart diagram that illustrates a computer-implemented method for determining an origin of a target source code for a computer program or a part thereof. The steps shown in <FIG> are not necessarily performed sequentially, as for example system input and output latency may affect certain steps of the method. The method comprises an initial step of receiving a request <NUM> for determining the origin <NUM> of the target source code <NUM>. The method further involves searching a plurality of software archives <NUM> from different sources <NUM> in a global computer network <NUM> to find occurrences <NUM> of the target source code <NUM> among code files in said software archives <NUM>. For every found occurrence of the target source code <NUM>, the method further involves collecting key information about the matching source code file <NUM>; <NUM>; <NUM>; <NUM>. Moreover, the method involves, for all collected key information about the matching source code file <NUM>; <NUM>; <NUM>; <NUM> of the target source code <NUM>, building a frequency map <NUM> of the key information, wherein the frequency map contains, for each keyword found in the key information of each matching source code files <NUM>; <NUM>; <NUM>; <NUM>, a keyword count value, indicative of the number of times the keyword occurs in the key information. The method further involves applying a scoring scheme <NUM> to the matching source code files <NUM>; <NUM>; <NUM>; <NUM> based on the built frequency map <NUM>, determining a highest score Vmax among the matching source code files <NUM>; <NUM>; <NUM>; <NUM> after the scoring scheme (<NUM>) has been applied, and determining the origin <NUM> of the target source code <NUM> as the matching source code file having the highest score Vmax. Finally, the method comprises a concluding step <NUM> of returning at least one of author, repository name, filename or resource location of the matching source code file <NUM>; <NUM>; <NUM>; <NUM> in response to said request <NUM>. A target source code origin <NUM> is provided from the computer system <NUM>.

<FIG> is a schematic illustration of a computer-readable medium <NUM> in one exemplary embodiment, capable of storing a computer program product <NUM>. The computer-readable medium <NUM> in the disclosed embodiment is a memory stick, such as a Universal Serial Bus (USB) stick. The USB stick <NUM> comprises a housing <NUM> having an interface, such as a connector <NUM>, and a memory chip <NUM>. In the disclosed embodiment, the memory chip <NUM> is a flash memory, i.e. a non-volatile data storage that can be electrically erased and re-programmed. The memory chip <NUM> stores the computer program product <NUM> which is programmed with computer program code (instructions) that when loaded into a processing device, such as the processing device <NUM> or <NUM> as described above, will perform a method <NUM> according to any or all of the embodiments disclosed above. The USB stick <NUM> is arranged to be connected to and read by a reading device for loading the instructions into the processing device. It should be noted that a computer-readable medium can also be other mediums such as compact discs, digital video discs, hard drives or other memory technologies commonly used. The computer program code (instructions) can also be downloaded from the computer-readable medium via a wireless interface to be loaded into the processing device.

References to a 'controller', 'computer', 'processor' etc. should be understood to encompass not only computers having different architectures such as single /multi-processor architectures and sequential (Von Neumann)/parallel architectures but also specialized circuits such as field-programmable gate arrays (FPGA), application specific circuits (ASIC), signal processing devices and other devices.

Claim 1:
A computer-implemented method (<NUM>) for determining an origin (<NUM>) of a target source code (<NUM>) for a computer program or a part thereof, the method involving:
searching a plurality of software archives (<NUM>) from different sources (<NUM>) in a global computer network (<NUM>) to find occurrences (<NUM>) of the target source code (<NUM>) among source code files in said software archives (<NUM>);
for every found occurrence of the target source code (<NUM>), collecting key information about the matching source code file (<NUM>; <NUM>; <NUM>; <NUM>);
from the key information collected for all matching source code files (<NUM>; <NUM>; <NUM>; <NUM>), building a frequency map (<NUM>) that contains, for each keyword found in the key information, a keyword count value being indicative of the number of times the keyword occurs in the key information;
applying a scoring scheme (<NUM>) to the matching source code files (<NUM>; <NUM>; <NUM>; <NUM>) based on the built frequency map (<NUM>);
determining a highest score (Vmax) among the matching source code files (<NUM>; <NUM>; <NUM>; <NUM>) after the scoring scheme (<NUM>) has been applied;
determining the origin (<NUM>) of the target source code (<NUM>) as the matching source code file having the highest score (Vmax); and
generating a control signal to prevent execution of the computer program if the validity of the author or organization behind the origin of the target code is not credible,
wherein the key information about each matching source code file (<NUM>; <NUM>; <NUM>; <NUM>) is collected as one or more keywords from a plurality of attributes of the matching source code file and/or the software archive (<NUM>) in which it was found and wherein the plurality of attributes includes at least two of the following: an author, a repository name, a filename and a resource location of the matching source code file (<NUM>; <NUM>; <NUM>; <NUM>) and/or the software archive (<NUM>) in which it was found.