声纳问题:确保此记录器的配置是安全的 [英] Sonar issue: Make sure that this logger's configuration is safe
问题描述
我在 Sonar 上的代码遇到以下问题:
I am getting the following issue for my code on Sonar:
确保此记录器的配置是安全的.
Make sure that this logger's configuration is safe.
我写的代码是:
public static final Logger logger = Logger.getLogger("logger");
if (logLevel.equalsIgnoreCase("info"))
logger.setLevel(Level.INFO);
else
logger.setLevel(Level.ALL);
它在 logger.setLevel
调用中向我显示此错误.
It is showing me this error on logger.setLevel
calls.
我该如何解决这些问题?
How can I solve these?
推荐答案
根据SonarQube 规则,此规则标记启动记录器配置的审查代码.
According to SonarQube rules, This rule flags for review code that initiates loggers configuration.
目标是指导安全代码审查.此外,没有办法通过代码来修复它,您应该问自己是否:
The goal is to guide security code reviews. Also, there is no way to fix it by code instead you should ask yourself whether:
- 未经授权的用户可能有权访问日志,因为它们存储在不安全的位置,或者因为应用程序允许访问它们.
- 日志包含生产服务器上的敏感信息.当记录器处于调试模式时,可能会发生这种情况.
- 日志可以无限增长.当用户每次执行某项操作时将附加信息写入日志并且用户可以根据需要执行该操作多次时,就会发生这种情况.
- 日志没有包含足够的信息来了解攻击者可能造成的损害.记录器模式(信息、警告、错误)可能会过滤掉重要信息.他们可能不会打印上下文信息,例如事件的精确时间或服务器主机名.
- 日志仅存储在本地,不会被备份或复制.
如果您对这些问题中的任何一个回答是",您将面临风险.
You are at risk if you answered yes to any of those questions.
有关安全日志记录项目的更多信息,请查看 owasp 页面
For more info about security logging project, check the owasp page
这篇关于声纳问题:确保此记录器的配置是安全的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!