repotoire 0.9.0

Graph-powered code analysis CLI. 110 detectors for security, architecture, bus factor, and code quality.
Documentation
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
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
//! Curated registry of dangerous sinks per language. Quality over coverage โ€” ~a dozen of the
//! highest-confidence sinks per language. See spec ยง2 Group A. A taint finding is Blocking only
//! when the SSA path terminates at a sink classified here AND no sanitizer is on the path.

// ---- Public types ----------------------------------------------------------------

/// Language discriminant. Maps 1-to-1 from the file extension / parser language.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Lang {
    Js,
    Ts,
    Python,
    Rust,
    Go,
    Java,
    CSharp,
    C,
    Cpp,
}

/// The kind of dangerous sink.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SinkKind {
    /// OS-level command execution (CWE-78)
    Exec,
    /// Raw SQL execution (CWE-89)
    SqlExec,
    /// Code evaluation / dynamic code generation (CWE-94)
    Eval,
    /// File write where path comes from user input (CWE-22 / CWE-73)
    FsWritePath,
    /// HTML/DOM sink that can lead to XSS (CWE-79)
    HtmlSink,
    /// Outbound HTTP request with user-controlled URL (CWE-918 SSRF)
    UrlFetch,
    /// Unsafe deserialization (CWE-502)
    Deserialize,
    /// XML External Entity injection (CWE-611).
    ///
    /// Intentionally has no entries in the sink tables below โ€” `classify_sink`
    /// never returns this variant. The `XxeDetector` emits it directly when it
    /// identifies an XML parser configured to resolve external entities; the
    /// dangerous condition is a parser-config fact, not a callee name, so it
    /// can't be expressed in this receiver/name registry.
    Xxe,
    /// NoSQL query execution โ€” MongoDB/etc. query objects built from tainted input
    /// (operator injection, `$where`, `$regex`, etc.) (CWE-943).
    ///
    /// Not in the generic sink tables: the `NosqlInjectionDetector` recognizes
    /// the query-build terminus via its own taint config and emits this kind
    /// directly when it classifies a taint path.
    NosqlQuery,
}

impl SinkKind {
    pub fn as_str(&self) -> &'static str {
        match self {
            SinkKind::Exec => "exec",
            SinkKind::SqlExec => "sql_exec",
            SinkKind::Eval => "eval",
            SinkKind::FsWritePath => "fs_write_path",
            SinkKind::HtmlSink => "html_sink",
            SinkKind::UrlFetch => "url_fetch",
            SinkKind::Deserialize => "deserialize",
            SinkKind::Xxe => "xxe",
            SinkKind::NosqlQuery => "nosql_query",
        }
    }
}

// ---- Internal sink table type ----------------------------------------------------

/// A sink entry: (receiver-or-module, method-or-function, kind).
///
/// `receiver` is the qualifier text before the dot (module/object name), or `""` for a
/// bare call. Matching is conservative: exact name match on the call's callee text
/// (`receiver + "." + name`, or just `name` if receiver is `""`). Conditionals such as
/// `shell=True` / `mode='w'` / `SafeLoader` are handled in the individual detectors โ€”
/// not here.
struct Sink {
    receiver: &'static str,
    name: &'static str,
    kind: SinkKind,
}

// ---- JS / TS (shared) -----------------------------------------------------------

