コード例 #1
0
        public static SecurityAction ToSecurityAction(this SecurityActionRequest securityActionRequest)
        {
            return(new SecurityAction()
            {
                Name = securityActionRequest?.Name,
                ActionReason = securityActionRequest?.Reason?.Comment,
                Parameters = new List <KeyValuePair>()
                {
                    new KeyValuePair()
                    {
                        Name = "AlertId", Value = securityActionRequest?.Reason?.AlertId
                    },
                    new KeyValuePair()
                    {
                        Name = "targetName", Value = securityActionRequest?.Target?.Name,
                    },
                    new KeyValuePair()
                    {
                        Name = "targetValue", Value = securityActionRequest?.Target?.Value,
                    }
                },

                VendorInformation = new SecurityVendorInformation()
                {
                    Provider = securityActionRequest?.Vendor,
                    Vendor = "Microsoft"
                },

                User = securityActionRequest?.User,

                LastActionDateTime = DateTimeOffset.UtcNow,
                CreatedDateTime = DateTimeOffset.UtcNow
            });
        }
コード例 #2
0
        public async Task <ActionResult> AddAction([FromBody] SecurityActionRequest securityActionRequest)
        {
            try
            {
                var token = string.Empty;

                if (Request.Headers.ContainsKey("Authorization"))
                {
                    token = Request.Headers["Authorization"].ToString()?.Split(" ")?[1];
                }

                _graphService = _graphServiceProvider.GetService(token);
                var securityActions = await _graphService.AddSecurityActionsAsync(securityActionRequest.ToSecurityAction());

                return(Ok(securityActions));
            }
            catch (Exception exception)
            {
                return(BadRequest(exception.Message));
            }
        }