Object EnvironmentVariableFilter

  • All Implemented Interfaces:

    
    public class EnvironmentVariableFilter
    
                        

    An object providing functionality to filter environments that are passed to newly created processes.

    For many tasks, ORT spawns new processes using the ProcessCapture class. When creating a new process, the child process by default inherits all environment variables from the parent. This could impose a security risk, for instance if logic in build scripts could theoretically access sensitive information stored in environment variables, such as database or service credentials.

    To reduce this risk, this object filters the environment variables passed to child processes based on the following criteria:

    • Substrings for variable names can be defined to determine variables with sensitive information. The object provides some default strings to match variable names like "PASS", "USER", "TOKEN", etc.

    • There is an allow list to include variables even if they contain one of these substrings.

    So in order to determine whether a specific variable "E" can be passed to a child process, this filter applies the following steps:

    • If E is contained in the allow list, it is included.

    • Otherwise, E is included if and only if its name does not contain one of the exclusion substrings (ignoring case).

    TODO: Find an alternative mechanism to initialize this object from the ORT configuration (maybe using dependency injection) which does not require this object to be public.