Ejemplo n.º 1
0
    def repository_delete(self, id):
        """Delete a repository

        .. :quickref: Module; Delete repository

        Requires the `manage_modules` permission.
        Returns "ok".

        :param id: id of the repository.
        """
        repository = Repository(get_or_404(Repository.get_collection(),
                                           _id=id))
        repository.delete()
        dispatcher.reload()

        return redirect('ok', url_for('ModulesView:index'))
Ejemplo n.º 2
0
    def repository_update(self, id):
        """Update a repository

        .. :quickref: Module; Update repository

        Requires the `manage_modules` permission.

        :param id: id of the repository.

        :>json Repository repository: the repository.
        """
        repository = Repository(get_or_404(Repository.get_collection(),
                                           _id=id))
        repository.pull()

        return redirect({'repository': clean_repositories(repository)},
                        url_for('ModulesView:index'))
Ejemplo n.º 3
0
    def reload(self):
        """Reload the workers

        .. :quickref: Module; Reload workers

        Requires the `manage_modules` permission.

        Returns "ok".
        """
        for repository in Repository.get_collection().find():
            dispatcher.update_modules(Repository(repository))

        updates = Internals(
            get_or_404(Internals.get_collection(), name="updates"))
        updates.update_value("last_update", time())

        flash(
            'Workers will reload once they are done with their current tasks',
            'success')

        return redirect('ok', url_for('ModulesView:index'))
Ejemplo n.º 4
0
    def index(self):
        """Get the list of modules.

        .. :quickref: Module; Get the list of modules

        Requires the `manage_modules` permission.

        The response is a dict with several elements:

        * ``modules``, which is a list of modules, sorted by type::

            "modules": {
                "Antivirus": [
                    ...
                ],
                "Preloading": [
                    ...
                ],
                "Processing": [
                    {
                        "_id": {
                            "$oid": "MODULE_ID"
                        },
                        "acts_on": [
                            ACTS_ON_FAME_TYPES
                        ],
                        "class": "CLASS_NAME",
                        "config": [ CONFIG_OPTIONS ],
                        "description": "DESCRIPTION",
                        "enabled": false,
                        "generates": [GENERATES],
                        "name": "NAME",
                        "path": "MODULE_PATH",
                        "queue": "QUEUE",
                        "triggered_by": [
                            TRIGGERS
                        ],
                        "type": "Processing"
                    },
                    ...
                ],
                "Reporting": [
                    ...
                ],
                "Threat Intelligence": [
                    ...
                ],
                "Filetype": [
                    ...
                ]
            }

        * ``repositories``: list of configured repositories::

            "repositories": [
                {
                    "_id": {
                        "$oid": "ID"
                    },
                    "address": "[email protected]:certsocietegenerale/fame_modules.git",
                    "name": "community",
                    "private": false,
                    "status": "active"
                },
                ...
            ]

        * ``configs``: list of named configurations::

            "configs": [
                {
                    "_id": {
                        "$oid": "ID"
                    },
                    "config": [
                        {
                            "description": "List of patterns (strings) to look for in malware configurations. There should be one pattern per line.",
                            "name": "monitor",
                            "type": "text",
                            "value": null
                        }
                    ],
                    "description": "Needed in order to be able to track malware targets",
                    "name": "malware_config"
                },
                ...
            ]
        """
        types = {
            'Preloading': [],
            'Processing': [],
            'Reporting': [],
            'Threat Intelligence': [],
            'Antivirus': [],
            'Virtualization': [],
            'Filetype': []
        }

        for module in ModuleInfo.get_collection().find():
            types[module['type']].append(clean_modules(module))

        for type in types:
            types[type] = sorted(types[type], key=get_name)

        configs = Config.get_collection().find()

        repositories = clean_repositories(
            list(Repository.get_collection().find()))

        return render(
            {
                'modules': types,
                'configs': configs,
                'repositories': repositories
            }, 'modules/index.html')