-
Notifications
You must be signed in to change notification settings - Fork 132
Bugfix/210 bugip stack api key flow needs improvement for better user experience new #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dcodev1702
wants to merge
56
commits into
Development
Choose a base branch
from
bugfix/210-bugip-stack-api-key-flow-needs-improvement-for-better-user-experience-new
base: Development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
6deb0c6
Added a very valuable comment :)
21773ac
Better comment, aye, aye sir!
288597d
Added logic for checking ipstack.com API Key with some error handling.
e1f7352
Added logic for checking ipstack.com API Key with some error handling.
63f79dc
Resolved merge conflict.
f9340ec
added -EnableGeoIPLocation command line switch and IPSTACK API logic …
75de877
added help .PARAMETERS for EnableGeoIPLocation for 2 files to pass pe…
54cd832
added additional information for help parameters for EnableGeoIPLocation
599f733
Enhanced comments for deeper understanding and minor refactoring of u…
1cfbc10
Add internal helper function to rest hawk environment.
jonnybottles 33bc25a
Add internal helper function to rest hawk environment.
jonnybottles 2fb3c96
Delete Hawk/internal/functions/Reset-HawkEnvironment.ps1
jonnybottles 06ffb5b
accepted and resolved merge conflicts from development branch into th…
8fb8725
Merge branch 'bugfix/210-bugip-stack-api-key-flow-needs-improvement-f…
c0c3a6b
Initial commit on new workstation
3bea42a
Validated use cases for EnableGeoIPLocation for interactive and non-i…
7c9b2b8
Fixed cosmetic output in Hawk Configuration Summary - 'Enable Geo IP …
7726dfe
Added checks for any 1 of 3 CmdLets were called to validate the use o…
b7acab5
Fleshing out logic for API Access Key if absored from file or provide…
bb91e8f
Still narrowing down the bug. Additional checks for malformed and bad…
595fd23
Still narrowing down the bug. Additional checks for malformed and bad…
26dfdbc
If key exists on disk and user chooses to use it, we will validate it…
2cd6c07
cosmetics
e9dd6b8
cosmetics
c0c89c2
Prepping for all the AI's
d05dcc0
moved IP Stack API Key check to a better / sane location && FIXED GET…
d0cac86
Get-IPGeolocation - Line: 59 :: ConvertTo-Json -Depth 10
f27d393
Removed Global variable for
4c1f2f7
Inserted a while loop to select Y/N to use existing AccessKey
3ef29a2
Updated output
a04911a
cosmetic / removed START-USERINVESTIGATION output
0af959b
Added do/while loop to repeatedly prompt the user for a valid IP Stac…
fcf286f
modified Read-HawkAppData and more importantly restructured the logic…
0ffebc4
Fixed issue with the API Key not correctly writing itself to Hawk.jso…
f3183d7
cleaning up commented out code / variables.
7ca6f48
Specifically looked for value of .access_key to determine which branc…
770b816
Cosmetic mod to Add-HawkAppData method.
70b2775
If access key on file is invalid, set access key to null so user is p…
4bb3b09
Coded USE CASE: Invalid/Expired key exists on disk, check key, comes …
6316120
Updated comment section of Get-IPGeolocation.ps1
6c129af
added documentation and comments throughout code.
d798ad0
Validated Y/N input when user is asked if they want to save REST API …
f5daaad
Validated Y/N input when user is asked if they want to save REST API …
690f0db
cosmetics / minor refactoring
fc580b9
comments / corrections
cefb42b
updated changelog.md and Hawk.psd1 to reflect version 4.0.1
cd474b6
Need to add Hawk GeoIPLocation Automation logic.
b89f0c4
added logic to support to get Geo IP data in non-interactive mode
4c0ce3d
valided the log telemetry still get proceeded in non-interactive mode…
b3dc3a1
added GeoIPNonInteractive variable to Hawk Global Object to help dete…
191561a
Logic for non-interacive use case added to Hawk ISO version 4.0.1
0ac07c4
Changed Get-IPGeolocation to Get-IPGeoLocation
e27ffa1
renaming files
47a1239
added Get-IPGeoLocation.ps1
a59ea1e
Modified changelog.md
0d61d17
Changed AccessKey Parameter from False to True
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10000
16 changes: 8 additions & 8 deletions
16
Hawk/functions/Tenant/Get-HawkTenantRiskyServicePrincipals.ps1
Loading
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Import-Module "C:\Users\Lorenzo\hawk\Hawk\Hawk.psd1" | ||
Start-HawkUserInvestigation -UserPrincipalName irelandl@semperhunt.onmicrosoft.com -DaysToLookBack 60 -FilePath C:\Temp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,7 +195,7 @@ | |
Out-LogFile "Running Get-HawkTenantRBACChange" -action | ||
Get-HawkTenantRBACChange | ||
} | ||
|
||
|
||
if ($PSCmdlet.ShouldProcess("Entra ID Audit Log", "Get Entra ID audit logs")) { | ||
Out-LogFile "Running Get-HawkTenantEntraIDAuditLog" -action | ||
Get-HawkTenantEntraIDAuditLog | ||
|
@@ -247,6 +247,4 @@ | |
$investigationEndTime = Get-Date | ||
Write-HawkInvestigationSummary -StartTime $investigationStartTime -EndTime $investigationEndTime -InvestigationType 'Tenant' | ||
} | ||
|
||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<# | ||
.SYNOPSIS | ||
Get-IPGeoLocation is called by Get-HawkUserUALSignInLog to resolve IP addresses to geolocation data. | ||
An IP address and IP Stack API Key is passed to the function, as it returns a PSCustomObject with the geolocation data. | ||
|
||
.DESCRIPTION | ||
Get the Geographic Location of an IP address using the ipstack.com REST API | ||
.PARAMETER IPAddress | ||
IP address to look up for its geographic location | ||
.PARAMETER AccessKey | ||
Access key for ipstack.com's REST API | ||
.EXAMPLE | ||
Get-IPGeoLocation -IPAddress 8.8.8.8 -AccessKey e904134b5cbb91f752a79f3ba9cbe59a | ||
Gets all IP GeoLocation data of IPs that recieved | ||
.NOTES | ||
General notes | ||
#> | ||
function Get-IPGeoLocation { | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory = $true)] | ||
[string]$IPAddress, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string]$AccessKey | ||
) | ||
|
||
begin {} | ||
|
||
process { | ||
try { | ||
|
||
if ($IPAddress -eq "<null>") { | ||
Write-Verbose "Null IP Provided: $IPAddress" | ||
return [PSCustomObject]@{ | ||
IP = $IPAddress | ||
CountryName = "NULL IP" | ||
RegionName = "Unknown" | ||
RegionCode = "Unknown" | ||
ContinentName = "Unknown" | ||
City = "Unknown" | ||
KnownMicrosoftIP = "Unknown" | ||
} | ||
} | ||
|
||
# Check cache | ||
if ($Global:IPLocationCache.ip -contains $IPAddress) { | ||
Write-Verbose "IP Cache Hit: $IPAddress" | ||
return ($Global:IPLocationCache | Where-Object { $_.ip -eq $IPAddress }) | ||
} | ||
|
||
# Make API calls to IP Stack to look up IP addresses | ||
$resource = "http://api.ipstack.com/$($IPAddress)?access_key=$AccessKey" | ||
$geoip = Invoke-RestMethod -Method Get -URI $resource -ErrorAction Stop | ||
$geoip | ConvertTo-Json -Depth 10 | ||
|
||
# Create result object | ||
Write-Output "`n" | ||
$isMSFTIP = Test-MicrosoftIP -IPToTest $geoip.ip -Type $geoip.type | ||
$result = [PSCustomObject]@{ | ||
IP = $geoip.ip | ||
CountryName = $geoip.country_name | ||
ContinentName = $geoip.continent_name | ||
RegionName = $geoip.region_name | ||
RegionCode = $geoip.region_code | ||
City = $geoip.city | ||
KnownMicrosoftIP = $isMSFTIP | ||
} | ||
|
||
# Update cache | ||
[array]$Global:IPLocationCache += $result | ||
|
||
return $result | ||
} | ||
catch { | ||
Out-LogFile "Failed to retrieve location for IP $IPAddress : $_" -isError | ||
return [PSCustomObject]@{ | ||
IP = $IPAddress | ||
CountryName = "Failed to Resolve" | ||
RegionName = "Unknown" | ||
RegionCode = "Unknown" | ||
ContinentName = "Unknown" | ||
City = "Unknown" | ||
KnownMicrosoftIP = "Unknown" | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.