public bool CheckThreatLevel(string SessionID, ulong RegionHandle, string function, ThreatLevel defaultThreatLevel)
        {
            GridRegistrationURLs urls = m_genericsConnector.GetGeneric <GridRegistrationURLs>(UUID.Zero,
                                                                                              "GridRegistrationUrls", RegionHandle.ToString(), new GridRegistrationURLs());

            if (urls != null)
            {
                //Past time for it to expire
                if (urls.Expiration < DateTime.Now)
                {
                    RemoveUrlsForClient(SessionID, RegionHandle);
                    return(false);
                }
                //First find the threat level that this setting has to have do be able to run
                ThreatLevel functionThreatLevel = PermissionSet.FindThreatLevelForFunction(function, defaultThreatLevel);
                //Now find the permission for that threat level
                //else, check it against the threat level that the region has
                GridRegion region = FindRegion(RegionHandle);
                if (region == null)
                {
                    return(false);
                }
                string      rThreat           = region.GenericMap["ThreatLevel"].AsString();
                ThreatLevel regionThreatLevel = m_defaultRegionThreatLevel;
                if (rThreat != "")
                {
                    regionThreatLevel = (ThreatLevel)Enum.Parse(typeof(ThreatLevel), rThreat);
                }
                //Return whether the region threat level is higher than the function threat level
                return(functionThreatLevel <= regionThreatLevel);
            }
            return(false);
        }
Example #2
0
        public ThreatLevelDefinition GetDefinition(ThreatLevel level)
        {
            switch (level)
            {
            case ThreatLevel.None:
                return(m_threatLevelNone);

            case ThreatLevel.Nuisance:
                return(m_threatLevelNuisance);

            case ThreatLevel.VeryLow:
                return(m_threatLevelVeryLow);

            case ThreatLevel.Low:
                return(m_threatLevelLow);

            case ThreatLevel.Moderate:
                return(m_threatLevelModerate);

            case ThreatLevel.High:
                return(m_threatLevelHigh);

            case ThreatLevel.VeryHigh:
                return(m_threatLevelVeryHigh);

            case ThreatLevel.Severe:
                return(m_threatLevelSevere);

            case ThreatLevel.NoAccess:
                return(m_threatLevelNoAccess);
            }
            return(null);
        }
		public ThreatLevel GetThreatLevel()
		{
			if(m_MaxThreatLevel != 0)
				return m_MaxThreatLevel;
            string risk = m_config.GetString("FunctionThreatLevel", "VeryLow");
			switch (risk)
			{
				case "None":
					m_MaxThreatLevel = ThreatLevel.None;
					break;
				case "VeryLow":
					m_MaxThreatLevel = ThreatLevel.VeryLow;
					break;
				case "Low":
					m_MaxThreatLevel = ThreatLevel.Low;
					break;
				case "Moderate":
					m_MaxThreatLevel = ThreatLevel.Moderate;
					break;
				case "High":
					m_MaxThreatLevel = ThreatLevel.High;
					break;
				case "VeryHigh":
					m_MaxThreatLevel = ThreatLevel.VeryHigh;
					break;
				case "Severe":
					m_MaxThreatLevel = ThreatLevel.Severe;
					break;
				default:
					break;
			}
            return m_MaxThreatLevel;
		}
        private ThreatLevel FindRegionThreatLevel(string SessionID)
        {
            ThreatLevel regionThreatLevel = m_defaultRegionThreatLevel;

            if (m_cachedThreatLevels.TryGetValue(SessionID, out regionThreatLevel))
            {
                return(regionThreatLevel);
            }
            regionThreatLevel = m_defaultRegionThreatLevel;
            ulong handle;

            if (ulong.TryParse(SessionID, out handle))
            {
                int x;
                int y;
                Util.UlongToInts(handle, out x, out y);
                GridRegion region = m_registry.RequestModuleInterface <IGridService> ().GetRegionByPosition(null, x, y);
                if (region == null)
                {
                    regionThreatLevel = ThreatLevel.None;
                }
                else
                {
                    string rThreat = region.GenericMap["ThreatLevel"].AsString();
                    if (rThreat != "")
                    {
                        regionThreatLevel = (ThreatLevel)Enum.Parse(typeof(ThreatLevel), rThreat);
                    }
                }
            }
            m_cachedThreatLevels[SessionID] = regionThreatLevel;
            return(regionThreatLevel);
        }
Example #5
0
        public static bool VerifyPassphrase(OpCore core, ThreatLevel threat)
        {
            //crit revise
            if (threat != ThreatLevel.High)
            {
                return(true);
            }

            bool trying = true;

            while (trying)
            {
                GetTextDialog form = new GetTextDialog(core, core.User.GetTitle(), "Enter Passphrase", "");

                form.StartPosition = FormStartPosition.CenterScreen;
                form.ResultBox.UseSystemPasswordChar = true;

                if (form.ShowDialog() != DialogResult.OK)
                {
                    return(false);
                }

                byte[] key = Utilities.GetPasswordKey(form.ResultBox.Text, core.User.PasswordSalt);

                if (Utilities.MemCompare(core.User.PasswordKey, key))
                {
                    return(true);
                }

                MessageBox.Show("Wrong passphrase", "DeOps");
            }

            return(false);
        }
        public bool CheckThreatLevel(string SessionID, string function, ThreatLevel defaultThreatLevel)
        {
            if (!m_useRegistrationService)
            {
                return(true);
            }

            GridRegistrationURLs urls = m_genericsConnector.GetGeneric <GridRegistrationURLs>(UUID.Zero,
                                                                                              "GridRegistrationUrls", SessionID);

            if (urls != null)
            {
                //Past time for it to expire
                if (m_useSessionTime && urls.Expiration < DateTime.UtcNow)
                {
                    MainConsole.Instance.Warn("[GridRegService]: URLs expired for " + SessionID);
                    RemoveUrlsForClient(SessionID);
                    return(false);
                }
                //First find the threat level that this setting has to have do be able to run
                ThreatLevel functionThreatLevel = PermissionSet.FindThreatLevelForFunction(function, defaultThreatLevel);
                //Now find the permission for that threat level
                //else, check it against the threat level that the region has
                ThreatLevel regionThreatLevel = FindRegionThreatLevel(SessionID);
                //Return whether the region threat level is higher than the function threat level
                if (!(functionThreatLevel <= regionThreatLevel))
                {
                    MainConsole.Instance.Warn("[GridRegService]: checkThreatLevel (" + function + ") failed for " + SessionID + ", fperm " + functionThreatLevel + ", rperm " + regionThreatLevel + "!");
                }
                return(functionThreatLevel <= regionThreatLevel);
            }
            MainConsole.Instance.Warn("[GridRegService]: Could not find URLs for checkThreatLevel for " + SessionID + "!");
            return(false);
        }
Example #7
0
        private ThreatLevel FindRegionThreatLevel(ulong RegionHandle)
        {
            ThreatLevel regionThreatLevel = m_defaultRegionThreatLevel;

            if (m_cachedThreatLevels.TryGetValue(RegionHandle, out regionThreatLevel))
            {
                return(regionThreatLevel);
            }
            regionThreatLevel = m_defaultRegionThreatLevel;
            int x, y;

            Util.UlongToInts(RegionHandle, out x, out y);
            GridRegion region = m_registry.RequestModuleInterface <IGridService>().GetRegionByPosition(UUID.Zero, x, y);

            if (region == null)
            {
                regionThreatLevel = ThreatLevel.None;
            }
            else
            {
                string rThreat = region.GenericMap["ThreatLevel"].AsString();
                if (rThreat != "")
                {
                    regionThreatLevel = (ThreatLevel)Enum.Parse(typeof(ThreatLevel), rThreat);
                }
            }
            m_cachedThreatLevels[RegionHandle] = regionThreatLevel;
            return(regionThreatLevel);
        }
Example #8
0
        private void MapTopRiskByScore(List <RiskEntity> riskEntities, Dashboard dashboard)
        {
            var highchart = new Highchart();
            var series    = new Series
            {
                Name = "Risks"
            };
            var risksByScoreDescending = riskEntities.OrderByDescending(r => r.FinalScore).ThenBy(r => Decrypt <string>(r.NameBytes)).ToList();

            for (var index = 0; index < risksByScoreDescending.Count; index++)
            {
                var riskEntity = risksByScoreDescending[index];
                var data       = new Data
                {
                    Id           = riskEntity.Id.ToString(),
                    Name         = $"{index + 1}. {Decrypt<string>(riskEntity.NameBytes)}", //include index so that duplicate names will be displayed
                    Value        = riskEntity.FinalScore.GetValueOrDefault(),
                    Color        = ThreatLevel.LookupByValue(riskEntity.FinalScore).Color,
                    SeverityName = ThreatLevel.LookupByValue(riskEntity.FinalScore).Name
                };
                series.Data.Add(data);
            }
            highchart.Series.Add(series);

            dashboard.TopRiskByScore = highchart;
        }
