Esempio n. 1
0
    def __init__(self, debug):
        handlers = [

            ##### Notification API
            (r"/api/v1/notifications?", NotificationsHandler),
            (r"/api/v1/notification/([a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})?",
             NotificationHandler),
            (r"/api/v1/notifications/get_valid_fields/?",
             GetAllValidFieldsForNotifications),
            (r"/api/v1/permissions?", RetrieveValidPermissionsHandler),

            ##### RA Api
            (r"/api/ra/rd/password/?", SetPassword),
            (r"/api/ra/rd/([^/]+)/?", RDSession),
            (r"/ws/ra/status/?", RDStatusQueue),

            ##### MightyMouse API Handlers
            (r'/api/v1/relay/([A-Za-z0-9:,"_ ]+.*)?', RelayServerHandler),
            (r"/api/v1/relay", RelayServersHandler),

            ##### Os Apps API Handlers
            (r"/api/v1/app/os/([0-9A-Za-z]{64})?", AppIdOsAppsHandler),
            (r"/api/v1/app/os/([0-9A-Za-z]{64})/agents?",
             GetAgentsByAppIdHandler),
            (r"/api/v1/apps/os", OsAppsHandler),

            ##### Custom Apps API Handlers
            (r"/api/v1/app/custom/([a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})?",
             AppIdCustomAppsHandler),
            (r"/api/v1/app/custom/([a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})/agents?",
             GetAgentsByCustomAppIdHandler),
            (r"/api/v1/apps/custom?", CustomAppsHandler),
            (r"/api/v1/apps/custom/upload/finalize?",
             ThirdPartyPackageUploadHandler),
            (r"/api/v1/apps/custom/upload/data?", ThirdPartyUploadHandler),
            (r"/upload/package?", ThirdPartyPackageUploadHandler),
            (r"/api/v1/apps/custom/upload/uuid?", GetThirdPartyUuidHandler),

            ##### Supported Apps API Handlers
            (r"/api/v1/app/supported/([0-9A-Za-z]{64})?",
             AppIdSupportedAppsHandler),
            (r"/api/v1/app/supported/([0-9A-Za-z]{64})/agents?",
             GetAgentsBySupportedAppIdHandler),
            (r"/api/v1/apps/supported?", SupportedAppsHandler),

            ##### Agent Apps API Handlers
            (r"/api/v1/app/remediationvault/([0-9A-Za-z]{64})?",
             AppIdAgentAppsHandler),
            (r"/api/v1/app/remediationvault/([0-9A-Za-z]{64})/agents?",
             GetAgentsByAgentAppIdHandler),
            (r"/api/v1/apps/remediationvault?", AgentAppsHandler),

            ##### Dashboard API Handlers
            (r"/api/v1/dashboard/graphs/bar/severity?", CustomerSeverityHandler
             ),
            #(r"/api/v1/dashboard/graphs/linear/severity?",PackageSeverityOverTimeHandler),
            (r"/api/v1/dashboard/graphs/bar/stats_by_os?",
             CustomerStatsByOsHandler),
            (r"/api/v1/dashboard/graphs/column/range/apps/os?",
             OsAppsOverTimeHandler),
            (r"/api/v1/dashboard/widgets/unique_count?", WidgetHandler),
            (r"/api/v1/dashboard/widgets/top_needed?", TopAppsNeededHandler),
            (r"/api/v1/dashboard/widgets/recently_released?",
             RecentlyReleasedHandler),

            ##### Operations API Handlers
            (r"/api/v1/operations?", GetTransactionsHandler),
            (r"/api/v1/operation/([a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})?",
             OperationHandler),

            ##### Vulnerability API Handlers
            (r'/api/v1/vulnerability/os/([A-Za-z0-9_-]+)?', VulnIdHandler),
            (r'/api/v1/vulnerability/cve/(CVE-[0-9]+-[0-9]+)?', CveIdHandler),

            ##### File system access whitelist
            (r"/css/(.*?)", tornado.web.StaticFileHandler, {
                "path": os.path.join(VFENSE_WWW_PATH, "css")
            }),
            (r"/font/(.*?)", tornado.web.StaticFileHandler, {
                "path": os.path.join(VFENSE_WWW_PATH, "font")
            }),
            (r"/img/(.*?)", tornado.web.StaticFileHandler, {
                "path": os.path.join(VFENSE_WWW_PATH, "img")
            }),
            (r"/js/(.*?)", tornado.web.StaticFileHandler, {
                "path": os.path.join(VFENSE_WWW_PATH, "js")
            }),
            (r"/packages/*/(.*?)", tornado.web.StaticFileHandler, {
                "path": VFENSE_APP_PATH
            })
        ]

        core_loader = vFense_module_loader.CoreLoader()
        plugin_loader = vFense_module_loader.PluginsLoader()

        # TODO: check for colliding regex's from plugins
        handlers.extend(core_loader.get_core_web_api_handlers())
        handlers.extend(plugin_loader.get_plugins_web_api_handlers())

        settings = {
            "cookie_secret":
            base64.b64encode(uuid.uuid4().bytes + uuid.uuid4().bytes),
            "login_url":
            "/login",
        }
        self.scheduler = start_scheduler()
        initialize_indexes_and_create_tables()
        hierarchy_db.init()

        tornado.web.Application.__init__(self,
                                         handlers,
                                         template_path=VFENSE_TEMPLATE_PATH,
                                         debug=debug,
                                         **settings)
