예제 #1
0
        public ActionResult ExecuteCommand(HomeModel model)
        {
            UpdateAvailableOptions(model);

            if (String.IsNullOrWhiteSpace(model.RelativePath))
            {
                model.RelativePath = String.Empty;
            }

            using (var client = new WhitelistExecuterClient())
            {
                ExecutionResult result;
                try
                {
                    _logger.InfoFormat("Executing command: {0} in {1}:{2}/{3}. User: {4}", model.Command, model.Target, model.BaseDir, model.RelativePath, WebSecurity.CurrentUserName);
                    result = client.APIs[model.Target].ExecuteCommand(model.BaseDir, model.Command, model.RelativePath);
                }
                catch (Exception e)
                {
                    model.Error = (e.InnerException ?? e).Message;
                    return(View("Index", model));
                }
                //.....ViewBag.ViewBag.mo
                model.LastCommandPath = Path.Combine(model.BaseDir, model.RelativePath);
                model.StandardOutput += result.StandardOutput.Trim();
                model.StandardError  += result.StandardError.Trim();
            }
            return(View("Index", model));
        }
예제 #2
0
        public ActionResult Index()
        {
            var targets    = WhitelistExecuterClient.GetEndpointNames();
            var targetName = targets.First();

            return(View("Index", CreateHomeModel()));
        }
예제 #3
0
        private static List <KeyValuePair <string, string[]> > GetPaths(string target)
        {
            List <KeyValuePair <string, string[]> > paths;

            if (WebSecurity.IsAuthenticated)
            {
                using (var client = new WhitelistExecuterClient())
                {
                    paths = client.APIs[target].GetPaths();
                }
            }
            else
            {
                paths = new List <KeyValuePair <string, string[]> >();
            }
            return(paths);
        }
예제 #4
0
 private static SelectListItem[] GetAvailableTargets()
 {
     return(ToSelectList(WhitelistExecuterClient.GetEndpointNames()));
 }