Skip to content

Commit 61021b6

Browse files
committed
PS: Regenerate models.
1 parent c3b0c2d commit 61021b6

File tree

2,155 files changed

+130311
-128880
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,155 files changed

+130311
-128880
lines changed

powershell/misc/typemodelgen.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,25 @@
22
from pathlib import Path
33
import sys
44
import os
5+
import re
56
from collections import defaultdict
67

78

89
def fixup(t):
910
"""Sometimes the docs specify a type that doesn't align with what
1011
PowerShell reports. This function fixes up those types so that it aligns with PowerShell.
1112
"""
12-
if t.startswith("System.ReadOnlySpan<"):
13-
return "System.String"
14-
return t
13+
if t.startswith("system.readonlyspan<"):
14+
return "system.string"
15+
# A regular expression that matches strings like a.b.c<T, U, W>
16+
# and replacee it with a.b.c
17+
return re.sub(r"<.*>", "", t)
18+
19+
def skipQualifier(name):
20+
"""Removes the qualifier from the name."""
21+
# A regular expression that matches strings like a.b.c and returns c
22+
# and replaces it with c
23+
return re.sub(r".*\.", "", name)
1524

1625

1726
def isStatic(member):
@@ -88,11 +97,18 @@ def generateTypeModels(arg):
8897

8998
thisType = root.attrib["FullName"]
9099

91-
if "`" in file_path.stem or "+" in file_path.stem:
92-
continue # Skip generics (and nested types?) for now
100+
parentName = file_path.parent.name
101+
# Remove `and + in parentName
102+
parentName = parentName.replace("`", "").replace("+", "")
103+
104+
# Remove ` in file_path.stem
105+
# and + in file_path.stem
106+
if thisType == "":
107+
print("Error: Empty type name")
108+
continue
93109

94-
folderName = "generated/" + file_path.parent.name.replace(".", "")
95-
filename = folderName + "/typemodel.yml"
110+
folderName = "generated/" + parentName
111+
filename = folderName + ".typemodel.yml"
96112
s = set()
97113
for elem in root.findall(".//Members/Member"):
98114
name = elem.attrib["MemberName"]
@@ -136,7 +152,7 @@ def generateTypeModels(arg):
136152
continue # Don't generate type summaries for void methods
137153

138154
s.add(
139-
f' - ["{fixup(returnType.lower())}", "{thisType.lower() + staticMarker}", "{startSelectorMarker}[{name.lower()}]{endSelectorMarker}"]\n'
155+
f' - ["{fixup(returnType.lower())}", "{fixup(thisType.lower()) + staticMarker}", "{startSelectorMarker}[{skipQualifier(fixup(name.lower()))}]{endSelectorMarker}"]\n'
140156
)
141157

142158
summaries[filename].update(s)
@@ -153,7 +169,7 @@ def writeModels():
153169
if len(s) == 0:
154170
continue
155171
os.makedirs(os.path.dirname(filename), exist_ok=True)
156-
with open(filename, "x") as file:
172+
with open(filename, "w") as file:
157173
file.write("# THIS FILE IS AN AUTO-GENERATED MODELS AS DATA FILE. DO NOT EDIT.\n")
158174
file.write("extensions:\n")
159175
file.write(" - addsTo:\n")

powershell/ql/lib/qlpack.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ dependencies:
1616
dataExtensions:
1717
- semmle/code/powershell/frameworks/**/model.yml
1818
- semmle/code/powershell/frameworks/**/*.model.yml
19+
- semmle/code/powershell/frameworks/**/typemodel.yml
20+
- semmle/code/powershell/frameworks/**/*.typemodel.yml
1921
warnOnImplicitThis: true

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
* Helper file that imports all framework modeling.
33
*/
44

5-
import semmle.code.powershell.frameworks.SystemManagementAutomationRunspaces.Runspaces
6-
import semmle.code.powershell.frameworks.SystemManagementAutomationPowerShell.PowerShell
7-
import semmle.code.powershell.frameworks.SystemManagementAutomationEngineIntrinsics.EngineIntrinsics
5+
import semmle.code.powershell.frameworks.Runspaces
6+
import semmle.code.powershell.frameworks.PowerShell
7+
import semmle.code.powershell.frameworks.EngineIntrinsics

powershell/ql/lib/semmle/code/powershell/frameworks/Accessibility/model.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ private import semmle.code.powershell.dataflow.internal.DataFlowPublic as DataFl
55
module EngineIntrinsics {
66
private class EngineIntrinsicsGlobalEntry extends ModelInput::TypeModel {
77
override DataFlow::Node getASource(string type) {
8-
type = "System.Management.Automation.EngineIntrinsics" and
9-
result.asExpr().getExpr().(VarReadAccess).getVariable().matchesName("ExecutionContext")
8+
type = "system.management.automation.engineintrinsics" and
9+
result.asExpr().getExpr().(VarReadAccess).getVariable().matchesName("executioncontext")
1010
}
1111
}
1212
}

powershell/ql/lib/semmle/code/powershell/frameworks/IEHostExecute/model.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

powershell/ql/lib/semmle/code/powershell/frameworks/MicrosoftActivitiesBuild/model.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

powershell/ql/lib/semmle/code/powershell/frameworks/MicrosoftActivitiesBuildDebugger/model.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

powershell/ql/lib/semmle/code/powershell/frameworks/MicrosoftActivitiesBuildExpressions/model.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

powershell/ql/lib/semmle/code/powershell/frameworks/MicrosoftActivitiesBuildValidation/model.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)