在 Scala 代码中未发现路径遍历漏洞

Path traversal vulnerabilities not found at Scala code

我一直在尝试使用 SonarQube + FindBugs + FindSecBugs 插件来扫描我的代码。

这个想法是检测代码中的漏洞,正如它在 github 项目主题中所说的那样,它适用于 scala https://github.com/find-sec-bugs/find-sec-bugs

我已经按照文档说明安装了插件,并尝试了几次扫描,但没有发现任何与 scala 漏洞相关的信息。

所以,为了弄清楚代码是真的好还是我的 SonarQube 设置配置错误,我去了 http://find-sec-bugs.github.io/bugs.htm,我拿了一个例子(潜在路径遍历),插入示例代码和我再次 运行 扫描仪。没找到。

质量配置文件中激活了规则(安全 - 潜在路径遍历(文件读取)),尽管它是一个 Java 配置文件,但它已分配给项目,因为上述代码中的代码例如 Scala。

我注意到来自 find-sec-bugs 的所有规则都是 java 规则,所以我想知道它们是否不能在 Scala 上工作,或者我可以做些什么来实现它工作。

提前致谢,如果您需要任何额外信息,请告诉我,我们很乐意为您提供。

看起来发生这种情况的主要原因是由于某些原因明确排除了 Scala 错误模式:

Their are plenty of limitation with the SonarQube architecture regarding the multi-language support. It is closely tie to the sonar-source plugin design.

  • Language can't have the same extension (https://jira.sonarsource.com/browse/MMF-672)
  • Repository can't contains rule that apply to multiple languages. (If you would have Scala only code, the Java core rules would not be enable unless you have one Java file present)
  • Sensor are couple to the language definition (depends on the most popular plugin that declares it).
  • etc, etc..

来源:https://github.com/spotbugs/sonar-findbugs/issues/108#issuecomment-305909652

所有排除可以在这里看到:https://github.com/spotbugs/sonar-findbugs/commit/526ca6b29fae2684f86b1deba074a4be8a05b67e

特别是对于 Scala:

  static exclusions = ['CUSTOM_INJECTION',
                   'SCALA_SENSITIVE_DATA_EXPOSURE',
                   'SCALA_PLAY_SSRF',
                   'SCALA_XSS_TWIRL',
                   'SCALA_XSS_MVC_API',
                   'SCALA_PATH_TRAVERSAL_IN',
                   'SCALA_COMMAND_INJECTION',
                   "SCALA_SQL_INJECTION_SLICK",
                   "SCALA_SQL_INJECTION_ANORM",
                   "PREDICTABLE_RANDOM_SCALA"]