Exemple #1
0
        //Adding check that Registry values exist
        //FEATURE_BROWSER_EMULATION- Defines in which document mode WebBrowser Control(Internal browser) should launch (IE 11 )
        //FEATURE_SCRIPTURL_MITIGATION - feature allows the href attribute of a objects to support the javascript prototcol.
        //                               It is by default disabled for WebBrowser Control and enabled for IE
        public static void CheckRegistryValues()
        {
            bool   osBitTypeIs64     = false;
            string appExeName        = string.Empty;
            string registryKeyPath   = string.Empty;
            string requiredValueName = string.Empty;
            object requiredValue     = string.Empty;

            try
            {
                //Find out the OS bit type
                osBitTypeIs64 = Environment.Is64BitOperatingSystem;

                //Get the App name
                appExeName = System.AppDomain.CurrentDomain.FriendlyName;

                //######################## FEATURE_BROWSER_EMULATION ###########################
                if (osBitTypeIs64)
                {
                    registryKeyPath = @"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION";
                }
                else
                {
                    registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION";
                }
                requiredValueName = appExeName;
                requiredValue     = string.Empty;
                object installedIEVersion =
                    RegistryFunctions.GetRegistryValue(eRegistryRoot.HKEY_LOCAL_MACHINE, @"Software\Microsoft\Internet Explorer", "svcUpdateVersion");
                if (installedIEVersion != null)
                {
                    if (installedIEVersion != null)
                    {
                        requiredValue = (installedIEVersion.ToString().Split(new char[] { '.' }))[0] + "000";
                    }
                }
                if (requiredValue.ToString() == string.Empty || requiredValue.ToString() == "000")
                {
                    requiredValue = "11000"; //defualt value
                }
                //write registry key to the User level if failed to write to Local Machine level

                if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_LOCAL_MACHINE, registryKeyPath,
                                                               requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true))
                {
                    //Try User Level
                    registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION";
                    if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_CURRENT_USER, registryKeyPath,
                                                                   requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true))
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Failed to add the required registry key 'FEATURE_BROWSER_EMULATION' value to both Local Machine and User level");
                    }
                }
                //End

                //######################## FEATURE_SCRIPTURL_MITIGATION ###########################
                if (osBitTypeIs64)
                {
                    registryKeyPath = @"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_SCRIPTURL_MITIGATION";
                }
                else
                {
                    registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_SCRIPTURL_MITIGATION";
                }
                requiredValueName = appExeName;
                requiredValue     = 1;
                //write registry key to the User level if failed to write to Local Machine level
                if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_LOCAL_MACHINE, registryKeyPath,
                                                               requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true))
                {
                    //Try User Level
                    registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_SCRIPTURL_MITIGATION";
                    if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_CURRENT_USER, registryKeyPath,
                                                                   requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true))
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Failed to add the required registry key 'FEATURE_SCRIPTURL_MITIGATION' value to both Local Machine and User level");
                    }
                }
                //End
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to complete the registry values check", ex);
                Reporter.ToUser(eUserMsgKey.RegistryValuesCheckFailed);
            }
        }
Exemple #2
0
        public void SetDriverConfiguration()
        {
            Boolean bValue;

            if (DriverConfiguration == null)
            {
                return;
            }
            if (ProjEnvironment == null)
            {
                ProjEnvironment = new Environments.ProjEnvironment();//to avoid value expertion exception
            }
            if (BusinessFlow == null)
            {
                BusinessFlow = new GingerCore.BusinessFlow();//to avoid value expertion exception
            }
            if (AgentType == eAgentType.Service)
            {
                SetServiceConfiguration();
            }
            else
            {
                DriverClass = RepositoryItemHelper.RepositoryItemFactory.GetDriverType(this);

                SetDriverMissingParams(DriverClass);

                foreach (DriverConfigParam DCP in DriverConfiguration)
                {
                    //process Value expression in case used
                    ValueExpression VE = new ValueExpression(ProjEnvironment, BusinessFlow, DSList);
                    VE.Value = DCP.Value;
                    string value = VE.ValueCalculated;

                    //TODO: check if Convert.To is better option
                    //TODO: hanlde other feilds type
                    PropertyInfo tp = Driver.GetType().GetProperty(DCP.Parameter);
                    if (tp != null)
                    {
                        string tpName = tp.PropertyType.Name;
                        switch (tpName)
                        {
                        case "String":
                            Driver.GetType().GetProperty(DCP.Parameter).SetValue(Driver, value);
                            break;

                        case "Boolean":
                            try
                            {
                                bValue = Convert.ToBoolean(value);
                            }
                            catch (Exception)
                            {
                                bValue = true;
                            }
                            Driver.GetType().GetProperty(DCP.Parameter).SetValue(Driver, bValue);
                            break;

                        case "Int32":
                            int i = int.Parse(value);
                            Driver.GetType().GetProperty(DCP.Parameter).SetValue(Driver, i);
                            break;

                        case "eType":
                            //TODO: Handle enums later...
                            throw new Exception("Driver Config - Enum not supported yet");

                        default:
                            Reporter.ToUser(eUserMsgKey.SetDriverConfigTypeNotHandled, DCP.GetType().ToString());
                            break;
                        }
                    }
                    else
                    {
                        // TODO: show message to user to remove param - old
                    }
                }

                Driver.AdvanceDriverConfigurations = this.AdvanceAgentConfigurations;
            }
        }