diff --git a/app/models/yara_rule.py b/app/models/yara_rule.py index 56b21fc..074a18a 100755 --- a/app/models/yara_rule.py +++ b/app/models/yara_rule.py @@ -125,7 +125,7 @@ def metadata_values(self): def to_dict(self, include_yara_rule_string=None, short=False, include_relationships=True, include_metadata=True, include_tags=True, include_comments=True, metadata_cache=None, users_cache=None, tags_mapping_cache=None, - comments_cache=None): + comments_cache=None, include_revisions=True): yara_dict = dict( creation_date=self.creation_date.isoformat() if self.creation_date else None, last_revision_date=self.last_revision_date.isoformat() if self.last_revision_date else None, @@ -185,8 +185,9 @@ def to_dict(self, include_yara_rule_string=None, short=False, include_relationsh yara_dict["owner_user"] = self.owner_user.to_dict() if self.owner_user else None if not short: - revision_limit = int(cfg_settings.Cfg_settings.get_setting("FETCH_REVISION_COUNT_LIMIT") or 25) - revisions = Yara_rule_history.query.filter_by(yara_rule_id=self.id).order_by(Yara_rule_history.date_created.desc()).limit(revision_limit).all() + if include_revisions: + revision_limit = int(cfg_settings.Cfg_settings.get_setting("FETCH_REVISION_COUNT_LIMIT") or 25) + revisions = Yara_rule_history.query.filter_by(yara_rule_id=self.id).order_by(Yara_rule_history.date_created.desc()).limit(revision_limit).all() comments = Comments.query.filter_by(entity_id=self.id).filter_by( entity_type=ENTITY_MAPPING["SIGNATURE"]).all() files = Files.query.filter_by(entity_id=self.id).filter_by(entity_type=ENTITY_MAPPING["SIGNATURE"]).all() diff --git a/app/routes/yara_rules.py b/app/routes/yara_rules.py index 6dda937..b9c749f 100755 --- a/app/routes/yara_rules.py +++ b/app/routes/yara_rules.py @@ -242,6 +242,7 @@ def get_yara_rule(id): """Return yara_rule artifact associated with the given id Return: yara_rule artifact dictionary""" include_yara_string = request.args.get("include_yara_string", False) + include_revisions = request.args.get("include_revisions", True) short = distutils.util.strtobool(request.args.get("short", "false")) if include_yara_string: @@ -253,7 +254,7 @@ def get_yara_rule(id): if not current_user.admin and entity.owner_user_id != current_user.id: abort(403) - return_dict = entity.to_dict(include_yara_string, short) + return_dict = entity.to_dict(include_yara_string, short, include_revisions) return_dict["bookmarked"] = True if is_bookmarked(ENTITY_MAPPING["SIGNATURE"], id, current_user.id) \ else False diff --git a/app/static/js/yara_rule/yara_rule-controller.js b/app/static/js/yara_rule/yara_rule-controller.js index a921f99..fe40073 100755 --- a/app/static/js/yara_rule/yara_rule-controller.js +++ b/app/static/js/yara_rule/yara_rule-controller.js @@ -410,7 +410,7 @@ angular.module('ThreatKB') }; $scope.update = function (id) { - $scope.yara_rule = Yara_rule.resource.get({id: id, include_yara_string: 1}); + $scope.yara_rule = Yara_rule.resource.get({id: id, include_yara_string: 1, include_revisions: 0}); $scope.cfg_states = Cfg_states.query(); $scope.users = Users.query(); $scope.cfg_category_range_mapping = CfgCategoryRangeMapping.query(); @@ -418,12 +418,12 @@ angular.module('ThreatKB') }; $scope.viewRule = function (id) { - $scope.yara_rule = Yara_rule.resource.get({id: id, include_yara_string: 1}); + $scope.yara_rule = Yara_rule.resource.get({id: id, include_yara_string: 1, include_revisions: 0}); $scope.view(id); }; $scope.viewRevision = function (id) { - $scope.yara_rule = Yara_rule.resource.get({id: id, include_yara_string: 1}); + $scope.yara_rule = Yara_rule.resource.get({id: id, include_yara_string: 1, include_revisions: 1}); $scope.revision_view(id); }; diff --git a/app/static/views/yara_rule/yara_rules.html b/app/static/views/yara_rule/yara_rules.html index 551ef9c..5d942ae 100755 --- a/app/static/views/yara_rule/yara_rules.html +++ b/app/static/views/yara_rule/yara_rules.html @@ -684,84 +684,6 @@
- {{ selectedRevisions.main ? selectedRevisions.main.yara_rule_string : yara_rule.yara_rule_string }}
-