Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

fix serilizer fields No indication of range #320

Merged
merged 1 commit into from
Dec 13, 2021
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
16 changes: 12 additions & 4 deletions iast/views/sensitive_info_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ class SensitiveInfoRuleSerializer(serializers.ModelSerializer):
pattern_type_name = serializers.SerializerMethodField()
class Meta:
model = IastSensitiveInfoRule
fields = ['id', 'strategy_name','strategy_id','pattern_type_id','pattern_type_name','pattern','status','latest_time']
fields = [
'id', 'strategy_name', 'strategy_id', 'pattern_type_id',
'pattern_type_name', 'pattern', 'status', 'latest_time'
]

def get_strategy_name(self,obj):
try:
Expand Down Expand Up @@ -89,10 +92,15 @@ def get_url(self, obj):


class SensitiveInfoRuleCreateSerializer(serializers.Serializer):
strategy_id = serializers.IntegerField(min_value=1, required=True)
pattern_type_id = serializers.IntegerField(min_value=1, required=True)
strategy_id = serializers.IntegerField(min_value=1,
max_value=2147483646,
required=True)
pattern_type_id = serializers.IntegerField(min_value=1,
max_value=2147483646,
required=True)
pattern = serializers.CharField(required=True)
status = serializers.IntegerField(required=True)
status = serializers.ChoiceField(choices=(0, 1), required=True)


class _SensitiveInfoArgsSerializer(serializers.Serializer):
page_size = serializers.IntegerField(default=20,
Expand Down
26 changes: 26 additions & 0 deletions test/iast/views/test_sensitive_info_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
######################################################################
# @author : bidaya0 (bidaya0@$HOSTNAME)
# @file : test_sensitive_info_rule
# @created : 星期一 12月 13, 2021 19:50:46 CST
#
# @description :
######################################################################


from rest_framework.test import APITestCase
from dongtai.models.user import User

class SensitiveInfoRuleTestCase(APITestCase):
def setUp(self):
self.user = User.objects.filter(pk=1).first()
self.client.force_authenticate(user=self.user)

def test_sensitive_info_rule_create(self):
response = self.client.post('/api/v1/sensitive_info_rule',
data={
'pattern': '0',
'pattern_type_id': 1,
'status': 0,
'strategy_id': 2147483648
})
assert response.status_code == 200
2 changes: 0 additions & 2 deletions test/iast/views/test_vul_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ def mockdata(self):
port=22,
container=None)

def tearDown(self):
IastServer.objects.filter(pk=self.server.id).delete()

def test_get_server(self):
obj = VulDetail()
Expand Down
2 changes: 0 additions & 2 deletions test/iast/views/test_vul_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,3 @@ def test_create(self):
response = self.client.get('/api/v1/vuln/summary')
assert response.status_code == 200

def tearDown(self):
IastAgent.objects.filter(token='testtoken').delete()