django - 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',
)
解决方案
推荐阅读
- php - 将字符串格式存储在db中的数据转换为对象日期时间
- apache - 导入 .war 文件时出现 Apache 错误。“错误:失败 - 无法启动上下文路径 [/文件夹] 处的应用程序”
- java - 如何转换复杂对象列表并将其表示为值 yaml 图表
- javascript - 在Javascript中使用Symbol.iterable进行迭代时如何检测当前元素是最后一个元素?
- linux - 并行运行命令,如果任何命令使用 wait 失败,则运行失败
- javascript - 显示数组中第一个值的函数,如果再次运行,显示数组的第二个值
- python - 如何在 Django 中获取过滤键和结果元组
- php - 如何在POST php中获取特殊字符'
- android - Android:清单合并失败
- spring-boot - 在 catalina.bat 文件中设置属性与在 setenv.bat 文件中设置属性有什么区别