Example #9
0
    public void RemoveCard(ThreatLevel threatLevel)
    {
        var array    = threatStack.ToArray();
        var newStack = new Queue <ThreatCard>();

        if (threatLevel == ThreatLevel.High)
        {
            array[0] = new ThreatCard(null, Card_basicBackground);
        }
        else
        {
            array[1] = new ThreatCard(null, Card_basicBackground);
        }

        newStack.Enqueue(array[0]);
        newStack.Enqueue(array[1]);
        threatStack = newStack;

        foreach (var item in threatStack)
        {
            Debug.Log(item);
        }

        imageUpdateUI();
    }
Example #10
0
 protected override void MapToModel(RiskEntity source, Risk destination)
 {
     destination.Id                           = source.Id.ToString();
     destination.EngagementId                 = source.EngagementId.ToString();
     destination.Phase                        = source.Phase?.Name ?? "Unknown";
     destination.PhaseId                      = source.PhaseId.ToString();
     destination.ResourceId                   = source.ResourceId;
     destination.GroupId                      = source.GroupId;
     destination.RemediationStatus            = MitigationStatus.LookupByValue(source.RemediationStatusId.GetValueOrDefault())?.Name;
     destination.RemediationStatusId          = source.RemediationStatusId.ToString();
     destination.Name                         = Decrypt <string>(source.NameBytes);
     destination.Description                  = Decrypt <string>(source.DescriptionBytes);
     destination.InherentRisk                 = source.InheritScore?.ToString("N1");
     destination.InherentSeverity             = ThreatLevel.LookupByValue(source.InheritScore).Name;
     destination.Likelihood                   = source.Likelihood?.ToString("N1");
     destination.LikelihoodSeverity           = ThreatLevel.LookupByValue(source.Likelihood).Name;
     destination.Recommendation               = Decrypt <string>(source.RecommendationBytes);
     destination.RemediationResource          = GetRemediationResource(source);
     destination.MitigationDate               = source.MitigatedDate?.ToString("M/d/yyyy");
     destination.TargetRemediationDate        = source.TargetRemediationDate?.ToString("M/d/yyyy");
     destination.AffectedSystemsCount         = source.AffectedSystems?.ToString();
     destination.PossibleAffectedSystemsCount = source.PossibleAffectedSystems?.ToString();
     destination.Effectiveness                = source.Effectiveness?.ToString("N1");
     destination.ControlEffectiveness         = source.ControlEffectiveness?.ToString("N1");
     destination.Impact                       = source.Impact?.ToString("N1");
     destination.ImpactSeverity               = ThreatLevel.LookupByValue(source.Impact).Name;
     destination.References                   = Decrypt <string>(source.ReferencesBytes);
     destination.RiskScore                    = source.FinalScore?.ToString("N1");
     destination.ScoreSeverity                = ThreatLevel.LookupByValue(source.FinalScore).Name;
 }
 public static ThreatLevel FindThreatLevelForFunction(string function, ThreatLevel requestedLevel)
 {
     if (PermittedFunctions.ContainsKey(function))
     {
         return PermittedFunctions[function];
     }
     return requestedLevel;
 }
 public override void FromOSD(OSDMap map)
 {
     Connection = new IWCConnection();
     Connection.FromOSD(map);
     ValidUntil  = map["ValidUntil"].AsDate();
     Active      = map["Active"].AsBoolean();
     ThreatLevel = (ThreatLevel)map["ThreatLevel"].AsInteger();
 }
Example #13
0
 public static ThreatLevel FindThreatLevelForFunction(string function, ThreatLevel requestedLevel)
 {
     if (PermittedFunctions.ContainsKey(function))
     {
         return(PermittedFunctions[function]);
     }
     return(requestedLevel);
 }
Example #14
0
    private void UpdateThreatLevelSlider()
    {
        ThreatLevel threatLevel = GetCurrentThreatLevel();

        threatSlider.value    = threatLevel.level + 1;
        threatLevelFill.color = threatLevel.color;
        threatLevelText.text  = THREAT_TEXT + threatLevel.threatLevelName;
    }
Example #15
0
        public bool UserVerifyPass(ThreatLevel threatLevel)
        {
            if (VerifyPass != null)
            {
                return(VerifyPass(threatLevel));
            }

            return(false);
        }
Example #16
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     slider = GetComponent <Slider>();
     threat = slider.value;
 }
Example #17
0
        public ThreatLevelDefinition GetThreatLevel()
        {
            if (m_MaxThreatLevel != 0)
            {
                return(GetDefinition(m_MaxThreatLevel));
            }
            string risk = m_config.GetString("FunctionThreatLevel", "VeryLow");

            switch (risk)
            {
            case "NoAccess":
                m_MaxThreatLevel = ThreatLevel.NoAccess;
                break;

            case "None":
                m_MaxThreatLevel = ThreatLevel.None;
                break;

            case "Nuisance":
                m_MaxThreatLevel = ThreatLevel.Nuisance;
                break;

            case "VeryLow":
                m_MaxThreatLevel = ThreatLevel.VeryLow;
                break;

            case "Low":
                m_MaxThreatLevel = ThreatLevel.Low;
                break;

            case "Moderate":
                m_MaxThreatLevel = ThreatLevel.Moderate;
                break;

            case "High":
                m_MaxThreatLevel = ThreatLevel.High;
                break;

            case "VeryHigh":
                m_MaxThreatLevel = ThreatLevel.VeryHigh;
                break;

            case "Severe":
                m_MaxThreatLevel = ThreatLevel.Severe;
                break;

            default:
                break;
            }
            return(GetDefinition(m_MaxThreatLevel));
        }
 public void Initialize(IConfigSource source, IRegistryCore registry)
 {
     m_source = source;
     m_config = source.Configs["AuroraInterWorldConnectors"];
     if (m_config != null)
     {
         m_Enabled = m_config.GetBoolean("Enabled", false);
         m_allowUntrustedConnections        = m_config.GetBoolean("AllowUntrustedConnections", m_allowUntrustedConnections);
         m_untrustedConnectionsDefaultTrust = (ThreatLevel)Enum.Parse(typeof(ThreatLevel), m_config.GetString("UntrustedConnectionsDefaultTrust", m_untrustedConnectionsDefaultTrust.ToString()));
         registry.RegisterModuleInterface <ICommunicationService>(this);
         registry.RegisterModuleInterface <InterWorldCommunications>(this);
         m_registry = registry;
     }
 }
Example #19
0
        private void MapVulnerabilities(List <VulnerabilityEntity> vulnerabilityEntities, Dashboard dashboard)
        {
            var highchart = new Highchart();

            // TODO: Make more efficient? Either filter by importId on the repository level or use Queryable clauses instead of this tedious mapping
            List <VulnerabilityEntity> vulnerabilityEntitiesToKeep = new List <VulnerabilityEntity>();

            foreach (var vulnerabilityEntity in vulnerabilityEntities)
            {
                var vulnerability = _vulnerabilityMapper.Map(vulnerabilityEntity);

                List <HostVulnerabilityEntity> hostVulnerabilitiesToKeep = new List <HostVulnerabilityEntity>();
                foreach (var hostVulnerability in vulnerabilityEntity.HostVulnerabilities)
                {
                    hostVulnerabilitiesToKeep.Add(hostVulnerability);
                }
                vulnerabilityEntity.HostVulnerabilities = hostVulnerabilitiesToKeep;
                vulnerabilityEntitiesToKeep.Add(vulnerabilityEntity);
            }

            var threatLevelGroups = vulnerabilityEntitiesToKeep
                                    .OrderBy(x => x.CvssScore)
                                    .GroupBy(x => ThreatLevel.LookupByValue(x.CvssScore));

            foreach (var threatLevelGroup in threatLevelGroups)
            {
                var threatLevel = new Series
                {
                    Name  = threatLevelGroup.Key.Name,
                    Color = threatLevelGroup.Key.Color
                };

                var categories = threatLevelGroup
                                 .OrderBy(v => v.VulnerabilityCategory)
                                 .GroupBy(v => v.VulnerabilityCategory)
                                 .Select(x => new Data
                {
                    Name  = x.Key,
                    Value = x.Count(),
                    Color = threatLevelGroup.Key.Color
                });

                threatLevel.Data.AddRange(categories);
                highchart.Series.Add(threatLevel);
            }

            dashboard.Vulnerabilities = highchart;
        }
