Ad

Avoid arbitary code execution

Code
Diff
  • function Calculator {
        param (
            [int]$n1,
            [ValidateSet("+", "*", "-")]
            [string]$s,
            [int]$n2
        )
        Invoke-Expression ("$n1 $s $n2")
    }
    • function Calculator ($n1,$s,$n2 ){
    • Invoke-Expression ("$n1 $s $n2")
    • function Calculator {
    • param (
    • [int]$n1,
    • [ValidateSet("+", "*", "-")]
    • [string]$s,
    • [int]$n2
    • )
    • Invoke-Expression ("$n1 $s $n2")
    • }