Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add vul log time range #1879

Merged
merged 3 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dongtai_web/views/engine_hook_rule_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ def post(self, request):
language_id=ser.validated_data["language_id"],
type=type_,
value__contains=rule_value,
value=rule_value,
).exists():
return R.failure(msg="Already exists same rule")

Expand Down
6 changes: 3 additions & 3 deletions dongtai_web/vul_log/vul_log_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class VulLogListArgsSerializer(serializers.Serializer):
vul_type = serializers.IntegerField(min_value=1, max_value=2, help_text="漏洞类型")
msg_type = serializers.IntegerField(min_value=1, max_value=5, required=False, help_text="消息类型")
start_time = serializers.IntegerField(required=False, help_text="开始时间")
end_time = serializers.IntegerField(required=False, help_text="结束时间")
end_time = serializers.IntegerField(required=False, help_text="结束时间")


class VulLogViewSet(UserEndPoint, viewsets.ViewSet):
Expand Down Expand Up @@ -44,8 +44,8 @@ def list(self, request, vul_id):
q = q & Q(asset_vul_id=vul_id)
if "msg_type" in request.query_params and msg_type:
q = q & Q(msg_type=msg_type)
if "start_time" in request.query_params and "end_time" in request.query_params :
q = q & Q(datetime__gt=request.query_params["start_time"],datetime__lt=request.query_params["end_time"])
if "start_time" in request.query_params and "end_time" in request.query_params:
q = q & Q(datetime__gt=request.query_params["start_time"], datetime__lt=request.query_params["end_time"])
data = IastVulLog.objects.filter(q).all()

return R.success([model_to_dict(i) for i in data])