const JS_SINKS: &[Sink] = &[
    // OS command execution
    Sink {
        receiver: "child_process",
        name: "exec",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "child_process",
        name: "execSync",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "child_process",
        name: "execFile",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "child_process",
        name: "execFileSync",
        kind: SinkKind::Exec,
    },
    // spawn with {shell:true} โ€” detector checks args before reporting Blocking
    Sink {
        receiver: "child_process",
        name: "spawn",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "child_process",
        name: "spawnSync",
        kind: SinkKind::Exec,
    },
    // Code evaluation
    Sink {
        receiver: "",
        name: "eval",
        kind: SinkKind::Eval,
    },
    Sink {
        receiver: "",
        name: "Function",
        kind: SinkKind::Eval,
    }, // new Function(src)
    // setTimeout/setInterval are eval-equivalent ONLY when the first arg is a
    // string literal, not a callback โ€” the EvalDetector must confirm that
    // before promoting to Blocking.
    Sink {
        receiver: "",
        name: "setInterval",
        kind: SinkKind::Eval,
    },
    Sink {
        receiver: "",
        name: "setTimeout",
        kind: SinkKind::Eval,
    },
    // Filesystem write โ€” path taint
    Sink {
        receiver: "fs",
        name: "writeFile",
        kind: SinkKind::FsWritePath,
    },
    Sink {
        receiver: "fs",
        name: "writeFileSync",
        kind: SinkKind::FsWritePath,
    },
    Sink {
        receiver: "fs",
        name: "appendFile",
        kind: SinkKind::FsWritePath,
    },
    Sink {
        receiver: "fs",
        name: "appendFileSync",
        kind: SinkKind::FsWritePath,
    },
    Sink {
        receiver: "fs",
        name: "createWriteStream",
        kind: SinkKind::FsWritePath,
    },
    Sink {
        receiver: "fs",
        name: "unlink",
        kind: SinkKind::FsWritePath,
    },
    Sink {
        receiver: "fs",
        name: "rename",
        kind: SinkKind::FsWritePath,
    },
    Sink {
        receiver: "fs",
        name: "rmdir",
        kind: SinkKind::FsWritePath,
    },
    // Outbound HTTP / SSRF โ€” detector checks that URL arg is tainted
    Sink {
        receiver: "",
        name: "fetch",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "axios",
        name: "get",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "axios",
        name: "post",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "axios",
        name: "put",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "axios",
        name: "request",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "http",
        name: "get",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "http",
        name: "request",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "https",
        name: "get",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "https",
        name: "request",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "got",
        name: "get",
        kind: SinkKind::UrlFetch,
    },
    // HTML / DOM sinks โ†’ XSS. Property-write sinks (innerHTML = x, dangerouslySetInnerHTML,
    // res.send / res.write) are detected per-property by the XSS detector; it reports
    // SinkKind::HtmlSink itself. The entries below cover function-call forms.
    Sink {
        receiver: "document",
        name: "write",
        kind: SinkKind::HtmlSink,
    },
    Sink {
        receiver: "document",
        name: "writeln",
        kind: SinkKind::HtmlSink,
    },
];

// ---- Python ---------------------------------------------------------------------

