def configuration(self, id): """Configure a named configuration. .. :quickref: Module; Configure a named configuration Requires the `manage_modules` permission. For each configuration available, you should set the value in a form parameter named ``config_NAME``. For boolean values, any value not ``0`` or ``False`` is considered to be ``True``. If successful, will return the named configuration in ``config``. Otherwise, errors will be available in ``errors``. :param id: id of the named configuration. """ config = Config(get_or_404(Config.get_collection(), _id=id)) if request.method == "POST": errors = update_config(config['config']) if errors is not None: return errors config.save() dispatcher.reload() return redirect({'config': config}, url_for('ModulesView:index')) else: return render({'config': config}, 'modules/configuration.html')
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')