Skip to content

Commit

Permalink
Merge pull request #140 from TehMuffinMoo/dev
Browse files Browse the repository at this point in the history
v1.9.7.2
  • Loading branch information
TehMuffinMoo authored Jun 18, 2024
2 parents c8fb14e + d51d6ad commit eeb8fa8
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 66 deletions.
1 change: 1 addition & 0 deletions .github/workflows/PSGallery-Publish-ibPS.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
if ($CustomModuleVersion -eq "true") {
[version]$ModuleVersion = "${{ inputs.versionNumber }}"
} else {
$ModuleVersion = $Module.Version
$ModuleVersion = [version]::New($ModuleVersion.Major,$ModuleVersion.Minor,$ModuleVersion.Build,$ModuleVersion.Revision+1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ function Get-B1CSPCurrentUser {
.PARAMETER Groups
Using the -Groups switch will return a list of Groups associated with the current user
.PARAMETER Compartments
Using the -Compartments switch will return a list of Compartments associated with the current user
.PARAMETER Account
Using the -Account switch will return the account data associated with the current user
Expand All @@ -26,12 +29,16 @@ function Get-B1CSPCurrentUser {
[Parameter(ParameterSetName="Groups")]
[Switch]$Groups,
[Parameter(ParameterSetName="Account")]
[Switch]$Account
[Switch]$Account,
[Parameter(ParameterSetName="Compartments")]
[Switch]$Compartments
)
if ($Groups) {
Invoke-CSP -Method GET -Uri "$(Get-B1CSPUrl)/v2/current_user/groups" | Select-Object -ExpandProperty results
} elseif ($Account) {
Invoke-CSP -Method GET -Uri "$(Get-B1CSPUrl)/v2/current_user/accounts" | Select-Object -ExpandProperty results
} elseif ($Compartments) {
Invoke-CSP -Method GET -Uri "$(Get-B1CSPUrl)/v2/current_user/compartments" | Select-Object -ExpandProperty results
} else {
Invoke-CSP -Method GET -Uri "$(Get-B1CSPUrl)/v2/current_user" | Select-Object -ExpandProperty result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
$NewObj.dhcp_options = $DHCPOptions
}
if ($Tags) {
$AddressBlockPatch.tags = $Tags
$NewObj.tags = $Tags
}
if ($DHCPLeaseSeconds) {
$NewObj.inheritance_sources.dhcp_config.lease_time.action = "override"
Expand Down
2 changes: 1 addition & 1 deletion Modules/ibPS/Functions/BloxOne/BloxOneDDI/Set-B1Subnet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
$NewObj.dhcp_host = $HAGroupID
}
if ($Tags) {
$AddressBlockPatch.tags = $Tags
$NewObj.tags = $Tags
}
if ($DHCPLeaseSeconds) {
$NewObj.inheritance_sources.dhcp_config.lease_time.action = "override"
Expand Down
56 changes: 49 additions & 7 deletions Modules/ibPS/Functions/BloxOne/BloxOneTD/Get-B1CustomList.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
This function is used to retrieve named lists from BloxOne Threat Defense. These are referred to and displayed as Custom Lists within the CSP.
.PARAMETER Name
Filter results by Name. Whilst this is here, the API does not currently support filtering by name. (01/04/24)
Filter results by Name.
.PARAMETER Description
Filter results by Description. Whilst this is here, the API does not currently support filtering by description. (01/04/24)
Filter results by Description.
.PARAMETER Description
Filter results by Type.
.PARAMETER ReturnItems
Optionally return the list of domains contained within the Named List. Only required when -id is not specified.
Expand Down Expand Up @@ -40,6 +43,23 @@
.PARAMETER Strict
Use strict filter matching. By default, filters are searched using wildcards where possible. Using strict matching will only return results matching exactly what is entered in the applicable parameters.
.EXAMPLE
PS> Get-B1CustomList -Type 'zero_day_dns' -ReturnItems
confidence_level : HIGH
created_time : 4/29/2024 3:45:51 PM
description : Auto-generated
id : 797118
item_count : 3
items : {123moviess.mom, auto-bg.info, cap-caps.shop}
items_described : {@{description=; item=123moviess.mom}, @{description=; item=auto-bg.info}, @{description=; item=cap-caps.shop}}
name : Threat Insight - Zero Day DNS
policies : {corporate-policy}
tags :
threat_level : HIGH
type : zero_day_dns
updated_time : 6/12/2024 12:05:44 PM
.EXAMPLE
PS> Get-B1CustomList -Limit 1 -ReturnItems
Expand Down Expand Up @@ -86,6 +106,8 @@
[String]$Name,
[parameter(ParameterSetName="Default")]
[String]$Description,
[parameter(ParameterSetName="Default")]
[String]$Type,
[Parameter(ParameterSetName="Default")]
[Switch]$ReturnItems,
[Parameter(ParameterSetName="Default")]
Expand Down Expand Up @@ -116,11 +138,15 @@
if ($CustomFilters) {
$Filters.Add($CustomFilters) | Out-Null
}
if ($Name) {
$Filters.Add("name$($MatchType)`"$Name`"") | Out-Null
}
if ($Description) {
$Filters.Add("description$($MatchType)`"$Description`"") | Out-Null
## API Filtering not currently supported on this endpoint - (01/04/24)
# if ($Name) {
# $Filters.Add("name$($MatchType)`"$Name`"") | Out-Null
# }
# if ($Description) {
# $Filters.Add("description$($MatchType)`"$Description`"") | Out-Null
# }
if ($Type) {
$Filters.Add("type==`"$Type`"") | Out-Null
}
if ($Filters) {
$Filter = Combine-Filters $Filters
Expand Down Expand Up @@ -152,6 +178,22 @@
$Results = Invoke-CSP -Method GET -Uri "$(Get-B1CSPUrl)/api/atcfw/v1/named_lists$($QueryString)" | Select-Object -ExpandProperty results -ErrorAction SilentlyContinue
}

## Temporary Workaround to API Filtering Limitations. This ensures -Name & -Description can still be used, but filtering is performed by Powershell instead of the API.
if ($Name) {
if ($Strict) {
$Results = $Results | Where-Object {$_.name -eq $Name}
} else {
$Results = $Results | Where-Object {$_.name -like "*$($Name)*"}
}
}
if ($Description) {
if ($Strict) {
$Results = $Results | Where-Object {$_.description -eq $Description}
} else {
$Results = $Results | Where-Object {$_.description -like "*$($Description)*"}
}
}

if ($ReturnItems) {
$Results = $Results | Get-B1CustomList
}
Expand Down
12 changes: 6 additions & 6 deletions Modules/ibPS/Functions/Misc/Set-ibPSConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Set-ibPSConfiguration {
Optionally configure the DNS over HTTPS Server to use when calling Resolve-DoHQuery
.PARAMETER Persist
Setting the -Persist parameter will save the configuration peremenantly for your user on this device. Without using this switch, the settings will only be saved for the duration of the PowerShell session.
Setting the -Persist parameter will save the configuration permanently for your user on this device. Without using this switch, the settings will only be saved for the duration of the PowerShell session.
.PARAMETER DevelopmentMode
Enabling development mode will expose additional functions to allow development of new cmdlets. Enabling development mode will always apply as a persistent setting until it is disabled. This is because in some cases it may require a restart of the PowerShell session to fully enable.
Expand All @@ -33,7 +33,7 @@ function Set-ibPSConfiguration {
.EXAMPLE
PS> Set-ibPSConfiguration -CSPAPIKey 'longapikeygoeshere' -Persist
BloxOne API key has been stored permenantly for user on MAC-DSD984HG
BloxOne API key has been stored permanently for user on MAC-DSD984HG
.EXAMPLE
PS> Set-ibPSConfiguration -CSPRegion EU
Expand Down Expand Up @@ -80,15 +80,15 @@ function Set-ibPSConfiguration {
if ($Platform -eq "Windows") {
[System.Environment]::SetEnvironmentVariable('B1CSPUrl',$CSPUrl,[System.EnvironmentVariableTarget]::User)
$ENV:B1CSPUrl = $CSPUrl
Write-Host "BloxOne CSP URL ($CSPUrl) has been stored permenantly for $env:USERNAME on $env:COMPUTERNAME." -ForegroundColor Green
Write-Host "BloxOne CSP URL ($CSPUrl) has been stored permanently for $env:USERNAME on $env:COMPUTERNAME." -ForegroundColor Green
} elseif ($Platform -eq "Mac" -or $Platform -eq "Unix") {
$ENV:B1CSPUrl = $CSPUrl
if (!(Test-Path ~/.zshenv)) {
touch ~/.zshenv
}
sed -i '' -e '/B1CSPUrl/d' ~/.zshenv
echo "export B1CSPUrl=$CSPUrl" >> ~/.zshenv
Write-Host "BloxOne CSP URL ($CSPUrl) has been stored permenantly for $env:USER on $(scutil --get LocalHostName)." -ForegroundColor Green
Write-Host "BloxOne CSP URL ($CSPUrl) has been stored permanently for $env:USER on $(scutil --get LocalHostName)." -ForegroundColor Green
}
} else {
$ENV:B1CSPUrl = $CSPUrl
Expand All @@ -107,15 +107,15 @@ function Set-ibPSConfiguration {
if ($Platform -eq "Windows") {
[System.Environment]::SetEnvironmentVariable('B1APIKey',$Base64,[System.EnvironmentVariableTarget]::User)
$ENV:B1APIKey = $Base64
Write-Host "BloxOne API key has been stored permenantly for $env:USERNAME on $env:COMPUTERNAME." -ForegroundColor Green
Write-Host "BloxOne API key has been stored permanently for $env:USERNAME on $env:COMPUTERNAME." -ForegroundColor Green
} elseif ($Platform -eq "Mac" -or $Platform -eq "Unix") {
$ENV:B1APIKey = $Base64
if (!(Test-Path ~/.zshenv)) {
touch ~/.zshenv
}
sed -i '' -e '/B1APIKey/d' ~/.zshenv
echo "export B1APIKey=$Base64" >> ~/.zshenv
Write-Host "BloxOne API key has been stored permenantly for $env:USER on $(scutil --get LocalHostName)." -ForegroundColor Green
Write-Host "BloxOne API key has been stored permanently for $env:USER on $(scutil --get LocalHostName)." -ForegroundColor Green
}
} else {
$ENV:B1APIKey = $Base64
Expand Down
6 changes: 3 additions & 3 deletions Modules/ibPS/Functions/Misc/build.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Build": "0",
"SHA": "23cea78d6c4a812ce21325b0899b05c61ce71d2a",
"Branch": "main"
"Build": 10,
"SHA": "ebf0f0c6dc59e801a1595be078cd361bf2559230",
"Branch": "dev"
}
4 changes: 2 additions & 2 deletions Modules/ibPS/Functions/NIOS/Set-NIOSConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
if ($Platform -eq "Windows") {
[System.Environment]::SetEnvironmentVariable('NIOSConfig',$Base64,[System.EnvironmentVariableTarget]::User)
$ENV:NIOSConfig = $Base64
Write-Host "Configuration has been stored permenantly for $env:USERNAME on $env:COMPUTERNAME." -ForegroundColor Green
Write-Host "Configuration has been stored permanently for $env:USERNAME on $env:COMPUTERNAME." -ForegroundColor Green
} elseif ($Platform -eq "Mac" -or $Platform -eq "Unix") {
[System.Environment]::SetEnvironmentVariable('NIOSConfig',$Base64,[System.EnvironmentVariableTarget]::User)
$ENV:NIOSConfig = $Base64
Expand All @@ -48,7 +48,7 @@
}
sed -i '' -e '/NIOSConfig/d' ~/.zshenv
echo "export NIOSConfig=$Base64" >> ~/.zshenv
Write-Host "NIOS configuration has been stored permenantly for $env:USER on $(scutil --get LocalHostName)." -ForegroundColor Green
Write-Host "NIOS configuration has been stored permanently for $env:USER on $(scutil --get LocalHostName)." -ForegroundColor Green
}
} else {
$ENV:NIOSConfig = $Base64
Expand Down
4 changes: 2 additions & 2 deletions Modules/ibPS/Functions/NIOS/Set-NIOSCredentials.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
if ($Platform -eq "Windows") {
[System.Environment]::SetEnvironmentVariable('NIOSCredentials',$Base64,[System.EnvironmentVariableTarget]::User)
$ENV:NIOSCredentials = $Base64
Write-Host "Credentials for $Username have been stored permenantly for $env:USERNAME on $env:COMPUTERNAME." -ForegroundColor Green
Write-Host "Credentials for $Username have been stored permanently for $env:USERNAME on $env:COMPUTERNAME." -ForegroundColor Green
} elseif ($Platform -eq "Mac" -or $Platform -eq "Unix") {
[System.Environment]::SetEnvironmentVariable('NIOSCredentials',$Base64,[System.EnvironmentVariableTarget]::User)
$ENV:NIOSCredentials = $Base64
Expand All @@ -48,7 +48,7 @@
}
sed -i '' -e '/NIOSCredentials/d' ~/.zshenv
echo "export NIOSCredentials=$Base64" >> ~/.zshenv
Write-Host "NIOS Credentials have been stored permenantly for $env:USER on $(scutil --get LocalHostName)." -ForegroundColor Green
Write-Host "NIOS Credentials have been stored permanently for $env:USER on $(scutil --get LocalHostName)." -ForegroundColor Green
}
} else {
$ENV:NIOSCredentials = $Base64
Expand Down
42 changes: 4 additions & 38 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,4 @@
- Add `Get-B1Compartment` for listing Organizational Compartments
- Add support for configuring Organizational Compartments when using:

| | | |
|:---------------------------|:---------------------------|:---------------------------|
| `New-B1AuthoritativeZone` | `New-B1AddressBlock` | `New-B1Space` |
| `Set-B1AuthoritativeZone` | `Set-B1AddressBlock` | |

- Add support for filtering by Organizational Compartment when using:

| | | |
|:---------------------------|:---------------------------|:---------------------------|
| `Get-B1Subnet` | `Get-B1AddressBlock` | `Get-B1Range` |
| `Get-B1AuthoritativeZone` | `Get-B1ForwardZone` | `Get-B1Record` |
| `Get-B1Address` | `Get-B1Space` | |

- Add/Align `-CustomFilters` support to:

| | | |
|:---------------------------|:---------------------------|:---------------------------|
| `Get-B1AuthoriativeNSG` | `Get-B1AuthoriativeZone` | `Get-B1CloudProvider` |
| `Get-B1DelegatedZone` | `Get-B1DFP` | `Get-B1DHCPConfigProfile` |
| `Get-B1DHCPHardwareFilter` | `Get-B1DHCPHost` | `Get-B1DHCPLease` |
| `Get-B1DHCPOptionCode` | `Get-B1DHCPOptionGroup` | `Get-B1DHCPOptionSpace` |
| `Get-B1DNSACL` | `Get-B1DNSConfigProfile` | `Get-B1DNSHost` |
| `Get-B1DNSView` | `Get-B1DTCHealthCheck` | `Get-B1DTCLBDN` |
| `Get-B1DTCPolicy` | `Get-B1DTCPool` | `Get-B1DTCServer` |
| `Get-B1FixedAddress` | `Get-B1ForwardNSG` | `Get-B1ForwardZone` |
| `Get-B1HAGroup` | `Get-B1Range` | `Get-B1Record` |
| `Get-B1Space` | `Get-B1Subnet` | `Get-B1Address` |
| `Get-B1AddressBlock` | `Get-B1AuditLog` | `Get-B1APIKey` |
| `Get-B1DNSEvent` | `Get-B1Location` | `Get-B1SecurityLog` |
| `Get-B1Tag` | `Get-B1User` | `Get-B1UserAPIKey` |
| `Get-B1Host` | `Get-B1Service` | `Get-B1ApplicationFilter` |
| `Get-B1BypassCode` | `Get-B1CategoryFilter` | `Get-B1CustomList` |
| `Get-B1InternalDomainList` | `Get-B1LookalikeDomains` | `Get-B1Lookalikes` |
| `Get-B1NetworkList` | `Get-B1PoPRegion` | `Get-B1SecurityPolicy` |
| `Get-B1SecurityPolicyRules`| `Get-B1ThirdPartyProvider` | |
- Improve `Get-B1CustomList`
- Add `-Compartments` paremeter to `Get-B1CSPCurrentUser`
- Fix some typos
- Fix bug when updating tags using `Set-B1AddressBlock` and `Set-B1Subnet` [#139](https://github.com/TehMuffinMoo/ibPS/issues/139)
3 changes: 0 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ The list of items below are those which are not yet implemented within ibPS. Onc
- [ ] Investigate need & implement API calls for `dns/host` with `dns/service`
- [ ] Investigate need & implement API calls for `dhcp/host` with `dhcp/service`
- [ ] Improve coverage of Pester Tests
- [X] Add `-CustomFilters` parameter to all functions where filters are supported. See [docs](https://ibps.readthedocs.io/en/dev/#-customfilters)
- [ ] Add TSIG_KEY support to `Set-B1DNSACL` & `New-B1DNSACLItem`
- [ ] Add IPAM Hosts, Tags & Metadata Network Scope support for `New-B1SecurityPolicy` & `Set-B1SecurityPolicy`
- [X] Add Compartment Support to IPAM Functions
- [X] Add Compartment Support to DNS Functions

## Bug Fixes
2 changes: 1 addition & 1 deletion docs/General/Set-ibPSConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This function is used to set ibPS specific configuration, such as the BloxOne CS
```powershell
Set-ibPSConfiguration -CSPAPIKey 'longapikeygoeshere' -Persist
BloxOne API key has been stored permenantly for user on MAC-DSD984HG
BloxOne API key has been stored permanently for user on MAC-DSD984HG
```

### EXAMPLE 2
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Import-Module -Name ".\Modules\ibPS\BloxOne-Main.psm1" -DisableNameChecking
In order to authenticate against the BloxOne CSP (Cloud Services Portal), you must first set your API Key. You can do this for either your current powershell session or save the API Key as persistent for your current user.

##### Persistent
To store your API Key permenantly for your user, you can specify the <b>-Persist</b> option as shown below.
To store your API Key permanently for your user, you can specify the <b>-Persist</b> option as shown below.
```powershell
Set-ibPSConfiguration -CSPAPIKey "<ApiKeyFromCSP>" -Persist
```
Expand Down

0 comments on commit eeb8fa8

Please sign in to comment.