Esempio n. 2
0
from vFense.plugins.vuln.cve.parser import parse_cve_and_udpatedb
from vFense.plugins.vuln.windows.parser import parse_bulletin_and_updatedb
from vFense.plugins.vuln.ubuntu.parser import begin_usn_home_page_processing

from vFense.core.agent.agent_uptime_verifier import all_agent_status
from vFense.jobs.jobs import remove_expired_jobs_and_update_operations
from vFense.errorz.status_codes import SchedulerCodes

logging.config.fileConfig(VFENSE_LOGGING_CONFIG)
logger = logging.getLogger('admin_scheduler')
get_supported_apps()
#get_agents_apps()

if __name__ == '__main__':

    sched = start_scheduler(redis_db=11)
    jobstore_name = 'administrative'
    username='******'
    list_of_cron_jobs = [
        #{
        #    'name': 'get_supported_apps',
        #    'job': get_supported_apps,
        #    'hour': '0,6,12,18',
        #    'minute': 0,
        #    'max_instances': 1,
        #    'coalesce': True
        #},
        #{
        #    'name': 'get_agents_apps',
        #    'jobstore': jobstore_name,
        #    'job': get_agents_apps,
Esempio n. 3
0
from vFense.scheduler.jobManager import start_scheduler, job_exists, remove_job
from vFense.plugins.patching.apps.supported_apps.syncer import get_supported_apps
from vFense.plugins.vuln.cve.parser import parse_cve_and_udpatedb
from vFense.plugins.vuln.windows.parser import parse_bulletin_and_updatedb
from vFense.plugins.vuln.ubuntu.parser import begin_usn_home_page_processing

from vFense.core.agent.agent_uptime_verifier import all_agent_status
from vFense.jobs.jobs import remove_expired_jobs_and_update_operations
from vFense.errorz.status_codes import SchedulerCodes

logging.config.fileConfig(VFENSE_LOGGING_CONFIG)
logger = logging.getLogger('admin_scheduler')

if __name__ == '__main__':

    sched = start_scheduler(redis_db=11)
    jobstore_name = 'administrative'
    username='******'
    list_of_cron_jobs = [
        #{
        #    'name': 'get_supported_apps',
        #    'job': get_supported_apps,
        #    'hour': '0,6,12,18',
        #    'minute': 0,
        #    'max_instances': 1,
        #    'coalesce': True
        #},
        #{
        #    'name': 'get_agents_apps',
        #    'jobstore': jobstore_name,
        #    'job': get_agents_apps,
Esempio n. 4
0
    def __init__(self, debug):
        handlers = [

            ##### Notification API
            (r"/api/v1/notifications?", NotificationsHandler),
            (r"/api/v1/notification/([a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})?", NotificationHandler),
            (r"/api/v1/notifications/get_valid_fields/?",
                GetAllValidFieldsForNotifications),
            (r"/api/v1/permissions?", RetrieveValidPermissionsHandler),

            ##### RA Api
            (r"/api/ra/rd/password/?", SetPassword),
            (r"/api/ra/rd/([^/]+)/?", RDSession),
            (r"/ws/ra/status/?", RDStatusQueue),

            ##### MightyMouse API Handlers
            (r'/api/v1/relay/([A-Za-z0-9:,"_ ]+.*)?', RelayServerHandler),
            (r"/api/v1/relay", RelayServersHandler),

            ##### Os Apps API Handlers
            (r"/api/v1/app/os/([0-9A-Za-z]{64})?", AppIdOsAppsHandler),
            (r"/api/v1/app/os/([0-9A-Za-z]{64})/agents?", GetAgentsByAppIdHandler),
            (r"/api/v1/apps/os", OsAppsHandler),

            ##### Custom Apps API Handlers
            (r"/api/v1/app/custom/([a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})?", AppIdCustomAppsHandler),
            (r"/api/v1/app/custom/([a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})/agents?", GetAgentsByCustomAppIdHandler),
            (r"/api/v1/apps/custom?", CustomAppsHandler),

            (r"/api/v1/apps/custom/upload/finalize?", ThirdPartyPackageUploadHandler),
            (r"/api/v1/apps/custom/upload/data?",ThirdPartyUploadHandler),
            (r"/upload/package?",ThirdPartyPackageUploadHandler),
            (r"/api/v1/apps/custom/upload/uuid?", GetThirdPartyUuidHandler),

            ##### Supported Apps API Handlers
            (r"/api/v1/app/supported/([0-9A-Za-z]{64})?", AppIdSupportedAppsHandler),
            (r"/api/v1/app/supported/([0-9A-Za-z]{64})/agents?", GetAgentsBySupportedAppIdHandler),
            (r"/api/v1/apps/supported?", SupportedAppsHandler),

            ##### Agent Apps API Handlers
            (r"/api/v1/app/remediationvault/([0-9A-Za-z]{64})?", AppIdAgentAppsHandler),
            (r"/api/v1/app/remediationvault/([0-9A-Za-z]{64})/agents?", GetAgentsByAgentAppIdHandler),
            (r"/api/v1/apps/remediationvault?", AgentAppsHandler),

            ##### Dashboard API Handlers
            (r"/api/v1/dashboard/graphs/bar/severity?",CustomerSeverityHandler),
            #(r"/api/v1/dashboard/graphs/linear/severity?",PackageSeverityOverTimeHandler),
            (r"/api/v1/dashboard/graphs/bar/stats_by_os?", CustomerStatsByOsHandler),
            (r"/api/v1/dashboard/graphs/column/range/apps/os?", OsAppsOverTimeHandler),
            (r"/api/v1/dashboard/widgets/unique_count?", WidgetHandler),
            (r"/api/v1/dashboard/widgets/top_needed?", TopAppsNeededHandler),
            (r"/api/v1/dashboard/widgets/recently_released?", RecentlyReleasedHandler),

            ##### Operations API Handlers
            (r"/api/v1/operations?", GetTransactionsHandler),
            (r"/api/v1/operation/([a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})?", OperationHandler),

            ##### Vulnerability API Handlers
            (r'/api/v1/vulnerability/os/([A-Za-z0-9_-]+)?', VulnIdHandler),
            (r'/api/v1/vulnerability/cve/(CVE-[0-9]+-[0-9]+)?', CveIdHandler),

            ##### File system access whitelist
            (r"/css/(.*?)", tornado.web.StaticFileHandler,
                {"path": os.path.join(VFENSE_WWW_PATH, "css")}),
            (r"/font/(.*?)", tornado.web.StaticFileHandler,
                {"path": os.path.join(VFENSE_WWW_PATH, "font")}),
            (r"/img/(.*?)", tornado.web.StaticFileHandler,
                {"path": os.path.join(VFENSE_WWW_PATH, "img")}),
            (r"/js/(.*?)", tornado.web.StaticFileHandler,
                {"path": os.path.join(VFENSE_WWW_PATH, "js")}),
            (r"/packages/*/(.*?)", tornado.web.StaticFileHandler,
                {"path": VFENSE_APP_PATH})
        ]

        core_loader = vFense_module_loader.CoreLoader()
        plugin_loader = vFense_module_loader.PluginsLoader()

        # TODO: check for colliding regex's from plugins
        handlers.extend(core_loader.get_core_web_api_handlers())
        handlers.extend(plugin_loader.get_plugins_web_api_handlers())

        settings = {
            "cookie_secret": base64.b64encode(uuid.uuid4().bytes +
                                              uuid.uuid4().bytes),
            "login_url": "/login",
        }
        self.scheduler = start_scheduler()
        initialize_indexes_and_create_tables()
        hierarchy_db.init()

        tornado.web.Application.__init__(self, handlers,
                                         template_path=VFENSE_TEMPLATE_PATH,
                                         debug=debug, **settings)