static void ZoneTestCallback([NotNull] Player player, [NotNull] Vector3I[] marks, [CanBeNull] object tag) { if (player == null) { throw new ArgumentNullException("player"); } if (marks == null) { throw new ArgumentNullException("marks"); } Zone[] allowed, denied; if (player.WorldMap.Zones.CheckDetailed(marks[0], player, out allowed, out denied)) { foreach (Zone zone in allowed) { SecurityCheckResult status = zone.Controller.CheckDetailed(player.Info); player.Message("> Zone {0}&S: {1}{2}", zone.ClassyName, ChatColor.Lime, status); } foreach (Zone zone in denied) { SecurityCheckResult status = zone.Controller.CheckDetailed(player.Info); player.Message("> Zone {0}&S: {1}{2}", zone.ClassyName, ChatColor.Red, status); } } else { player.Message("No zones affect this block."); } }
private static void ZoneTestCallback(Player player, Vector3I[] marks, object tag) { Zone[] allowed, denied; if (player.WorldMap.Zones.CheckDetailed(marks[0], player, out allowed, out denied)) { foreach (Zone zone in allowed) { SecurityCheckResult status = zone.Controller.CheckDetailed(player.Info); player.Message("> Zone {0}&S: {1}{2}", zone.ClassyName, Color.Lime, status); } foreach (Zone zone in denied) { SecurityCheckResult status = zone.Controller.CheckDetailed(player.Info); player.Message("> Zone {0}&S: {1}{2}", zone.ClassyName, Color.Red, status); } } else { player.Message("No zones affect this block."); } }
public SecurityCheckResultDecorator(ISecurityCheck check, SecurityCheckResult result, string secureMessage, string unsecureMessage, bool secureWhenFailed) : base(check, result.Passed) { IsSecure = secureWhenFailed ? !result.Passed : result.Passed; this.secureMessage = secureMessage; this.unsecureMessage = unsecureMessage; this.result = result; }
protected override SecurityCheckResult CheckCore(HttpResponseMessage httpResponseMessage) { if (string.Equals(httpResponseMessage.RequestMessage.RequestUri.Scheme, Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { return(SecurityCheckResult.Create(SecurityCheckState.Best, string.Empty, httpResponseMessage.RequestMessage.RequestUri.Scheme)); } return(SecurityCheckResult.Create(SecurityCheckState.Bad, Recommendation, Uri.UriSchemeHttp)); }
protected override SecurityCheckResult CheckHeaderValue(string value) { var trimedValue = value.Trim(); var headerValueCheck = HeaderValueChecks.FirstOrDefault(check => check.Matches(trimedValue)); if (!(headerValueCheck is null)) { return(SecurityCheckResult.Create(headerValueCheck.SecurityCheckState, headerValueCheck.Recommendation, value)); }
private static void ZoneAddCallback(Player player, Vector3I[] marks, object tag) { World playerWorld = player.World; if (playerWorld == null) { PlayerOpException.ThrowNoWorld(player); } if (!player.Info.Rank.AllowSecurityCircumvention) { SecurityCheckResult buildCheck = playerWorld.BuildSecurity.CheckDetailed(player.Info); switch (buildCheck) { case SecurityCheckResult.BlackListed: player.Message("Cannot add zones to world {0}&S: You are barred from building here.", playerWorld.ClassyName); return; case SecurityCheckResult.RankTooLow: player.Message("Cannot add zones to world {0}&S: You are not allowed to build here.", playerWorld.ClassyName); return; //case SecurityCheckResult.RankTooHigh: } } Zone zone = (Zone)tag; var zones = player.WorldMap.Zones; lock (zones.SyncRoot) { Zone dupeZone = zones.FindExact(zone.Name); if (dupeZone != null) { player.Message("A zone named \"{0}\" has just been created by {1}", dupeZone.Name, dupeZone.CreatedBy); return; } zone.Create(new BoundingBox(marks[0], marks[1]), player.Info); player.Message("Zone \"{0}\" created, {1} blocks total.", zone.Name, zone.Bounds.Volume); Logger.Log(LogType.UserActivity, "Player {0} created a new zone \"{1}\" containing {2} blocks.", player.Name, zone.Name, zone.Bounds.Volume); zones.Add(zone); } }
public SecurityCheckResult Check(HttpResponseMessage httpResponseMessage) { if (httpResponseMessage is null) { throw new ArgumentNullException(nameof(httpResponseMessage)); } if (HttpsOnly && httpResponseMessage.RequestMessage.RequestUri.Scheme != Uri.UriSchemeHttps) { return(SecurityCheckResult.Create(SecurityCheckState.Skipped, $"{Name} is HTTPS only.")); } return(CheckCore(httpResponseMessage)); }
private bool CheckWorldPermissions(Player p) { if (!p.Info.Rank.AllowSecurityCircumvention) { SecurityCheckResult buildCheck = _world.BuildSecurity.CheckDetailed(p.Info); switch (buildCheck) { case SecurityCheckResult.BlackListed: p.Message("Cannot add life to world {0}&S: You are barred from building here.", p.ClassyName); return(false); case SecurityCheckResult.RankTooLow: p.Message("Cannot add life to world {0}&S: You are not allowed to build here.", p.ClassyName); return(false); } } return(true); }
internal static void ZoneTestCallback(Player player, Position[] marks, object tag) { Zone[] allowed, denied; if (player.World.Map.TestZones(marks[0].X, marks[0].Y, marks[0].H, player, out allowed, out denied)) { foreach (Zone zone in allowed) { SecurityCheckResult status = zone.Controller.CheckDetailed(player.Info); player.Message("> {0}: {1}{2}", zone.Name, Color.Lime, status); } foreach (Zone zone in denied) { SecurityCheckResult status = zone.Controller.CheckDetailed(player.Info); player.Message("> {0}: {1}{2}", zone.Name, Color.Red, status); } } else { player.Message("No zones affect this block."); } }
protected override SecurityCheckResult CheckCore(HttpResponseMessage httpResponseMessage) { var request = httpResponseMessage.RequestMessage; if (request.Properties.TryGetValue(nameof(ServerCertificateInfo), out object obj)) { var serverCertificateValidation = (ServerCertificateInfo)obj; if (serverCertificateValidation.SslPolicyErrors == System.Net.Security.SslPolicyErrors.None) { return(SecurityCheckResult.Create(SecurityCheckState.Best, value: serverCertificateValidation.X509CertificateName)); } else { return(SecurityCheckResult.Create(SecurityCheckState.Bad, $"The server certificate has '{serverCertificateValidation.SslPolicyErrors}'. Ensure that the certificate has no erros.", serverCertificateValidation.X509CertificateName)); } } else { throw new InvalidOperationException($"No {nameof(ServerCertificateInfo)} found on the request."); } }
static void ZoneAddHandler(Player player, CommandReader cmd) { World playerWorld = player.World; if (playerWorld == null) { PlayerOpException.ThrowNoWorld(player); } string givenZoneName = cmd.Next(); if (givenZoneName == null) { CdZoneAdd.PrintUsage(player); return; } if (!player.Info.Rank.AllowSecurityCircumvention) { SecurityCheckResult buildCheck = playerWorld.BuildSecurity.CheckDetailed(player.Info); switch (buildCheck) { case SecurityCheckResult.BlackListed: player.Message("Cannot add zones to world {0}&S: You are barred from building here.", playerWorld.ClassyName); return; case SecurityCheckResult.RankTooLow: player.Message("Cannot add zones to world {0}&S: You are not allowed to build here.", playerWorld.ClassyName); return; } } Zone newZone = new Zone(); ZoneCollection zoneCollection = player.WorldMap.Zones; if (givenZoneName.StartsWith("+")) { // personal zone (/ZAdd +Name) givenZoneName = givenZoneName.Substring(1); // Find the target player PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, givenZoneName); if (info == null) { return; } // Make sure that the name is not taken already. // If a zone named after the player already exists, try adding a number after the name (e.g. "Notch2") newZone.Name = info.Name; for (int i = 2; zoneCollection.Contains(newZone.Name); i++) { newZone.Name = givenZoneName + i; } newZone.Controller.MinRank = info.Rank.NextRankUp ?? info.Rank; newZone.Controller.Include(info); player.Message("ZoneAdd: Creating a {0}+&S zone for player {1}&S. Click or &H/Mark&S 2 blocks.", newZone.Controller.MinRank.ClassyName, info.ClassyName); player.SelectionStart(2, ZoneAddCallback, newZone, CdZoneAdd.Permissions); } else { // Adding an ordinary, rank-restricted zone. if (!World.IsValidName(givenZoneName)) { player.Message("\"{0}\" is not a valid zone name", givenZoneName); return; } if (zoneCollection.Contains(givenZoneName)) { player.Message("A zone with this name already exists. Use &H/ZEdit&S to edit."); return; } newZone.Name = givenZoneName; string rankName = cmd.Next(); if (rankName == null) { player.Message("No rank was specified. See &H/Help zone"); return; } Rank minRank = RankManager.FindRank(rankName); if (minRank == null) { player.MessageNoRank(rankName); return; } string name; while ((name = cmd.Next()) != null) { if (name.Length < 1) { CdZoneAdd.PrintUsage(player); return; } PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches(player, name.Substring(1)); if (info == null) { return; } if (name.StartsWith("+")) { newZone.Controller.Include(info); } else if (name.StartsWith("-")) { newZone.Controller.Exclude(info); } } newZone.Controller.MinRank = minRank; player.SelectionStart(2, ZoneAddCallback, newZone, CdZoneAdd.Permissions); player.Message("ZoneAdd: Creating zone {0}&S. Click or &H/Mark&S 2 blocks.", newZone.ClassyName); } }
public SecurityCheckResultReport(SecurityCheckResult result) { Result = result; }
protected override SecurityCheckResult CheckHeaderValue(string value) { return(SecurityCheckResult.Create(SecurityCheckState.Bad, Recommendation, value)); }
protected override SecurityCheckResult CreateForMissingHeader() { return(SecurityCheckResult.Create(SecurityCheckState.Best)); }