Skip to content

Commit 308afb9

Browse files
committed
PS: Add common GAC (global assembly cache) assemblies and all automatic varibles.
1 parent f103fed commit 308afb9

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

powershell/ql/lib/semmle/code/powershell/ApiGraphs.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,16 @@ module API {
466466

467467
cached
468468
private module Impl {
469+
private predicate isGacModule(string s) {
470+
s =
471+
[
472+
"System.Management.Automation",
473+
"Microsoft.Management.Infrastructure",
474+
"Microsoft.PowerShell.Security",
475+
"Microsoft.PowerShell.Commands.Management",
476+
"Microsoft.PowerShell.Commands.Utility"
477+
]
478+
}
469479

470480
private predicate isModule(string s, int n) {
471481
(
@@ -476,6 +486,8 @@ module API {
476486
any(TypeNameExpr tn).getName() = s
477487
or
478488
any(ModuleManifest manifest).getModuleName() = s
489+
or
490+
isGacModule(s)
479491
) and
480492
exists(s.splitAt(".", n))
481493
}

powershell/ql/lib/semmle/code/powershell/dataflow/internal/DataFlowPrivate.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,24 @@ private module Cached {
289289
TypeTrackingInput::withoutContentStepImpl(_, n, _)
290290
}
291291

292+
private predicate isAutomaticVariable(Node n) {
293+
n.asExpr().(CfgNodes::ExprNodes::VarReadAccessCfgNode).getVariable().getName() =
294+
[
295+
"args", "ConsoleFileName", "EnabledExperimentalFeatures", "Error", "Event", "EventArgs",
296+
"EventSubscriber", "ExecutionContext", "HOME", "Host", "input", "IsCoreCLR", "IsLinux",
297+
"IsMacOS", "IsWindows", "LASTEXITCODE", "MyInvocation", "NestedPromptLevel", "PID",
298+
"PROFILE", "PSBoundParameters", "PSCmdlet", "PSCommandPath", "PSCulture", "PSDebugContext",
299+
"PSEdition", "PSHOME", "PSItem", "PSScriptRoot", "PSSenderInfo", "PSUICulture",
300+
"PSVersionTable", "PWD", "Sender", "ShellId", "StackTrace"
301+
]
302+
}
303+
292304
cached
293305
predicate isLocalSourceNode(Node n) {
294306
n instanceof ParameterNode
295307
or
308+
isAutomaticVariable(n)
309+
or
296310
// Expressions that can't be reached from another entry definition or expression
297311
(
298312
n instanceof ExprNode

0 commit comments

Comments
 (0)