-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathserializers.py
64 lines (43 loc) · 1.91 KB
/
serializers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from rest_framework import serializers
from apps.exploits.models import EPSS, Exploit
from osidb.models import Affect, Flaw, PsModule, Tracker
class ExploitsSimpleSerializer(serializers.ModelSerializer):
class Meta:
model = Exploit
fields = ["date", "source", "reference"]
class AffectExploitReportSerializer(serializers.ModelSerializer):
cve = serializers.CharField(source="flaw.cve_id")
product = serializers.CharField(source="ps_module")
component = serializers.CharField(source="ps_component")
resolution = serializers.CharField(source="resolution_expanded")
class Meta:
model = Affect
fields = ["cve", "product", "component", "affectedness", "resolution"]
class TrackerReportDataSerializer(serializers.ModelSerializer):
class Meta:
model = Tracker
extra_kwargs = {"external_system_id": {"required": True}}
fields = ["type", "external_system_id", "status", "resolution"]
class AffectReportDataSerializer(serializers.ModelSerializer):
trackers = TrackerReportDataSerializer(many=True, required=False)
class Meta:
model = Affect
fields = ["ps_module", "ps_component", "affectedness", "resolution", "trackers"]
class FlawReportDataSerializer(serializers.ModelSerializer):
affects = AffectReportDataSerializer(many=True, required=False)
class Meta:
model = Flaw
fields = ["cve_id", "affects"]
class ExploitOnlyReportDataSerializer(serializers.ModelSerializer):
flaw = serializers.BooleanField(source="flaw_exists")
class Meta:
model = Exploit
fields = ["cve", "date", "source", "reference", "maturity_preliminary", "flaw"]
class EPSSSerializer(serializers.ModelSerializer):
class Meta:
model = EPSS
fields = ["cve", "epss"]
class SupportedProductsSerializer(serializers.ModelSerializer):
class Meta:
model = PsModule
fields = ["name"]