Ejemplo n.º 1
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ListFindingsResponse response = new ListFindingsResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("findingIds", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <string, StringUnmarshaller>(StringUnmarshaller.Instance);
                    response.FindingIds = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("nextToken", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextToken = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Ejemplo n.º 2
0
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonInspectorConfig config = new AmazonInspectorConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonInspectorClient client = new AmazonInspectorClient(creds, config);

            ListFindingsResponse resp = new ListFindingsResponse();

            do
            {
                ListFindingsRequest req = new ListFindingsRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

                resp = client.ListFindings(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.FindingArns)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
        static void Main(string[] args)
        {
            String detectorId = "cdc02bexample0a8882c959g3e95c24b"; // set your detector id

            //instantiate a FindingCriteria obj
            FindingCriteria criteria = new FindingCriteria();

            //instantiate a Condtion obj
            Condition condition = new Condition();

            //set the comparison operation e.g. "EQ" value that your condition is looking for
            //as well as add the values that you are looking for to the List<String>
            condition.Eq.Add("Recon:EC2/PortProbeUnprotectedPort"); //include results for this value
            condition.Eq.Add("Recon:EC2/Portscan");                 //include results for this value

            //add your Key and condition to your criteria obj
            criteria.Criterion.Add("type", condition);

            // instantiate a GD Service client ob
            using (IAmazonGuardDuty gdClient = new AmazonGuardDutyClient())
            {
                ListFindingsRequest request = new ListFindingsRequest
                {
                    DetectorId      = detectorId,
                    FindingCriteria = criteria
                };

                // Make GD service call and get back the response.
                ListFindingsResponse response = gdClient.ListFindings(request);

                foreach (String findingId in response.FindingIds)
                {
                    Console.WriteLine(findingId.ToString());
                }

                Console.ReadLine();
            }
        }