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
//! Literal and option metadata that the extractor attaches to a sink site.
/// Literal values attached to literal-aware security sink captures.
#[derive(
Debug,
Clone,
PartialEq,
Eq,
serde::Serialize,
serde::Deserialize,
bitcode::Encode,
bitcode::Decode,
)]
pub enum SinkLiteralValue {
/// A string literal value.
String(String),
/// An integer numeric literal value.
Integer(i64),
/// A boolean literal value.
Boolean(bool),
/// A null literal value.
Null,
}
/// Static object-literal property metadata attached to a captured sink
/// argument. Nested object paths are flattened with dot-separated keys.
#[derive(
Debug,
Clone,
PartialEq,
Eq,
serde::Serialize,
serde::Deserialize,
bitcode::Encode,
bitcode::Decode,
)]
pub struct SinkObjectProperty {
/// Static property name. Nested object properties use dot-separated paths.
pub key: String,
/// Literal property value when statically knowable.
pub value: SinkLiteralValue,
}
/// Static metadata of the options object of a call whose options position the
/// extractor knows, attached to the command argument of the call (for example
/// `child_process.spawn(command, args, options)`). A call without an options
/// argument has empty, complete metadata.
#[derive(
Debug,
Clone,
PartialEq,
Eq,
serde::Serialize,
serde::Deserialize,
bitcode::Encode,
bitcode::Decode,
)]
pub struct SinkCallOptions {
/// Static literal properties of the options object.
pub properties: Vec<SinkObjectProperty>,
/// Static top-level keys of the options object, including keys whose
/// values are not literal.
pub keys: Vec<String>,
/// Whether [`keys`](Self::keys) is complete. False when the options
/// argument is not an object literal, or has a spread or a computed key.
pub keys_complete: bool,
}
/// Static URL construction shape captured for URL-shaped security sinks.
#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
serde::Serialize,
serde::Deserialize,
bitcode::Encode,
bitcode::Decode,
)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "kebab-case")]
pub enum SecurityUrlShape {
/// The sink target has a fixed origin, scheme, or relative root while only
/// path or query components are dynamic.
FixedOriginDynamicPath,
/// The sink target's scheme or origin is dynamic or opaque.
DynamicOrigin,
}