示例#1
0
    def test_run_command_new_credential(self):
        ospd_ssh.paramiko = fakeparamiko

        daemon = OSPDaemonSimpleSSH('cert', 'key', 'ca', '10')

        cred_dict = {
            'ssh': {
                'type': 'up',
                'password': '******',
                'port': '22',
                'username': '******',
            },
            'smb': {
                'type': 'up',
                'password': '******',
                'username': '******'
            },
        }

        scanid = daemon.create_scan(
            None,
            [['host.example.com', '80, 443', cred_dict, '', '']],
            dict(port=5, ssh_timeout=15),
            '',
        )
        res = daemon.run_command(scanid, 'host.example.com', 'cat /etc/passwd')

        self.assertIsInstance(res, list)
        self.assertEqual(commands, ['nice -n 10 cat /etc/passwd'])
示例#2
0
 def testRunCommandNoCredential(self):
     ospd_ssh.paramiko = fakeparamiko
     daemon = OSPDaemonSimpleSSH('cert', 'key', 'ca')
     scanid = daemon.create_scan(None, [
         ['host.example.com', '80, 443', ''],
     ], '', dict(port=5, ssh_timeout=15), '')
     self.assertRaises(ValueError, daemon.run_command, scanid,
                       'host.example.com', 'cat /etc/passwd')
示例#3
0
 def testRunCommand(self):
     ospd_ssh.paramiko = fakeparamiko
     daemon = OSPDaemonSimpleSSH('cert', 'key', 'ca')
     scanid = daemon.create_scan(None, 'host.example.com', '80, 443',
                                 dict(port=5, ssh_timeout=15,
                                      username='******', password='******'))
     res = daemon.run_command(scanid, 'host.example.com', 'cat /etc/passwd')
     self.assertTrue(isinstance(res, list))
     self.assertEqual(commands, ['cat /etc/passwd'])
示例#4
0
    def test_run_command_no_credential(self):
        ospd_ssh.paramiko = fakeparamiko

        daemon = OSPDaemonSimpleSSH('cert', 'key', 'ca', '10')
        scanid = daemon.create_scan(
            None,
            [['host.example.com', '80, 443', '', '', '']],
            dict(port=5, ssh_timeout=15),
            '',
        )

        with self.assertRaises(ValueError):
            daemon.run_command(scanid, 'host.example.com', 'cat /etc/passwd')
示例#5
0
    def test_run_command(self):
        ospd_ssh.paramiko = fakeparamiko
        daemon = OSPDaemonSimpleSSH('cert', 'key', 'ca', '10')
        scanid = daemon.create_scan(
            None,
            [['host.example.com', '80, 443', '', '', '']],
            dict(port=5, ssh_timeout=15, username_password='******'),
            '',
        )

        res = daemon.run_command(scanid, 'host.example.com', 'cat /etc/passwd')

        self.assertIsInstance(res, list)
        self.assertEqual(commands, ['nice -n 10 cat /etc/passwd'])
示例#6
0
    def testRunCommandNewCredential(self):
        ospd_ssh.paramiko = fakeparamiko
        daemon = OSPDaemonSimpleSSH('cert', 'key', 'ca')

        cred_dict = {
            'ssh': {
                'type': 'up',
                'password': '******',
                'port': '22',
                'username': '******'
            },
            'smb': {
                'type': 'up',
                'password': '******',
                'username': '******'
            }
        }

        scanid = daemon.create_scan(None, [
            ['host.example.com', '80, 443', cred_dict],
        ], '', dict(port=5, ssh_timeout=15), '')
        res = daemon.run_command(scanid, 'host.example.com', 'cat /etc/passwd')
        self.assertTrue(isinstance(res, list))
        self.assertEqual(commands, ['cat /etc/passwd'])
示例#7
0
    def test_no_paramiko(self):
        ospd_ssh.paramiko = None

        with self.assertRaises(ImportError):
            OSPDaemonSimpleSSH()