Skip to content

Commit a1b0ce2

Browse files
authored
Merge pull request #640 from DataDog/jf/K9VULN-3523
Handle C# `using` directive without a qualified namespace.
2 parents a37a1c0 + 4e3cb91 commit a1b0ce2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Diff for: crates/static-analysis-kernel/src/analysis/languages/csharp/using_directives.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,17 @@ pub fn parse_using_with_tree<'text>(
137137
}
138138
}
139139

140-
let namespace = qualified_namespace
141-
.expect("grammar structure invariant: this should have been populated");
140+
// Hotfix:
141+
// The above parser does not handle cases like
142+
// using (var resource = new ResourceType())
143+
// {
144+
// // ...
145+
// }
146+
//
147+
// In this case, we just set the qualified namespace to "".
148+
//
149+
// This should be revisited.
150+
let namespace = qualified_namespace.unwrap_or_default();
142151
usings.push(Using { namespace, alias })
143152
}
144153
usings

0 commit comments

Comments
 (0)