From 53c61eb3736eac288e79c9509e8282cbd0b3e177 Mon Sep 17 00:00:00 2001 From: elsapet Date: Fri, 26 Jan 2024 12:35:55 +0200 Subject: [PATCH] refactor: simplify --- rules/java/lang/blowfish_key_size.yml | 13 ++++++++++--- .../lang/blowfish_key_generator_init.yml | 19 ------------------- 2 files changed, 10 insertions(+), 22 deletions(-) delete mode 100644 rules/java/shared/lang/blowfish_key_generator_init.yml diff --git a/rules/java/lang/blowfish_key_size.yml b/rules/java/lang/blowfish_key_size.yml index 6e597e9cc..1267d90f9 100644 --- a/rules/java/lang/blowfish_key_size.yml +++ b/rules/java/lang/blowfish_key_size.yml @@ -1,12 +1,19 @@ -imports: - - java_shared_lang_blowfish_key_generator_init patterns: - pattern: $.init($); filters: - variable: BLOWFISH_KEY_GEN - detection: java_shared_lang_blowfish_key_generator_init + detection: java_lang_blowfish_key_generator_init - variable: SIZE less_than: 128 +auxiliary: + - id: java_lang_blowfish_key_generator_init + patterns: + - pattern: $.getInstance($$<...>); + filters: + - variable: KEY_GENERATOR + regex: \A(java\.crypto\.)?KeyGenerator\z + - variable: BLOWFISH_ALGORITHM + string_regex: (?i)\ABlowfish\z languages: - java severity: warning diff --git a/rules/java/shared/lang/blowfish_key_generator_init.yml b/rules/java/shared/lang/blowfish_key_generator_init.yml deleted file mode 100644 index fcf9ab172..000000000 --- a/rules/java/shared/lang/blowfish_key_generator_init.yml +++ /dev/null @@ -1,19 +0,0 @@ -type: shared -languages: - - java -imports: - - java_shared_lang_string -patterns: - - pattern: $.getInstance($$<...>) - filters: - - variable: KEY_GENERATOR - regex: \A(javax\.crypto\.)?KeyGenerator\z - - variable: BLOWFISH_ALGORITHM - detection: java_shared_lang_string - scope: cursor - filters: - - variable: JAVA_SHARED_LANG_STRING_VALUE - string_regex: (?i)\ABlowfish\z -metadata: - description: "Java Crypto Blowfish key generator initializer" - id: java_shared_lang_blowfish_key_generator_init