Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ private import semmle.code.powershell.dataflow.DataFlow
/**
* A dataflow node that is guarenteed to have a "simple" type.
*
* Simple types include integers, floats, characters, booleans, and `datetime`.
* Simple types include integers, floats, characters, booleans, `datetime`, and `guid`.
*/
class SimpleTypeSanitizer extends DataFlow::Node {
SimpleTypeSanitizer() {
this.asParameter().getStaticType() =
["int32", "int64", "single", "double", "decimal", "char", "boolean", "datetime"]
["int32", "int64", "single", "double", "decimal", "char", "boolean", "datetime", "guid"]
}
}
11 changes: 10 additions & 1 deletion powershell/ql/test/query-tests/security/cwe-089/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,13 @@ $QueryConn3 = @{

Invoke-Sqlcmd @QueryConn3 # GOOD

&sqlcmd -e -S $userinput -U "Login" -P "MyPassword" -d "MyDBName" -i "input_file.sql" # GOOD
&sqlcmd -e -S $userinput -U "Login" -P "MyPassword" -d "MyDBName" -i "input_file.sql" # GOOD

function WithGuid {
PARAM([Parameter(Mandatory = $true)] [guid] $r)

$query = "SELECT * FROM MyTable WHERE MyColumn = '$r'"
Invoke-Sqlcmd -ServerInstance "MyServer" -Database "MyDatabase" -q $query # GOOD
}

WithGuid $userinput
Loading