const PY_SINKS: &[Sink] = &[
    // OS command execution
    Sink {
        receiver: "os",
        name: "system",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "os",
        name: "popen",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "os",
        name: "execv",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "os",
        name: "execve",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "os",
        name: "execvp",
        kind: SinkKind::Exec,
    },
    // subprocess โ€” only when shell=True; detector checks before reporting Blocking
    Sink {
        receiver: "subprocess",
        name: "call",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "subprocess",
        name: "run",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "subprocess",
        name: "Popen",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "subprocess",
        name: "check_output",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "subprocess",
        name: "check_call",
        kind: SinkKind::Exec,
    },
    // Code evaluation
    Sink {
        receiver: "",
        name: "eval",
        kind: SinkKind::Eval,
    },
    Sink {
        receiver: "",
        name: "exec",
        kind: SinkKind::Eval,
    },
    // (`compile()` alone is not a sink โ€” it returns a code object; the danger is
    //  `eval`/`exec` of the result, which are already covered above.)
    // Filesystem write โ€” only write/append modes; detector checks mode arg
    Sink {
        receiver: "",
        name: "open",
        kind: SinkKind::FsWritePath,
    },
    // Unsafe deserialization
    Sink {
        receiver: "pickle",
        name: "loads",
        kind: SinkKind::Deserialize,
    },
    Sink {
        receiver: "pickle",
        name: "load",
        kind: SinkKind::Deserialize,
    },
    Sink {
        receiver: "_pickle",
        name: "loads",
        kind: SinkKind::Deserialize,
    },
    Sink {
        receiver: "_pickle",
        name: "load",
        kind: SinkKind::Deserialize,
    },
    // yaml.load without SafeLoader โ€” detector checks Loader kwarg
    Sink {
        receiver: "yaml",
        name: "load",
        kind: SinkKind::Deserialize,
    },
    // Outbound HTTP / SSRF
    Sink {
        receiver: "requests",
        name: "get",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "requests",
        name: "post",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "requests",
        name: "put",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "requests",
        name: "delete",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "requests",
        name: "request",
        kind: SinkKind::UrlFetch,
    },
    // Both `urllib` and `urllib.request` are listed because the call's
    // qualifier text depends on the import form (`import urllib` vs
    // `import urllib.request`); the dotted-path entry is a no-op if the taint
    // infra never produces that receiver string, never a false negative.
    Sink {
        receiver: "urllib",
        name: "urlopen",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "urllib.request",
        name: "urlopen",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "httpx",
        name: "get",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "httpx",
        name: "post",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "httpx",
        name: "request",
        kind: SinkKind::UrlFetch,
    },
];

// ---- Rust -----------------------------------------------------------------------

const RUST_SINKS: &[Sink] = &[
    // OS command execution
    Sink {
        receiver: "Command",
        name: "new",
        kind: SinkKind::Exec,
    }, // std::process::Command::new(<tainted>)
    Sink {
        receiver: "",
        name: "system",
        kind: SinkKind::Exec,
    }, // libc::system
    // Filesystem write โ€” path taint
    Sink {
        receiver: "fs",
        name: "write",
        kind: SinkKind::FsWritePath,
    },
    Sink {
        receiver: "fs",
        name: "remove_file",
        kind: SinkKind::FsWritePath,
    },
    Sink {
        receiver: "File",
        name: "create",
        kind: SinkKind::FsWritePath,
    },
    // (`File::open` is read-only by default โ€” not a write-path sink. A tainted
    //  path to it is a read-side path-traversal concern handled by the
    //  PathTraversalDetector, not promoted here.)
    // Outbound HTTP / SSRF
    Sink {
        receiver: "reqwest",
        name: "get",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "reqwest",
        name: "post",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "reqwest",
        name: "request",
        kind: SinkKind::UrlFetch,
    },
];

// ---- Go -------------------------------------------------------------------------

const GO_SINKS: &[Sink] = &[
    // OS command execution
    Sink {
        receiver: "exec",
        name: "Command",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "exec",
        name: "CommandContext",
        kind: SinkKind::Exec,
    },
    // Filesystem write โ€” path taint
    Sink {
        receiver: "os",
        name: "OpenFile",
        kind: SinkKind::FsWritePath,
    },
    Sink {
        receiver: "os",
        name: "Create",
        kind: SinkKind::FsWritePath,
    },
    Sink {
        receiver: "os",
        name: "Remove",
        kind: SinkKind::FsWritePath,
    },
    Sink {
        receiver: "os",
        name: "WriteFile",
        kind: SinkKind::FsWritePath,
    },
    // `ioutil.WriteFile` is deprecated since Go 1.16 in favour of `os.WriteFile`
    // above, but retained for older codebases.
    Sink {
        receiver: "ioutil",
        name: "WriteFile",
        kind: SinkKind::FsWritePath,
    },
    // Outbound HTTP / SSRF
    Sink {
        receiver: "http",
        name: "Get",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "http",
        name: "Post",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "http",
        name: "NewRequest",
        kind: SinkKind::UrlFetch,
    },
    // HTML template sinks
    Sink {
        receiver: "template",
        name: "HTML",
        kind: SinkKind::HtmlSink,
    },
];