Example #20
0
        private void MapRiskScoreByPhase(List <PhaseEntity> phaseEntities, Dashboard dashboard)
        {
            var highchart = new Highchart();
            var series    = new Series
            {
                Name = "Phases"
            };

            foreach (var phaseEntity in phaseEntities)
            {
                var data = new Data
                {
                    Name      = phaseEntity.Name,
                    Value     = phaseEntity.RiskScore ?? 0,
                    Drilldown = phaseEntity.Name,
                    Color     = ThreatLevel.LookupByValue(phaseEntity.RiskScore).Color
                };
                series.Data.Add(data);

                //Order By Asc so that the severity levels will be drawn from low to high (left to right)
                var riskSeverityPhaseGroups = phaseEntity.Risks.OrderBy(r => r.FinalScore).GroupBy(r => ThreatLevel.LookupByValue(r.FinalScore)).ToList();
                if (riskSeverityPhaseGroups.Any())
                {
                    var drilldownSeries = new Series
                    {
                        Name = phaseEntity.Name,
                        Id   = phaseEntity.Name
                    };

                    foreach (var riskSeverityPhaseGroup in riskSeverityPhaseGroups)
                    {
                        var drilldownData = new Data
                        {
                            Name  = riskSeverityPhaseGroup.Key.Name,
                            Value = riskSeverityPhaseGroup.Count(),
                            Color = riskSeverityPhaseGroup.Key.Color
                        };
                        drilldownSeries.Data.Add(drilldownData);
                    }
                    highchart.DrilldownSeries.Add(drilldownSeries);
                }
            }

            highchart.Series.Add(series);

            dashboard.RiskScoreByPhase = highchart;
        }
Example #21
0
        private void deduceThreat(SnakeType snake, FoodType food)
        {
            int yClose = (int)(snake.Vector.Y - food.Vector.Y);
            int xClose = (int)(snake.Vector.X - food.Vector.X);

            if ((Math.Abs(yClose) <= innerZone) || (Math.Abs(xClose) <= innerZone))
            {
                threat = ThreatLevel.high;
            }
            else if ((Math.Abs(yClose) <= outerZone) || (Math.Abs(xClose) <= outerZone))
            {
                threat = ThreatLevel.medium;
            }
            else if ((Math.Abs(yClose) > outerZone) || (Math.Abs(xClose) > outerZone))
            {
                threat = ThreatLevel.low;
            }
        }
Example #22
0
            public ThreatLevelDefinition(ThreatLevel threatLevel, UserSet userSet, ScriptProtectionModule module)
            {
                m_threatLevel            = threatLevel;
                m_userSet                = userSet;
                m_scriptProtectionModule = module;
                m_allowGroupPermissions  = m_scriptProtectionModule.m_config.GetBoolean(
                    "AllowGroupThreatPermissionCheck", m_allowGroupPermissions);

                string perm = m_scriptProtectionModule.m_config.GetString("Allow_" + m_threatLevel, "");

                if (perm != "")
                {
                    string[] ids = perm.Split(',');
                    m_allowedUsers = ids.Select(id =>
                    {
                        UUID uuid;
                        if (UUID.TryParse(id.Trim(), out uuid))
                        {
                            return(uuid);
                        }
                        else
                        {
                            return(UUID.Zero);
                        }
                    }).Where((id) => id != UUID.Zero).ToList();
                }
                perm = m_scriptProtectionModule.m_config.GetString("Allow_All", "");
                if (perm != "")
                {
                    string[] ids = perm.Split(',');
                    m_allowedUsers = ids.Select(id =>
                    {
                        UUID uuid;
                        if (UUID.TryParse(id.Trim(), out uuid))
                        {
                            return(uuid);
                        }
                        else
                        {
                            return(UUID.Zero);
                        }
                    }).Where((id) => id != UUID.Zero).ToList();
                }
            }
Example #23
0
        public void MapRiskGauge(EngagementEntity engagementEntity, Dashboard dashboard)
        {
            var highchart = new Highchart();
            var series    = new Series
            {
                Type      = "pie",
                Name      = "Severity",
                InnerSize = "70%"
            };

            dashboard.RiskScore = engagementEntity.RiskScore?.ToString("N1") ?? "N/A";

            Func <ThreatLevel, decimal?, List <Data> > buildData = (threatLevel, nextThreatLevelValue) =>
            {
                var dataSlices = new List <Data>();
                for (var slice = threatLevel.Value; slice < nextThreatLevelValue; slice += 0.1m)
                {
                    dataSlices.Add(new Data
                    {
                        Name  = 5 == slice ? ThreatLevel.LookupByValue(engagementEntity.RiskScore).Name : string.Empty,
                        Color = engagementEntity.RiskScore >= slice ? threatLevel.Color : "#eee",
                        Value = 0.1m
                    });
                }
                return(dataSlices);
            };

            series.Data.AddRange(buildData(ThreatLevel.VeryLow, ThreatLevel.Low.Value));
            series.Data.AddRange(buildData(ThreatLevel.Low, ThreatLevel.Moderate.Value));
            series.Data.AddRange(buildData(ThreatLevel.Moderate, ThreatLevel.High.Value));
            series.Data.AddRange(buildData(ThreatLevel.High, ThreatLevel.VeryHigh.Value));
            series.Data.AddRange(buildData(ThreatLevel.VeryHigh, 10m));
            highchart.Series.Add(series);

            dashboard.RiskGauge = highchart;
        }
Example #24
0
        private void MapMitigationSummaryRisksByPhase(List <PhaseEntity> phaseEntities, Dashboard dashboard)
        {
            var highcharts  = new Dictionary <int, Highchart>();
            var chartPhases = phaseEntities.ToList();

            // The first item should always be "All Phases" -- a complete list of Risks from all the Phases together.
            // Build up a list of RiskEntities
            var risksForAllPhases = chartPhases.SelectMany(cp => cp.Risks).ToList();

            // Create a new chartPhase for our "All Phases" chart
            var allPhasesEntity = new PhaseEntity();

            allPhasesEntity.Id   = 0;
            allPhasesEntity.Name = "All Phases";

            // Add the complete list of distinct RiskEntities to the new chartPhase
            allPhasesEntity.Risks = risksForAllPhases.Distinct().ToList();

            // Unshift the "All Phases" chartPhase onto the beginning of our array of ChartPhases
            chartPhases.Insert(0, allPhasesEntity);

            // Now we can create our array of Highcharts
            foreach (var chartPhase in chartPhases)
            {
                var highchart = new NamedHighchart();

                var risksByThreatLevel = chartPhase.Risks
                                         .OrderBy(x => x.FinalScore)
                                         .GroupBy(x => ThreatLevel.LookupByValue(x.FinalScore))
                                         .ToList();

                // Skip this risk entity if there are no vulns associated with it
                if (risksByThreatLevel.Count == 0)
                {
                    continue;
                }

                // Add each Severity bar in our three-bar columns (Moderate Severity, High Severity, Very High Severity)
                foreach (var threatLevelGroup in risksByThreatLevel)
                {
                    var series = new Series
                    {
                        Name  = threatLevelGroup.Key.Name + " Severity",
                        Color = threatLevelGroup.Key.Color
                    };

                    // Guard against the Remediation Status being null
                    var defaultStatusValue = MitigationStatus.NotMitigated.Value;

                    // Add the data for each Remediation Status (Not Mitigated, Mitigation in Progress, etcetera)
                    foreach (var status in MitigationStatus.List)
                    {
                        var data = new Data
                        {
                            Name  = status.Name,
                            Value = threatLevelGroup.Count(x => (x.RemediationStatusId ?? defaultStatusValue) == status.Value),
                            Color = threatLevelGroup.Key.Color
                        };

                        series.Data.Add(data);
                    }

                    highchart.Series.Add(series);
                }

                // Decrypt the risk name and assign it as the title of the Highchart
                highchart.Name = chartPhase.Name;
                highcharts.Add(chartPhase.Id, highchart);
            }

            dashboard.MitigationSummaryRisksByPhase = highcharts;
        }
		public void CheckThreatLevel(ThreatLevel level, string function, ISceneChildEntity m_host, string API)
        {
            GetDefinition(level).CheckThreatLevel (function, m_host, API);
        }
