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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
use crate::rules::Rule;
use crate::{Finding, Language, Severity};
use regex::Regex;
// ─── Helpers ──────────────────────────────────────────────────────────────────
fn get_source_line(source: &str, byte_offset: usize) -> String {
let start = source[..byte_offset].rfind('\n').map_or(0, |p| p + 1);
let end = source[byte_offset..]
.find('\n')
.map_or(source.len(), |p| byte_offset + p);
source[start..end].to_string()
}
fn walk_tree(
node: tree_sitter::Node,
source: &str,
callback: &mut dyn FnMut(tree_sitter::Node, &str),
) {
callback(node, source);
let mut cursor = node.walk();
for child in node.children(&mut cursor) {
walk_tree(child, source, callback);
}
}
fn make_finding(
rule_id: &str,
severity: Severity,
cwe: Option<&str>,
description: &str,
node: tree_sitter::Node,
source: &str,
) -> Finding {
let start = node.start_position();
let end = node.end_position();
Finding {
rule_id: rule_id.to_string(),
severity,
cwe: cwe.map(|s| s.to_string()),
description: description.to_string(),
file: String::new(),
line: start.row + 1,
column: start.column + 1,
end_line: end.row + 1,
end_column: end.column + 1,
snippet: get_source_line(source, node.start_byte()),
}
}
fn make_finding_from_offsets(
rule_id: &str,
severity: Severity,
cwe: Option<&str>,
description: &str,
source: &str,
start_byte: usize,
end_byte: usize,
) -> Finding {
let line = source[..start_byte].bytes().filter(|b| *b == b'\n').count() + 1;
let line_start = source[..start_byte].rfind('\n').map_or(0, |idx| idx + 1);
let column = source[line_start..start_byte].chars().count() + 1;
let end_line = source[..end_byte].bytes().filter(|b| *b == b'\n').count() + 1;
let end_line_start = source[..end_byte].rfind('\n').map_or(0, |idx| idx + 1);
let end_column = source[end_line_start..end_byte].chars().count() + 1;
Finding {
rule_id: rule_id.to_string(),
severity,
cwe: cwe.map(|s| s.to_string()),
description: description.to_string(),
file: String::new(),
line,
column,
end_line,
end_column,
snippet: get_source_line(source, start_byte),
}
}
/// Check whether any descendant of `node` is a `binary_expression` with a `+`
/// operator that involves a `string_literal`.
fn has_string_concat(node: tree_sitter::Node, src: &str) -> bool {
if node.kind() == "binary_expression" {
if let Some(op) = node.child_by_field_name("operator") {
if &src[op.byte_range()] == "+" {
// Check if either side is or contains a string_literal
let left_has_str = node
.child_by_field_name("left")
.is_some_and(|n| contains_kind(n, "string_literal"));
let right_has_str = node
.child_by_field_name("right")
.is_some_and(|n| contains_kind(n, "string_literal"));
if left_has_str || right_has_str {
return true;
}
}
}
}
let mut cursor = node.walk();
for child in node.children(&mut cursor) {
if has_string_concat(child, src) {
return true;
}
}
false
}
fn contains_kind(node: tree_sitter::Node, kind: &str) -> bool {
if node.kind() == kind {
return true;
}
let mut cursor = node.walk();
for child in node.children(&mut cursor) {
if contains_kind(child, kind) {
return true;
}
}
false
}
/// Check if a node is a literal (string_literal, number, null, boolean, etc.).
fn is_literal(node: tree_sitter::Node) -> bool {
matches!(
node.kind(),
"string_literal"
| "character_literal"
| "decimal_integer_literal"
| "hex_integer_literal"
| "octal_integer_literal"
| "binary_integer_literal"
| "decimal_floating_point_literal"
| "hex_floating_point_literal"
| "true"
| "false"
| "null_literal"
)
}
// ─── Rule 1: no-sql-injection ───────────────────────────────────────────────
pub struct NoSqlInjection;
impl Rule for NoSqlInjection {
fn id(&self) -> &str {
"java/no-sql-injection"
}
fn severity(&self) -> Severity {
Severity::Critical
}
fn cwe(&self) -> Option<&str> {
Some("CWE-89")
}
fn description(&self) -> &str {
"Potential SQL injection via string concatenation in query method"
}
fn language(&self) -> Language {
Language::Java
}
fn check(&self, source: &str, tree: &tree_sitter::Tree) -> Vec<Finding> {
let mut findings = Vec::new();
let sql_methods =
Regex::new(r"^(executeQuery|execute|createQuery|createNativeQuery)$").unwrap();
walk_tree(tree.root_node(), source, &mut |node, src| {
if node.kind() == "method_invocation" {
if let Some(name) = node.child_by_field_name("name") {
let name_text = &src[name.byte_range()];
if sql_methods.is_match(name_text) {
if let Some(args) = node.child_by_field_name("arguments") {
if has_string_concat(args, src) {
findings.push(make_finding(
self.id(),
self.severity(),
self.cwe(),
"SQL query built with string concatenation — use parameterized queries or prepared statements",
node,
src,
));
}
}
}
}
}
});
findings
}
}
// ─── Rule 2: no-command-injection ───────────────────────────────────────────
pub struct NoCommandInjection;
impl Rule for NoCommandInjection {
fn id(&self) -> &str {
"java/no-command-injection"
}
fn severity(&self) -> Severity {
Severity::Critical
}
fn cwe(&self) -> Option<&str> {
Some("CWE-78")
}
fn description(&self) -> &str {
"Potential command injection via Runtime.exec or ProcessBuilder with dynamic input"
}
fn language(&self) -> Language {
Language::Java
}
fn check(&self, source: &str, tree: &tree_sitter::Tree) -> Vec<Finding> {
let mut findings = Vec::new();
walk_tree(tree.root_node(), source, &mut |node, src| {
// Runtime.getRuntime().exec(variable)
if node.kind() == "method_invocation" {
if let Some(name) = node.child_by_field_name("name") {
let name_text = &src[name.byte_range()];
if name_text == "exec" {
if let Some(obj) = node.child_by_field_name("object") {
let obj_text = &src[obj.byte_range()];
if obj_text.contains("getRuntime()") || obj_text.contains("Runtime") {
if let Some(args) = node.child_by_field_name("arguments") {
if let Some(first_arg) = args.named_child(0) {
if !is_literal(first_arg) {
findings.push(make_finding(
self.id(),
self.severity(),
self.cwe(),
"Runtime.exec() called with dynamic argument — risk of command injection",
node,
src,
));
}
}
}
}
}
}
}
}
// new ProcessBuilder(variable)
if node.kind() == "object_creation_expression" {
if let Some(type_node) = node.child_by_field_name("type") {
let type_text = &src[type_node.byte_range()];
if type_text == "ProcessBuilder" {
if let Some(args) = node.child_by_field_name("arguments") {
if let Some(first_arg) = args.named_child(0) {
if !is_literal(first_arg) {
findings.push(make_finding(
self.id(),
self.severity(),
self.cwe(),
"ProcessBuilder created with dynamic argument — risk of command injection",
node,
src,
));
}
}
}
}
}
}
});
findings
}
}
// ─── Rule 3: no-unsafe-deserialization ──────────────────────────────────────
pub struct NoUnsafeDeserialization;
impl Rule for NoUnsafeDeserialization {
fn id(&self) -> &str {
"java/no-unsafe-deserialization"
}
fn severity(&self) -> Severity {
Severity::Critical
}
fn cwe(&self) -> Option<&str> {
Some("CWE-502")
}
fn description(&self) -> &str {
"Unsafe deserialization can lead to remote code execution"
}
fn language(&self) -> Language {
Language::Java
}
fn check(&self, source: &str, tree: &tree_sitter::Tree) -> Vec<Finding> {
let mut findings = Vec::new();
walk_tree(tree.root_node(), source, &mut |node, src| {
if node.kind() == "method_invocation" {
if let Some(name) = node.child_by_field_name("name") {
let name_text = &src[name.byte_range()];
// ObjectInputStream.readObject() or XMLDecoder.readObject()
if name_text == "readObject" {
if let Some(obj) = node.child_by_field_name("object") {
let obj_text = &src[obj.byte_range()];
if obj_text.contains("ObjectInputStream")
|| obj_text.contains("XMLDecoder")
// Also match variable references that may be an ObjectInputStream
|| !obj_text.contains('.')
{
findings.push(make_finding(
self.id(),
self.severity(),
self.cwe(),
"readObject() on untrusted data can lead to remote code execution — use allowlist-based deserialization",
node,
src,
));
}
}
}
// Yaml.load() (not safeLoad)
if name_text == "load" {
if let Some(obj) = node.child_by_field_name("object") {
let obj_text = &src[obj.byte_range()];
if obj_text.contains("Yaml") || obj_text.contains("yaml") {
findings.push(make_finding(
self.id(),
self.severity(),
self.cwe(),
"Yaml.load() deserializes arbitrary objects — use Yaml.safeLoad() or a safe constructor",
node,
src,
));
}
}
}
}
}
});
findings
}
}
// ─── Rule 4: no-ssrf ───────────────────────────────────────────────────────
pub struct NoSsrf;
impl Rule for NoSsrf {
fn id(&self) -> &str {
"java/no-ssrf"
}
fn severity(&self) -> Severity {
Severity::High
}
fn cwe(&self) -> Option<&str> {
Some("CWE-918")
}
fn description(&self) -> &str {
"Potential SSRF via URL or RestTemplate with dynamic input"
}
fn language(&self) -> Language {
Language::Java
}
fn check(&self, source: &str, tree: &tree_sitter::Tree) -> Vec<Finding> {
let mut findings = Vec::new();
walk_tree(tree.root_node(), source, &mut |node, src| {
// new URL(variable)
if node.kind() == "object_creation_expression" {
if let Some(type_node) = node.child_by_field_name("type") {
let type_text = &src[type_node.byte_range()];
if type_text == "URL" {
if let Some(args) = node.child_by_field_name("arguments") {
if let Some(first_arg) = args.named_child(0) {
if !is_literal(first_arg) {
findings.push(make_finding(
self.id(),
self.severity(),
self.cwe(),
"new URL() with dynamic argument — validate and allowlist target hosts to prevent SSRF",
node,
src,
));
}
}
}
}
}
}
// RestTemplate.getForObject(variable, ...)
if node.kind() == "method_invocation" {
if let Some(name) = node.child_by_field_name("name") {
let name_text = &src[name.byte_range()];
if name_text == "getForObject"
|| name_text == "getForEntity"
|| name_text == "postForObject"
|| name_text == "postForEntity"
|| name_text == "exchange"
{
if let Some(obj) = node.child_by_field_name("object") {
let obj_text = &src[obj.byte_range()];
if obj_text.contains("restTemplate")
|| obj_text.contains("RestTemplate")
|| obj_text.contains("template")
{
if let Some(args) = node.child_by_field_name("arguments") {
if let Some(first_arg) = args.named_child(0) {
if !is_literal(first_arg) {
findings.push(make_finding(
self.id(),
self.severity(),
self.cwe(),
"RestTemplate called with dynamic URL — validate and allowlist target hosts to prevent SSRF",
node,
src,
));
}
}
}
}
}
}
}
}
});
findings
}
}
// ─── Rule 5: no-path-traversal ──────────────────────────────────────────────
pub struct NoPathTraversal;
impl Rule for NoPathTraversal {
fn id(&self) -> &str {
"java/no-path-traversal"
}
fn severity(&self) -> Severity {
Severity::High
}
fn cwe(&self) -> Option<&str> {
Some("CWE-22")
}
fn description(&self) -> &str {
"Potential path traversal via dynamic file path"
}
fn language(&self) -> Language {
Language::Java
}
fn check(&self, source: &str, tree: &tree_sitter::Tree) -> Vec<Finding> {
let mut findings = Vec::new();
walk_tree(tree.root_node(), source, &mut |node, src| {
// new File(variable), new FileInputStream(variable)
if node.kind() == "object_creation_expression" {
if let Some(type_node) = node.child_by_field_name("type") {
let type_text = &src[type_node.byte_range()];
if type_text == "File" || type_text == "FileInputStream" {
if let Some(args) = node.child_by_field_name("arguments") {
if let Some(first_arg) = args.named_child(0) {
if !is_literal(first_arg) {
findings.push(make_finding(
self.id(),
self.severity(),
self.cwe(),
&format!(
"new {}() with dynamic path — sanitize input to prevent path traversal",
type_text
),
node,
src,
));
}
}
}
}
}
}
// Paths.get(variable)
if node.kind() == "method_invocation" {
if let Some(name) = node.child_by_field_name("name") {
let name_text = &src[name.byte_range()];
if name_text == "get" {
if let Some(obj) = node.child_by_field_name("object") {
let obj_text = &src[obj.byte_range()];
if obj_text == "Paths" || obj_text == "Path" {
if let Some(args) = node.child_by_field_name("arguments") {
if let Some(first_arg) = args.named_child(0) {
if !is_literal(first_arg) {
findings.push(make_finding(
self.id(),
self.severity(),
self.cwe(),
"Paths.get() with dynamic path — sanitize input to prevent path traversal",
node,
src,
));
}
}
}
}
}
}
}
}
});
findings
}
}
// ─── Rule 6: no-weak-crypto ────────────────────────────────────────────────
pub struct NoWeakCrypto;
impl Rule for NoWeakCrypto {
fn id(&self) -> &str {
"java/no-weak-crypto"
}
fn severity(&self) -> Severity {
Severity::Medium
}
fn cwe(&self) -> Option<&str> {
Some("CWE-327")
}
fn description(&self) -> &str {
"Use of weak cryptographic algorithm"
}
fn language(&self) -> Language {
Language::Java
}
fn check(&self, source: &str, tree: &tree_sitter::Tree) -> Vec<Finding> {
let mut findings = Vec::new();
let weak_algo =
Regex::new(r#"(?i)"(DES|DESede|RC2|RC4|Blowfish|MD5|SHA-?1|.*ECB.*)"#).unwrap();
walk_tree(tree.root_node(), source, &mut |node, src| {
if node.kind() == "method_invocation" {
if let Some(name) = node.child_by_field_name("name") {
let name_text = &src[name.byte_range()];
if name_text == "getInstance" {
if let Some(obj) = node.child_by_field_name("object") {
let obj_text = &src[obj.byte_range()];
if obj_text == "Cipher"
|| obj_text == "MessageDigest"
|| obj_text == "SecretKeyFactory"
|| obj_text == "KeyGenerator"
{
if let Some(args) = node.child_by_field_name("arguments") {
if let Some(first_arg) = args.named_child(0) {
let arg_text = &src[first_arg.byte_range()];
if weak_algo.is_match(arg_text) {
findings.push(make_finding(
self.id(),
self.severity(),
self.cwe(),
&format!(
"{}.getInstance({}) uses a weak algorithm — use AES-GCM, SHA-256, or stronger",
obj_text, arg_text
),
node,
src,
));
}
}
}
}
}
}
}
}
});
findings
}
}
// ─── Rule 7: no-hardcoded-secret ────────────────────────────────────────────
pub struct NoHardcodedSecret;
impl Rule for NoHardcodedSecret {
fn id(&self) -> &str {
"java/no-hardcoded-secret"
}
fn severity(&self) -> Severity {
Severity::High
}
fn cwe(&self) -> Option<&str> {
Some("CWE-798")
}
fn description(&self) -> &str {
"Hardcoded secret or credential detected"
}
fn language(&self) -> Language {
Language::Java
}
fn check(&self, source: &str, tree: &tree_sitter::Tree) -> Vec<Finding> {
let mut findings = Vec::new();
let secret_pattern =
Regex::new(r"(?i)(password|secret|api_?key|apiKey|token|auth|credential|private_?key)")
.unwrap();
walk_tree(tree.root_node(), source, &mut |node, src| {
// variable_declarator: String password = "hardcoded";
if node.kind() == "variable_declarator" {
if let Some(name_node) = node.child_by_field_name("name") {
let name = &src[name_node.byte_range()];
if secret_pattern.is_match(name) {
if let Some(value) = node.child_by_field_name("value") {
if value.kind() == "string_literal" {
let val = &src[value.byte_range()];
let inner = val.trim_matches('"');
if inner.len() >= 4 {
findings.push(make_finding(
self.id(),
self.severity(),
self.cwe(),
&format!(
"Hardcoded secret in '{}' — use environment variables or a secret manager",
name
),
node,
src,
));
}
}
}
}
}
}
// Assignment: password = "hardcoded";
if node.kind() == "assignment_expression" {
if let Some(left) = node.child_by_field_name("left") {
let left_text = &src[left.byte_range()];
if secret_pattern.is_match(left_text) {
if let Some(right) = node.child_by_field_name("right") {
if right.kind() == "string_literal" {
let val = &src[right.byte_range()];
let inner = val.trim_matches('"');
if inner.len() >= 4 {
findings.push(make_finding(
self.id(),
self.severity(),
self.cwe(),
&format!(
"Hardcoded secret in '{}' — use environment variables or a secret manager",
left_text.trim()
),
node,
src,
));
}
}
}
}
}
}
});
findings
}
}
// ─── Rule 8: no-xxe ────────────────────────────────────────────────────────
pub struct NoXxe;
impl Rule for NoXxe {
fn id(&self) -> &str {
"java/no-xxe"
}
fn severity(&self) -> Severity {
Severity::High
}
fn cwe(&self) -> Option<&str> {
Some("CWE-611")
}
fn description(&self) -> &str {
"XML parser created without disabling external entities (XXE)"
}
fn language(&self) -> Language {
Language::Java
}
fn check(&self, source: &str, _tree: &tree_sitter::Tree) -> Vec<Finding> {
let mut findings = Vec::new();
let factory_pattern = Regex::new(
r"(DocumentBuilderFactory|SAXParserFactory|XMLInputFactory)\.newInstance\(\)",
)
.unwrap();
let secure_pattern =
Regex::new(r"setFeature\s*\(|setProperty\s*\(|setAttribute\s*\(").unwrap();
// Simple heuristic: if a factory is created but no setFeature is called
// in the same file, flag it.
if factory_pattern.is_match(source) && !secure_pattern.is_match(source) {
for matched in factory_pattern.find_iter(source) {
findings.push(make_finding_from_offsets(
self.id(),
self.severity(),
self.cwe(),
"XML parser factory created without disabling external entities — set feature to prevent XXE attacks",
source,
matched.start(),
matched.end(),
));
}
}
findings
}
}
// ─── Rule 9: spring-csrf-disabled ───────────────────────────────────────────
pub struct SpringCsrfDisabled;
impl Rule for SpringCsrfDisabled {
fn id(&self) -> &str {
"java/spring-csrf-disabled"
}
fn severity(&self) -> Severity {
Severity::High
}
fn cwe(&self) -> Option<&str> {
Some("CWE-352")
}
fn description(&self) -> &str {
"Spring Security CSRF protection is disabled"
}
fn language(&self) -> Language {
Language::Java
}
fn check(&self, source: &str, _tree: &tree_sitter::Tree) -> Vec<Finding> {
let mut findings = Vec::new();
// .csrf().disable() or csrf(csrf -> csrf.disable()) or csrf(c -> c.disable())
let csrf_pattern = Regex::new(
r"\.csrf\(\s*\)\s*\.\s*disable\(\s*\)|csrf\s*\([^)]*\.\s*disable\(\s*\)\s*\)",
)
.unwrap();
for matched in csrf_pattern.find_iter(source) {
findings.push(make_finding_from_offsets(
self.id(),
self.severity(),
self.cwe(),
"CSRF protection is disabled — enable CSRF unless this is a stateless API with token auth",
source,
matched.start(),
matched.end(),
));
}
findings
}
}
// ─── Rule 10: spring-cors-permissive ────────────────────────────────────────
pub struct SpringCorsPermissive;
impl Rule for SpringCorsPermissive {
fn id(&self) -> &str {
"java/spring-cors-permissive"
}
fn severity(&self) -> Severity {
Severity::Medium
}
fn cwe(&self) -> Option<&str> {
Some("CWE-942")
}
fn description(&self) -> &str {
"Permissive CORS configuration allows any origin"
}
fn language(&self) -> Language {
Language::Java
}
fn check(&self, source: &str, tree: &tree_sitter::Tree) -> Vec<Finding> {
let mut findings = Vec::new();
// allowedOrigins("*")
let wildcard_pattern = Regex::new(r#"allowedOrigins\s*\(\s*"\*"\s*\)"#).unwrap();
for matched in wildcard_pattern.find_iter(source) {
findings.push(make_finding_from_offsets(
self.id(),
self.severity(),
self.cwe(),
"allowedOrigins(\"*\") permits any origin — restrict to trusted domains",
source,
matched.start(),
matched.end(),
));
}
// @CrossOrigin with wildcard or no origin restriction
walk_tree(tree.root_node(), source, &mut |node, src| {
if node.kind() == "annotation" || node.kind() == "marker_annotation" {
let text = &src[node.byte_range()];
if text.contains("CrossOrigin") {
// @CrossOrigin without arguments defaults to *, or with explicit "*"
if text == "@CrossOrigin"
|| text.contains("\"*\"")
|| text.contains("origins = \"*\"")
{
findings.push(make_finding(
self.id(),
self.severity(),
self.cwe(),
"@CrossOrigin with wildcard origin — restrict to trusted domains",
node,
src,
));
}
}
}
});
findings
}
}