// ---- Java -----------------------------------------------------------------------

const JAVA_SINKS: &[Sink] = &[
    // OS command execution
    Sink {
        receiver: "Runtime",
        name: "exec",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "ProcessBuilder",
        name: "command",
        kind: SinkKind::Exec,
    },
    // Raw SQL
    Sink {
        receiver: "Statement",
        name: "execute",
        kind: SinkKind::SqlExec,
    },
    Sink {
        receiver: "Statement",
        name: "executeQuery",
        kind: SinkKind::SqlExec,
    },
    Sink {
        receiver: "Statement",
        name: "executeUpdate",
        kind: SinkKind::SqlExec,
    },
    Sink {
        receiver: "Statement",
        name: "executeLargeUpdate",
        kind: SinkKind::SqlExec,
    },
    // Outbound HTTP / SSRF
    Sink {
        receiver: "URL",
        name: "openConnection",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "HttpClient",
        name: "send",
        kind: SinkKind::UrlFetch,
    },
];

// ---- C# -------------------------------------------------------------------------

const CSHARP_SINKS: &[Sink] = &[
    // OS command execution
    Sink {
        receiver: "Process",
        name: "Start",
        kind: SinkKind::Exec,
    },
    // Raw SQL
    Sink {
        receiver: "SqlCommand",
        name: "ExecuteReader",
        kind: SinkKind::SqlExec,
    },
    Sink {
        receiver: "SqlCommand",
        name: "ExecuteNonQuery",
        kind: SinkKind::SqlExec,
    },
    Sink {
        receiver: "SqlCommand",
        name: "ExecuteScalar",
        kind: SinkKind::SqlExec,
    },
    // Outbound HTTP / SSRF
    Sink {
        receiver: "HttpClient",
        name: "GetAsync",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "HttpClient",
        name: "PostAsync",
        kind: SinkKind::UrlFetch,
    },
    Sink {
        receiver: "HttpClient",
        name: "SendAsync",
        kind: SinkKind::UrlFetch,
    },
    // Code evaluation
    Sink {
        receiver: "CSharpScript",
        name: "EvaluateAsync",
        kind: SinkKind::Eval,
    },
];

// ---- C / C++ -------------------------------------------------------------------

// C++ shares C_SINKS. The narrow list covers only the clearest cases where tainted
// data reaches a bare libc / POSIX function that is *always* dangerous.
const C_SINKS: &[Sink] = &[
    Sink {
        receiver: "",
        name: "system",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "",
        name: "popen",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "",
        name: "execve",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "",
        name: "execvp",
        kind: SinkKind::Exec,
    },
    Sink {
        receiver: "",
        name: "execv",
        kind: SinkKind::Exec,
    },
];

// ---- Dispatch -------------------------------------------------------------------

fn sinks_for(lang: Lang) -> &'static [Sink] {
    match lang {
        Lang::Js | Lang::Ts => JS_SINKS,
        Lang::Python => PY_SINKS,
        Lang::Rust => RUST_SINKS,
        Lang::Go => GO_SINKS,
        Lang::Java => JAVA_SINKS,
        Lang::CSharp => CSHARP_SINKS,
        Lang::C | Lang::Cpp => C_SINKS,
    }
}

// ---- Public API -----------------------------------------------------------------

/// Classify a call site as a dangerous sink, if it is one.
///
/// `receiver` is the qualifier text before the dot (module / object), or `""` for a bare
/// call. `name` is the method or function name (no dot). Returns `None` if the site is
/// not in the registry โ€” the caller must NOT promote it to Blocking.
pub fn classify_sink(lang: Lang, receiver: &str, name: &str) -> Option<SinkKind> {
    sinks_for(lang)
        .iter()
        .find(|s| s.receiver == receiver && s.name == name)
        .map(|s| s.kind)
}

