Skip to content

Commit 47cc1b8

Browse files
committed
Update views.py
1 parent f709f9f commit 47cc1b8

File tree

1 file changed

+41
-11
lines changed

1 file changed

+41
-11
lines changed

vulmatch/server/views.py

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,11 @@ def versions(self, request, *args, cve_id=None, **kwargs):
292292
summary='Get Software Objects for CPEs',
293293
description=textwrap.dedent(
294294
"""
295-
Search and filter CPE records.\n\nThis endpoint only returns the `software` objects for matching CPEs.\n\nThis endpoint is useful to find CPEs that can be used to filter CVEs.
295+
Search and filter CPE records.
296+
297+
This endpoint only returns the `software` objects for matching CPEs.
298+
299+
This endpoint is useful to find CPEs that can be used to filter CVEs.
296300
"""
297301
),
298302
filters=True,
@@ -324,22 +328,48 @@ class CpeView(viewsets.ViewSet):
324328
serializer_class = serializers.StixObjectsSerializer(many=True)
325329
lookup_url_kwarg = 'stix_id'
326330
openapi_path_params = [
327-
OpenApiParameter('stix_id', type=OpenApiTypes.STR, location=OpenApiParameter.PATH, description='The full STIX `id` of the object. e.g. `vulnerability--4d2cad44-0a5a-5890-925c-29d535c3f49e`'),
331+
OpenApiParameter('stix_id', type=OpenApiTypes.STR, location=OpenApiParameter.PATH, description='The full STIX `id` of the object. e.g. `software--93ff5b30-0322-50e8-90c1-1c3f151c8adc`'),
328332
OpenApiParameter('cpe_name', type=OpenApiTypes.STR, location=OpenApiParameter.PATH, description='The full CPE name. e.g. `cpe:2.3:a:slicewp:affiliate_program_suite:1.0.13:*:*:*:*:wordpress:*:*`'),
329333
]
330334

331335

332336
class filterset_class(FilterSet):
333-
id = BaseCSVFilter(help_text='Filter the results by the STIX ID of the `software` object. e.g. `software--93ff5b30-0322-50e8-90c1-1c3f151c8adc`')
334-
cpe_match_string = CharFilter(help_text='Filter CPEs that contain a full or partial CPE Match String. Search is a wildcard to support partial match strings (e.g. `cpe:2.3:o:microsoft:windows` will match `cpe:2.3:o:microsoft:windows_10_1607:-:*:*:*:*:*:x86:*`, `cpe:2.3:o:microsoft:windows_10_1607:-:*:*:*:*:*:x64:*`, etc.')
335-
vendor = CharFilter(help_text='Filters CPEs returned by vendor name. Is wildcard search so `goog` will match `google`, `googe`, etc.')
336-
product = CharFilter(help_text='Filters CPEs returned by product name. Is wildcard search so `chrom` will match `chrome`, `chromium`, etc.')
337-
337+
id = BaseCSVFilter(help_text=textwrap.dedent(
338+
"""
339+
Filter the results by the STIX ID of the `software` object. e.g. `software--93ff5b30-0322-50e8-90c1-1c3f151c8adc`
340+
"""
341+
))
342+
cpe_match_string = CharFilter(help_text=textwrap.dedent(
343+
"""
344+
Filter CPEs that contain a full or partial CPE Match String. Search is a wildcard to support partial match strings (e.g. `cpe:2.3:o:microsoft:windows` will match `cpe:2.3:o:microsoft:windows_10_1607:-:*:*:*:*:*:x86:*`, `cpe:2.3:o:microsoft:windows_10_1607:-:*:*:*:*:*:x64:*`, etc.
345+
"""
346+
))
347+
vendor = CharFilter(help_text=textwrap.dedent(
348+
"""
349+
Filters CPEs returned by vendor name. Is wildcard search so `goog` will match `google`, `googe`, etc.
350+
"""
351+
))
352+
product = CharFilter(help_text=textwrap.dedent(
353+
"""
354+
Filters CPEs returned by product name. Is wildcard search so `chrom` will match `chrome`, `chromium`, etc.
355+
"""
356+
))
338357
product_type = ChoiceFilter(choices=[('operating-system', 'Operating System'), ('application', 'Application'), ('hardware', 'Hardware')],
339-
help_text='Filters CPEs returned by product type.'
340-
)
341-
cve_vulnerable = BaseCSVFilter(help_text='Filters CPEs returned to those vulnerable to CVE ID specified. e.g. `CVE-2023-22518`.')
342-
in_cve_pattern = BaseCSVFilter(help_text='Filters CPEs returned to those referenced CVE ID specified (if you want to only filter by vulnerable CPEs, use the `cve_vulnerable` parameter. e.g. `CVE-2023-22518`.')
358+
help_text=textwrap.dedent(
359+
"""
360+
Filters CPEs returned by product type.
361+
"""
362+
))
363+
cve_vulnerable = BaseCSVFilter(help_text=textwrap.dedent(
364+
"""
365+
Filters CPEs returned to those vulnerable to CVE ID specified. e.g. `CVE-2023-22518`.
366+
"""
367+
))
368+
in_cve_pattern = BaseCSVFilter(help_text=textwrap.dedent(
369+
"""
370+
Filters CPEs returned to those referenced CVE ID specified (if you want to only filter by vulnerable CPEs, use the `cve_vulnerable` parameter. e.g. `CVE-2023-22518`.
371+
"""
372+
))
343373

344374
def create(self, request, *args, **kwargs):
345375
serializer = serializers.NVDTaskSerializer(data=request.data)

0 commit comments

Comments
 (0)