/// <summary>Snippet for SearchHashes</summary>
 public void SearchHashes_RequestObject()
 {
     // Snippet: SearchHashes(SearchHashesRequest,CallSettings)
     // Create client
     WebRiskServiceV1Beta1Client webRiskServiceV1Beta1Client = WebRiskServiceV1Beta1Client.Create();
     // Initialize request argument(s)
     SearchHashesRequest request = new SearchHashesRequest();
     // Make the request
     SearchHashesResponse response = webRiskServiceV1Beta1Client.SearchHashes(request);
     // End snippet
 }
 /// <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 List <ThreatType>();
     // Make the request
     SearchHashesResponse response = webRiskServiceV1Beta1Client.SearchHashes(hashPrefix, threatTypes);
     // End snippet
 }
 /// <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 List <ThreatType>();
     // Make the request
     SearchUrisResponse response = webRiskServiceV1Beta1Client.SearchUris(uri, threatTypes);
     // End snippet
 }
예제 #4
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
        }
        /// <summary>Snippet for SearchHashesAsync</summary>
        public async Task SearchHashesAsync_RequestObject()
        {
            // Snippet: SearchHashesAsync(SearchHashesRequest,CallSettings)
            // Additional: SearchHashesAsync(SearchHashesRequest,CancellationToken)
            // Create client
            WebRiskServiceV1Beta1Client webRiskServiceV1Beta1Client = await WebRiskServiceV1Beta1Client.CreateAsync();

            // Initialize request argument(s)
            SearchHashesRequest request = new SearchHashesRequest();
            // Make the request
            SearchHashesResponse response = await webRiskServiceV1Beta1Client.SearchHashesAsync(request);

            // End snippet
        }
 /// <summary>Snippet for ComputeThreatListDiff</summary>
 public void ComputeThreatListDiff_RequestObject()
 {
     // Snippet: ComputeThreatListDiff(ComputeThreatListDiffRequest,CallSettings)
     // Create client
     WebRiskServiceV1Beta1Client webRiskServiceV1Beta1Client = WebRiskServiceV1Beta1Client.Create();
     // Initialize request argument(s)
     ComputeThreatListDiffRequest request = new ComputeThreatListDiffRequest
     {
         ThreatType  = ThreatType.Unspecified,
         Constraints = new ComputeThreatListDiffRequest.Types.Constraints(),
     };
     // Make the request
     ComputeThreatListDiffResponse response = webRiskServiceV1Beta1Client.ComputeThreatListDiff(request);
     // End snippet
 }
        /// <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 List <ThreatType>();
            // Make the request
            SearchHashesResponse response = await webRiskServiceV1Beta1Client.SearchHashesAsync(hashPrefix, threatTypes);

            // End snippet
        }
        /// <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 List <ThreatType>();
            // Make the request
            SearchUrisResponse response = await webRiskServiceV1Beta1Client.SearchUrisAsync(uri, threatTypes);

            // End snippet
        }
예제 #9
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
        }
예제 #10
0
 /// <summary>Snippet for SearchHashes</summary>
 public void SearchHashes_RequestObject()
 {
     // Snippet: SearchHashes(SearchHashesRequest, CallSettings)
     // Create client
     WebRiskServiceV1Beta1Client webRiskServiceV1Beta1Client = WebRiskServiceV1Beta1Client.Create();
     // Initialize request argument(s)
     SearchHashesRequest request = new SearchHashesRequest
     {
         HashPrefix  = ByteString.Empty,
         ThreatTypes =
         {
             ThreatType.Unspecified,
         },
     };
     // Make the request
     SearchHashesResponse response = webRiskServiceV1Beta1Client.SearchHashes(request);
     // End snippet
 }
        /// <summary>Snippet for ComputeThreatListDiffAsync</summary>
        public async Task ComputeThreatListDiffAsync_RequestObject()
        {
            // Snippet: ComputeThreatListDiffAsync(ComputeThreatListDiffRequest,CallSettings)
            // Additional: ComputeThreatListDiffAsync(ComputeThreatListDiffRequest,CancellationToken)
            // Create client
            WebRiskServiceV1Beta1Client webRiskServiceV1Beta1Client = await WebRiskServiceV1Beta1Client.CreateAsync();

            // Initialize request argument(s)
            ComputeThreatListDiffRequest request = new ComputeThreatListDiffRequest
            {
                ThreatType  = ThreatType.Unspecified,
                Constraints = new ComputeThreatListDiffRequest.Types.Constraints(),
            };
            // Make the request
            ComputeThreatListDiffResponse response = await webRiskServiceV1Beta1Client.ComputeThreatListDiffAsync(request);

            // End snippet
        }
        public void SearchUri()
        {
            // Sample: SearchUris
            WebRiskServiceV1Beta1Client client   = WebRiskServiceV1Beta1Client.Create();
            SearchUrisResponse          response = client.SearchUris(
                "http://testsafebrowsing.appspot.com/s/malware.html",
                new[] { ThreatType.Malware, ThreatType.SocialEngineering });
            ThreatUri threat = response.Threat;

            if (threat == null)
            {
                Console.WriteLine("No threat detected");
            }
            else
            {
                Console.WriteLine($"Threat types: {string.Join(", ", threat.ThreatTypes)}");
                Console.WriteLine($"Cache lifetime expiry: {threat.ExpireTime}");
            }
            // End sample
        }
예제 #13
0
        /// <summary>Snippet for SearchHashesAsync</summary>
        public async Task SearchHashesAsync_RequestObject()
        {
            // Snippet: SearchHashesAsync(SearchHashesRequest, CallSettings)
            // Additional: SearchHashesAsync(SearchHashesRequest, CancellationToken)
            // Create client
            WebRiskServiceV1Beta1Client webRiskServiceV1Beta1Client = await WebRiskServiceV1Beta1Client.CreateAsync();

            // Initialize request argument(s)
            SearchHashesRequest request = new SearchHashesRequest
            {
                HashPrefix  = ByteString.Empty,
                ThreatTypes =
                {
                    ThreatType.Unspecified,
                },
            };
            // Make the request
            SearchHashesResponse response = await webRiskServiceV1Beta1Client.SearchHashesAsync(request);

            // End snippet
        }
        public void SearchHashes()
        {
            // Sample: SearchHashes
            WebRiskServiceV1Beta1Client client = WebRiskServiceV1Beta1Client.Create();
            ByteString           hashPrefix    = ByteString.CopyFrom(new byte[] { 0x5b, 0x0b, 0x89, 0x75 });
            SearchHashesResponse response      = client.SearchHashes(
                hashPrefix,
                new[] { ThreatType.Malware, ThreatType.SocialEngineering });

            if (response.NegativeExpireTime != null)
            {
                Console.WriteLine($"Cache expiry for negative response: {response.NegativeExpireTime}");
            }
            foreach (ThreatHash threat in response.Threats)
            {
                string hexHash = BitConverter.ToString(threat.Hash.ToByteArray()).Replace("-", "");
                Console.WriteLine($"Hash {hexHash}");
                Console.WriteLine($"Threat types: {string.Join(", ", threat.ThreatTypes)}");
                Console.WriteLine($"Cache lifetime expiry: {threat.ExpireTime}");
            }
            // End sample
        }