首页 > 解决方案 > Django-rest 序列化程序上的 SSL 上下文覆盖漏洞

问题描述

我在 VScode 上安装了 HCL AppScan CodeSweep,它在我的一个 Django 序列化程序上发现了一个 SSL 上下文漏洞,我只是想知道我可以在不改变我想要的功能的情况下修复它。

class CategoryDetailSerializer(CategoryListSerializer):
products = serializers.SerializerMethodField()

class Meta:
    model = Category
    fields = (
        'id',
        'title',
        'products',
    )

def get_products(self, obj):
    # The source of the SSL context override
    return ProductListSerializer(obj.product_set.all(), many=True, context=self.context).data

class ProductListSerializer(serializers.HyperlinkedModelSerializer):
url = serializers.HyperlinkedIdentityField(
    view_name='products:product-detail-view', lookup_field='slug')

class Meta:
    model = Product
    fields = (
        'id',
        'slug',
        'title',
        'price',
        'image',
        'url',
    )

标签: djangosecuritydjango-rest-frameworkdjango-serializerowasp

解决方案


推荐阅读