Esempio n. 1
0
        public List <object> GetPackagesActions()
        {
            using var client = SshManager.CreateSshClient(System);
            var actions = ActionsProvider.GetPackagesActions(client, false);

            return(new List <object>(actions));
        }
Esempio n. 2
0
        public void SetupSystem()
        {
            using var sshClient    = SshManager.CreateSshClient(System);
            using var keyGenerator = new SshKeyGenerator(4096);

            Setup.SetupPortCollection(sshClient, keyGenerator.ToRfcPublicKey(Setup.Username));

            System.SshLogin        = Setup.Username;
            System.OneTimePassword = null;
            System.SshPrivateKey   = keyGenerator.ToPrivateKey();
        }
Esempio n. 3
0
 public void ExecuteScheduledAction(ScheduledAction scheduledAction)
 {
     using var client = SshManager.CreateSshClient(System);
     if (scheduledAction.ScheduledActionType == ScheduledActionType.Packages)
     {
         Packages.UpdatePackages(client, scheduledAction);
     }
     else if (scheduledAction.ScheduledActionType == ScheduledActionType.System)
     {
         SystemUpdate.ExecuteUpdate(client, scheduledAction);
     }
 }
Esempio n. 4
0
        public void SetUp()
        {
            gameletClient        = Substitute.For <IGameletClient>();
            gameletClientFactory = Substitute.For <GameletClient.Factory>();
            gameletClientFactory.Create(Arg.Any <ICloudRunner>()).Returns(gameletClient);

            cloudRunner         = Substitute.For <ICloudRunner>();
            sshKeyLoader        = Substitute.For <ISshKeyLoader>();
            sshKnownHostsWriter = Substitute.For <ISshKnownHostsWriter>();
            remoteCommand       = Substitute.For <IRemoteCommand>();

            sshManager = new SshManager(gameletClientFactory, cloudRunner, sshKeyLoader,
                                        sshKnownHostsWriter, remoteCommand);
        }
Esempio n. 5
0
        // Creates a DebugPortSupplier.  This will be invoked by Visual Studio based on this class
        // Guid being in the registry.
        public DebugPortSupplier()
        {
            // Factory creation for the PortSupplier entry point.
            var serviceManager        = new ServiceManager();
            IExtensionOptions options =
                ((YetiVSIService)serviceManager.RequireGlobalService(typeof(YetiVSIService)))
                .Options;
            var taskContext               = serviceManager.GetJoinableTaskContext();
            var debugPropertyFactory      = new DebugProperty.Factory();
            var debugProgramFactory       = new DebugProgram.Factory(debugPropertyFactory, options);
            var debugProcessFactory       = new DebugProcess.Factory(debugProgramFactory);
            var managedProcessFactory     = new ManagedProcess.Factory();
            var processListRequestFactory = new ProcessListRequest.Factory(managedProcessFactory);
            var jsonUtil                = new JsonUtil();
            var sdkConfigFactory        = new SdkConfig.Factory(jsonUtil);
            var credentialConfigFactory = new CredentialConfig.Factory(jsonUtil);
            var accountOptionLoader     = new VsiAccountOptionLoader(options);
            var credentialManager       =
                new CredentialManager(credentialConfigFactory, accountOptionLoader);

            _developerAccount = credentialManager.LoadAccount();
            _dialogUtil       = new DialogUtil();
            var progressDialogFactory = new ProgressDialog.Factory();

            _cancelableTaskFactory = new CancelableTask.Factory(taskContext, progressDialogFactory);
            var cloudConnection = new CloudConnection();

            // NOTE: this CloudRunner is re-used for all subsequent Attach to Process windows.
            _cloudRunner = new CloudRunner(sdkConfigFactory, credentialManager, cloudConnection,
                                           new GgpSDKUtil());
            var sshKeyLoader        = new SshKeyLoader(managedProcessFactory);
            var sshKnownHostsWriter = new SshKnownHostsWriter();

            _gameletClientFactory = new GameletClient.Factory();
            var sshManager =
                new SshManager(_gameletClientFactory, _cloudRunner, sshKeyLoader,
                               sshKnownHostsWriter, new RemoteCommand(managedProcessFactory));

            _metrics          = (IMetrics)serviceManager.RequireGlobalService(typeof(SMetrics));
            _debugPortFactory = new DebugPort.Factory(
                debugProcessFactory, processListRequestFactory, _cancelableTaskFactory, _dialogUtil,
                sshManager, _metrics, _developerAccount);
        }
Esempio n. 6
0
        public Dictionary <string, string> GetSystemInformation()
        {
            using var sshClient = SshManager.CreateSshClient(System);
            using var dbContext = DbContextFactory.CreateDbContext();
            var hasNotFinishedScheduledActions = dbContext.ScheduledActions.SystemHasNotFinishedUpdate(System);

            var packagesActions = ActionsProvider.GetPackagesActions(sshClient, hasNotFinishedScheduledActions).ToList();

            var vulnerablePackages = Audit.GetVulnerablePackages(sshClient);
            var systemUpdateInfo   = SystemUpdate.GetUpdateInfo(sshClient);

            System.PackageActions           = packagesActions.Count;
            System.HasSystemUpdateAvailable = systemUpdateInfo.HasUpdate;
            System.UpdatesFetchedAt         = DateTime.Now;

            if (!string.IsNullOrEmpty(vulnerablePackages?.Trim()))
            {
                System.AddProblem("Found vulnerable packages!!!");
            }

            var result = new Dictionary <string, string>
            {
                { "Hostname", new Hostname().GetHostname(sshClient) },
                { "Logged users", Uptime.CurrentLoggedUsers(sshClient) },
                {
                    "Kernel\nUserland\nRunning",
                    $"{SystemVersion.GetKernel(sshClient)}{SystemVersion.GetUserland(sshClient)}{SystemVersion.GetRunning(sshClient)}"
                },
                { "Vulnerable packages", vulnerablePackages },
                { $"Packages actions ({System.PackageActions})", string.Join("\n", packagesActions) },
            };

            if (System.HasSystemUpdateAvailable)
            {
                result.Add("Has system update", System.HasSystemUpdateAvailable.ToString());
            }

            return(result);
        }
Esempio n. 7
0
 public string GetScheduledActionDetails(ScheduledAction scheduledAction)
 {
     using var client = SshManager.CreateSshClient(System);
     return(Screen.GetScreenOutput(client, scheduledAction));
 }
Esempio n. 8
0
 public void PreparePackagesActions(List <object> actions)
 {
     using var client = SshManager.CreateSshClient(System);
     PrepareActions.PreparePackageActions(client, actions);
 }
Esempio n. 9
0
 public SystemUpdateInfo GetInformationAboutSystemUpdate()
 {
     using var client = SshManager.CreateSshClient(System);
     return(SystemUpdate.GetUpdateInfo(client));
 }
Esempio n. 10
0
 public List <PackageInformation> GetListOfPackages()
 {
     using var client = SshManager.CreateSshClient(System);
     return(Audit.ListAllPackages(client));
 }