コード例 #1
0
 public static void RemoveIllegalComponents(GameObject[] targets, WhiteListConfiguration config, bool retry = true)
 {
     ConfigureWhiteList(config);
     foreach (GameObject target in targets)
     {
         ValidationUtils.RemoveIllegalComponents(target, ValidationUtils.WhitelistedTypes("world" + config.ToString(), ComponentTypeWhiteList), retry, true);
     }
 }
コード例 #2
0
        public static void ScanGameObject(GameObject target, WhiteListConfiguration config)
        {
            if (WasScanned(target))
            {
                return;
            }

            ConfigureWhiteList(config);
            HashSet <Type> whitelist = ValidationUtils.WhitelistedTypes("world" + config, ComponentTypeWhiteList);

            ValidationUtils.RemoveIllegalComponents(target, whitelist);
            SecurityScan(target);
            AddScanned(target);

            // Must be called after AddScanned to avoid infinite recursion.
            ScanDropdownTemplates(target, config);
        }
コード例 #3
0
        public static void RemoveIllegalComponents(List <GameObject> targets, WhiteListConfiguration config, bool retry = true, HashSet <Type> tagWhitelistedTypes = null)
        {
            ConfigureWhiteList(config);

            HashSet <Type> whitelist = ValidationUtils.WhitelistedTypes($"world{config}", ComponentTypeWhiteList);

            // combine whitelist types from world tags with cached whitelist
            if (tagWhitelistedTypes != null)
            {
                tagWhitelistedTypes.UnionWith(whitelist);
            }

            foreach (GameObject target in targets)
            {
                ValidationUtils.RemoveIllegalComponents(target, (tagWhitelistedTypes == null) ? whitelist : tagWhitelistedTypes, retry, true, true);
                SecurityScan(target);
                AddScanned(target);
            }
        }
コード例 #4
0
        private static void ScanDropdownTemplates(GameObject target, WhiteListConfiguration config)
        {
            Dropdown[] dropdowns = target.GetComponentsInChildren <Dropdown>(true);
            foreach (Dropdown dropdown in dropdowns)
            {
                if (dropdown == null)
                {
                    continue;
                }

                RectTransform dropdownTemplate = dropdown.template;
                if (dropdownTemplate == null)
                {
                    continue;
                }

                ScanGameObject(dropdownTemplate.transform.root.gameObject, config);
            }

            #if TextMeshPro
            TMP_Dropdown[] tmpDropdowns = target.GetComponentsInChildren <TMP_Dropdown>(true);
            foreach (TMP_Dropdown textMeshProDropdown in tmpDropdowns)
            {
                if (textMeshProDropdown == null)
                {
                    continue;
                }

                RectTransform dropdownTemplate = textMeshProDropdown.template;
                if (dropdownTemplate == null)
                {
                    continue;
                }

                ScanGameObject(dropdownTemplate.transform.root.gameObject, config);
            }
            #endif
        }
コード例 #5
0
        internal static WhiteListForecastWorker GetWhiteListForecastWorker()
        {
            IConfigurationSource   configurationSource    = GetConfigurationSource();
            WhiteListConfiguration whiteListConfiguration = configurationSource.GetWindowsAzureHostedServiceWhiteListConfiguration();

            if (whiteListConfiguration != null)
            {
                SubscriptionConfiguration[] subscriptionConfigurations = configurationSource.GetAllWindowsAzureSubscriptionConfigurations();
                ISubscription[]             subscriptions = new ISubscription[subscriptionConfigurations.Length];
                for (int i = 0; i < subscriptionConfigurations.Length; i++)
                {
                    subscriptions[i] = subscriptionConfigurations[i].Convert();
                }

                if (whiteListConfiguration.IncludeDeploymentCreateServices)
                {
                    foreach (DeploymentCreateConfiguration deploymentCreateConfiguration in configurationSource.GetWindowsAzureDeploymentCreateConfigurations())
                    {
                        bool alreadyIncluded = false;
                        foreach (WhiteListService configuredWhiteListService in whiteListConfiguration.Services)
                        {
                            if (configuredWhiteListService.Name == deploymentCreateConfiguration.ServiceName)
                            {
                                alreadyIncluded = true;
                            }
                        }

                        if (!alreadyIncluded)
                        {
                            WhiteListService whiteListService = new WhiteListService {
                                Name = deploymentCreateConfiguration.ServiceName
                            };
                            whiteListConfiguration.Services.Add(whiteListService);
                        }
                    }
                }

                if (whiteListConfiguration.IncludeDeploymentDeleteServices)
                {
                    foreach (DeploymentDeleteConfiguration deploymentDeleteConfiguration in configurationSource.GetWindowsAzureDeploymentDeleteConfigurations())
                    {
                        bool alreadyIncluded = false;
                        foreach (WhiteListService configuredWhiteListService in whiteListConfiguration.Services)
                        {
                            if (configuredWhiteListService.Name == deploymentDeleteConfiguration.ServiceName)
                            {
                                alreadyIncluded = true;
                            }
                        }

                        if (!alreadyIncluded)
                        {
                            WhiteListService whiteListService = new WhiteListService {
                                Name = deploymentDeleteConfiguration.ServiceName
                            };
                            whiteListConfiguration.Services.Add(whiteListService);
                        }
                    }
                }

                if (whiteListConfiguration.IncludeHorizontalScaleServices)
                {
                    foreach (ScheduledHorizontalScaleConfiguration windowsAzureScheduledHorizontalScaleConfiguration in configurationSource.GetWindowsAzureScheduledHorizontalScaleConfigurations())
                    {
                        bool alreadyIncluded = false;
                        foreach (WhiteListService configuredWhiteListService in whiteListConfiguration.Services)
                        {
                            if (configuredWhiteListService.Name == windowsAzureScheduledHorizontalScaleConfiguration.ServiceName)
                            {
                                alreadyIncluded = true;
                            }
                        }

                        if (!alreadyIncluded)
                        {
                            WhiteListService whiteListService = new WhiteListService {
                                Name = windowsAzureScheduledHorizontalScaleConfiguration.ServiceName
                            };
                            whiteListConfiguration.Services.Add(whiteListService);
                        }
                    }
                }

                WhiteListForecastWorker whiteListForecastWorker = new WhiteListForecastWorker(
                    subscriptions,
                    new Deployment(),
                    new Operation(),
                    whiteListConfiguration.Services.ToArray(),
                    whiteListConfiguration.PollingIntervalInMinutes);
                return(whiteListForecastWorker);
            }

            return(null);
        }