Example #26
0
        public void CheckThreatLevel(ThreatLevel level, string function)
        {
            if (!m_OSFunctionsEnabled)
                OSSLError(String.Format("{0} permission denied.  All OS functions are disabled.", function)); // throws

            if (!m_FunctionPerms.ContainsKey(function))
            {
                FunctionPerms perms = new FunctionPerms();
                m_FunctionPerms[function] = perms;

                string ownerPerm = m_ScriptEngine.Config.GetString("Allow_" + function, "");
                string creatorPerm = m_ScriptEngine.Config.GetString("Creators_" + function, "");
                if (ownerPerm == "" && creatorPerm == "")
                {
                    // Default behavior
                    perms.AllowedOwners = null;
                    perms.AllowedCreators = null;
                }
                else
                {
                    bool allowed;

                    if (bool.TryParse(ownerPerm, out allowed))
                    {
                        // Boolean given
                        if (allowed)
                        {
                            // Allow globally
                            perms.AllowedOwners.Add(UUID.Zero);
                        }
                    }
                    else
                    {
                        string[] ids = ownerPerm.Split(new char[] {','});
                        foreach (string id in ids)
                        {
                            string current = id.Trim();
                            UUID uuid;

                            if (UUID.TryParse(current, out uuid))
                            {
                                if (uuid != UUID.Zero)
                                    perms.AllowedOwners.Add(uuid);
                            }
                        }

                        ids = creatorPerm.Split(new char[] {','});
                        foreach (string id in ids)
                        {
                            string current = id.Trim();
                            UUID uuid;

                            if (UUID.TryParse(current, out uuid))
                            {
                                if (uuid != UUID.Zero)
                                    perms.AllowedCreators.Add(uuid);
                            }
                        }
                    }
                }
            }

            // If the list is null, then the value was true / undefined
            // Threat level governs permissions in this case
            //
            // If the list is non-null, then it is a list of UUIDs allowed
            // to use that particular function. False causes an empty
            // list and therefore means "no one"
            //
            // To allow use by anyone, the list contains UUID.Zero
            //
            if (m_FunctionPerms[function].AllowedOwners == null)
            {
                // Allow / disallow by threat level
                if (level > m_MaxThreatLevel)
                    OSSLError(
                        String.Format(
                            "{0} permission denied.  Allowed threat level is {1} but function threat level is {2}.",
                            function, m_MaxThreatLevel, level));
            }
            else
            {
                if (!m_FunctionPerms[function].AllowedOwners.Contains(UUID.Zero))
                {
                    // Not anyone. Do detailed checks
                    if (m_FunctionPerms[function].AllowedOwners.Contains(m_host.OwnerID))
                    {
                        // prim owner is in the list of allowed owners
                        return;
                    }

                    TaskInventoryItem ti = m_host.Inventory.GetInventoryItem(m_itemID);
                    if (ti == null)
                    {
                        OSSLError(
                            String.Format("{0} permission error. Can't find script in prim inventory.",
                            function));
                    }
                    if (!m_FunctionPerms[function].AllowedCreators.Contains(ti.CreatorID))
                        OSSLError(
                            String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.",
                            function));
                    if (ti.CreatorID != ti.OwnerID)
                    {
                        if ((ti.CurrentPermissions & (uint)PermissionMask.Modify) != 0)
                            OSSLError(
                                String.Format("{0} permission denied. Script permissions error.",
                                function));

                    }
                }
            }
        }
Example #27
0
        public void CheckThreatLevel(ThreatLevel level, string function)
        {
            if (!m_OSFunctionsEnabled)
                OSSLError(String.Format("{0} permission denied.  All OS functions are disabled.", function)); // throws

            if (!m_FunctionPerms.ContainsKey(function))
            {
                string perm = m_ScriptEngine.Config.GetString("Allow_" + function, "");
                if (perm == "")
                {
                    m_FunctionPerms[function] = null; // a null value is default
                }
                else
                {
                    bool allowed;

                    if (bool.TryParse(perm, out allowed))
                    {
                        // Boolean given
                        if (allowed)
                        {
                            m_FunctionPerms[function] = new List<UUID>();
                            m_FunctionPerms[function].Add(UUID.Zero);
                        }
                        else
                            m_FunctionPerms[function] = new List<UUID>(); // Empty list = none
                    }
                    else
                    {
                        m_FunctionPerms[function] = new List<UUID>();

                        string[] ids = perm.Split(new char[] {','});
                        foreach (string id in ids)
                        {
                            string current = id.Trim();
                            UUID uuid;

                            if (UUID.TryParse(current, out uuid))
                            {
                                if (uuid != UUID.Zero)
                                    m_FunctionPerms[function].Add(uuid);
                            }
                        }
                    }
                }
            }

            // If the list is null, then the value was true / undefined
            // Threat level governs permissions in this case
            //
            // If the list is non-null, then it is a list of UUIDs allowed
            // to use that particular function. False causes an empty
            // list and therefore means "no one"
            //
            // To allow use by anyone, the list contains UUID.Zero
            //
            if (m_FunctionPerms[function] == null) // No list = true
            {
                if (level > m_MaxThreatLevel)
                    OSSLError(
                        String.Format(
                            "{0} permission denied.  Allowed threat level is {1} but function threat level is {2}.",
                            function, m_MaxThreatLevel, level));
            }
            else
            {
                if (!m_FunctionPerms[function].Contains(UUID.Zero))
                {
                    if (!m_FunctionPerms[function].Contains(m_host.OwnerID))
                        OSSLError(
                            String.Format("{0} permission denied.  Prim owner is not in the list of users allowed to execute this function.",
                            function));
                }
            }
        }
 public ThreatLevelDefinition GetDefinition(ThreatLevel level)
 {
     switch (level)
     {
         case ThreatLevel.None:
             return m_threatLevelNone;
         case ThreatLevel.Nuisance:
             return m_threatLevelNuisance;
         case ThreatLevel.VeryLow:
             return m_threatLevelVeryLow;
         case ThreatLevel.Low:
             return m_threatLevelLow;
         case ThreatLevel.Moderate:
             return m_threatLevelModerate;
         case ThreatLevel.High:
             return m_threatLevelHigh;
         case ThreatLevel.VeryHigh:
             return m_threatLevelVeryHigh;
         case ThreatLevel.Severe:
             return m_threatLevelSevere;
         case ThreatLevel.NoAccess:
             return m_threatLevelNoAccess;
     }
     return null;
 }
        public bool CheckThreatLevel(string SessionID, string function, ThreatLevel defaultThreatLevel)
        {
            if (!m_useRegistrationService)
                return true;

            GridRegistrationURLs urls = m_genericsConnector.GetGeneric<GridRegistrationURLs>(UUID.Zero,
                "GridRegistrationUrls", SessionID);
            if (urls != null)
            {
                //Past time for it to expire
                if (m_useSessionTime && urls.Expiration < DateTime.UtcNow)
                {
                    MainConsole.Instance.Warn ("[GridRegService]: URLs expired for " + SessionID);
                    RemoveUrlsForClient(SessionID);
                    return false;
                }
                //First find the threat level that this setting has to have do be able to run
                ThreatLevel functionThreatLevel = PermissionSet.FindThreatLevelForFunction(function, defaultThreatLevel);
                //Now find the permission for that threat level
                //else, check it against the threat level that the region has
                ThreatLevel regionThreatLevel = FindRegionThreatLevel (SessionID);
                //Return whether the region threat level is higher than the function threat level
                if(!(functionThreatLevel <= regionThreatLevel))
                    MainConsole.Instance.Warn ("[GridRegService]: checkThreatLevel (" + function + ") failed for " + SessionID + ", fperm " + functionThreatLevel + ", rperm " + regionThreatLevel + "!");
                return functionThreatLevel <= regionThreatLevel;
            }
            MainConsole.Instance.Warn ("[GridRegService]: Could not find URLs for checkThreatLevel for " + SessionID + "!");
            return false;
        }
