Skip to content

Commit f5b5a03

Browse files
committed
fix(core): normalize rule keywords and optimize base64 decoding
1 parent 061bba9 commit f5b5a03

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/main/java/com/arqsz/burpgitleaks/config/RuleLoader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ private static GitleaksRule parseRule(TomlTable t, String id, String sourceName)
164164
String regex = t.getString("regex");
165165
String path = t.getString("path");
166166

167-
List<String> keywords = toList(t.getArray("keywords"));
167+
List<String> keywords = toList(t.getArray("keywords")).stream()
168+
.map(String::toLowerCase)
169+
.toList();
168170

169171
List<GitleaksAllowlist> localAllowlists = extractAllowlists(t, "Rule Allowlist (" + id + ")");
170172

src/main/java/com/arqsz/burpgitleaks/scan/GitleaksScanCheck.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,20 @@ private String tryDecode(String s) {
357357
}
358358

359359
private boolean isPrintable(String s) {
360-
if (s.isEmpty())
360+
if (s == null || s.isEmpty())
361361
return false;
362-
long controlChars = s.chars()
363-
.filter(c -> (c < 32 && c != '\n' && c != '\r' && c != '\t') || c > 126)
364-
.count();
365-
return (double) controlChars / s.length() < 0.3;
362+
363+
int controlChars = 0;
364+
int len = s.length();
365+
366+
for (int i = 0; i < len; i++) {
367+
char c = s.charAt(i);
368+
if ((c < 32 && c != '\n' && c != '\r' && c != '\t') || c > 126) {
369+
controlChars++;
370+
}
371+
}
372+
373+
return (double) controlChars / len < 0.3;
366374
}
367375

368376
private String extractLine(String body, int start, int end) {

0 commit comments

Comments
 (0)