def reset_db(): remove_PBA_files() # We can't drop system collections. [ mongo.db[x].drop() for x in mongo.db.collection_names() if not x.startswith('system.') ] ConfigService.init_config() AttackConfig.reset_config() logger.info('DB was reset') return jsonify(status='OK')
def reset_db(): logger.info("Resetting database") # We can't drop system collections. [ Database.drop_collection(x) for x in mongo.db.collection_names() if not x.startswith("system.") and not x == AttackMitigations.COLLECTION_NAME ] ConfigService.init_config() AttackConfig.reset_config() logger.info("DB was reset") return jsonify(status="OK")
def reset_db(): logger.info('Resetting database') remove_PBA_files() # We can't drop system collections. [ Database.drop_collection(x) for x in mongo.db.collection_names() if not x.startswith('system.') and not x == AttackMitigations.COLLECTION_NAME ] ConfigService.init_config() AttackConfig.reset_config() logger.info('DB was reset') return jsonify(status='OK')
def generate_new_report(): """ Generates new report based on telemetries, replaces old report in db with new one. :return: Report object """ report = \ { 'techniques': {}, 'meta': {'latest_monkey_modifytime': Monkey.get_latest_modifytime()}, 'name': REPORT_NAME } for tech_id, tech_info in list( AttackConfig.get_techniques_for_report().items()): try: technique_report_data = TECHNIQUES[tech_id].get_report_data() technique_report_data.update(tech_info) report['techniques'].update({tech_id: technique_report_data}) except KeyError as e: LOG.error( "Attack technique does not have it's report component added " "to attack report service. %s" % e) mongo.db.attack_report.replace_one({'name': REPORT_NAME}, report, upsert=True) return report
def get(self): return current_app.response_class( json.dumps({"configuration": AttackConfig.get_config()}, indent=None, separators=(",", ":"), sort_keys=False) + "\n", mimetype=current_app.config['JSONIFY_MIMETYPE'])
def post(self): """ Based on request content this endpoint either resets ATT&CK configuration or updates it. :return: Technique types dict with techniques on reset and nothing on update """ config_json = json.loads(request.data) if 'reset_attack_matrix' in config_json: AttackConfig.reset_config() return jsonify(configuration=AttackConfig.get_config()['properties']) else: AttackConfig.update_config({'properties': json.loads(request.data)}) AttackConfig.apply_to_monkey_config() return {}
def get(self): return jsonify(configuration=AttackConfig.get_config()['properties'])
def _is_enabled_in_config(cls) -> bool: return AttackConfig.get_technique_values()[cls.tech_id]
def technique_title(cls): """ :return: techniques title. E.g. "T1110 Brute force" """ return AttackConfig.get_technique(cls.tech_id)['title']