Example #30
0
File: OpCore.cs Project: swax/DeOps
        public bool UserVerifyPass(ThreatLevel threatLevel)
        {
            if (VerifyPass != null)
                return VerifyPass(threatLevel);

            return false;
        }
 public ThreatLevelDefinition GetThreatLevel()
 {
     if (m_MaxThreatLevel != 0)
         return GetDefinition(m_MaxThreatLevel);
     string risk = m_config.GetString("FunctionThreatLevel", "VeryLow");
     switch (risk)
     {
         case "NoAccess":
             m_MaxThreatLevel = ThreatLevel.NoAccess;
             break;
         case "None":
             m_MaxThreatLevel = ThreatLevel.None;
             break;
         case "Nuisance":
             m_MaxThreatLevel = ThreatLevel.Nuisance;
             break;
         case "VeryLow":
             m_MaxThreatLevel = ThreatLevel.VeryLow;
             break;
         case "Low":
             m_MaxThreatLevel = ThreatLevel.Low;
             break;
         case "Moderate":
             m_MaxThreatLevel = ThreatLevel.Moderate;
             break;
         case "High":
             m_MaxThreatLevel = ThreatLevel.High;
             break;
         case "VeryHigh":
             m_MaxThreatLevel = ThreatLevel.VeryHigh;
             break;
         case "Severe":
             m_MaxThreatLevel = ThreatLevel.Severe;
             break;
     }
     return GetDefinition(m_MaxThreatLevel);
 }
Example #32
0
        private void MapRiskByScore(List <RiskEntity> riskEntities, Dashboard dashboard)
        {
            var highchart = new Highchart();
            var series    = new Series
            {
                Type = "pie",
                Name = "Score"
            };
            var riskSeverityGroups = riskEntities.OrderBy(r => r.FinalScore).GroupBy(r => ThreatLevel.LookupByValue(r.FinalScore)).ToList();

            foreach (var riskSeverityGroup in riskSeverityGroups)
            {
                var data = new Data
                {
                    Name      = riskSeverityGroup.Key.Name,
                    Value     = riskSeverityGroup.Count(),
                    Color     = riskSeverityGroup.Key.Color,
                    Drilldown = riskSeverityGroup.Key.Name
                };
                series.Data.Add(data);

                var riskSeverityPhaseGroups = riskSeverityGroup.OrderBy(r => r.Phase?.DisplayOrder).GroupBy(r => r.Phase ?? new PhaseEntity {
                    Name = "Unknown"
                }).ToList();
                if (riskSeverityPhaseGroups.Any())
                {
                    var drilldownSeries = new Series
                    {
                        Name = riskSeverityGroup.Key.Name,
                        Id   = riskSeverityGroup.Key.Name
                    };

                    foreach (var riskSeverityPhaseGroup in riskSeverityPhaseGroups)
                    {
                        var drilldownData = new Data
                        {
                            Name  = riskSeverityPhaseGroup.Key.Name,
                            Value = riskSeverityPhaseGroup.Count()
                        };
                        drilldownSeries.Data.Add(drilldownData);
                    }
                    highchart.DrilldownSeries.Add(drilldownSeries);
                }
            }
            highchart.Series.Add(series);

            dashboard.RiskByScore = highchart;
        }
Example #33
0
        // Returns of the function is allowed. Throws a script exception if not allowed.
        public void CheckThreatLevel(ThreatLevel level, string function)
        {
            if (!m_OSFunctionsEnabled)
                OSSLError(String.Format("{0} permission denied.  All OS functions are disabled.", function)); // throws

            string reasonWhyNot = CheckThreatLevelTest(level, function);
            if (!String.IsNullOrEmpty(reasonWhyNot))
            {
                OSSLError(reasonWhyNot);
            }
        }
 public void Initialize(IConfigSource source, IRegistryCore registry)
 {
     m_source = source;
     m_config = source.Configs["AuroraInterWorldConnectors"];
     if (m_config != null)
     {
         m_Enabled = m_config.GetBoolean("Enabled", false);
         m_allowUntrustedConnections = m_config.GetBoolean("AllowUntrustedConnections", m_allowUntrustedConnections);
         m_untrustedConnectionsDefaultTrust = (ThreatLevel)Enum.Parse(typeof(ThreatLevel), m_config.GetString("UntrustedConnectionsDefaultTrust", m_untrustedConnectionsDefaultTrust.ToString()));
         registry.RegisterModuleInterface<InterWorldCommunications>(this);
         registry.StackModuleInterface<ICommunicationService> (this);
         m_registry = registry;
     }
 }
Example #35
0
        private void MapMitigationSummaryVulnsByRisk(List <RiskEntity> riskEntities, Dashboard dashboard)
        {
            var highcharts = new Dictionary <int, Highchart>();

            // The first item should always be "All Risks" -- a complete list of unique RiskVulns from all the risks together.
            // Build up a list of RiskVulns
            var allRiskVulns = new List <RiskVulnerabilityEntity>();

            foreach (var riskEntity in riskEntities)
            {
                allRiskVulns.AddRange(riskEntity.RiskVulnerabilities);
            }

            // Create a new RiskEntity for our "All Risks" chart
            var allRisksEntity = new RiskEntity();

            allRisksEntity.Id        = 0;
            allRisksEntity.NameBytes = Encrypt("All Risks");

            // Add the complete list of distinct RiskVulns to the new RiskEntity
            allRisksEntity.RiskVulnerabilities = allRiskVulns.ToList();

            // Unshift the "All Risks" RiskEntity onto the beginning of our array of risks
            riskEntities.Insert(0, allRisksEntity);

            // Now we can create our array of Highcharts
            foreach (var riskEntity in riskEntities)
            {
                var highchart = new NamedHighchart();

                var vulnerabilitiesByThreatLevel = riskEntity.RiskVulnerabilities
                                                   .Select(x => x.Vulnerability)
                                                   .OrderBy(x => x.CvssScore)
                                                   .GroupBy(x => ThreatLevel.LookupByValue(x.CvssScore))
                                                   .ToList();

                // Skip this risk entity if there are no vulns associated with it
                if (vulnerabilitiesByThreatLevel.Count == 0)
                {
                    continue;
                }

                // Add each Severity bar in our three-bar columns (Moderate Severity, High Severity, Very High Severity)
                foreach (var threatLevelGroup in vulnerabilitiesByThreatLevel)
                {
                    var series = new Series
                    {
                        Name  = threatLevelGroup.Key.Name + " Severity",
                        Color = threatLevelGroup.Key.Color
                    };

                    // Guard against the Remediation Status being null
                    var defaultStatusValue = MitigationStatus.NotMitigated.Value;

                    // Add the data for each Remediation Status (Not Mitigated, Mitigation in Progress, etcetera)
                    foreach (var status in MitigationStatus.List)
                    {
                        var data = new Data
                        {
                            Name  = status.Name,
                            Value = threatLevelGroup.Count(x => (x.RemediationStatusId ?? defaultStatusValue) == status.Value),
                            Color = threatLevelGroup.Key.Color
                        };

                        series.Data.Add(data);
                    }

                    highchart.Series.Add(series);
                }

                // Decrypt the risk name and assign it as the title of the Highchart
                highchart.Name = Decrypt <string>(riskEntity.NameBytes);
                highcharts.Add(riskEntity.Id, highchart);
            }

            dashboard.MitigationSummaryRisks = highcharts;
        }
		public void CheckThreatLevel(ThreatLevel level, string function, ISceneChildEntity m_host, string API)
        {
            List<UUID> FunctionPerms = new List<UUID>();
            if (!m_FunctionPerms.TryGetValue(function, out FunctionPerms))
            {
                string perm = m_config.GetString("Allow_" + function, "");
                if (perm == "")
                {
                    FunctionPerms = null;// a null value is default
                }
                else
                {
                    bool allowed;

                    if (bool.TryParse(perm, out allowed))
                    {
                        // Boolean given
                        if (allowed)
                        {
                            FunctionPerms = new List<UUID>();
                            FunctionPerms.Add(UUID.Zero);
                        }
                        else
                            FunctionPerms = new List<UUID>(); // Empty list = none
                    }
                    else
                    {
                        FunctionPerms = new List<UUID>();

                        string[] ids = perm.Split(new char[] {','});
                        foreach (string id in ids)
                        {
                            string current = id.Trim();
                            UUID uuid;

                            if (UUID.TryParse(current, out uuid))
                            {
                                if (uuid != UUID.Zero)
                                    FunctionPerms.Add(uuid);
                            }
                        }
                    }
                m_FunctionPerms[function] = FunctionPerms;
                }
            }

            // If the list is null, then the value was true / undefined
            // Threat level governs permissions in this case
            //
            // If the list is non-null, then it is a list of UUIDs allowed
            // to use that particular function. False causes an empty
            // list and therefore means "no one"
            //
            // To allow use by anyone, the list contains UUID.Zero
            //
            if (FunctionPerms == null) // No list = true
            {
                if (level > m_MaxThreatLevel)
                    Error("Runtime Error: ",
                        String.Format(
                            "{0} permission denied.  Allowed threat level is {1} but function threat level is {2}.",
                            function, m_MaxThreatLevel, level));
            }
            else
            {
                if (!FunctionPerms.Contains(UUID.Zero))
                {
                    if (!FunctionPerms.Contains(m_host.OwnerID))
                        Error("Runtime Error: ",
                            String.Format("{0} permission denied.  Prim owner is not in the list of users allowed to execute this function.",
                            function));
                }
            }
        }
 public bool CheckThreatLevel(string SessionID, ulong RegionHandle, string function, ThreatLevel defaultThreatLevel)
 {
     GridRegistrationURLs urls = m_genericsConnector.GetGeneric<GridRegistrationURLs>(UUID.Zero,
         "GridRegistrationUrls", RegionHandle.ToString(), new GridRegistrationURLs());
     if (urls != null)
     {
         //Past time for it to expire
         if (urls.Expiration < DateTime.Now)
         {
             RemoveUrlsForClient(SessionID, RegionHandle);
             return false;
         }
         //First find the threat level that this setting has to have do be able to run
         ThreatLevel functionThreatLevel = PermissionSet.FindThreatLevelForFunction(function, defaultThreatLevel);
         //Now find the permission for that threat level
         //else, check it against the threat level that the region has
         ThreatLevel regionThreatLevel = FindRegionThreatLevel(RegionHandle);
         //Return whether the region threat level is higher than the function threat level
         return functionThreatLevel <= regionThreatLevel;
     }
     return false;
 }
            public ThreatLevelDefinition(ThreatLevel threatLevel, UserSet userSet, ScriptProtectionModule module)
            {
                m_threatLevel = threatLevel;
                m_userSet = userSet;
                m_scriptProtectionModule = module;
                m_allowGroupPermissions = m_scriptProtectionModule.m_config.GetBoolean(
                    "AllowGroupThreatPermissionCheck", m_allowGroupPermissions);

                string perm = m_scriptProtectionModule.m_config.GetString("Allow_" + m_threatLevel.ToString(), "");
                if (perm != "")
                {
                    string[] ids = perm.Split(',');
                    m_allowedUsers = ids.Select(id =>
                    {
                        UUID uuid;
                        if (UUID.TryParse(id.Trim(), out uuid))
                            return uuid;
                        else
                            return UUID.Zero;
                    }).Where((id) => id != UUID.Zero).ToList();
                }
                perm = m_scriptProtectionModule.m_config.GetString("Allow_All", "");
                if (perm != "")
                {
                    string[] ids = perm.Split(',');
                    m_allowedUsers = ids.Select(id =>
                    {
                        UUID uuid;
                        if (UUID.TryParse(id.Trim(), out uuid))
                            return uuid;
                        else
                            return UUID.Zero;
                    }).Where((id) => id != UUID.Zero).ToList();
                }
            }
