首页 > 解决方案 > SonarQube 规则:Spring Boot 应用程序中的“使用命令行参数是安全敏感的”

问题描述

SonarQube 只是在非常基本的 Spring Boot 应用程序中显示了一个严重的安全问题。在主要方法中。

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}

SonarQube 想要我Make sure that command line arguments are used safely here.

我在 StackOverflow 和 Google 上都搜索了这个,我很惊讶我找不到任何关于这个问题的评论。我几乎可以肯定该SpringApplication.run方法内部已经进行了一些安全检查。而且,我什至不记得有人在调用SpringApplication.run. 我只是想将其标记为误报并继续前进。

这个问题的一部分也在这里问:SonarQube 在 Spring Framework 控制器和 Spring Framework Application 主类中显示安全错误

是误报吗?

标签: javaspring-bootsonarqube

解决方案


如果你没有使用任何命令行参数,那么你可以避免在 run 方法中提及 args 参数。就像下面的代码。

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class);
    }

}

这将消除声纳热点问题。


推荐阅读