Powershell Initial Commit

This commit is contained in:
Justin Grote 2020-06-19 16:13:13 +00:00
parent 2e94f3c355
commit d39d5c62ff
4 changed files with 52 additions and 3 deletions

View file

@ -0,0 +1,14 @@
#Plaintext Parameters
function BadFunction {
param(
[String]$Username = 'me',
[String]$Password = 'password'
)
$Username
$Password
$VariableThatIsNotUsedLater = '5'
try {
'Empty Catch Block'
} catch {}
}

View file

@ -0,0 +1 @@
Write-Output "hello world!"

View file

@ -0,0 +1,18 @@
#Documentation: https://github.com/PowerShell/PSScriptAnalyzer/blob/master/docs/markdown/Invoke-ScriptAnalyzer.md#-settings
@{
#CustomRulePath='path\to\CustomRuleModule.psm1'
#RecurseCustomRulePath='path\of\customrules'
#Severity = @(
# 'Error'
# 'Warning'
#)
#IncludeDefaultRules=$true
#ExcludeRules = @(
# 'PSAvoidUsingWriteHost',
# 'MyCustomRuleName'
#)
#IncludeRules = @(
# 'PSAvoidUsingWriteHost',
# 'MyCustomRuleName'
#)
}

View file

@ -48,20 +48,24 @@ GO_LINTER_RULES="$DEFAULT_RULES_LOCATION/$GO_FILE_NAME" # Path to th
# Terraform Vars
TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file
TERRAFORM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TERRAFORM_FILE_NAME" # Path to the Terraform lint rules
# Powershell Vars
POWERSHELL_FILE_NAME='.powershell-psccriptanalyzer.psd1' # Name of the file
POWERSHELL_LINTER_RULES="$DEFAULT_RULES_LOCATION/$POWERSHELL_FILE_NAME" # Path to the Powershell lint rules
#######################################
# Linter array for information prints #
#######################################
LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck"
"pylint" "perl" "rubocop" "coffeelint" "eslint" "standard"
"ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint")
"ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint" "powershell")
#############################
# Language array for prints #
#############################
LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'RUBY' 'PYTHON'
'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES'
'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM')
'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' 'POWERSHELL')
###################
# GitHub ENV Vars #
@ -88,6 +92,7 @@ VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to val
VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language
VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language
VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language
VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language
TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases
##############
@ -2225,7 +2230,18 @@ if [ "$VALIDATE_DOCKER" == "true" ]; then
LintCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}"
fi
######################
# POWERSHELL LINTING #
######################
if [ "$VALIDATE_POWERSHELL" == "true" ]; then
#############################
# Lint the powershell files #
#############################
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
LintCodebase "POWERSHELL" "pwsh" "pwsh -c 'Invoke-ScriptAnalyzer -Settings $POWERSHELL_LINTER_RULES -Path' " 'ps[md]?1$' "${FILE_ARRAY_POWERSHELL[@]}"
fi
##########
# Footer #
##########
Footer
Footer