Example #39
0
 // Returns of the function is allowed. Throws a script exception if not allowed.
 public void CheckThreatLevel(ThreatLevel level, string function)
 {
     string reasonWhyNot = CheckThreatLevelTest(level, function);
     if (!String.IsNullOrEmpty(reasonWhyNot))
     {
         OSSLError(reasonWhyNot);
     }
 }
 protected void ReadConfiguration(IConfig config)
 {
     PermissionSet.ReadFunctions(config);
     m_timeBeforeTimeout = config.GetFloat("DefaultTimeout", m_timeBeforeTimeout);
     m_defaultRegionThreatLevel = (ThreatLevel)Enum.Parse(typeof(ThreatLevel), config.GetString("DefaultRegionThreatLevel", m_defaultRegionThreatLevel.ToString()));
 }
Example #41
0
        public void Initialize(
            IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle)
        {
            m_ScriptEngine = scriptEngine;
            m_host = host;
            m_item = item;

            m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();

            m_ScriptDelayFactor =
                    m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
            m_ScriptDistanceFactor =
                    m_ScriptEngine.Config.GetFloat("ScriptDistanceLimitFactor", 1.0f);

            string risk = m_ScriptEngine.Config.GetString("OSFunctionThreatLevel", "VeryLow");
            switch (risk)
            {
            case "NoAccess":
                m_MaxThreatLevel = ThreatLevel.NoAccess;
                break;
            case "None":
                m_MaxThreatLevel = ThreatLevel.None;
                break;
            case "VeryLow":
                m_MaxThreatLevel = ThreatLevel.VeryLow;
                break;
            case "Low":
                m_MaxThreatLevel = ThreatLevel.Low;
                break;
            case "Moderate":
                m_MaxThreatLevel = ThreatLevel.Moderate;
                break;
            case "High":
                m_MaxThreatLevel = ThreatLevel.High;
                break;
            case "VeryHigh":
                m_MaxThreatLevel = ThreatLevel.VeryHigh;
                break;
            case "Severe":
                m_MaxThreatLevel = ThreatLevel.Severe;
                break;
            default:
                break;
            }
        }
 public bool CheckThreatLevel(ThreatLevel level, string function, ISceneChildEntity m_host, string API,
     UUID itemID)
 {
     GetDefinition(level).CheckThreatLevel(function, m_host, API);
     return CheckFunctionLimits(function, m_host, API, itemID);
 }
Example #43
0
 protected void ReadConfiguration(IConfig config)
 {
     PermissionSet.ReadFunctions(config);
     m_timeBeforeTimeout        = config.GetInt("DefaultTimeout", m_timeBeforeTimeout);
     m_defaultRegionThreatLevel = (ThreatLevel)Enum.Parse(typeof(ThreatLevel), config.GetString("DefaultRegionThreatLevel", m_defaultRegionThreatLevel.ToString()));
 }
            public ThreatLevelDefinition(ThreatLevel threatLevel, UserSet userSet, ScriptProtectionModule module)
            {
                m_threatLevel = threatLevel;
                m_userSet = userSet;
                m_scriptProtectionModule = module;
                m_allowGroupPermissions = m_scriptProtectionModule.m_config.GetBoolean(
                    "AllowGroupThreatPermissionCheck", m_allowGroupPermissions);

                string perm = m_scriptProtectionModule.m_config.GetString("Allow_" + m_threatLevel.ToString(), "");
                if (perm != "")
                {
                    string[] ids = perm.Split(',');

                    foreach (string current in ids.Select(id => id.Trim()))
                    {
                        UUID uuid;

                        if (UUID.TryParse(current, out uuid))
                        {
                            if (uuid != UUID.Zero)
                                m_allowedUsers.Add(uuid);
                        }
                    }
                }
                perm = m_scriptProtectionModule.m_config.GetString("Allow_All", "");
                if (perm != "")
                {
                    string[] ids = perm.Split(',');
                    foreach (string current in ids.Select(id => id.Trim()))
                    {
                        UUID uuid;

                        if (UUID.TryParse(current, out uuid))
                        {
                            if (uuid != UUID.Zero)
                                m_allowedUsers.Add(uuid);
                        }
                    }
                }
            }
Example #45
0
 public bool Core_VerifyPass(ThreatLevel threat)
 {
     return GuiUtils.VerifyPassphrase(Core, ThreatLevel.Medium);
 }
Example #46
0
        public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
        {
            m_ScriptEngine = ScriptEngine;
            m_host = host;
            m_localID = localID;
            m_itemID = itemID;

            if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
                m_OSFunctionsEnabled = true;

            m_ScriptDelayFactor =
                    m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
            m_ScriptDistanceFactor =
                    m_ScriptEngine.Config.GetFloat("ScriptDistanceLimitFactor", 1.0f);

            string risk = m_ScriptEngine.Config.GetString("OSFunctionThreatLevel", "VeryLow");
            switch (risk)
            {
            case "None":
                m_MaxThreatLevel = ThreatLevel.None;
                break;
            case "VeryLow":
                m_MaxThreatLevel = ThreatLevel.VeryLow;
                break;
            case "Low":
                m_MaxThreatLevel = ThreatLevel.Low;
                break;
            case "Moderate":
                m_MaxThreatLevel = ThreatLevel.Moderate;
                break;
            case "High":
                m_MaxThreatLevel = ThreatLevel.High;
                break;
            case "VeryHigh":
                m_MaxThreatLevel = ThreatLevel.VeryHigh;
                break;
            case "Severe":
                m_MaxThreatLevel = ThreatLevel.Severe;
                break;
            default:
                break;
            }
        }