// ---- Tests ----------------------------------------------------------------------

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn classifies_known_sinks() {
        assert_eq!(
            classify_sink(Lang::Js, "child_process", "exec"),
            Some(SinkKind::Exec)
        );
        assert_eq!(classify_sink(Lang::Js, "", "eval"), Some(SinkKind::Eval));
        assert_eq!(
            classify_sink(Lang::Python, "os", "system"),
            Some(SinkKind::Exec)
        );
        assert_eq!(classify_sink(Lang::Python, "", "println"), None); // not a sink
        assert_eq!(
            classify_sink(Lang::Rust, "Command", "new"),
            Some(SinkKind::Exec)
        );
        assert_eq!(SinkKind::Exec.as_str(), "exec");
    }

    #[test]
    fn classifies_js_sinks_exhaustively() {
        // Eval
        assert_eq!(
            classify_sink(Lang::Js, "", "Function"),
            Some(SinkKind::Eval)
        );
        // FS write
        assert_eq!(
            classify_sink(Lang::Js, "fs", "writeFile"),
            Some(SinkKind::FsWritePath)
        );
        assert_eq!(
            classify_sink(Lang::Js, "fs", "createWriteStream"),
            Some(SinkKind::FsWritePath)
        );
        assert_eq!(
            classify_sink(Lang::Js, "fs", "unlink"),
            Some(SinkKind::FsWritePath)
        );
        // URL fetch
        assert_eq!(
            classify_sink(Lang::Js, "", "fetch"),
            Some(SinkKind::UrlFetch)
        );
        assert_eq!(
            classify_sink(Lang::Js, "axios", "get"),
            Some(SinkKind::UrlFetch)
        );
        assert_eq!(
            classify_sink(Lang::Js, "https", "get"),
            Some(SinkKind::UrlFetch)
        );
        // HTML
        assert_eq!(
            classify_sink(Lang::Js, "document", "write"),
            Some(SinkKind::HtmlSink)
        );
    }

    #[test]
    fn classifies_python_sinks_exhaustively() {
        // exec
        assert_eq!(
            classify_sink(Lang::Python, "subprocess", "run"),
            Some(SinkKind::Exec)
        );
        assert_eq!(
            classify_sink(Lang::Python, "subprocess", "Popen"),
            Some(SinkKind::Exec)
        );
        assert_eq!(
            classify_sink(Lang::Python, "os", "popen"),
            Some(SinkKind::Exec)
        );
        // eval
        assert_eq!(
            classify_sink(Lang::Python, "", "eval"),
            Some(SinkKind::Eval)
        );
        assert_eq!(
            classify_sink(Lang::Python, "", "exec"),
            Some(SinkKind::Eval)
        );
        // fs
        assert_eq!(
            classify_sink(Lang::Python, "", "open"),
            Some(SinkKind::FsWritePath)
        );
        // deserialize
        assert_eq!(
            classify_sink(Lang::Python, "pickle", "loads"),
            Some(SinkKind::Deserialize)
        );
        assert_eq!(
            classify_sink(Lang::Python, "yaml", "load"),
            Some(SinkKind::Deserialize)
        );
        // url
        assert_eq!(
            classify_sink(Lang::Python, "requests", "get"),
            Some(SinkKind::UrlFetch)
        );
        assert_eq!(
            classify_sink(Lang::Python, "urllib", "urlopen"),
            Some(SinkKind::UrlFetch)
        );
    }

    #[test]
    fn classifies_rust_sinks_exhaustively() {
        assert_eq!(
            classify_sink(Lang::Rust, "Command", "new"),
            Some(SinkKind::Exec)
        );
        assert_eq!(
            classify_sink(Lang::Rust, "fs", "write"),
            Some(SinkKind::FsWritePath)
        );
        assert_eq!(
            classify_sink(Lang::Rust, "File", "create"),
            Some(SinkKind::FsWritePath)
        );
        assert_eq!(
            classify_sink(Lang::Rust, "reqwest", "get"),
            Some(SinkKind::UrlFetch)
        );
    }

    #[test]
    fn classifies_go_sinks_exhaustively() {
        assert_eq!(
            classify_sink(Lang::Go, "exec", "Command"),
            Some(SinkKind::Exec)
        );
        assert_eq!(
            classify_sink(Lang::Go, "os", "Create"),
            Some(SinkKind::FsWritePath)
        );
        assert_eq!(
            classify_sink(Lang::Go, "http", "Get"),
            Some(SinkKind::UrlFetch)
        );
        assert_eq!(
            classify_sink(Lang::Go, "template", "HTML"),
            Some(SinkKind::HtmlSink)
        );
    }

    #[test]
    fn classifies_java_sinks_exhaustively() {
        assert_eq!(
            classify_sink(Lang::Java, "Runtime", "exec"),
            Some(SinkKind::Exec)
        );
        assert_eq!(
            classify_sink(Lang::Java, "Statement", "executeQuery"),
            Some(SinkKind::SqlExec)
        );
        assert_eq!(
            classify_sink(Lang::Java, "URL", "openConnection"),
            Some(SinkKind::UrlFetch)
        );
    }

    #[test]
    fn classifies_csharp_sinks_exhaustively() {
        assert_eq!(
            classify_sink(Lang::CSharp, "Process", "Start"),
            Some(SinkKind::Exec)
        );
        assert_eq!(
            classify_sink(Lang::CSharp, "SqlCommand", "ExecuteReader"),
            Some(SinkKind::SqlExec)
        );
        assert_eq!(
            classify_sink(Lang::CSharp, "HttpClient", "GetAsync"),
            Some(SinkKind::UrlFetch)
        );
    }

    #[test]
    fn classifies_c_and_cpp_sinks() {
        assert_eq!(classify_sink(Lang::C, "", "system"), Some(SinkKind::Exec));
        assert_eq!(classify_sink(Lang::C, "", "popen"), Some(SinkKind::Exec));
        assert_eq!(classify_sink(Lang::Cpp, "", "system"), Some(SinkKind::Exec));
        assert_eq!(classify_sink(Lang::Cpp, "", "execve"), Some(SinkKind::Exec));
    }

    #[test]
    fn ts_shares_js_sinks() {
        // TypeScript reuses the JS table
        assert_eq!(
            classify_sink(Lang::Ts, "child_process", "exec"),
            Some(SinkKind::Exec)
        );
        assert_eq!(classify_sink(Lang::Ts, "", "eval"), Some(SinkKind::Eval));
        assert_eq!(
            classify_sink(Lang::Ts, "axios", "request"),
            Some(SinkKind::UrlFetch)
        );
    }

    #[test]
    fn unknown_callees_return_none() {
        assert_eq!(classify_sink(Lang::Js, "", "console.log"), None);
        assert_eq!(classify_sink(Lang::Python, "", "print"), None);
        assert_eq!(classify_sink(Lang::Rust, "", "println"), None);
        assert_eq!(classify_sink(Lang::Go, "", "fmt.Println"), None);
    }

    #[test]
    fn sink_kind_as_str_round_trips() {
        assert_eq!(SinkKind::Exec.as_str(), "exec");
        assert_eq!(SinkKind::SqlExec.as_str(), "sql_exec");
        assert_eq!(SinkKind::Eval.as_str(), "eval");
        assert_eq!(SinkKind::FsWritePath.as_str(), "fs_write_path");
        assert_eq!(SinkKind::HtmlSink.as_str(), "html_sink");
        assert_eq!(SinkKind::UrlFetch.as_str(), "url_fetch");
        assert_eq!(SinkKind::Deserialize.as_str(), "deserialize");
        assert_eq!(SinkKind::Xxe.as_str(), "xxe");
        assert_eq!(SinkKind::NosqlQuery.as_str(), "nosql_query");
    }
}