fallow_types/extract_sink_values.rs
1//! Literal and option metadata that the extractor attaches to a sink site.
2
3/// Literal values attached to literal-aware security sink captures.
4#[derive(
5 Debug,
6 Clone,
7 PartialEq,
8 Eq,
9 serde::Serialize,
10 serde::Deserialize,
11 bitcode::Encode,
12 bitcode::Decode,
13)]
14pub enum SinkLiteralValue {
15 /// A string literal value.
16 String(String),
17 /// An integer numeric literal value.
18 Integer(i64),
19 /// A boolean literal value.
20 Boolean(bool),
21 /// A null literal value.
22 Null,
23}
24
25/// Static object-literal property metadata attached to a captured sink
26/// argument. Nested object paths are flattened with dot-separated keys.
27#[derive(
28 Debug,
29 Clone,
30 PartialEq,
31 Eq,
32 serde::Serialize,
33 serde::Deserialize,
34 bitcode::Encode,
35 bitcode::Decode,
36)]
37pub struct SinkObjectProperty {
38 /// Static property name. Nested object properties use dot-separated paths.
39 pub key: String,
40 /// Literal property value when statically knowable.
41 pub value: SinkLiteralValue,
42}
43
44/// Static metadata of the options object of a call whose options position the
45/// extractor knows, attached to the command argument of the call (for example
46/// `child_process.spawn(command, args, options)`). A call without an options
47/// argument has empty, complete metadata.
48#[derive(
49 Debug,
50 Clone,
51 PartialEq,
52 Eq,
53 serde::Serialize,
54 serde::Deserialize,
55 bitcode::Encode,
56 bitcode::Decode,
57)]
58pub struct SinkCallOptions {
59 /// Static literal properties of the options object.
60 pub properties: Vec<SinkObjectProperty>,
61 /// Static top-level keys of the options object, including keys whose
62 /// values are not literal.
63 pub keys: Vec<String>,
64 /// Whether [`keys`](Self::keys) is complete. False when the options
65 /// argument is not an object literal, or has a spread or a computed key.
66 pub keys_complete: bool,
67}