Example #47
0
        public static bool VerifyPassphrase(OpCore core, ThreatLevel threat)
        {
            //crit revise
            if (threat != ThreatLevel.High)
                return true;

            bool trying = true;

            while (trying)
            {
                GetTextDialog form = new GetTextDialog(core, core.User.GetTitle(), "Enter Passphrase", "");

                form.StartPosition = FormStartPosition.CenterScreen;
                form.ResultBox.UseSystemPasswordChar = true;

                if (form.ShowDialog() != DialogResult.OK)
                    return false;

                byte[] key = Utilities.GetPasswordKey(form.ResultBox.Text, core.User.PasswordSalt);

                if (Utilities.MemCompare(core.User.PasswordKey, key))
                    return true;

                MessageBox.Show("Wrong passphrase", "DeOps");
            }

            return false;
        }
Example #48
0
 public bool CheckThreatLevel(ThreatLevel level, string function, ISceneChildEntity m_host, string API,
                              UUID itemID)
 {
     GetDefinition(level).CheckThreatLevel(function, m_host, API);
     return(CheckFunctionLimits(function, m_host, API, itemID));
 }
Example #49
0
        public void CheckThreatLevel(ThreatLevel level, string function, ISceneChildEntity m_host, string API)
        {
            List <UUID> FunctionPerms = new List <UUID>();

            if (!m_FunctionPerms.TryGetValue(function, out FunctionPerms))
            {
                string perm = m_config.GetString("Allow_" + function, "");
                if (perm == "")
                {
                    FunctionPerms = null;// a null value is default
                }
                else
                {
                    bool allowed;

                    if (bool.TryParse(perm, out allowed))
                    {
                        // Boolean given
                        if (allowed)
                        {
                            FunctionPerms = new List <UUID>();
                            FunctionPerms.Add(UUID.Zero);
                        }
                        else
                        {
                            FunctionPerms = new List <UUID>(); // Empty list = none
                        }
                    }
                    else
                    {
                        FunctionPerms = new List <UUID>();

                        string[] ids = perm.Split(new char[] { ',' });
                        foreach (string id in ids)
                        {
                            string current = id.Trim();
                            UUID   uuid;

                            if (UUID.TryParse(current, out uuid))
                            {
                                if (uuid != UUID.Zero)
                                {
                                    FunctionPerms.Add(uuid);
                                }
                            }
                        }
                    }
                    m_FunctionPerms[function] = FunctionPerms;
                }
            }

            // If the list is null, then the value was true / undefined
            // Threat level governs permissions in this case
            //
            // If the list is non-null, then it is a list of UUIDs allowed
            // to use that particular function. False causes an empty
            // list and therefore means "no one"
            //
            // To allow use by anyone, the list contains UUID.Zero
            //
            if (FunctionPerms == null) // No list = true
            {
                if (level > m_MaxThreatLevel)
                {
                    Error("Runtime Error: ",
                          String.Format(
                              "{0} permission denied.  Allowed threat level is {1} but function threat level is {2}.",
                              function, m_MaxThreatLevel, level));
                }
            }
            else
            {
                if (!FunctionPerms.Contains(UUID.Zero))
                {
                    if (!FunctionPerms.Contains(m_host.OwnerID))
                    {
                        Error("Runtime Error: ",
                              String.Format("{0} permission denied.  Prim owner is not in the list of users allowed to execute this function.",
                                            function));
                    }
                }
            }
        }
Example #50
0
        private void AttatchNewDeerFSM(Deer deer, Game game)
        {
            //Declaring Actions for states
            ScaredAction scaredAction = new ScaredAction();
            WanderAction wanderAction = new WanderAction();
            GrazeAction  grazeAction  = new GrazeAction();
            //FleeFromLionAction fleeFromLionAction = new FleeFromLionAction();
            //FleeFromHunterAction fleeFromHunterAction = new FleeFromHunterAction();
            DeerFleeAction deerFleeAction = new DeerFleeAction();
            resetWander    resetWander    = new resetWander();
            emptyAction    emptyAction    = new emptyAction();
            FlockAction    flockAction    = new FlockAction();

            //Declaring States for FSM
            State scaredState = new State("scared", scaredAction);
            State wanderState = new State("wander", emptyAction, wanderAction, resetWander);
            State grazeState  = new State("graze", grazeAction);
            State fleeState   = new State("flee", deerFleeAction);
            //fleeState.AddActions();
            State flockState = new State("flock", flockAction);


            //Declaring conditions used for transitions
            FearGreaterThan  fearGreaterThan80                 = new FearGreaterThan(80);
            FearGreaterThan  fearGreaterThan60                 = new FearGreaterThan(60);
            FearLessThan     fearLessThan40                    = new FearLessThan(40);
            FearLessThan     fearLessThan20                    = new FearLessThan(20);
            ThreatLevel      hunterHighThreatLevel             = new ThreatLevel(75f);
            DistanceToHunter distanceToHunter                  = new DistanceToHunter(200f);
            AndCondition     andThreatDistanceHunter           = new AndCondition(hunterHighThreatLevel, distanceToHunter);
            OrCondition      orFearThreat                      = new OrCondition(fearGreaterThan60, andThreatDistanceHunter);
            NeighborCountGreaterCondition neighborCountGreater = new NeighborCountGreaterCondition(5);
            NeighborCountLessCondition    neighborCountLess    = new NeighborCountLessCondition(2);
            RandomTimerCondition          fleetoScaredTimer    = new RandomTimerCondition(initialTime, 600);
            RandomTimerCondition          wandertoGrazeTimer   = new RandomTimerCondition(initialTime, shortTimer);//800 to 1200
            RandomTimerCondition          flocktoGrazeTimer    = new RandomTimerCondition(initialTime, 600);
            RandomTimerCondition          grazetoFlockTimer    = new RandomTimerCondition(initialTime, 600);
            RandomCondition randomCondition                    = new RandomCondition(2, 2);
            //AndCondition andRandomLowFear = new AndCondition(randomCondition, fearLessThan40);
            AndCondition andTimerLowFear = new AndCondition(fleetoScaredTimer, fearLessThan20);
            AndCondition andRandomNeighborCountGreater = new AndCondition(randomCondition, neighborCountGreater);
            AndCondition andRandomNeighborCountLess    = new AndCondition(grazetoFlockTimer, neighborCountLess);
            //AndCondition andRNCRandom = new AndCondition(andRandomNeighborCount, grazetoFlockTimer);
            WanderCondition wanderTrue = new WanderCondition();


            //Declaring Transitions
            Transition gotoWanderFromScared = new Transition(andTimerLowFear, wanderState, 0);
            //Transition gotoWanderFromScared = new Transition(andRandomLowFear, wanderState, 0);
            Transition gotoWanderFromGraze  = new Transition(wanderTrue, wanderState, 0);
            Transition gotoWanderFromGraze2 = new Transition(andRandomNeighborCountLess, wanderState, 0);

            Transition gotoGrazeFromScared = new Transition(andTimerLowFear, grazeState, 0);
            //Transition gotoGrazeFromScared = new Transition(andRandomLowFear, grazeState, 0);
            Transition gotoGrazeFromWander = new Transition(wandertoGrazeTimer, grazeState, 0);

            Transition gotoFlockfromGraze = new Transition(andRandomNeighborCountGreater, flockState, 0);
            Transition gotoGrazefromFlock = new Transition(flocktoGrazeTimer, grazeState, 0);

            Transition gotoScaredFromWander = new Transition(orFearThreat, scaredState, 0); //old cond was feargreaterthan 60
            Transition gotoScaredFromGraze  = new Transition(orFearThreat, scaredState, 0);
            Transition gotoScaredFromFlock  = new Transition(orFearThreat, scaredState, 0);

            Transition gotoFlee = new Transition(fearGreaterThan80, fleeState, 0);
            //Transition gotoScaredFromFlee = new Transition(andTimerLowFear, scaredState, 0);
            Transition gotoScaredFromFlee = new Transition(fearLessThan40, scaredState, 0);

            //Declaring actions for transitions
            gotoWanderFromScared.addActions(wanderAction);
            gotoWanderFromGraze.addActions(wanderAction);
            gotoWanderFromGraze2.addActions(wanderAction);
            gotoGrazeFromScared.addActions(grazeAction);
            gotoGrazeFromWander.addActions(grazeAction);
            gotoGrazefromFlock.addActions(grazeAction);
            gotoScaredFromWander.addActions(scaredAction);
            gotoScaredFromGraze.addActions(scaredAction);
            gotoFlee.addActions(deerFleeAction);
            gotoFlockfromGraze.addActions(flockAction);
            gotoScaredFromFlock.addActions(scaredAction);
            gotoScaredFromFlee.addActions(scaredAction);


            //Hooking up transitions to states
            scaredState.addTransition(gotoWanderFromScared);
            scaredState.addTransition(gotoGrazeFromScared);
            scaredState.addTransition(gotoFlee);

            wanderState.addTransition(gotoScaredFromWander);
            wanderState.addTransition(gotoGrazeFromWander);

            grazeState.addTransition(gotoScaredFromGraze);
            grazeState.addTransition(gotoWanderFromGraze);
            grazeState.addTransition(gotoFlockfromGraze);
            grazeState.addTransition(gotoWanderFromGraze2);

            fleeState.addTransition(gotoScaredFromFlee);

            flockState.addTransition(gotoGrazefromFlock);
            flockState.addTransition(gotoScaredFromFlock);


            FiniteStateMachine newFSM = new FiniteStateMachine(wanderState);

            deer.fsm = newFSM;
        }
