dart-decimate 0.0.39 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +27 -28
- package/Cargo.toml +3 -3
- package/README.md +6 -2
- package/package.json +2 -2
- package/src/baseline.rs +7 -7
- package/src/ci_template.rs +6 -6
- package/src/cli/coverage_run.rs +12 -12
- package/src/cli/dupes_args.rs +16 -16
- package/src/cli/health_args.rs +28 -28
- package/src/cli/request_args.rs +4 -4
- package/src/cli.rs +4 -4
- package/src/dart_parser.rs +707 -31
- package/src/extract/members.rs +4 -4
- package/src/extract/primary_constructors.rs +5 -5
- package/src/extract/references.rs +8 -8
- package/src/extract/routes.rs +38 -40
- package/src/extract/signatures.rs +8 -8
- package/src/extract/strings.rs +2 -3
- package/src/extract/tests.rs +71 -0
- package/src/extract.rs +8 -8
- package/src/graph/parts.rs +5 -6
- package/src/graph.rs +24 -25
- package/src/health/runtime_coverage.rs +5 -5
- package/src/output/next_steps.rs +4 -4
- package/src/output/security_sarif.rs +10 -10
- package/src/output/suppressions.rs +12 -12
- package/src/package_map.rs +18 -20
- package/src/security/detect/weak_randomness.rs +3 -5
- package/src/security/detect.rs +18 -17
- package/src/widgets/patterns.rs +2 -0
- package/src/widgets/tests.rs +28 -5
- package/src/widgets/top_level.rs +2 -0
- package/src/widgets/unrendered.rs +8 -8
package/src/extract/members.rs
CHANGED
|
@@ -202,10 +202,10 @@ fn collect_member_field_names(node: Node<'_>, source: &str, names: &mut Vec<Stri
|
|
|
202
202
|
&["static_final_declaration", "initialized_identifier"],
|
|
203
203
|
names,
|
|
204
204
|
);
|
|
205
|
-
if names.is_empty()
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
205
|
+
if names.is_empty()
|
|
206
|
+
&& let Some(identifier_list) = find_first_named_descendant(node, "identifier_list")
|
|
207
|
+
{
|
|
208
|
+
collect_direct_identifier_children(identifier_list, source, names);
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
|
|
@@ -76,11 +76,11 @@ fn primary_constructor_headers(source: &str) -> Vec<PrimaryConstructorHeader> {
|
|
|
76
76
|
};
|
|
77
77
|
let declaration = source[name_start..name_end].to_owned();
|
|
78
78
|
let mut header_cursor = skip_whitespace(source, name_end).unwrap_or(name_end);
|
|
79
|
-
if source.as_bytes().get(header_cursor).copied() == Some(b'<')
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
if source.as_bytes().get(header_cursor).copied() == Some(b'<')
|
|
80
|
+
&& let Some(type_params_end) = matching_delimiter(source, header_cursor, b'<', b'>')
|
|
81
|
+
{
|
|
82
|
+
header_cursor =
|
|
83
|
+
skip_whitespace(source, type_params_end + 1).unwrap_or(type_params_end + 1);
|
|
84
84
|
}
|
|
85
85
|
if source.as_bytes().get(header_cursor).copied() == Some(b'.') {
|
|
86
86
|
let suffix_start =
|
|
@@ -20,14 +20,14 @@ fn collect_identifier_references(
|
|
|
20
20
|
collect_string_interpolation_references(node, source, references);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
if is_reference_identifier(node, source)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
23
|
+
if is_reference_identifier(node, source)
|
|
24
|
+
&& let Ok(name) = node.utf8_text(source.as_bytes())
|
|
25
|
+
{
|
|
26
|
+
references.push(IdentifierReference {
|
|
27
|
+
name: name.to_owned(),
|
|
28
|
+
qualifier: simple_member_qualifier(node, source),
|
|
29
|
+
location: node.start_position().into(),
|
|
30
|
+
});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
let mut cursor = node.walk();
|
package/src/extract/routes.rs
CHANGED
|
@@ -72,35 +72,35 @@ fn collect_raw_routes_in(
|
|
|
72
72
|
parent_resolved: bool,
|
|
73
73
|
routes: &mut Vec<DartRouteDeclaration>,
|
|
74
74
|
) {
|
|
75
|
-
if is_object_constructor(node)
|
|
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
|
-
return;
|
|
75
|
+
if is_object_constructor(node)
|
|
76
|
+
&& let Some(route_kind) = raw_route_constructor_kind(node, source)
|
|
77
|
+
{
|
|
78
|
+
let next_parent = match route_kind {
|
|
79
|
+
RawRouteKind::GoRoute => collect_go_route(
|
|
80
|
+
node,
|
|
81
|
+
source,
|
|
82
|
+
constants,
|
|
83
|
+
parent_path,
|
|
84
|
+
parent_resolved,
|
|
85
|
+
routes,
|
|
86
|
+
),
|
|
87
|
+
RawRouteKind::RouteContainer => None,
|
|
88
|
+
};
|
|
89
|
+
let next_parent_resolved = match route_kind {
|
|
90
|
+
RawRouteKind::GoRoute => next_parent.is_some(),
|
|
91
|
+
RawRouteKind::RouteContainer => parent_resolved,
|
|
92
|
+
};
|
|
93
|
+
for child_routes_arg in route_child_argument_nodes(node, source) {
|
|
94
|
+
collect_raw_routes_in(
|
|
95
|
+
child_routes_arg,
|
|
96
|
+
source,
|
|
97
|
+
constants,
|
|
98
|
+
next_parent.as_deref().or(parent_path),
|
|
99
|
+
next_parent_resolved,
|
|
100
|
+
routes,
|
|
101
|
+
);
|
|
103
102
|
}
|
|
103
|
+
return;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
let mut cursor = node.walk();
|
|
@@ -235,19 +235,17 @@ fn collect_string_constants_in(
|
|
|
235
235
|
node.kind(),
|
|
236
236
|
"static_final_declaration" | "initialized_identifier"
|
|
237
237
|
) && is_const_string_declaration(node, source)
|
|
238
|
+
&& let Some(name) = field_text(node, "name", source)
|
|
239
|
+
&& let Some(value) = node.child_by_field_name("value").and_then(|value| {
|
|
240
|
+
value
|
|
241
|
+
.utf8_text(source.as_bytes())
|
|
242
|
+
.ok()
|
|
243
|
+
.and_then(unquote_dart_string)
|
|
244
|
+
})
|
|
238
245
|
{
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
.utf8_text(source.as_bytes())
|
|
243
|
-
.ok()
|
|
244
|
-
.and_then(unquote_dart_string)
|
|
245
|
-
}) {
|
|
246
|
-
constants.insert(name.clone(), value.clone());
|
|
247
|
-
if let Some(class_name) = containing_class_name(node, source) {
|
|
248
|
-
constants.insert(format!("{class_name}.{name}"), value);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
246
|
+
constants.insert(name.clone(), value.clone());
|
|
247
|
+
if let Some(class_name) = containing_class_name(node, source) {
|
|
248
|
+
constants.insert(format!("{class_name}.{name}"), value);
|
|
251
249
|
}
|
|
252
250
|
}
|
|
253
251
|
|
|
@@ -192,10 +192,10 @@ fn variable_names(node: Node<'_>, source: &str) -> Vec<String> {
|
|
|
192
192
|
&mut names,
|
|
193
193
|
);
|
|
194
194
|
|
|
195
|
-
if names.is_empty()
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
if names.is_empty()
|
|
196
|
+
&& let Some(identifier_list) = find_first_named_descendant(node, "identifier_list")
|
|
197
|
+
{
|
|
198
|
+
collect_direct_identifier_children(identifier_list, source, &mut names);
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
names
|
|
@@ -218,10 +218,10 @@ fn collect_named_fields(
|
|
|
218
218
|
owner_kinds: &[&str],
|
|
219
219
|
names: &mut Vec<String>,
|
|
220
220
|
) {
|
|
221
|
-
if owner_kinds.contains(&node.kind())
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
if owner_kinds.contains(&node.kind())
|
|
222
|
+
&& let Some(name) = field_text(node, "name", source)
|
|
223
|
+
{
|
|
224
|
+
names.push(name);
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
let mut cursor = node.walk();
|
package/src/extract/strings.rs
CHANGED
|
@@ -13,10 +13,9 @@ fn quoted_dart_string_body(trimmed: &str) -> Option<(&str, bool)> {
|
|
|
13
13
|
if let Some(raw) = trimmed
|
|
14
14
|
.strip_prefix('r')
|
|
15
15
|
.or_else(|| trimmed.strip_prefix('R'))
|
|
16
|
+
&& let Some(quoted) = quoted_dart_string_body_without_prefix(raw)
|
|
16
17
|
{
|
|
17
|
-
|
|
18
|
-
return Some((quoted, true));
|
|
19
|
-
}
|
|
18
|
+
return Some((quoted, true));
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
quoted_dart_string_body_without_prefix(trimmed).map(|quoted| (quoted, false))
|
package/src/extract/tests.rs
CHANGED
|
@@ -524,6 +524,77 @@ extension type UserId(String value) {
|
|
|
524
524
|
Ok(())
|
|
525
525
|
}
|
|
526
526
|
|
|
527
|
+
#[test]
|
|
528
|
+
fn extracts_dart_313_abbreviated_constructors_with_exact_member_names() -> Result<(), ExtractError>
|
|
529
|
+
{
|
|
530
|
+
let source = r"
|
|
531
|
+
class Box {
|
|
532
|
+
new() {}
|
|
533
|
+
new named() {}
|
|
534
|
+
const new cached();
|
|
535
|
+
final untouched = new Other();
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
class FactoryBox {
|
|
539
|
+
factory() {}
|
|
540
|
+
factory namedFactory() {}
|
|
541
|
+
const factory constFactory() = FactoryBox.cached;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
mixin class MixinBox {
|
|
545
|
+
new() {}
|
|
546
|
+
new named() {}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
enum Tone {
|
|
550
|
+
quiet;
|
|
551
|
+
const new();
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
extension type UserId(int value) {
|
|
555
|
+
new() : this(0);
|
|
556
|
+
}
|
|
557
|
+
";
|
|
558
|
+
|
|
559
|
+
let extracted = extract_dart_source("lib/constructors.dart", source)?;
|
|
560
|
+
let members = extracted
|
|
561
|
+
.members
|
|
562
|
+
.iter()
|
|
563
|
+
.map(|member| (member.owner.as_str(), member.kind, member.name.as_str()))
|
|
564
|
+
.collect::<Vec<_>>();
|
|
565
|
+
|
|
566
|
+
for expected in [
|
|
567
|
+
("Box", MemberKind::Constructor, "Box"),
|
|
568
|
+
("Box", MemberKind::Constructor, "named"),
|
|
569
|
+
("Box", MemberKind::Constructor, "cached"),
|
|
570
|
+
("Box", MemberKind::Field, "untouched"),
|
|
571
|
+
("FactoryBox", MemberKind::Constructor, "FactoryBox"),
|
|
572
|
+
("FactoryBox", MemberKind::Constructor, "namedFactory"),
|
|
573
|
+
("FactoryBox", MemberKind::Constructor, "constFactory"),
|
|
574
|
+
("MixinBox", MemberKind::Constructor, "MixinBox"),
|
|
575
|
+
("MixinBox", MemberKind::Constructor, "named"),
|
|
576
|
+
("Tone", MemberKind::Constructor, "Tone"),
|
|
577
|
+
("UserId", MemberKind::Constructor, "UserId"),
|
|
578
|
+
] {
|
|
579
|
+
assert!(members.contains(&expected), "missing member {expected:?}");
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
assert_eq!(
|
|
583
|
+
members
|
|
584
|
+
.iter()
|
|
585
|
+
.filter(|(owner, kind, _)| {
|
|
586
|
+
*kind == MemberKind::Constructor
|
|
587
|
+
&& matches!(
|
|
588
|
+
*owner,
|
|
589
|
+
"Box" | "FactoryBox" | "MixinBox" | "Tone" | "UserId"
|
|
590
|
+
)
|
|
591
|
+
})
|
|
592
|
+
.count(),
|
|
593
|
+
10
|
|
594
|
+
);
|
|
595
|
+
Ok(())
|
|
596
|
+
}
|
|
597
|
+
|
|
527
598
|
#[test]
|
|
528
599
|
fn extracts_identifier_references_without_directive_metadata_or_declaration_names()
|
|
529
600
|
-> Result<(), ExtractError> {
|
package/src/extract.rs
CHANGED
|
@@ -557,10 +557,10 @@ fn push_variable_declarations(
|
|
|
557
557
|
&mut names,
|
|
558
558
|
);
|
|
559
559
|
|
|
560
|
-
if names.is_empty()
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
560
|
+
if names.is_empty()
|
|
561
|
+
&& let Some(identifier_list) = find_first_named_descendant(node, "identifier_list")
|
|
562
|
+
{
|
|
563
|
+
collect_direct_identifier_children(identifier_list, source, &mut names);
|
|
564
564
|
}
|
|
565
565
|
|
|
566
566
|
declarations.extend(names.into_iter().map(|name| TopLevelDeclaration {
|
|
@@ -608,10 +608,10 @@ fn collect_named_fields(
|
|
|
608
608
|
owner_kinds: &[&str],
|
|
609
609
|
names: &mut Vec<String>,
|
|
610
610
|
) {
|
|
611
|
-
if owner_kinds.contains(&node.kind())
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
611
|
+
if owner_kinds.contains(&node.kind())
|
|
612
|
+
&& let Some(name) = field_text(node, "name", source)
|
|
613
|
+
{
|
|
614
|
+
names.push(name);
|
|
615
615
|
}
|
|
616
616
|
|
|
617
617
|
let mut cursor = node.walk();
|
package/src/graph/parts.rs
CHANGED
|
@@ -129,13 +129,12 @@ pub(super) fn add_part_dependency(
|
|
|
129
129
|
});
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
|
-
if let Some(part) = files_by_path.get(&target_path).copied()
|
|
133
|
-
|
|
132
|
+
if let Some(part) = files_by_path.get(&target_path).copied()
|
|
133
|
+
&& let Some(relationship) =
|
|
134
134
|
invalid_part_relationship(root, packages, library, part, specifier)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
135
|
+
{
|
|
136
|
+
invalid_part_relationships.push(relationship);
|
|
137
|
+
return;
|
|
139
138
|
}
|
|
140
139
|
part_owners.insert(target_path.clone(), from_path.to_path_buf());
|
|
141
140
|
|
package/src/graph.rs
CHANGED
|
@@ -394,23 +394,23 @@ fn add_file_dependencies(
|
|
|
394
394
|
return;
|
|
395
395
|
};
|
|
396
396
|
|
|
397
|
-
if let Some(library) = &file.library
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
)
|
|
413
|
-
|
|
397
|
+
if let Some(library) = &file.library
|
|
398
|
+
&& let Some(augment_uri) = &library.augment_uri
|
|
399
|
+
{
|
|
400
|
+
add_dependency(
|
|
401
|
+
root,
|
|
402
|
+
packages,
|
|
403
|
+
known_paths,
|
|
404
|
+
nodes_by_path,
|
|
405
|
+
graph,
|
|
406
|
+
unresolved,
|
|
407
|
+
from_index,
|
|
408
|
+
&from_path,
|
|
409
|
+
augment_uri,
|
|
410
|
+
DependencyKind::Augment,
|
|
411
|
+
library.location,
|
|
412
|
+
DependencyVisibility::default(),
|
|
413
|
+
);
|
|
414
414
|
}
|
|
415
415
|
|
|
416
416
|
let imports = selected_imports(&file.imports, &options.conditional_environment);
|
|
@@ -578,14 +578,13 @@ fn percent_decode_uri_path(value: &str) -> String {
|
|
|
578
578
|
let mut index = 0;
|
|
579
579
|
|
|
580
580
|
while index < bytes.len() {
|
|
581
|
-
if bytes[index] == b'%'
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
}
|
|
581
|
+
if bytes[index] == b'%'
|
|
582
|
+
&& let (Some(high), Some(low)) = (bytes.get(index + 1), bytes.get(index + 2))
|
|
583
|
+
&& let Some(decoded_byte) = decode_hex_pair(*high, *low)
|
|
584
|
+
{
|
|
585
|
+
decoded.push(decoded_byte);
|
|
586
|
+
index += 3;
|
|
587
|
+
continue;
|
|
589
588
|
}
|
|
590
589
|
|
|
591
590
|
decoded.push(bytes[index]);
|
|
@@ -535,11 +535,11 @@ fn decode_runtime_path(raw_path: &str) -> String {
|
|
|
535
535
|
if byte == b'%' {
|
|
536
536
|
let high = bytes.next();
|
|
537
537
|
let low = bytes.next();
|
|
538
|
-
if let (Some(high), Some(low)) = (high, low)
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
538
|
+
if let (Some(high), Some(low)) = (high, low)
|
|
539
|
+
&& let Some(decoded) = decode_hex_pair(high, low)
|
|
540
|
+
{
|
|
541
|
+
output.push(char::from(decoded));
|
|
542
|
+
continue;
|
|
543
543
|
}
|
|
544
544
|
output.push('%');
|
|
545
545
|
if let Some(high) = high {
|
package/src/output/next_steps.rs
CHANGED
|
@@ -72,9 +72,10 @@ pub(super) fn next_steps(root: &Path, results: &AnalysisResults) -> Vec<NextStep
|
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
if let Some(health) = &results.health
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
if let Some(health) = &results.health
|
|
76
|
+
&& let Some(complexity) = health.complexity.first()
|
|
77
|
+
{
|
|
78
|
+
steps.push(NextStep {
|
|
78
79
|
id: "complexity-breakdown".to_owned(),
|
|
79
80
|
command: format!(
|
|
80
81
|
"dart-decimate health --format json --complexity-breakdown --top 1 --max-cyclomatic {} --max-cognitive {}",
|
|
@@ -85,7 +86,6 @@ pub(super) fn next_steps(root: &Path, results: &AnalysisResults) -> Vec<NextStep
|
|
|
85
86
|
display_path(root, &complexity.path)
|
|
86
87
|
),
|
|
87
88
|
});
|
|
88
|
-
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
if results.security.as_ref().is_some_and(|report| {
|
|
@@ -131,16 +131,16 @@ fn result_properties(
|
|
|
131
131
|
properties.insert("safeToDelete".to_owned(), json!(finding.safe_to_delete));
|
|
132
132
|
properties.insert("files".to_owned(), json!(&finding.files));
|
|
133
133
|
properties.insert("actions".to_owned(), json!(&finding.actions));
|
|
134
|
-
if let Some(fingerprint) = &finding.fingerprint
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
)
|
|
143
|
-
|
|
134
|
+
if let Some(fingerprint) = &finding.fingerprint
|
|
135
|
+
&& let Some(security) = security_by_fingerprint.get(fingerprint)
|
|
136
|
+
{
|
|
137
|
+
properties.insert("cwe".to_owned(), security["cwe"].clone());
|
|
138
|
+
properties.insert("effect".to_owned(), security["effect"].clone());
|
|
139
|
+
if !security["reachability"].is_null() {
|
|
140
|
+
properties.insert(
|
|
141
|
+
"securityReachability".to_owned(),
|
|
142
|
+
security["reachability"].clone(),
|
|
143
|
+
);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
Value::Object(properties)
|
|
@@ -287,18 +287,18 @@ struct ParsedSuppression {
|
|
|
287
287
|
fn parse_suppression(line: &str) -> Option<ParsedSuppression> {
|
|
288
288
|
let comment = line.trim_start().strip_prefix("//")?.trim_start();
|
|
289
289
|
for directive in ["dart-decimate-ignore-next-line"] {
|
|
290
|
-
if let Some(rest) = comment.strip_prefix(directive)
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
290
|
+
if let Some(rest) = comment.strip_prefix(directive)
|
|
291
|
+
&& rest.chars().next().is_none_or(char::is_whitespace)
|
|
292
|
+
{
|
|
293
|
+
let (rules, reason) = split_reason(rest.trim_start());
|
|
294
|
+
return Some(ParsedSuppression {
|
|
295
|
+
rules: rules
|
|
296
|
+
.split(|character: char| character == ',' || character.is_whitespace())
|
|
297
|
+
.filter(|rule| !rule.is_empty())
|
|
298
|
+
.map(str::to_owned)
|
|
299
|
+
.collect(),
|
|
300
|
+
has_reason: reason.is_some_and(|value| !value.trim().is_empty()),
|
|
301
|
+
});
|
|
302
302
|
}
|
|
303
303
|
}
|
|
304
304
|
None
|
package/src/package_map.rs
CHANGED
|
@@ -68,30 +68,29 @@ impl PackageMap {
|
|
|
68
68
|
let roots = self.by_name.get(package)?;
|
|
69
69
|
let owner_package = self.owner_package(from_path);
|
|
70
70
|
let owner_root = owner_package.map(|package| package.root.as_path());
|
|
71
|
-
if let Some(owner_package) = owner_package
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
if let Some(owner_package) = owner_package
|
|
72
|
+
&& owner_package.name == package
|
|
73
|
+
{
|
|
74
|
+
return Some(package_resolution(owner_package, path));
|
|
75
75
|
}
|
|
76
76
|
let configured_root = roots.iter().find(|root| root.from_package_config);
|
|
77
|
-
if owner_package.is_some_and(|package| package.from_package_config)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
if owner_package.is_some_and(|package| package.from_package_config)
|
|
78
|
+
&& let Some(root) = configured_root
|
|
79
|
+
{
|
|
80
|
+
return Some(package_resolution(root, path));
|
|
81
81
|
}
|
|
82
|
-
if let Some(owner_root) = owner_root
|
|
83
|
-
|
|
82
|
+
if let Some(owner_root) = owner_root
|
|
83
|
+
&& let Some(root) = self
|
|
84
84
|
.by_owner_dependency
|
|
85
85
|
.get(owner_root)
|
|
86
86
|
.and_then(|dependencies| dependencies.get(package))
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
87
|
+
{
|
|
88
|
+
return Some(package_resolution(root, path));
|
|
90
89
|
}
|
|
91
|
-
if let Some(owner_package) = owner_package
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
if let Some(owner_package) = owner_package
|
|
91
|
+
&& (owner_package.from_package_config || self.uses_package_config)
|
|
92
|
+
{
|
|
93
|
+
return None;
|
|
95
94
|
}
|
|
96
95
|
if let Some(root) = configured_root {
|
|
97
96
|
return Some(package_resolution(root, path));
|
|
@@ -223,10 +222,9 @@ impl PackageMap {
|
|
|
223
222
|
self.discover_nested_pubspecs(&path, visited)?;
|
|
224
223
|
} else if file_type.is_file()
|
|
225
224
|
&& path.file_name().is_some_and(|name| name == "pubspec.yaml")
|
|
225
|
+
&& let Some(package_root) = path.parent()
|
|
226
226
|
{
|
|
227
|
-
|
|
228
|
-
self.discover_optional_pubspec(package_root, visited)?;
|
|
229
|
-
}
|
|
227
|
+
self.discover_optional_pubspec(package_root, visited)?;
|
|
230
228
|
}
|
|
231
229
|
}
|
|
232
230
|
|
|
@@ -417,14 +417,12 @@ fn initialized_binding_name(root: Node<'_>, source: &str, index: usize) -> Optio
|
|
|
417
417
|
) && node
|
|
418
418
|
.child_by_field_name("value")
|
|
419
419
|
.is_some_and(|value| value.start_byte() <= index && value.end_byte() >= index)
|
|
420
|
-
|
|
421
|
-
if let Some(binding) = node
|
|
420
|
+
&& let Some(binding) = node
|
|
422
421
|
.child_by_field_name("name")
|
|
423
422
|
.and_then(|name| name.utf8_text(source.as_bytes()).ok())
|
|
424
423
|
.map(str::to_owned)
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
}
|
|
424
|
+
{
|
|
425
|
+
return Some(binding);
|
|
428
426
|
}
|
|
429
427
|
let Some(parent) = node.parent() else {
|
|
430
428
|
break;
|
package/src/security/detect.rs
CHANGED
|
@@ -1076,16 +1076,17 @@ fn string_literals(source: &str) -> Vec<StringLiteral> {
|
|
|
1076
1076
|
let mut index = 0;
|
|
1077
1077
|
let bytes = source.as_bytes();
|
|
1078
1078
|
while index < bytes.len() {
|
|
1079
|
-
if matches!(bytes[index], b'\'' | b'"')
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1079
|
+
if matches!(bytes[index], b'\'' | b'"')
|
|
1080
|
+
&& !is_comment_match(source, index)
|
|
1081
|
+
&& let Some((value, value_index, end)) = read_string(source, index)
|
|
1082
|
+
{
|
|
1083
|
+
literals.push(StringLiteral {
|
|
1084
|
+
index,
|
|
1085
|
+
value_index,
|
|
1086
|
+
value,
|
|
1087
|
+
});
|
|
1088
|
+
index = end;
|
|
1089
|
+
continue;
|
|
1089
1090
|
}
|
|
1090
1091
|
index += 1;
|
|
1091
1092
|
}
|
|
@@ -1897,13 +1898,13 @@ fn lexical_binding_value<'source>(
|
|
|
1897
1898
|
) -> Option<&'source str> {
|
|
1898
1899
|
let mut child = root.descendant_for_byte_range(index, index.saturating_add(1))?;
|
|
1899
1900
|
while let Some(parent) = child.parent() {
|
|
1900
|
-
if parent.kind() == "class_body"
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
}
|
|
1901
|
+
if parent.kind() == "class_body"
|
|
1902
|
+
&& let Some(binding) = class_binding(parent, child, name, source)
|
|
1903
|
+
{
|
|
1904
|
+
return match binding {
|
|
1905
|
+
LexicalBinding::Value(value) => Some(value),
|
|
1906
|
+
LexicalBinding::Unknown => None,
|
|
1907
|
+
};
|
|
1907
1908
|
}
|
|
1908
1909
|
if process_scope_parameters_bind_name(parent, name, source)
|
|
1909
1910
|
|| process_scope_header_binds_name(parent, child, name, source)
|
package/src/widgets/patterns.rs
CHANGED
|
@@ -1908,6 +1908,8 @@ fn unquote_dart_string(text: &str) -> Option<String> {
|
|
|
1908
1908
|
|
|
1909
1909
|
fn framework_import_uri(uri: &str) -> bool {
|
|
1910
1910
|
uri.starts_with("package:flutter/")
|
|
1911
|
+
|| uri.starts_with("package:material_ui/")
|
|
1912
|
+
|| uri.starts_with("package:cupertino_ui/")
|
|
1911
1913
|
|| uri.starts_with("package:flutter_riverpod/")
|
|
1912
1914
|
|| uri.starts_with("package:hooks_riverpod/")
|
|
1913
1915
|
}
|