-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Security RegExes: ?<Security_AccessToken> and ?<Security_JWT>
- Loading branch information
1 parent
5e16230
commit 2ba9de3
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,39 @@ | ||
<# | ||
.Synopsis | ||
Matches Access Tokens | ||
.Description | ||
Matches Access Tokens. | ||
Access Tokens are single-line base64 strings that have more than -MinimumLength characters (default 40) | ||
#> | ||
param( | ||
# The Minimum Length of an Access Token. By default, 40 characters | ||
[int] | ||
$MinimumLength = 40, | ||
|
||
|
||
# The Maximum Length of an Access Token. By default, 1kb characters | ||
[int] | ||
$MaximumLength = 1kb, | ||
|
||
# If set, will look for a hexadecimal access token. | ||
# By default, will match Base64 access tokens | ||
[switch] | ||
$Hex, | ||
|
||
# If set, will allow the token to be a JSON Web Token. | ||
# These are similar to Base64 tokens, but may contain periods (and will tend to be longer) | ||
[Alias('JSONWebToken')] | ||
[switch] | ||
$JWT | ||
) | ||
|
||
if ($Hex) { | ||
"(?<AccessToken>[0-9a-f]{$MinimumLength,$MaximumLength})" | ||
} | ||
elseif ($JWT) { | ||
"(?<AccessToken>[0-9a-z/=\+\.]{$MinimumLength,$MaximumLength})" | ||
} | ||
else { | ||
"(?<AccessToken>[0-9a-z/=\+]{$MinimumLength,$MaximumLength})" | ||
} |
This file contains 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,11 @@ | ||
$myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt' | ||
$myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path | ||
Write-RegEx -Description @' | ||
Matches a JSON Web Token (JWT) | ||
'@ | | ||
Write-RegEx -Pattern '[0-9a-z=/\+]+' -Name Header -Comment "A base 64 string containing the header" | | ||
Write-RegEx -LiteralCharacter '.' -Comment "Followed by a period" | | ||
Write-RegEx -Pattern '[0-9a-z=/\+]+' -Name Payload -Comment "A base 64 string containing the payload" | | ||
Write-RegEx -LiteralCharacter '.' -Comment "Followed by a period" | | ||
Write-RegEx -Pattern '[0-9a-z=/\+]+' -Name Signature -Comment "A base 64 string containing the signature" | | ||
Set-Content -Path (Join-Path $myRoot $myName) -PassThru |
This file contains 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,7 @@ | ||
# Matches a JSON Web Token (JWT) | ||
(?<Header>[0-9a-z=/\+]+) # A base 64 string containing the header | ||
\. # Followed by a period | ||
(?<Payload>[0-9a-z=/\+]+) # A base 64 string containing the payload | ||
\. # Followed by a period | ||
(?<Signature>[0-9a-z=/\+]+) # A base 64 string containing the signature | ||
|
This file contains 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 @@ | ||
This directory contains Regular Expressions related to Security. |