diff --git a/powershell/ql/lib/semmle/code/powershell/frameworks/Microsoft.PowerShell.Utility.model.yml b/powershell/ql/lib/semmle/code/powershell/frameworks/Microsoft.PowerShell.Utility.model.yml new file mode 100644 index 00000000000..ff26e091291 --- /dev/null +++ b/powershell/ql/lib/semmle/code/powershell/frameworks/Microsoft.PowerShell.Utility.model.yml @@ -0,0 +1,77 @@ +extensions: + - addsTo: + pack: microsoft/powershell-all + extensible: sourceModel + data: + - ["microsoft.powershell.utility!", "Method[read-host].ReturnValue", "stdin"] + - ["microsoft.powershell.utility!", "Method[select-xml].ReturnValue[path]", "file"] + - ["microsoft.powershell.utility!", "Method[format-hex].ReturnValue[path]", "file"] + + - addsTo: + pack: microsoft/powershell-all + extensible: summaryModel + data: + - ["microsoft.powershell.utility!", "Method[get-unique]", "Argument[-inputobject,pipeline].Element[?]", "ReturnValue.Element[?]", "value"] + - ["microsoft.powershell.utility!", "Method[join-string]", "Argument[-inputobject,pipeline].Element[?]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[convertfrom-clixmlreference]", "Argument[-inputobject,0,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[convertfrom-csv]", "Argument[-inputobject,0,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[convertfrom-json]", "Argument[-inputobject,0,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[convertfrom-markdown]", "Argument[-inputobject,0,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[convertfrom-sddlstring]", "Argument[-sddl,0,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[convertfrom-stringdata]", "Argument[-stringdata,0,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[convertto-clixml]", "Argument[-inputobject,0,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[convertto-csv]", "Argument[-inputobject,0,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[convertto-html]", "Argument[-inputobject,0,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[convertto-json]", "Argument[-inputobject,0,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[convertto-xml]", "Argument[-inputobject,0,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[out-string]", "Argument[-inputobject,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[select-object]", "Argument[-inputobject,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[select-string]", "Argument[-inputobject,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[select-xml]", "Argument[-content,-path,-xml]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[sort-object]", "Argument[-inputobject,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[tee-object]", "Argument[-inputobject,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[write-output]", "Argument[-inputobject,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[format-custom]", "Argument[-inputobject,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[format-hex]", "Argument[-inputobject,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[format-list]", "Argument[-inputobject,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[format-table]", "Argument[-inputobject,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[format-wide]", "Argument[-inputobject,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[get-unique]", "Argument[-inputobject,pipeline]", "ReturnValue", "taint"] + - ["microsoft.powershell.utility!", "Method[join-string]", "Argument[-inputobject,pipeline]", "ReturnValue", "taint"] + + - addsTo: + pack: microsoft/powershell-all + extensible: typeModel + data: + - ["system.datetime", "microsoft.powershell.utility!", "Method[get-date].ReturnValue"] + - ["system.object", "microsoft.powershell.utility!", "Method[convertfrom-clixmlreference].ReturnValue"] + - ["pscustomobject", "microsoft.powershell.utility!", "Method[convertFrom-json].ReturnValue"] + - ["system.management.automation.hashtable", "microsoft.powershell.utility!", "Method[convertFrom-json].ReturnValue"] + - ["microsoft.powershell.markdownrender.markdownInfo", "microsoft.powershell.utility!", "Method[convertfrom-markdown].ReturnValue"] + - ["pscustomobject", "microsoft.powershell.utility!", "Method[convertfrom-sddlstring].ReturnValue"] + - ["system.collections.hashtable", "microsoft.powershell.utility!", "Method[convertfrom-stringdata].ReturnValue"] + - ["system.string", "microsoft.powershell.utility!", "Method[convertto-clixml].ReturnValue"] + - ["system.string", "microsoft.powershell.utility!", "Method[convertto-csv].ReturnValue"] + - ["system.string[]", "microsoft.powershell.utility!", "Method[convertto-csv].ReturnValue"] + - ["system.string", "microsoft.powershell.utility!", "Method[convertto-html].ReturnValue"] + - ["system.string[]", "microsoft.powershell.utility!", "Method[convertto-html].ReturnValue"] + - ["system.string", "microsoft.powershell.utility!", "Method[convertto-json].ReturnValue"] + - ["system.string[]", "microsoft.powershell.utility!", "Method[convertto-json].ReturnValue"] + - ["system.string", "microsoft.powershell.utility!", "Method[convertto-xml].ReturnValue"] + - ["system.string[]", "microsoft.powershell.utility!", "Method[convertto-xml].ReturnValue"] + - ["system.string", "microsoft.powershell.utility!", "Method[out-string].ReturnValue"] + - ["pscustomobject", "microsoft.powershell.utility!", "Method[select-object].ReturnValue"] + - ["microsoft.powerShell.commands.matchinfo", "microsoft.powershell.utility!", "Method[select-string].ReturnValue"] + - ["system.boolean", "microsoft.powershell.utility!", "Method[select-string].ReturnValue"] + - ["system.string", "microsoft.powershell.utility!", "Method[select-string].ReturnValue"] + - ["microsoft.powerShell.commands.selectxmlinfo", "microsoft.powershell.utility!", "Method[select-xml].ReturnValue"] + - ["pscustomobject", "microsoft.powershell.utility!", "Method[sort-object].ReturnValue"] + - ["pscustomobject", "microsoft.powershell.utility!", "Method[tee-object].ReturnValue"] + - ["pscustomobject", "microsoft.powershell.utility!", "Method[write-output].ReturnValue"] + - ["microsoft.powershell.commands.internal.format", "microsoft.powershell.utility!", "Method[format-custom].ReturnValue"] + - ["microsoft.powershell.commands.bytecollection", "microsoft.powershell.utility!", "Method[format-hex].ReturnValue"] + - ["microsoft.powershell.commands.internal.format", "microsoft.powershell.utility!", "Method[format-list].ReturnValue"] + - ["microsoft.powershell.commands.internal.format", "microsoft.powershell.utility!", "Method[format-table].ReturnValue"] + - ["microsoft.powershell.commands.internal.format", "microsoft.powershell.utility!", "Method[format-wide].ReturnValue"] + - ["pscustomobject", "microsoft.powershell.utility!", "Method[get-unique].ReturnValue"] + - ["system.string", "microsoft.powershell.utility!", "Method[join-string].ReturnValue"] \ No newline at end of file diff --git a/powershell/ql/lib/semmle/code/powershell/frameworks/Microsoft.Win32.RegistryKey.model.yml b/powershell/ql/lib/semmle/code/powershell/frameworks/Microsoft.Win32.RegistryKey.model.yml new file mode 100644 index 00000000000..40b0c3bcd45 --- /dev/null +++ b/powershell/ql/lib/semmle/code/powershell/frameworks/Microsoft.Win32.RegistryKey.model.yml @@ -0,0 +1,8 @@ +extensions: + - addsTo: + pack: microsoft/powershell-all + extensible: sourceModel + data: + - ["microsoft.win32.registrykey ", "Method[GetValue].ReturnValue", "windows-registry"] + - ["microsoft.win32.registrykey ", "Method[GetValueNames].ReturnValue", "windows-registry"] + - ["microsoft.win32.registrykey ", "Method[GetSubKeyNames].ReturnValue", "windows-registry"] \ No newline at end of file diff --git a/powershell/ql/lib/semmle/code/powershell/frameworks/Microsoft.Win32.model.yml b/powershell/ql/lib/semmle/code/powershell/frameworks/Microsoft.Win32.model.yml new file mode 100644 index 00000000000..63b24c780c6 --- /dev/null +++ b/powershell/ql/lib/semmle/code/powershell/frameworks/Microsoft.Win32.model.yml @@ -0,0 +1,9 @@ +extensions: + - addsTo: + pack: microsoft/powershell-all + extensible: sourceModel + data: + - ["microsoft.win32.registry!", "Method[getvalue].ReturnValue", "windows-registry"] + - ["microsoft.win32.registrykey", "Method[getvalue].ReturnValue", "windows-registry"] + - ["microsoft.win32.registrykey", "Method[getvaluenames].ReturnValue", "windows-registry"] + - ["microsoft.win32.registrykey", "Method[getsubkeynames].ReturnValue", "windows-registry"] \ No newline at end of file diff --git a/powershell/ql/lib/semmle/code/powershell/frameworks/System.IO.model.yml b/powershell/ql/lib/semmle/code/powershell/frameworks/System.IO.model.yml new file mode 100644 index 00000000000..88d4fb8587a --- /dev/null +++ b/powershell/ql/lib/semmle/code/powershell/frameworks/System.IO.model.yml @@ -0,0 +1,33 @@ +extensions: + - addsTo: + pack: microsoft/powershell-all + extensible: sourceModel + data: + - ["system.io.file!", "Method[appendtext].ReturnValue", "file-write"] + - ["system.io.file!", "Method[create].ReturnValue", "file-write"] + - ["system.io.file!", "Method[createtext].ReturnValue", "file-write"] + - ["system.io.file!", "Method[open].ReturnValue", "file-write"] + - ["system.io.file!", "Method[open].ReturnValue", "file"] + - ["system.io.file!", "Method[openread].ReturnValue", "file"] + - ["system.io.file!", "Method[opentext].ReturnValue", "file"] + - ["system.io.file!", "Method[openwrite].ReturnValue", "file-write"] + - ["system.io.file!", "Method[readallbytes].ReturnValue", "file"] + - ["system.io.file!", "Method[readallbytesasync].ReturnValue", "file"] + - ["system.io.file!", "Method[readalllines].ReturnValue", "file"] + - ["system.io.file!", "Method[readalllinesasync].ReturnValue", "file"] + - ["system.io.file!", "Method[readalltext].ReturnValue", "file"] + - ["system.io.file!", "Method[readalltextasync].ReturnValue", "file"] + - ["system.io.file!", "Method[readlines].ReturnValue", "file"] + - ["system.io.file!", "Method[readlinesasync].ReturnValue", "file"] + - ["system.io.fileinfo", "Method[appendtext].ReturnValue", "file-write"] + - ["system.io.fileinfo", "Method[create].ReturnValue", "file-write"] + - ["system.io.fileinfo", "Method[createtext].ReturnValue", "file-write"] + - ["system.io.fileinfo", "Method[open].ReturnValue", "file-write"] + - ["system.io.fileinfo", "Method[open].ReturnValue", "file"] + - ["system.io.fileinfo", "Method[openread].ReturnValue", "file"] + - ["system.io.fileinfo", "Method[opentext].ReturnValue", "file"] + - ["system.io.fileinfo", "Method[openwrite].ReturnValue", "file-write"] + - ["system.io.filestream", "Instance", "file"] + - ["system.io.filestream", "Instance", "file-write"] + - ["system.io.streamwriter", "Instance", "file-write"] + - ["system.io.streamwriter", "Instance", "file-write"] \ No newline at end of file diff --git a/powershell/ql/lib/semmle/code/powershell/frameworks/System.Management.Automation.Language.model.yml b/powershell/ql/lib/semmle/code/powershell/frameworks/System.Management.Automation.Language.model.yml new file mode 100644 index 00000000000..cfc575ae7aa --- /dev/null +++ b/powershell/ql/lib/semmle/code/powershell/frameworks/System.Management.Automation.Language.model.yml @@ -0,0 +1,6 @@ +extensions: + - addsTo: + pack: microsoft/powershell-all + extensible: summaryModel + data: + - ["system.management.automation.language.codegeneration!", "Method[escapesinglequotedstringcontent]", "Argument[0]", "ReturnValue", "taint"] \ No newline at end of file diff --git a/powershell/ql/lib/semmle/code/powershell/frameworks/System.Management.Automation.model.yml b/powershell/ql/lib/semmle/code/powershell/frameworks/System.Management.Automation.model.yml new file mode 100644 index 00000000000..94c7b76a71d --- /dev/null +++ b/powershell/ql/lib/semmle/code/powershell/frameworks/System.Management.Automation.model.yml @@ -0,0 +1,10 @@ +extensions: + - addsTo: + pack: microsoft/powershell-all + extensible: sinkModel + data: + - ["system.management.automation.scriptblock!", "Method[create].Argument[0]", "command-injection"] + - ["system.management.automation.powershell", "Method[addscript].Argument[0]", "command-injection"] + - ["system.management.automation.commandinvocationintrinsics", "Method[expandstring].Argument[0]", "command-injection"] + - ["System.Management.Automation.Runspaces.Runspace", "Method[CreateNestedPipeline].Argument[0]", "command-injection"] + - ["System.Management.Automation.Runspaces.Runspace", "Method[CreatePipeline].Argument[0]", "command-injection"] \ No newline at end of file diff --git a/powershell/ql/lib/semmle/code/powershell/frameworks/System.Net.Sockets.model.yml b/powershell/ql/lib/semmle/code/powershell/frameworks/System.Net.Sockets.model.yml new file mode 100644 index 00000000000..0fa8a829067 --- /dev/null +++ b/powershell/ql/lib/semmle/code/powershell/frameworks/System.Net.Sockets.model.yml @@ -0,0 +1,9 @@ +extensions: + - addsTo: + pack: microsoft/powershell-all + extensible: sourceModel + data: + - ["system.net.sockets.tcpclient", "Method[getstream].ReturnValue", "remote"] + - ["system.net.sockets.udpclient", "Method[endreceive].ReturnValue", "remote"] + - ["system.net.sockets.udpclient", "Method[receive].ReturnValue", "remote"] + - ["system.net.sockets.udpclient", "Method[receiveasync].ReturnValue", "remote"] \ No newline at end of file diff --git a/powershell/ql/lib/semmle/code/powershell/frameworks/System.model.yml b/powershell/ql/lib/semmle/code/powershell/frameworks/System.model.yml new file mode 100644 index 00000000000..dec6efc3108 --- /dev/null +++ b/powershell/ql/lib/semmle/code/powershell/frameworks/System.model.yml @@ -0,0 +1,12 @@ +extensions: + - addsTo: + pack: microsoft/powershell-all + extensible: sourceModel + data: + - ["system.console!", "Method[read].ReturnValue", "stdin"] + - ["system.console!", "Method[readkey].ReturnValue", "stdin"] + - ["system.console!", "Method[readline].ReturnValue", "stdin"] + - ["system.environment!", "Method[expandenvironmentvariables].ReturnValue", "environment"] + - ["system.environment!", "Method[getcommandlineargs].ReturnValue", "command-line"] + - ["system.environment!", "Method[getenvironmentvariable].ReturnValue", "environment"] + - ["system.environment!", "Method[getenvironmentvariables].ReturnValue", "environment"]