Advanced injection rule engine
11188352 · 2021-11-30
Assignee
Inventors
Cpc classification
G06F9/45504
PHYSICS
G06F9/44521
PHYSICS
International classification
G06F9/455
PHYSICS
Abstract
Systems and techniques are described for controlling injection of a library into a process. Specifically, some embodiments provide an Advanced Injection Rule Engine (AIRE), which uses a set of rules to selectively inject a library, e.g., a dynamic-link library (DLL), into a process. Some embodiments implement a Domain Specific Language (DSL), called AIRE Script, to define the injection rules that are used by the AIRE at runtime.
Claims
1. A method for controlling injection of a library into a process executing on a computer, the method comprising: creating a set of rules to control injection of the library, wherein each rule is specified in a domain specific language having a syntax comprising an action statement and a condition statement, wherein the action statement includes a first keyword associated with activation or a second keyword associated with deactivation, and wherein the condition statement specifies a logical function that is defined over one or more properties of the process; and applying, by an injection rule engine (IRE) executing on the computer, the set of rules to the process executing on the computer, wherein said applying comprises: selecting, by the IRE, a rule from the set of rules, evaluating, by the IRE, a condition specified in the selected rule, wherein the condition is defined over a set of properties associated with the process, wherein the set of properties includes an executable image name of the process, and in response to the condition evaluating as true, performing, by the IRE, an injection action specified in the rule on the process.
2. The method of claim 1, wherein rules are selected from the set of rules in a predetermined order.
3. The method of claim 2, wherein in response to the condition evaluating as false, selecting a next rule from the set of rules to apply to the process.
4. The method of claim 1, wherein performing the injection action comprises injecting the library into the process.
5. The method of claim 1, wherein performing the injection action comprises (1) not injecting the library into the process, and (2) not applying any additional rules in the set of rules to the process.
6. The method of claim 1, wherein the set of properties includes a filesystem path of the executable image of the process.
7. The method of claim 1, wherein the set of properties includes a version of the executable image of the process.
8. The method of claim 1, wherein the set of properties includes an indicator that specifies whether a particular library is loaded within the process.
9. The method of claim 1, wherein the set of properties includes command line arguments that were provided when the process was executed.
10. The method of claim 1, wherein the set of properties includes an environment variable of the process.
11. The method of claim 1, wherein the set of properties includes a processor architecture of the executable image of the process.
12. The method of claim 1, wherein the set of properties includes a user identifier associated with the process.
13. The method of claim 1, wherein the library is an instrumentation library which, when injected into the process, provides visibility into processor and memory usage of the process.
14. A non-transitory computer-readable storage medium storing instructions that, when executed by a computer, cause the computer to: create a set of rules to control injection of the library, wherein each rule is specified in a domain specific language having a syntax comprising an action statement and a condition statement, wherein the action statement includes a first keyword associated with activation or a second keyword associated with deactivation, and wherein the condition statement specifies a logical function that is defined over one or more properties of the process; and apply, by an injection rule engine (IRE) executing on the computer, the set of rules to a process executing on the computer, wherein said applying comprises: selecting, by the IRE, a rule from the set of rules, evaluating, by the IRE, a condition specified in the selected rule, wherein the condition is defined over a set of properties associated with the process, wherein the set of properties includes an executable image name of the process, and in response to the condition evaluating as true, performing, by the IRE, an injection action specified in the rule on the process.
15. The non-transitory computer-readable storage medium of claim 14, wherein rules are selected from the set of rules in a predetermined order.
16. The non-transitory computer-readable storage medium of claim 15, wherein in response to the condition evaluating as false, selecting a next rule from the set of rules to apply to the process.
17. The non-transitory computer-readable storage medium of claim 14, wherein performing the injection action comprises injecting the library into the process.
18. The non-transitory computer-readable storage medium of claim 14, wherein performing the injection action comprises (1) not injecting the library into the process, and (2) not applying any additional rules in the set of rules to the process.
19. An apparatus, comprising: a processor; and a non-transitory computer-readable storage medium storing instructions that, when executed by the processor, cause the processor to: create a set of rules to control injection of the library, wherein each rule is specified in a domain specific language having a syntax comprising an action statement and a condition statement, wherein the action statement includes a first keyword associated with activation or a second keyword associated with deactivation, and wherein the condition statement specifies a logical function that is defined over one or more properties of the process; and apply, by an injection rule engine (IRE) executing on the processor, the set of rules to a process executing on the processor, wherein said applying comprises: selecting, by the IRE, a rule from the set of rules, evaluating, by the IRE, a condition specified in the selected rule, wherein the condition is defined over a set of properties associated with the process, wherein the set of properties includes an executable image name of the process, and in response to the condition evaluating as true, performing, by the IRE, an injection action specified in the rule on the process.
Description
BRIEF DESCRIPTION OF THE FIGURES
(1)
(2)
(3)
DETAILED DESCRIPTION
(4) The following description is presented to enable any person skilled in the art to make and use the invention, and is provided in the context of a particular application and its requirements. Various modifications to the disclosed embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other embodiments and applications without departing from the spirit and scope of the present invention. Thus, the present invention is not limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features disclosed herein. In this disclosure, when the term “and/or” is used with a list of entities, it refers to all possible combinations of the list of entities. For example, the phrase “X, Y, and/or Z” covers the following cases: (1) only X; (2) only Y; (3) only Z; (4) X and Y; (5) X and Z; (6) Y and Z; and (7) X, Y, and Z. Additionally, in this disclosure, the term “based on” means “based solely or partially on.”
(5) According to one definition, a computer is any device that is capable of performing computations. In some embodiments, a computer can include a processing mechanism that is capable of executing instructions stored on a storage medium. Examples of computers include, but are not limited to, handheld computers, laptop computers, desktop computers, distributed computers, printers, appliances, etc.
(6) According to one definition, a data communication network (or “network” for short) is an interconnection of one or more devices that is capable of delivering information from one computer to another computer. Examples of networks include, but are not limited to, wireless and wired networks, local area networks (LANs), metropolitan area networks (MANs), wide area networks (WANs), private networks, public networks, intranets, internets, etc. Data communication networks often include a variety of network devices for sending, receiving, directing, and optimizing network data traffic.
(7)
(8) Apparatus 102 can also include switching logic 116 and set of network interfaces 118. Set of network interfaces 118 can be used to transmit data to and/or receive data from other communication devices. Switching logic 116 can forward network traffic received on one or more network interfaces in accordance with switching/forwarding/routing information stored in apparatus 102. Specifically, switching logic 116 can be configured by processor 104 in accordance with one or more methods that are implicitly or explicitly described in this disclosure.
(9)
(10) The techniques and systems described in this disclosure can generally be used with any injection method for injecting library 160 into process 154. Some techniques for injecting library 160 into process 154 are described in (1) pending U.S. patent application Ser. No. 15/347,496, entitled “Target process injection prior to execution of marker libraries,” and (2) U.S. Pat. No. 9,465,717, entitled “Native code profiler framework.” The contents of U.S. patent application Ser. No. 15/347,496 and U.S. Pat. No. 9,465,717 are herein incorporated by reference to provide non-limiting examples of techniques for injecting a library into a process.
(11) There have been numerous cases where customers could have benefited from a powerful and extensible framework to determine if a process should be injected with a library (e.g., an instrumentation library). AIRE provides such a framework. As one can imagine, various applications have differing properties that make the determination of injection unique. Sometimes users would like to make use of the image name, processor architecture, an environment variable, command line arguments, file properties such as company name, executing user, a library loaded, image path, etc. All of these and more can be specified in injection rules 158 by using a DSL, and are available for use within the AIRE framework. Moreover, the AIRE framework is extensible so that it can allow us to increase the number of available properties from which rules can be created. Specifically, a user can define the rules by using a DSL that includes constructs for specifying the conditions and the actions that are used by AIRE 156 at runtime to control injection of library 160 into process 154. An example of a DSL is shown below in reference to
(12)
(13) In some embodiments, rules can be selected from the set of rules in a predetermined order. For example, if the rules are stored in a file, then the rules can be selected in the order in which they appear in the file. In another example, if each rule is associated with a priority or an index, then the priority or index can be used to decide the order in which the rules are selected by the AIRE.
(14) The action specified in a rule can instruct the AIRE to inject the library into the process. On the other hand, the action specified in a rule can instruct the AIRE to (1) not inject the library into the process, and (2) not apply any additional rules in the set of rules to the process. For example, suppose injection rules 158 in
(15) In some embodiments, the set of properties that can be used to define the condition in a rule can include one or more of (1) a name of an executable image of the process, (2) a filesystem path of the executable image of the process, (3) a processor architecture of the executable image of the process, (4) a version of the executable image of the process, (5) an indicator that specifies whether a particular library is loaded within the process, (6) a user identifier associated with the process, (7) an environment variable of the process, or (8) information about command line arguments that were provided when the process was executed. The following table summarizes a set of properties and classes that can be used to define a condition in an injection rule. The following table is for illustration purposes only, and is not intended to limit the scope of this disclosure. Because the AIRE framework is extensible, more properties can be added to this list.
(16) TABLE-US-00001 Object Description Image.Name The name of the primary module or binary of the currently running process. Image.Path The path of the primary module or binary of the currently running process. Image.Architecture The processor architecture of the image and therefore of the currently running process. Image.GetVersionInfoString(String Returns the value of the specified version name) information property as a string. Image.IsLibraryLoaded(String Returns a Boolean value indicating if the libraryName) specified library is loaded within the currently running process. Process.User Returns the user account as a String associated with the currently running process. Process.Environment[String Returns the string value of the specified name] environment variable as it exists within the currently running process. Process.CommandLine[int Returns the string value of the specified index] command line argument. Process.CommandLine.Length Returns the number of arguments specified in the command line of the currently running process. Process.CommandLine.Contains Returns a Boolean value indicating if the (String) specified argument was specified. Process.CommandLine.Contains Returns a Boolean value indicating if the Sequence(String[ ] specified sequence of arguments is specified in sequence) the command line. Process.CommandLine.Get Returns the value of the argument at the RelativeFromValue(String specified offset from the found location of the start, int offset) start string. Process.CommandLine.Get Returns the value of the argument at the RelativeFromSequence(String[ ] specified offset from the found location of the sequence, int offset) specified sequence. String.Compare(String Performs a case sensitive comparison and string1, String string2) returns a numeric value indicating the comparison. Zero indicates that the strings are the same. String.CompareNoCase(String Performs a case insensitive comparison and string1, String string2) returns a numeric value indicating the comparison. Zero indicates that the strings are the same. String.Concat(String Concatenates the two specified strings and string1, String string2) returns the result. String.IndexOf(String Returns the zero based index of the search string source, String searchString) within the source string. −1 indicates that the search string was not found. String.Length(String str) Returns the length of the specified string. String.BeginsWith(String Returns a Boolean value indicating if the source source, String comperand) string begins with the comperand. Case sensitive. String.BeginsWithNoCase(String Returns a Boolean value indicating if the source source, String string begins with the comperand. Case comperand) insensitive. String.EndsWith(String Returns a Boolean value indicating if the source source, String comperand) string ends with the comperand. Case sensitive. String.EndsWithNoCase(String Returns a Boolean value indicating if the source source, String string ends with the comperand. Case comperand) insensitive. String.SubString(String Returns a substring. source, int startIndex, int length)
(17)
(18) In
(19) In
(20) An advantage of embodiments described herein is that a company's products, customers, and support will now be able to finely tune the injection of a library into a process. AIRE allows for only the necessary processes to be injected. Also, if a particular profiler library is incompatible with a specific application or a class of applications, then AIRE provides the control that would be required in such situations to disable injection for just the offending application while still allowing injection for other applications to continue.
(21) The data structures and code described in this disclosure can be partially or fully stored on a non-transitory computer-readable storage medium and/or a hardware module and/or hardware apparatus. A non-transitory computer-readable storage medium includes all computer-readable storage mediums with the sole exception of a propagating electromagnetic wave or signal. Specifically, a non-transitory computer-readable storage medium includes, but is not limited to, volatile memory, non-volatile memory, magnetic and optical storage devices such as disk drives, magnetic tape, CDs (compact discs), DVDs (digital versatile discs or digital video discs), or other media, now known or later developed, that are capable of storing code and/or data. Hardware modules or apparatuses described in this disclosure include, but are not limited to, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), dedicated or shared processors, and/or other hardware modules or apparatuses now known or later developed.
(22) The methods and processes described in this disclosure can be partially or fully embodied as code and/or data stored in a non-transitory computer-readable storage medium or device, so that when a computer system reads and executes the code and/or data, the computer system performs the associated methods and processes. The methods and processes can also be partially or fully embodied in hardware modules or apparatuses. Note that the methods and processes can be embodied using a combination of code, data, and hardware modules or apparatuses.
(23) The foregoing descriptions of embodiments of the present invention have been presented only for purposes of illustration and description. They are not intended to be exhaustive or to limit the present invention to the forms disclosed. Accordingly, many modifications and variations will be apparent to practitioners skilled in the art. Additionally, the above disclosure is not intended to limit the present invention. The scope of the present invention is defined by the appended claims.