优化被测件:慎重考虑写入日志文件信息的隐私性。避免把敏感信息写入日志文件

wuhaoyang
Guo XIn 10 months ago
parent 6fef801bcb
commit 753fbddae6
  1. 7
      sonar-keyware-plugins-cxx/src/test/resources/com/keyware/sonar/cxx/rules/checkers/LogFileWriteChecker.cc

@ -17,16 +17,14 @@ rotating_logger->set_level(spdlog::level::info);
int writeLogFile1() {
// 写入不同级别的日志信息
rotating_logger->track("This is an track message");
rotating_logger->debug("This is an debug message");
rotating_logger->info("This is an info message");
rotating_logger->warn("This is a warning");
rotating_logger->error("This is an error");
rotating_logger->track("This is an track message" + armsName); // error
rotating_logger->debug("This is an debug message %s, %s", username, orgName); // error
rotating_logger->info("This is an info message" + armsName); // error
rotating_logger->warn("This is a warning" + armsName); // error
rotating_logger->warn("This is a warning, {}", armsName); // error
rotating_logger->error("This is an error" + armsName); // error
return 0;
@ -47,10 +45,9 @@ int writeLogFile2() {
// 写入不同级别的日志信息
log4cpp::Category& myCat = log4cpp::Category::getInstance(std::string("MyCategory"));
myCat.track("This is an track message" + armsName); // error
myCat.debug("This is an debug message %s, %s", username, orgName); // error
myCat.info("This is an info message" + armsName); // error
myCat.warn("This is a warning" + armsName); // error
myCat.warn("This is a warning, {}", armsName); // error
myCat.error("This is an error" + armsName); // error
delete layout;

Loading…
Cancel
Save