コード例 #1
0
        public async Task ComputeThreatListDiffAsync()
        {
            Mock <WebRiskServiceV1Beta1.WebRiskServiceV1Beta1Client> mockGrpcClient = new Mock <WebRiskServiceV1Beta1.WebRiskServiceV1Beta1Client>(MockBehavior.Strict);
            ComputeThreatListDiffRequest expectedRequest = new ComputeThreatListDiffRequest
            {
                ThreatType   = ThreatType.Unspecified,
                VersionToken = ByteString.CopyFromUtf8("-46"),
                Constraints  = new ComputeThreatListDiffRequest.Types.Constraints(),
            };
            ComputeThreatListDiffResponse expectedResponse = new ComputeThreatListDiffResponse
            {
                NewVersionToken = ByteString.CopyFromUtf8("115"),
            };

            mockGrpcClient.Setup(x => x.ComputeThreatListDiffAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <ComputeThreatListDiffResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            WebRiskServiceV1Beta1Client client = new WebRiskServiceV1Beta1ClientImpl(mockGrpcClient.Object, null);
            ThreatType threatType   = ThreatType.Unspecified;
            ByteString versionToken = ByteString.CopyFromUtf8("-46");

            ComputeThreatListDiffRequest.Types.Constraints constraints = new ComputeThreatListDiffRequest.Types.Constraints();
            ComputeThreatListDiffResponse response = await client.ComputeThreatListDiffAsync(threatType, versionToken, constraints);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
コード例 #2
0
 protected InternalThreat(ThreatType type, ThreatDifficulty difficulty, int health, int speed, int timeAppears, StationLocation currentStation, PlayerAction actionType, ISittingDuck sittingDuck) :
     base(type, difficulty, health, speed, timeAppears, sittingDuck)
 {
     CurrentStation = currentStation;
     sittingDuck.StationByLocation[currentStation].Threats.Add(this);
     ActionType = actionType;
 }
コード例 #3
0
ファイル: RoleForm.cs プロジェクト: cmdrmander/Manderplan
        public RoleForm(IRole r, ThreatType type)
        {
            this.InitializeComponent();
            List <RoleType> roleTypes = new List <RoleType>();

            switch (type)
            {
            case ThreatType.Creature:
            {
                roleTypes.Add(RoleType.Artillery);
                roleTypes.Add(RoleType.Brute);
                roleTypes.Add(RoleType.Controller);
                roleTypes.Add(RoleType.Lurker);
                roleTypes.Add(RoleType.Skirmisher);
                roleTypes.Add(RoleType.Soldier);
                break;
            }

            case ThreatType.Trap:
            {
                roleTypes.Add(RoleType.Blaster);
                roleTypes.Add(RoleType.Lurker);
                roleTypes.Add(RoleType.Obstacle);
                roleTypes.Add(RoleType.Warder);
                this.LeaderBox.Text = "This trap is a leader";
                break;
            }
            }
            foreach (RoleType roleType in roleTypes)
            {
                this.RoleBox.Items.Add(roleType);
                this.MinionRoleBox.Items.Add(roleType);
            }
            foreach (RoleFlag value in Enum.GetValues(typeof(RoleFlag)))
            {
                this.ModBox.Items.Add(value);
            }
            Application.Idle += new EventHandler(this.Application_Idle);
            this.fRole        = r.Copy();
            if (this.fRole is ComplexRole)
            {
                this.StandardBtn.Checked = true;
                ComplexRole complexRole = this.fRole as ComplexRole;
                this.RoleBox.SelectedItem       = complexRole.Type;
                this.MinionRoleBox.SelectedItem = complexRole.Type;
                this.ModBox.SelectedItem        = complexRole.Flag;
                this.LeaderBox.Checked          = complexRole.Leader;
                this.HasRoleBox.Checked         = false;
            }
            if (this.fRole is Minion)
            {
                this.MinionBtn.Checked = true;
                Minion minion = this.fRole as Minion;
                this.RoleBox.SelectedItem       = minion.Type;
                this.MinionRoleBox.SelectedItem = minion.Type;
                this.ModBox.SelectedItem        = RoleFlag.Standard;
                this.LeaderBox.Checked          = false;
                this.HasRoleBox.Checked         = minion.HasRole;
            }
        }
コード例 #4
0
 protected InternalThreat(ThreatType threatType, ThreatDifficulty difficulty, int health, int speed, StationLocation currentStation, PlayerActionType?actionType, int?inaccessibility) :
     this(threatType, difficulty, health, speed, new List <StationLocation> {
     currentStation
 }, actionType)
 {
     TotalInaccessibility = RemainingInaccessibility = inaccessibility;
 }
コード例 #5
0
 protected InternalThreat(ThreatType type, ThreatDifficulty difficulty, int health, int speed, int timeAppears, StationLocation currentStation, PlayerAction actionType, ISittingDuck sittingDuck)
     : base(type, difficulty, health, speed, timeAppears, sittingDuck)
 {
     CurrentStation = currentStation;
     sittingDuck.StationByLocation[currentStation].Threats.Add(this);
     ActionType = actionType;
 }
コード例 #6
0
        /// <summary>
        ///     Create a Threat Type Model.
        /// </summary>
        /// <param name="this">
        ///     A <see cref="ThreatType" />.
        /// </param>
        /// <returns>
        ///     A string identifying a <see cref="ThreatType" />.
        /// </returns>
        internal static string AsThreatTypeModel(this ThreatType @this)
        {
            string threatTypeModel;

            switch (@this)
            {
            case ThreatType.Malware:
                threatTypeModel = "MALWARE";
                break;

            case ThreatType.PotentiallyHarmfulApplication:
                threatTypeModel = "POTENTIALLY_HARMFUL_APPLICATION";
                break;

            case ThreatType.SocialEngineering:
                threatTypeModel = "SOCIAL_ENGINEERING";
                break;

            case ThreatType.Unknown:
                threatTypeModel = "THREAT_TYPE_UNSPECIFIED";
                break;

            case ThreatType.UnwantedSoftware:
                threatTypeModel = "UNWANTED_SOFTWARE";
                break;

            default:
                threatTypeModel = "THREAT_TYPE_UNSPECIFIED";
                break;
            }

            return(threatTypeModel);
        }
コード例 #7
0
 /// <summary>
 /// Gets the most recent threat list diffs.
 /// </summary>
 /// <param name="threatType">
 /// The ThreatList to update.
 /// </param>
 /// <param name="versionToken">
 /// The current version token of the client for the requested list (the
 /// client version that was received from the last successful diff).
 /// </param>
 /// <param name="constraints">
 /// Required. The constraints associated with this request.
 /// </param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public virtual ComputeThreatListDiffResponse ComputeThreatListDiff(ThreatType threatType, proto::ByteString versionToken, ComputeThreatListDiffRequest.Types.Constraints constraints, gaxgrpc::CallSettings callSettings = null) =>
 ComputeThreatListDiff(new ComputeThreatListDiffRequest
 {
     ThreatType   = threatType,
     VersionToken = versionToken ?? proto::ByteString.Empty,
     Constraints  = gax::GaxPreconditions.CheckNotNull(constraints, nameof(constraints)),
 }, callSettings);
コード例 #8
0
ファイル: Threat.cs プロジェクト: smrq/space-alert-resolver
 protected Threat(ThreatType threatType, ThreatDifficulty difficulty, int health, int speed)
 {
     Difficulty  = difficulty;
     ThreatType  = threatType;
     TotalHealth = RemainingHealth = health;
     Speed       = speed;
 }
コード例 #9
0
 protected InternalThreat(ThreatType type, ThreatDifficulty difficulty, int health, int speed, int timeAppears, IList<StationLocation> currentStations, PlayerAction actionType, ISittingDuck sittingDuck)
     : base(type, difficulty, health, speed, timeAppears, sittingDuck)
 {
     CurrentStations = currentStations;
     foreach (var currentStation in CurrentStations)
         sittingDuck.StationByLocation[currentStation].Threats.Add(this);
     ActionType = actionType;
 }
コード例 #10
0
ファイル: Threat.cs プロジェクト: knexer/space-alert-resolver
 protected Threat(ThreatType type, ThreatDifficulty difficulty, int health, int speed, int timeAppears, ISittingDuck sittingDuck)
 {
     this.difficulty  = difficulty;
     this.type        = type;
     TotalHealth      = RemainingHealth = health;
     Speed            = speed;
     TimeAppears      = timeAppears;
     this.sittingDuck = sittingDuck;
 }
コード例 #11
0
 /// <summary>
 /// Gets the most recent threat list diffs.
 /// </summary>
 /// <param name="threatType">
 /// Required. The ThreatList to update.
 /// </param>
 /// <param name="versionToken">
 /// The current version token of the client for the requested list (the
 /// client version that was received from the last successful diff).
 /// </param>
 /// <param name="constraints">
 /// The constraints associated with this request.
 /// </param>
 /// <param name="cancellationToken">
 /// A <see cref="st::CancellationToken"/> to use for this RPC.
 /// </param>
 /// <returns>
 /// A Task containing the RPC response.
 /// </returns>
 public virtual stt::Task <ComputeThreatListDiffResponse> ComputeThreatListDiffAsync(
     ThreatType threatType,
     pb::ByteString versionToken,
     ComputeThreatListDiffRequest.Types.Constraints constraints,
     st::CancellationToken cancellationToken) => ComputeThreatListDiffAsync(
     threatType,
     versionToken,
     constraints,
     gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
コード例 #12
0
ファイル: Threat.cs プロジェクト: knexer/space-alert-resolver
 protected Threat(ThreatType type, ThreatDifficulty difficulty, int health, int speed, int timeAppears, ISittingDuck sittingDuck)
 {
     this.difficulty = difficulty;
     this.type = type;
     TotalHealth = RemainingHealth = health;
     Speed = speed;
     TimeAppears = timeAppears;
     this.sittingDuck = sittingDuck;
 }
コード例 #13
0
        /// <summary>
        ///     Restrict Updates.
        /// </summary>
        /// <param name="threatType">
        ///     A <see cref="ThreatType" /> identifying a <see cref="ThreatList" /> to restrict updates to.
        /// </param>
        /// <param name="platformType">
        ///     A <see cref="PlatformType" /> identifying a <see cref="ThreatList" /> to restrict updates to.
        /// </param>
        /// <param name="threatEntryType">
        ///     A <see cref="ThreatEntryType" /> identifying a <see cref="ThreatList" /> to restrict updates to.
        /// </param>
        /// <param name="updateConstraints">
        ///     The <see cref="ThreatListUpdateConstraints" /> to apply when the <see cref="ThreatList" /> identified
        ///     by <paramref name="threatType" />, <paramref name="platformType" />, and
        ///     <paramref name="threatEntryType" /> is retrieved.
        /// </param>
        /// <returns>
        ///     This managed service builder.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     Thrown if <paramref name="updateConstraints" /> is a null reference.
        /// </exception>
        public ManagedBrowsingServiceBuilder RestrictUpdatesTo(ThreatType threatType, PlatformType platformType, ThreatEntryType threatEntryType, ThreatListUpdateConstraints updateConstraints)
        {
            Guard.ThrowIf(nameof(updateConstraints), updateConstraints).Null();

            var threatListDescriptor = new ThreatListDescriptor(threatType, platformType, threatEntryType);

            this.UpdateConstraints[threatListDescriptor] = updateConstraints;
            return(this);
        }
コード例 #14
0
 public Square(SquareType type, ThreatType threat, int posX, int posY, int?number)
 {
     Type            = type;
     Threat          = threat;
     PosX            = posX;
     PosY            = posY;
     Number          = number;
     FlagTotal       = 0;
     IsPotentialFlag = false;
 }
コード例 #15
0
 protected InternalThreat(ThreatType type, ThreatDifficulty difficulty, int health, int speed, int timeAppears, IList <StationLocation> currentStations, PlayerAction actionType, ISittingDuck sittingDuck) :
     base(type, difficulty, health, speed, timeAppears, sittingDuck)
 {
     CurrentStations = currentStations;
     foreach (var currentStation in CurrentStations)
     {
         sittingDuck.StationByLocation[currentStation].Threats.Add(this);
     }
     ActionType = actionType;
 }
コード例 #16
0
        /// <summary>
        ///     Add Query.
        /// </summary>
        /// <param name="threatType">
        ///     A <see cref="ThreatType" /> identifying the <see cref="ThreatList" /> to query.
        /// </param>
        /// <param name="platformType">
        ///     A <see cref="PlatformType" /> identifying the <see cref="ThreatList" /> to query.
        /// </param>
        /// <param name="threatEntryType">
        ///     A <see cref="ThreatEntryType" /> identifying the <see cref="ThreatList" /> to query.
        /// </param>
        /// <param name="threatListState">
        ///     The state, formatted as a hexadecimal encoded string, of the <see cref="ThreatList" /> identified by
        ///     <paramref name="threatType" />, <paramref name="platformType" />, and
        ///     <paramref name="threatEntryType" />.
        /// </param>
        /// <returns>
        ///     This full hash request builder.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     Thrown if <paramref name="threatListState" /> is a null reference.
        /// </exception>
        /// <exception cref="System.FormatException">
        ///     Thrown if <paramref name="threatListState" /> is not hexadecimal encoded.
        /// </exception>
        public FullHashRequestBuilder AddQuery(ThreatType threatType, PlatformType platformType, ThreatEntryType threatEntryType, string threatListState)
        {
            // ...
            //
            // Throws an exception if the operation fails.
            var query = new FullHashQuery(threatType, platformType, threatEntryType, threatListState);

            this.Queries.Add(query);
            return(this);
        }
コード例 #17
0
        Threat makeRandomThreat(PlayerName player)
        {
            ThreatType type      = level.sampleRandomThreatType(player);
            Threat     newThreat = null;

            if (type == ThreatType.Music)
            {
                var info = new ThreatMusicInfo(level, player);
                newThreat = new Threat(info);
            }
            return(newThreat);
        }
コード例 #18
0
        public IThreatType AddThreatType([Required] string name, [NotNull] ISeverity severity)
        {
            IThreatType result = null;

            if (GetThreatType(name) == null)
            {
                result = new ThreatType(this, name, severity);
                Add(result);
                RegisterEvents(result);
            }

            return(result);
        }
コード例 #19
0
        /// <summary>Snippet for ComputeThreatListDiff</summary>
        public void ComputeThreatListDiff()
        {
            // Snippet: ComputeThreatListDiff(ThreatType, ByteString, ComputeThreatListDiffRequest.Types.Constraints, CallSettings)
            // Create client
            WebRiskServiceV1Beta1Client webRiskServiceV1Beta1Client = WebRiskServiceV1Beta1Client.Create();
            // Initialize request argument(s)
            ThreatType threatType   = ThreatType.Unspecified;
            ByteString versionToken = ByteString.Empty;

            ComputeThreatListDiffRequest.Types.Constraints constraints = new ComputeThreatListDiffRequest.Types.Constraints();
            // Make the request
            ComputeThreatListDiffResponse response = webRiskServiceV1Beta1Client.ComputeThreatListDiff(threatType, versionToken, constraints);
            // End snippet
        }
コード例 #20
0
        /// <summary>
        ///     Restrict Updates.
        /// </summary>
        /// <param name="threatType">
        ///     A <see cref="ThreatType" /> identifying a <see cref="ThreatList" /> to restrict updates to.
        /// </param>
        /// <param name="platformType">
        ///     A <see cref="PlatformType" /> identifying a <see cref="ThreatList" /> to restrict updates to.
        /// </param>
        /// <param name="threatEntryType">
        ///     A <see cref="ThreatEntryType" /> identifying a <see cref="ThreatList" /> to restrict updates to.
        /// </param>
        /// <param name="updateConstraintsAction">
        ///     An action to create the <see cref="ThreatListUpdateConstraints" /> to apply when the
        ///     <see cref="ThreatList" /> identified by <paramref name="threatType" />,
        ///     <paramref name="platformType" />, and <paramref name="threatEntryType" /> is retrieved.
        /// </param>
        /// <returns>
        ///     This managed service builder.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        ///     Thrown if <paramref name="updateConstraintsAction" /> is a null reference.
        /// </exception>
        public ManagedBrowsingServiceBuilder RestrictUpdatesTo(ThreatType threatType, PlatformType platformType, ThreatEntryType threatEntryType, Func <ThreatListUpdateConstraintsBuilder, ThreatListUpdateConstraints> updateConstraintsAction)
        {
            Guard.ThrowIf(nameof(updateConstraintsAction), updateConstraintsAction).Null();

            // ...
            //
            // Throws an exception if the operation fails.
            var threatListUpdateConstraintsBuilder = ThreatListUpdateConstraints.Build();
            var threatListUpdateConstraints        = updateConstraintsAction(threatListUpdateConstraintsBuilder);

            this.RestrictUpdatesTo(threatType, platformType, threatEntryType, threatListUpdateConstraints);

            return(this);
        }
コード例 #21
0
 /// <summary>Snippet for SearchUris</summary>
 public void SearchUris()
 {
     // Snippet: SearchUris(string, IEnumerable<ThreatType>, CallSettings)
     // Create client
     WebRiskServiceV1Beta1Client webRiskServiceV1Beta1Client = WebRiskServiceV1Beta1Client.Create();
     // Initialize request argument(s)
     string uri = "";
     IEnumerable <ThreatType> threatTypes = new ThreatType[]
     {
         ThreatType.Unspecified,
     };
     // Make the request
     SearchUrisResponse response = webRiskServiceV1Beta1Client.SearchUris(uri, threatTypes);
     // End snippet
 }
コード例 #22
0
 /// <summary>Snippet for SearchHashes</summary>
 public void SearchHashes()
 {
     // Snippet: SearchHashes(ByteString, IEnumerable<ThreatType>, CallSettings)
     // Create client
     WebRiskServiceV1Beta1Client webRiskServiceV1Beta1Client = WebRiskServiceV1Beta1Client.Create();
     // Initialize request argument(s)
     ByteString hashPrefix = ByteString.Empty;
     IEnumerable <ThreatType> threatTypes = new ThreatType[]
     {
         ThreatType.Unspecified,
     };
     // Make the request
     SearchHashesResponse response = webRiskServiceV1Beta1Client.SearchHashes(hashPrefix, threatTypes);
     // End snippet
 }
コード例 #23
0
        public static int ThreatPoints(this ThreatType threatType)
        {
            switch (threatType)
            {
            case ThreatType.MinorExternal:
            case ThreatType.MinorInternal:
                return(1);

            case ThreatType.SeriousExternal:
            case ThreatType.SeriousInternal:
                return(2);

            default:
                throw new InvalidOperationException();
            }
        }
コード例 #24
0
        private void CreateGenerationRule([NotNull] ThreatModel model,
                                          [NotNull] ThreatType source, [NotNull] IThreatType target)
        {
            SelectionRuleNode include = AnalyzeGenerationRule(model, target.Model, source.IncludeFilter);
            SelectionRuleNode exclude = AnalyzeGenerationRule(model, target.Model, source.ExcludeFilter);
            SelectionRule     rule    = null;

            var andNode = new AndRuleNode()
            {
                Name = "AND"
            };

            if (include != null)
            {
                andNode.Children.Add(include);
            }

            if (exclude != null)
            {
                andNode.Children.Add(new NotRuleNode()
                {
                    Name  = "NOT",
                    Child = exclude
                });
            }

            if (andNode.Children.Any())
            {
                andNode.Children.Add(new BooleanRuleNode("Out of Scope", Resources.DefaultNamespace, Resources.TmtFlowPropertySchema, false)
                {
                    Scope = AutoThreatGeneration.Engine.Scope.Object
                });

                rule = new SelectionRule()
                {
                    Root = andNode
                };

                var schemaManager = new AutoThreatGenPropertySchemaManager(target.Model);
                var propertyType  = schemaManager.GetPropertyType();
                var property      = target.GetProperty(propertyType) ?? target.AddProperty(propertyType, null);
                if (property is IPropertyJsonSerializableObject jsonSerializableObject)
                {
                    jsonSerializableObject.Value = rule;
                }
            }
        }
コード例 #25
0
        /// <summary>Snippet for ComputeThreatListDiffAsync</summary>
        public async Task ComputeThreatListDiffAsync()
        {
            // Snippet: ComputeThreatListDiffAsync(ThreatType, ByteString, ComputeThreatListDiffRequest.Types.Constraints, CallSettings)
            // Additional: ComputeThreatListDiffAsync(ThreatType, ByteString, ComputeThreatListDiffRequest.Types.Constraints, CancellationToken)
            // Create client
            WebRiskServiceV1Beta1Client webRiskServiceV1Beta1Client = await WebRiskServiceV1Beta1Client.CreateAsync();

            // Initialize request argument(s)
            ThreatType threatType   = ThreatType.Unspecified;
            ByteString versionToken = ByteString.Empty;

            ComputeThreatListDiffRequest.Types.Constraints constraints = new ComputeThreatListDiffRequest.Types.Constraints();
            // Make the request
            ComputeThreatListDiffResponse response = await webRiskServiceV1Beta1Client.ComputeThreatListDiffAsync(threatType, versionToken, constraints);

            // End snippet
        }
コード例 #26
0
        private void SetThreatPickerItemSource(ThreatType threatType)
        {
            NewThreatPicker.ItemsSource = threatsByType[threatType];
            switch (threatType)
            {
            case ThreatType.MinorExternal:
            case ThreatType.SeriousExternal:
                NewThreatZonePicker.IsEnabled = true;
                NewThreatZonePicker.Text      = "";
                break;

            case ThreatType.MinorInternal:
            case ThreatType.SeriousInternal:
                NewThreatZonePicker.IsEnabled = false;
                NewThreatZonePicker.Text      = "internal";
                break;
            }
        }
コード例 #27
0
        /// <summary>Snippet for SearchHashesAsync</summary>
        public async Task SearchHashesAsync()
        {
            // Snippet: SearchHashesAsync(ByteString, IEnumerable<ThreatType>, CallSettings)
            // Additional: SearchHashesAsync(ByteString, IEnumerable<ThreatType>, CancellationToken)
            // Create client
            WebRiskServiceV1Beta1Client webRiskServiceV1Beta1Client = await WebRiskServiceV1Beta1Client.CreateAsync();

            // Initialize request argument(s)
            ByteString hashPrefix = ByteString.Empty;
            IEnumerable <ThreatType> threatTypes = new ThreatType[]
            {
                ThreatType.Unspecified,
            };
            // Make the request
            SearchHashesResponse response = await webRiskServiceV1Beta1Client.SearchHashesAsync(hashPrefix, threatTypes);

            // End snippet
        }
コード例 #28
0
        /// <summary>Snippet for SearchUrisAsync</summary>
        public async Task SearchUrisAsync()
        {
            // Snippet: SearchUrisAsync(string, IEnumerable<ThreatType>, CallSettings)
            // Additional: SearchUrisAsync(string, IEnumerable<ThreatType>, CancellationToken)
            // Create client
            WebRiskServiceV1Beta1Client webRiskServiceV1Beta1Client = await WebRiskServiceV1Beta1Client.CreateAsync();

            // Initialize request argument(s)
            string uri = "";
            IEnumerable <ThreatType> threatTypes = new ThreatType[]
            {
                ThreatType.Unspecified,
            };
            // Make the request
            SearchUrisResponse response = await webRiskServiceV1Beta1Client.SearchUrisAsync(uri, threatTypes);

            // End snippet
        }
コード例 #29
0
ファイル: ThreatFactory.cs プロジェクト: AptusLite/ShapeWars
        public static Threat GetThreat(ThreatType threatType, Action <Threat> action)
        {
            switch (threatType)
            {
            case ThreatType.PULSE:
            {
                return(new RectanglePulse(action));
            }

            case ThreatType.YIN_AND_YANG:
            {
                return(new YinAndYang(action));
            }

            case ThreatType.RECTANGLE:
            default:
            {
                return(new Rectangle(action));
            }
            }
        }
コード例 #30
0
ファイル: ThreatFactory.cs プロジェクト: rbaker26/SAP1EMU
        public static Threat GetThreat(ThreatType threatType)
        {
            switch (threatType)
            {
            case ThreatType.Xss:
                return(new Threat()
                {
                    Id = (int)ThreatType.Xss,
                    Description = "Xss"
                });

            case ThreatType.SqlInjection:
                return(new Threat()
                {
                    Id = (int)ThreatType.SqlInjection,
                    Description = "Sql Injection"
                });

            case ThreatType.CSRF:
                return(new Threat()
                {
                    Id = (int)ThreatType.CSRF,
                    Description = "Cross-Site Request Forgery"
                });

            case ThreatType.Ddos:
                return(new Threat()
                {
                    Id = (int)ThreatType.Ddos,
                    Description = "Ddos"
                });

            default:
                return(new Threat()
                {
                    Id = (int)ThreatType.Unknown,
                    Description = "Unknown"
                });
            }
        }
コード例 #31
0
        /// <summary>
        ///     Create a Full Hash Query.
        /// </summary>
        /// <param name="threatType">
        ///     A <see cref="ThreatType" /> identifying the <see cref="ThreatList" /> to query.
        /// </param>
        /// <param name="platformType">
        ///     A <see cref="PlatformType" /> identifying the <see cref="ThreatList" /> to query.
        /// </param>
        /// <param name="threatEntryType">
        ///     A <see cref="ThreatEntryType" /> identifying the <see cref="ThreatList" /> to query.
        /// </param>
        /// <param name="threatListState">
        ///     The state, formatted as a hexadecimal encoded string, of the <see cref="ThreatList" /> identified by
        ///     <paramref name="threatType" />, <paramref name="platformType" />, and
        ///     <paramref name="threatEntryType" />.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        ///     Thrown if <paramref name="threatListState" /> is a null reference.
        /// </exception>
        /// <exception cref="System.FormatException">
        ///     Thrown if <paramref name="threatListState" /> is not hexadecimal encoded.
        /// </exception>
        public FullHashQuery(ThreatType threatType, PlatformType platformType, ThreatEntryType threatEntryType, string threatListState)
        {
            this.ThreatListDescriptor = new ThreatListDescriptor(threatType, platformType, threatEntryType);
            this.ThreatListState      = CreateThreatListState(threatListState);

            // <summary>
            //      Create Threat List State.
            // </summary>
            string CreateThreatListState(string cThreatListState)
            {
                // ...
                //
                // Throws an exception if the operation fails.
                var cIsThreatListStateHexadecimalEncoded = cThreatListState.IsHexadecimalEncoded();

                if (!cIsThreatListStateHexadecimalEncoded)
                {
                    var cDetailMessage = $"A threat list state ({cThreatListState}) is not hexadecimal encoded.";
                    throw new FormatException(cDetailMessage);
                }

                return(cThreatListState);
            }
        }
コード例 #32
0
 internal Sabotage(ThreatType threatType, ThreatDifficulty threatDifficulty, StationLocation currentStation, PlayerActionType actionType, CyberGremlin cyberGremlin)
     : base(threatType, threatDifficulty, 1, 0, currentStation, actionType)
 {
     Parent = cyberGremlin;
 }
コード例 #33
0
ファイル: LevelFile.cs プロジェクト: techmatt/GL2019
 public LevelThreatInfo(ThreatType _type, double _frequency)
 {
     type      = _type;
     frequency = _frequency;
 }
コード例 #34
0
 public static int GetPointsForDefeating(ThreatType type, ThreatDifficulty difficulty)
 {
     return GetPointsForSurviving(type, difficulty) * 2;
 }
コード例 #35
0
 protected ExternalThreat(ThreatType type, ThreatDifficulty difficulty, int shields, int health, int speed, int timeAppears, ZoneLocation currentZone, ISittingDuck sittingDuck)
     : base(type, difficulty, health, speed, timeAppears, sittingDuck)
 {
     this.shields = shields;
     CurrentZone = currentZone;
 }
コード例 #36
0
 public static int GetPointsForSurviving(ThreatType type, ThreatDifficulty difficulty)
 {
     return PointsForSurviving[Tuple.Create(type, difficulty)];
 }
コード例 #37
0
 private void SetThreatPickerItemSource(ThreatType threatType)
 {
     NewThreatPicker.ItemsSource = threatsByType[threatType];
     switch (threatType)
     {
         case ThreatType.MinorExternal:
         case ThreatType.SeriousExternal:
             NewThreatZonePicker.IsEnabled = true;
             NewThreatZonePicker.Text = "";
             break;
         case ThreatType.MinorInternal:
         case ThreatType.SeriousInternal:
             NewThreatZonePicker.IsEnabled = false;
             NewThreatZonePicker.Text = "internal";
             break;
     }
 }