GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — pmd/pmd-java/src/main/resources/category/java/security.xml at main · pmd/pmd Expand file tree/ Copy pathsecurity.xmlMore file actions 91 lines (78 loc) · 3.47 KB / Copy pathsecurity.xmlFile metadata and controls91 lines (78 loc) · 3.47 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 <?xml version="1.0" encoding="UTF-8"?> <ruleset name="Security" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd"> <description> Rules that flag potential security flaws. </description> <rule name="HardCodedCryptoKey" language="java" since="6.4.0" message="Do not use hard coded encryption keys" class="net.sourceforge.pmd.lang.java.rule.security.HardCodedCryptoKeyRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_security.html#hardcodedcryptokey"> <description> Do not use hard-coded values for cryptographic operations. Store keys outside of source code or generate it from a random source. </description> <priority>3</priority> <example> <![CDATA[ public class HardCodedCryptoKeyExample { void good() throws Exception { // loading the key via properties from outside of the source code SecretKey secretKey1 = new SecretKeySpec(Properties.getKey(), "AES"); // generating a fresh key KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); keyGenerator.init(256); SecretKey secretKey2 = keyGenerator.generateKey(); // generating from a password, the password is from outside the source code SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256"); KeySpec spec = new PBEKeySpec(Properties.getPassword().toCharArray(), Properties.getSalt().getBytes(), 65536, 256); SecretKey secretKey3 = new SecretKeySpec(factory.generateSecret(spec).getEncoded(), "AES"); } void bad() { SecretKey secretKey1 = new SecretKeySpec("my secret here".getBytes(), "AES"); byte[] key2 = new byte[] { 1, 2, 3 }; SecretKey secretKey2 = new SecretKeySpec(key2, "AES"); byte[] key3 = new byte[32]; SecretKey secretKey3 = new SecretKeySpec(key3, "AES"); } } ]]> </example> </rule> <rule name="InsecureCryptoIv" language="java" since="6.3.0" message="Do not use hard coded initialization vector in crypto operations" class="net.sourceforge.pmd.lang.java.rule.security.InsecureCryptoIvRule" externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_security.html#insecurecryptoiv"> <description> Do not use hard coded initialization vector in cryptographic operations. Use a randomly generated IV. </description> <priority>3</priority> <example> <![CDATA[ public class InsecureCryptoIvExample { void good(SecretKey key) throws Exception { SecureRandom random = SecureRandom.getInstanceStrong(); byte[] iv = new byte[Cipher.getInstance("AES").getBlockSize()]; random.nextBytes(iv); IvParameterSpec ivParam = new IvParameterSpec(iv); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.ENCRYPT_MODE, key, ivParam); } void bad() { byte[] iv1 = new byte[] { 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, }; IvParameterSpec ivParam1 = new IvParameterSpec(iv1); byte[] iv2 = new byte[16]; IvParameterSpec ivParam2 = new IvParameterSpec(iv2); byte[] iv3 = "secret iv in here".getBytes(); IvParameterSpec ivParam3 = new IvParameterSpec(iv3); } } ]]> </example> </rule> </ruleset> |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |