Exemple #1
0
        /// <summary>
        ///     Create a Threat Entry Type Model.
        /// </summary>
        /// <param name="this">
        ///     A <see cref="ThreatEntryType" />.
        /// </param>
        /// <returns>
        ///     A string identifying a <see cref="ThreatEntryType" />.
        /// </returns>
        internal static string AsThreatEntryTypeModel(this ThreatEntryType @this)
        {
            string threatEntryTypeModel;

            switch (@this)
            {
            case ThreatEntryType.Executable:
                threatEntryTypeModel = "EXECUTABLE";
                break;

            case ThreatEntryType.IpAddressRange:
                threatEntryTypeModel = "IP_RANGE";
                break;

            case ThreatEntryType.Unknown:
                threatEntryTypeModel = "THREAT_ENTRY_TYPE_UNSPECIFIED";
                break;

            case ThreatEntryType.Url:
                threatEntryTypeModel = "URL";
                break;

            default:
                threatEntryTypeModel = "THREAT_ENTRY_TYPE_UNSPECIFIED";
                break;
            }

            return(threatEntryTypeModel);
        }
Exemple #2
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);
            }
        }
Exemple #3
0
 /// <summary>
 ///     Set Threat List Descriptor.
 /// </summary>
 /// <param name="threatType">
 ///     A <see cref="ThreatType" /> identifying the <see cref="ThreatList" /> to retrieve.
 /// </param>
 /// <param name="platformType">
 ///     A <see cref="PlatformType" /> identifying the <see cref="ThreatList" /> to retrieve.
 /// </param>
 /// <param name="threatEntryType">
 ///     A <see cref="ThreatEntryType" /> identifying the <see cref="ThreatList" /> to retrieve.
 /// </param>
 /// <returns>
 ///     This threat list update query builder.
 /// </returns>
 public ThreatListUpdateQueryBuilder SetThreatListDescriptor(ThreatType threatType, PlatformType platformType, ThreatEntryType threatEntryType)
 {
     this.ThreatListDescriptor = new ThreatListDescriptor(threatType, platformType, threatEntryType);
     return(this);
 }
        /// <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);
        }
        /// <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);
        }
 /// <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>
 /// <returns>
 ///     This managed service builder.
 /// </returns>
 public ManagedBrowsingServiceBuilder RestrictUpdatesTo(ThreatType threatType, PlatformType platformType, ThreatEntryType threatEntryType)
 {
     return(this.RestrictUpdatesTo(threatType, platformType, threatEntryType, ThreatListUpdateConstraints.Default));
 }
Exemple #7
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);
        }
 /// <summary>
 ///     Create a Threat List Descriptor.
 /// </summary>
 /// <param name="threatType">
 ///     A <see cref="ThreatType" /> identifying the threat list.
 /// </param>
 /// <param name="platformType">
 ///     A <see cref="PlatformType" /> identifying the threat list.
 /// </param>
 /// <param name="threatEntryType">
 ///     A <see cref="ThreatEntryType" /> identifying the threat list.
 /// </param>
 public ThreatListDescriptor(ThreatType threatType, PlatformType platformType, ThreatEntryType threatEntryType)
 {
     this.PlatformType    = platformType;
     this.ThreatEntryType = threatEntryType;
     this.ThreatType      = threatType;
 }