我已经实现了 POC 并使用 slf4j 进行日志记录。log4j 中的零日漏洞问题是否也会影响 slf4j 日志?
我有一个来自数据库的条目,格式如下。我首先使用 replaceAll 而不是 replace 函数,但 SonarCloud 显示错误并要求从 replaceAll 更改为 replace。但是,替换并不会替换所有的反斜杠,事实上它不会更改文本中的任何内容。
用java代码从数据库中输入:
""{\"id\":\"5947223f-9c50-425f-950b-e126c94b3adf\",\"name\":\"shruti\"}
Run Code Online (Sandbox Code Playgroud)
使用 replaceAll 我编写的代码如下,工作正常:
abcString.replaceAll("\\\\", "").replaceFirst("\"","");
Run Code Online (Sandbox Code Playgroud)
为了让 SonarCloud 开心,我尝试将 replaceAll 更改为 replace ,这反过来告诉是删除 replaceFirst 方法,否则它会从数据库输出中删除双引号。
具有替换功能的代码:
abcString.replace("\\\\", "")
Run Code Online (Sandbox Code Playgroud)
我尝试的第二件事给出了错误:
Unexpected character ('\' (code 92)): was expecting double-quote to start field name
! at [Source: (String)"{\"id\":\"5947223f-9c50-425f-950b-e126c94b3adf\",\"name\":\"shruti\"}
Run Code Online (Sandbox Code Playgroud) 是否有更简单的执行||和&&操作方法,也许使用 Java 8?因为我有一些其他的类OrderSummaryService,它有更多的领域。
@Getters
@Setters
class Orders
{
String id;
String status;
Items items;
String orderDate;
String createdBy;
String updatedBy;
Double amount;
}
@Getters
@Setters
class Items
{
String itemId;
String itemName;
String amount;
String quantity;
}
class OrderSummaryService
{
public static void main(String args[])
{
Orders orders = orderRepository.getOrderDetails();
if (orders.getStatus() != null || orders.getCreatedBy() != null
|| orders.getUpdatedBy() != null || orders.getAmount() != null
|| orders.getOrderDate() != null && orders.getItems() != null) …Run Code Online (Sandbox Code Playgroud)