Example #51
0
        private void MapGovernanceControlsByRiskLevel(List <GovernanceControlEntity> governanceControlEntities, Dashboard dashboard)
        {
            var highchart = new Highchart();
            var series    = new Series
            {
                Type = "pie",
                Name = "Risk Level"
            };

            var governanceControlGroups = governanceControlEntities.OrderBy(gc => gc.ThreatLevelId).GroupBy(gc => ThreatLevel.LookupByValue(gc.ThreatLevelId)).ToList();

            foreach (var governanceControlGroup in governanceControlGroups)
            {
                var data = new Data
                {
                    Name  = governanceControlGroup.Key.Name,
                    Value = governanceControlGroup.Count(),
                    Color = governanceControlGroup.Key.Color
                };
                series.Data.Add(data);
            }

            highchart.Series.Add(series);

            dashboard.GovernanceControlsByRiskLevel = highchart;
        }
Example #52
0
        public void Initialize(
            IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item)
        {
            m_ScriptEngine = scriptEngine;
            m_host = host;
            m_item = item;
            m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);

            m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();

            if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
            {
                m_OSFunctionsEnabled = true;
                // m_log.Warn("[OSSL] OSSL FUNCTIONS ENABLED");
            }

            m_ScriptDelayFactor =
                    m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
            m_ScriptDistanceFactor =
                    m_ScriptEngine.Config.GetFloat("ScriptDistanceLimitFactor", 1.0f);

            string risk = m_ScriptEngine.Config.GetString("OSFunctionThreatLevel", "VeryLow");
            switch (risk)
            {
            case "NoAccess":
                m_MaxThreatLevel = ThreatLevel.NoAccess;
                break;
            case "None":
                m_MaxThreatLevel = ThreatLevel.None;
                break;
            case "VeryLow":
                m_MaxThreatLevel = ThreatLevel.VeryLow;
                break;
            case "Low":
                m_MaxThreatLevel = ThreatLevel.Low;
                break;
            case "Moderate":
                m_MaxThreatLevel = ThreatLevel.Moderate;
                break;
            case "High":
                m_MaxThreatLevel = ThreatLevel.High;
                break;
            case "VeryHigh":
                m_MaxThreatLevel = ThreatLevel.VeryHigh;
                break;
            case "Severe":
                m_MaxThreatLevel = ThreatLevel.Severe;
                break;
            default:
                break;
            }
         }
Example #53
0
 public HarmfulAI(FoodClassification food)
 {
     classification = food;
     threat         = ThreatLevel.low;
     moveFood       = true;
 }
Example #54
0
        // Check to see if function is allowed. Returns an empty string if function permitted
        //     or a string explaining why this function can't be used.
        private string CheckThreatLevelTest(ThreatLevel level, string function)
        {
            if (!m_FunctionPerms.ContainsKey(function))
            {
                FunctionPerms perms = new FunctionPerms();
                m_FunctionPerms[function] = perms;

                string ownerPerm = m_ScriptEngine.Config.GetString("Allow_" + function, "");
                string creatorPerm = m_ScriptEngine.Config.GetString("Creators_" + function, "");
                if (ownerPerm == "" && creatorPerm == "")
                {
                    // Default behavior
                    perms.AllowedOwners = null;
                    perms.AllowedCreators = null;
                    perms.AllowedOwnerClasses = null;
                }
                else
                {
                    bool allowed;

                    if (bool.TryParse(ownerPerm, out allowed))
                    {
                        // Boolean given
                        if (allowed)
                        {
                            // Allow globally
                            perms.AllowedOwners.Add(UUID.Zero);
                        }
                    }
                    else
                    {
                        string[] ids = ownerPerm.Split(new char[] {','});
                        foreach (string id in ids)
                        {
                            string current = id.Trim();
                            if (current.ToUpper() == "PARCEL_GROUP_MEMBER" || current.ToUpper() == "PARCEL_OWNER" || current.ToUpper() == "ESTATE_MANAGER" || current.ToUpper() == "ESTATE_OWNER" || current.ToUpper() == "GOD" || current.ToUpper() == "GRID_GOD")
                            {
                                if (!perms.AllowedOwnerClasses.Contains(current))
                                    perms.AllowedOwnerClasses.Add(current.ToUpper());
                            }
                            else
                            {
                                UUID uuid;

                                if (UUID.TryParse(current, out uuid))
                                {
                                    if (uuid != UUID.Zero)
                                        perms.AllowedOwners.Add(uuid);
                                }
                            }
                        }

                        ids = creatorPerm.Split(new char[] {','});
                        foreach (string id in ids)
                        {
                            string current = id.Trim();
                            UUID uuid;

                            if (UUID.TryParse(current, out uuid))
                            {
                                if (uuid != UUID.Zero)
                                    perms.AllowedCreators.Add(uuid);
                            }
                        }
                    }
                }
            }

            // If the list is null, then the value was true / undefined
            // Threat level governs permissions in this case
            //
            // If the list is non-null, then it is a list of UUIDs allowed
            // to use that particular function. False causes an empty
            // list and therefore means "no one"
            //
            // To allow use by anyone, the list contains UUID.Zero
            //
            if (m_FunctionPerms[function].AllowedOwners == null)
            {
                // Allow / disallow by threat level
                if (level > m_MaxThreatLevel)
                    return
                        String.Format(
                            "{0} permission denied.  Allowed threat level is {1} but function threat level is {2}.",
                            function, m_MaxThreatLevel, level);
            }
            else
            {
                if (!m_FunctionPerms[function].AllowedOwners.Contains(UUID.Zero))
                {
                    // Not anyone. Do detailed checks
                    if (m_FunctionPerms[function].AllowedOwners.Contains(m_host.OwnerID))
                    {
                        // prim owner is in the list of allowed owners
                        return String.Empty;
                    }

                    UUID ownerID = m_item.OwnerID;

                    //OSSL only may be used if object is in the same group as the parcel
                    if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER"))
                    {
                        ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);

                        if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero)
                        {
                            return String.Empty;
                        }
                    }

                    //Only Parcelowners may use the function
                    if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_OWNER"))
                    {
                        ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);

                        if (land.LandData.OwnerID == ownerID)
                        {
                            return String.Empty;
                        }
                    }

                    //Only Estate Managers may use the function
                    if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_MANAGER"))
                    {
                        //Only Estate Managers may use the function
                        if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID)
                        {
                            return String.Empty;
                        }
                    }

                    //Only regionowners may use the function
                    if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("ESTATE_OWNER"))
                    {
                        if (World.RegionInfo.EstateSettings.EstateOwner == ownerID)
                        {
                            return String.Empty;
                        }
                    }

                    //Only gods may use the function
                    if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("GOD"))
                    {
                        if (World.Permissions.IsGod(ownerID)) 
                        {
                            return String.Empty;
                        }
                    }

                    //Only grid gods may use the function
                    if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("GRID_GOD"))
                    {
                        if (World.Permissions.IsGridGod(ownerID)) 
                        {
                            return String.Empty;
                        }
                    }

                    if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID))
                        return(
                            String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.",
                            function));

                    if (m_item.CreatorID != ownerID)
                    {
                        if ((m_item.CurrentPermissions & (uint)PermissionMask.Modify) != 0)
                            return String.Format("{0} permission denied. Script permissions error.", function);

                    }
                }
            }
            return String.Empty;
        }
 public override void FromOSD(OSDMap map)
 {
     Connection = new IWCConnection ();
     Connection.FromOSD (map);
     ValidUntil = map["ValidUntil"].AsDate ();
     Active = map["Active"].AsBoolean ();
     ThreatLevel = (ThreatLevel)map["ThreatLevel"].AsInteger ();
 }