6

我将我的应用程序 EAR 提交给 Veracode 安全扫描工具,并在以下代码中发现了这个缺陷:

private String url = "jdbc:mysql://localhost:8081/sql";  
private String userName = "xyz";  
private String password = "abc";
DriverManager.getConnection(url, user, password); // At this line i am getting this flaw. 

有人请帮助我解决 CWE-259:使用硬编码密码漏洞。

4

2 回答 2

4

您获得硬编码密码缺陷的原因是因为在您的代码段的第三行中,您将密码硬编码在一个变量中。这是因为您在源代码中存储了敏感信息(用户名和密码),这是一个缺陷,因为您的 can 源可以被反编译。

修复此缺陷的一种方法是将凭据存储在高度加密的文件中,或将强单向哈希应用于凭据并将这些哈希存储在配置文件中。

您可以在此处获取更多信息:http: //cwe.mitre.org/data/definitions/259.html

于 2013-04-14T18:18:41.980 回答
-5

字符串密码 = 新 Securestring("123").GetValue()。

 class Securestring {
     private readonly string _password;

     public Securestring(string value) {
         _password = value;
     }

     public string GetValue() {
         return _password;
     }
 }

于 2016-05-19T10:17:40.217 回答