删除 SonarQube 最大文件大小限制警告

问题描述 投票:0回答:1

我正在使用 C# 和 .NET,并且我公开了一个 API,该 API 的文件上传限制为 100 MB。它需要像这样,不少于 8mb,正如 SonarQube 建议的那样,我正好需要 100mb。

这是代码:

[HttpPost("upload")]
[RequestFormLimits(ValueLengthLimit = int.MaxValue, MultipartBodyLengthLimit = int.MaxValue)]
[RequestSizeLimit(104857600)] // Compliant: 100MB
[SwaggerExtension("protected", "bearer")]
public async Task<IActionResult> UploadFile([FromForm] IFormFile file, [FromForm] string condition = "default")
{
    FileResource fileResource = await uploadService.UploadFileAsync(file, condition);

    if (fileResource == null) 
        return BadRequest(string.Empty);
    else 
        return Ok(fileResource);
}

我不想改变表格和尺寸的限制,客户需要这样。也就是说,我怎样才能避免 SonarQube 就此发出警告?这是警告:

Make sure the content length limit is safe here.

c# asp.net .net sonarqube
1个回答
0
投票

在文件内

sonar-project.properties
添加:

sonar.filesize.limit=100

https://community.sonarsource.com/t/how-to-increase-the-limit-of-sonar-filesize-limit/92593/4

© www.soinside.com 2019 - 2024. All rights reserved.