Skip to content

Commit

Permalink
Trim all whitespace across code base when accepting user input.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnybottles committed Jan 11, 2025
1 parent 45d4abe commit d6e385e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Hawk/functions/User/Get-HawkUserPWNCheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

# get the access key from the user
Out-LogFile "haveibeenpwned.com apikey" -isPrompt -NoNewLine
$hibpkey = Read-Host
$hibpkey = (Read-Host).Trim()
}
}#End of BEGIN block

Expand Down
2 changes: 1 addition & 1 deletion Hawk/internal/functions/Get-IPGeolocation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Function Get-IPGeolocation {
# get the access key from the user
# get the access key from the user
Out-LogFile "ipstack.com accesskey" -isPrompt -NoNewLine
$Accesskey = Read-Host
$Accesskey = (Read-Host).Trim()

# add the access key to the appdata file
Add-HawkAppData -name access_key -Value $Accesskey
Expand Down
12 changes: 7 additions & 5 deletions Hawk/internal/functions/Initialize-HawkGlobalObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
# Setup a while loop to get a valid path
Do {
# Ask the user for the output path
[string]$UserPath = Read-Host "[$timestamp] - [PROMPT] - Please provide an output directory"
[string]$UserPath = (Read-Host "[$timestamp] - [PROMPT] - Please provide an output directory").Trim()

# If the input is null or empty, prompt again
if ([string]::IsNullOrEmpty($UserPath)) {
Expand Down Expand Up @@ -260,7 +260,7 @@
Out-LogFile " Enter a number of days to go back (1-$MaxDaysToGoBack)" -isPrompt
Out-LogFile " OR enter a date in MM/DD/YYYY format" -isPrompt
Out-LogFile " Default is 90 days back: " -isPrompt -NoNewLine
$StartRead = Read-Host
$StartRead = (Read-Host).Trim()


# Determine if input is a valid date
Expand All @@ -274,7 +274,8 @@
# Validate the entered days back
if ($StartRead -gt $MaxDaysToGoBack) {
Out-LogFile -string "You have entered a time frame greater than your license allows ($MaxDaysToGoBack days)." -isWarning
$Proceed = Read-Host "Press ENTER to proceed or type 'R' to re-enter the value"
Out-LogFile "Press ENTER to proceed or type 'R' to re-enter the value: " -isPrompt -NoNewLine
$Proceed = (Read-Host).Trim()
if ($Proceed -eq 'R') { continue }
}

Expand All @@ -296,7 +297,8 @@
# Validate the date
if ($StartDate -lt ((Get-Date).ToUniversalTime().AddDays(-$MaxDaysToGoBack))) {
Out-LogFile -string "The date entered exceeds your license retention period of $MaxDaysToGoBack days." -isWarning
$Proceed = Read-Host "Press ENTER to proceed or type 'R' to re-enter the date"
Out-LogFile "Press ENTER to proceed or type 'R' to re-enter the date:" -isPrompt -NoNewLine
$Proceed = (Read-Host).Trim()
if ($Proceed -eq 'R') { $StartDate = $null; continue }
}

Expand All @@ -320,7 +322,7 @@
Out-LogFile " Enter a number of days to go back from today (1-365)" -isPrompt
Out-LogFile " OR enter a specific date in MM/DD/YYYY format" -isPrompt
Out-LogFile " Default is today's date:" -isPrompt -NoNewLine
$EndRead = Read-Host
$EndRead = (Read-Host).Trim()

# End date validation
if ($null -eq ($EndRead -as [DateTime])) {
Expand Down

0 comments on commit d6e385e

Please sign in to comment.