def crawl(
         self,
         root_dir='/',
         exclude_dirs=[
             '/dev',
             '/proc',
             '/mnt',
             '/tmp',
             '/var/cache',
             '/usr/share/man',
             '/usr/share/doc',
             '/usr/share/mime'],
         known_config_files=[
             '/etc/passwd',
             '/etc/group',
             '/etc/hosts',
             '/etc/hostname',
             '/etc/mtab',
             '/etc/fstab',
             '/etc/aliases',
             '/etc/ssh/ssh_config',
             '/etc/ssh/sshd_config',
             '/etc/sudoers'],
         discover_config_files=False,
         **kwargs):
     return crawl_config_files(
         root_dir=root_dir,
         exclude_dirs=exclude_dirs,
         known_config_files=known_config_files,
         discover_config_files=discover_config_files)
    def crawl(
            self,
            container_id=None,
            avoid_setns=False,
            root_dir='/',
            exclude_dirs=[
                '/dev',
                '/proc',
                '/mnt',
                '/tmp',
                '/var/cache',
                '/usr/share/man',
                '/usr/share/doc',
                '/usr/share/mime'],
            known_config_files=[
                '/etc/passwd',
                '/etc/group',
                '/etc/hosts',
                '/etc/hostname',
                '/etc/mtab',
                '/etc/fstab',
                '/etc/aliases',
                '/etc/ssh/ssh_config',
                '/etc/ssh/sshd_config',
                '/etc/sudoers'],
            discover_config_files=False,
            **kwargs):
        inspect = utils.dockerutils.exec_dockerinspect(container_id)
        state = inspect['State']
        pid = str(state['Pid'])
        logger.debug('Crawling config for container %s' % container_id)

        if avoid_setns:
            rootfs_dir = utils.dockerutils.get_docker_container_rootfs_path(
                container_id)
            exclude_dirs = [utils.misc.join_abs_paths(rootfs_dir, d)
                            for d in exclude_dirs]
            return crawl_config_files(
                root_dir=utils.misc.join_abs_paths(rootfs_dir, root_dir),
                exclude_dirs=exclude_dirs,
                root_dir_alias=root_dir,
                known_config_files=known_config_files,
                discover_config_files=discover_config_files)
        else:  # in all other cases, including wrong mode set
            return run_as_another_namespace(pid,
                                            ['mnt'],
                                            crawl_config_files,
                                            root_dir,
                                            exclude_dirs,
                                            None,
                                            known_config_files,
                                            discover_config_files)
Beispiel #3
0
 def crawl(self,
           root_dir='/',
           exclude_dirs=[
               '/dev', '/proc', '/mnt', '/tmp', '/var/cache',
               '/usr/share/man', '/usr/share/doc', '/usr/share/mime'
           ],
           known_config_files=[
               '/etc/passwd', '/etc/group', '/etc/hosts', '/etc/hostname',
               '/etc/mtab', '/etc/fstab', '/etc/aliases',
               '/etc/ssh/ssh_config', '/etc/ssh/sshd_config', '/etc/sudoers'
           ],
           discover_config_files=False,
           **kwargs):
     return crawl_config_files(root_dir=root_dir,
                               exclude_dirs=exclude_dirs,
                               known_config_files=known_config_files,
                               discover_config_files=discover_config_files)
Beispiel #4
0
    def crawl(self,
              container_id=None,
              avoid_setns=False,
              root_dir='/',
              exclude_dirs=[
                  '/dev', '/proc', '/mnt', '/tmp', '/var/cache',
                  '/usr/share/man', '/usr/share/doc', '/usr/share/mime'
              ],
              known_config_files=[
                  '/etc/passwd', '/etc/group', '/etc/hosts', '/etc/hostname',
                  '/etc/mtab', '/etc/fstab', '/etc/aliases',
                  '/etc/ssh/ssh_config', '/etc/ssh/sshd_config', '/etc/sudoers'
              ],
              discover_config_files=False,
              **kwargs):
        inspect = utils.dockerutils.exec_dockerinspect(container_id)
        state = inspect['State']
        pid = str(state['Pid'])
        logger.debug('Crawling config for container %s' % container_id)

        if avoid_setns:
            rootfs_dir = utils.dockerutils.get_docker_container_rootfs_path(
                container_id)
            exclude_dirs = [
                utils.misc.join_abs_paths(rootfs_dir, d) for d in exclude_dirs
            ]
            return crawl_config_files(
                root_dir=utils.misc.join_abs_paths(rootfs_dir, root_dir),
                exclude_dirs=exclude_dirs,
                root_dir_alias=root_dir,
                known_config_files=known_config_files,
                discover_config_files=discover_config_files)
        else:  # in all other cases, including wrong mode set
            return run_as_another_namespace(pid, ['mnt'], crawl_config_files,
                                            root_dir, exclude_dirs, None,
                                            known_config_files,
                                            discover_config_files)