From d0657697d6ae4a121427191a34d4d6a2b0c54f3f Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Thu, 23 Feb 2023 18:32:27 +0100 Subject: [PATCH] drop md5 pattern and add more names for hashes (IJ-CR-103414) GitOrigin-RevId: 0b74a662fdef33c697559cdadcb82cb62b04e3d1 --- .../openapi/util/text/LiteralNameSuggester.java | 9 ++++----- .../util/text/LiteralNameSuggesterTest.java | 15 +++++++-------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/platform/util/base/src/com/intellij/openapi/util/text/LiteralNameSuggester.java b/platform/util/base/src/com/intellij/openapi/util/text/LiteralNameSuggester.java index 2871477e686d..564aa8772796 100644 --- a/platform/util/base/src/com/intellij/openapi/util/text/LiteralNameSuggester.java +++ b/platform/util/base/src/com/intellij/openapi/util/text/LiteralNameSuggester.java @@ -48,11 +48,10 @@ public class LiteralNameSuggester { new PatternBasedSuggestions("SELECT\\s.*FROM\\s.*", "query", "sql"), new PatternBasedSuggestions("(19|20)[0-9][0-9]([-/])(0?[1-9]|1[0-2])\\2(0?[1-9]|[12][0-9]|30|31)", "date"), new PatternBasedSuggestions("(?:[0-1]?[0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9])?", "time"), - new PatternBasedSuggestions("[0-9a-fA-F]{32}", "md5", "hash"), - new PatternBasedSuggestions("[0-9a-fA-F]{40}", "sha1", "hash"), - new PatternBasedSuggestions("[0-9a-fA-F]{64}", "sha256", "hash"), - new PatternBasedSuggestions("[0-9a-fA-F]{96}|sha384-[A-Za-z0-9+=/]{64}", "sha384", "hash"), - new PatternBasedSuggestions("[0-9a-fA-F]{128}|sha512-[A-Za-z0-9+=/]{88}", "sha512", "hash"), + new PatternBasedSuggestions("[0-9a-fA-F]{40}", "sha1", "hash", "key", "secret", "token"), + new PatternBasedSuggestions("[0-9a-fA-F]{64}", "sha256", "hash", "key", "secret", "token"), + new PatternBasedSuggestions("[0-9a-fA-F]{96}|sha384-[A-Za-z0-9+=/]{64}", "sha384", "hash", "key", "secret", "token"), + new PatternBasedSuggestions("[0-9a-fA-F]{128}|sha512-[A-Za-z0-9+=/]{88}", "sha512", "hash", "key", "secret", "token"), }; /** diff --git a/platform/util/testSrc/com/intellij/util/text/LiteralNameSuggesterTest.java b/platform/util/testSrc/com/intellij/util/text/LiteralNameSuggesterTest.java index e6256f485139..cad3eadfc577 100644 --- a/platform/util/testSrc/com/intellij/util/text/LiteralNameSuggesterTest.java +++ b/platform/util/testSrc/com/intellij/util/text/LiteralNameSuggesterTest.java @@ -39,17 +39,16 @@ public class LiteralNameSuggesterTest { {"2012/2/3", "date"}, {"23:59", "time"}, {"7:00:00", "time"}, - {"79054025255fb1a26e4bc422adfebeed", "md5", "hash"}, - {"c3499c2729730aaff07efb8676a92dcb6f8a3f8f", "sha1", "hash"}, - {"50d858e0985ecc7f60418aaf0cc5ab587f42c2570a884095a9e8ccacd0f6545c", "sha256", "hash"}, - {"sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu", "sha384", "hash"}, - {"fe5ec832d75fd78ec517f33a181259bb953dc54aa8a6332ba0800172c64b18e92b362e0188891efcdb3e3c7d4fb3c14b", "sha384", "hash"}, - {"sha512-j0Q2QD83DuJB4LcfsSAoUINhA5gmZsrBgwxiYMXYhrRH+kwU09Ht3qKGuf+7WbaWnxDYOI0KiKKZ+HgshPR/fw==", "sha512", "hash"}, - {"a65a5831694db0d4ef143cfabce59d4a55c19999e308b34f642e93ccb17bd2cd45642e255d9ecc517c5565a874daa0f903b006d5fa905d158cee43adb28254fa", "sha512", "hash"}, + {"c3499c2729730aaff07efb8676a92dcb6f8a3f8f", "sha1", "hash", "key", "secret", "token"}, + {"50d858e0985ecc7f60418aaf0cc5ab587f42c2570a884095a9e8ccacd0f6545c", "sha256", "hash", "key", "secret", "token"}, + {"sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu", "sha384", "hash", "key", "secret", "token"}, + {"fe5ec832d75fd78ec517f33a181259bb953dc54aa8a6332ba0800172c64b18e92b362e0188891efcdb3e3c7d4fb3c14b", "sha384", "hash", "key", "secret", "token"}, + {"sha512-j0Q2QD83DuJB4LcfsSAoUINhA5gmZsrBgwxiYMXYhrRH+kwU09Ht3qKGuf+7WbaWnxDYOI0KiKKZ+HgshPR/fw==", "sha512", "hash", "key", "secret", "token"}, + {"a65a5831694db0d4ef143cfabce59d4a55c19999e308b34f642e93ccb17bd2cd45642e255d9ecc517c5565a874daa0f903b006d5fa905d158cee43adb28254fa", "sha512", "hash", "key", "secret", "token"}, }; for (String[] test : data) { List strings = LiteralNameSuggester.literalNames(test[0]); - assertEquals(test[0], strings, Arrays.asList(test).subList(1, test.length)); + assertEquals(test[0], Arrays.asList(test).subList(1, test.length), strings); } } }