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

            return(new List <object>(actions));
        }
Exemple #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();
        }
Exemple #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);
     }
 }
Exemple #4
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);
        }
Exemple #5
0
 public string GetScheduledActionDetails(ScheduledAction scheduledAction)
 {
     using var client = SshManager.CreateSshClient(System);
     return(Screen.GetScreenOutput(client, scheduledAction));
 }
Exemple #6
0
 public void PreparePackagesActions(List <object> actions)
 {
     using var client = SshManager.CreateSshClient(System);
     PrepareActions.PreparePackageActions(client, actions);
 }
Exemple #7
0
 public SystemUpdateInfo GetInformationAboutSystemUpdate()
 {
     using var client = SshManager.CreateSshClient(System);
     return(SystemUpdate.GetUpdateInfo(client));
 }
Exemple #8
0
 public List <PackageInformation> GetListOfPackages()
 {
     using var client = SshManager.CreateSshClient(System);
     return(Audit.ListAllPackages(client));
 }