Skip to content
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

Add Get Security Profile (IPS, DNS, App...) #236

Merged
merged 15 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions PowerFGT/Public/cmdb/antivirus/profile.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#
# Copyright, Alexis La Goutte <alexis dot lagoutte at gmail dot com>
#
# SPDX-License-Identifier: Apache-2.0
#
function Get-FGTAntivirusProfile {

<#
.SYNOPSIS
Get list of all Antivirus Profile settings

.DESCRIPTION
Get list of all Antivirus Profile (name, feature-set, protocol (http, ftp, imap...) ...)

.EXAMPLE
Get-FGTAntivirusProfile

Get list of all settings of Antivirus Profile

.EXAMPLE
Get-FGTAntivirusProfile -name myAntivirusProfile

Get Antivirus Profile named myAntivirusProfile

.EXAMPLE
Get-FGTAntivirusProfile -name FGT -filter_type contains

Get Antivirus Profile contains with *FGT*

.EXAMPLE
Get-FGTAntivirusProfile -meta

Get list of all settings of Antivirus Profile with metadata (q_...) like usage (q_ref)

.EXAMPLE
Get-FGTAntivirusProfile -skip

Get list of all settings of Antivirus Profile (but only relevant attributes)

.EXAMPLE
Get-FGTAntivirusProfile -vdom vdomX

Get list of all settings of Antivirus Profile on vdomX
#>

[CmdletBinding(DefaultParameterSetName = "default")]
Param(
[Parameter (Mandatory = $false, Position = 1, ParameterSetName = "name")]
[string]$name,
[Parameter (Mandatory = $false)]
[Parameter (ParameterSetName = "filter")]
[string]$filter_attribute,
[Parameter (Mandatory = $false)]
[Parameter (ParameterSetName = "name")]
[Parameter (ParameterSetName = "filter")]
[ValidateSet('equal', 'contains')]
[string]$filter_type = "equal",
[Parameter (Mandatory = $false)]
[Parameter (ParameterSetName = "filter")]
[psobject]$filter_value,
[Parameter(Mandatory = $false)]
[switch]$meta,
[Parameter(Mandatory = $false)]
[switch]$skip,
[Parameter(Mandatory = $false)]
[String[]]$vdom,
[Parameter(Mandatory = $false)]
[psobject]$connection = $DefaultFGTConnection
)

Begin {
}

Process {

$uri = 'api/v2/cmdb/antivirus/profile'

$invokeParams = @{ }
if ( $PsBoundParameters.ContainsKey('meta') ) {
$invokeParams.add( 'meta', $meta )
}
if ( $PsBoundParameters.ContainsKey('skip') ) {
$invokeParams.add( 'skip', $skip )
}
if ( $PsBoundParameters.ContainsKey('vdom') ) {
$invokeParams.add( 'vdom', $vdom )
}

#Filtering
switch ( $PSCmdlet.ParameterSetName ) {
"name" {
$filter_value = $name
$filter_attribute = "name"
}
default { }
}

#if filter value and filter_attribute, add filter (by default filter_type is equal)
if ( $filter_value -and $filter_attribute ) {
$invokeParams.add( 'filter_value', $filter_value )
$invokeParams.add( 'filter_attribute', $filter_attribute )
$invokeParams.add( 'filter_type', $filter_type )
}

$response = Invoke-FGTRestMethod -uri $uri -method 'GET' -connection $connection @invokeParams
$response.results
}

End {
}
}
111 changes: 111 additions & 0 deletions PowerFGT/Public/cmdb/application/list.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#
# Copyright, Alexis La Goutte <alexis dot lagoutte at gmail dot com>
#
# SPDX-License-Identifier: Apache-2.0
#
function Get-FGTApplicationList {

<#
.SYNOPSIS
Get list of all Application List settings

.DESCRIPTION
Get list of all Application List (name, options, entries ...)

.EXAMPLE
Get-FGTApplicationList

Get list of all settings of Application List

.EXAMPLE
Get-FGTApplicationList -name myApplicationList

Get Application List named myApplicationList

.EXAMPLE
Get-FGTApplicationList -name FGT -filter_type contains

Get Application List contains with *FGT*

.EXAMPLE
Get-FGTApplicationList -meta

Get list of all settings of Application List with metadata (q_...) like usage (q_ref)

.EXAMPLE
Get-FGTApplicationList -skip

Get list of all settings of Application List (but only relevant attributes)

.EXAMPLE
Get-FGTApplicationList -vdom vdomX

Get list of all settings of Application List on vdomX
#>

[CmdletBinding(DefaultParameterSetName = "default")]
Param(
[Parameter (Mandatory = $false, Position = 1, ParameterSetName = "name")]
[string]$name,
[Parameter (Mandatory = $false)]
[Parameter (ParameterSetName = "filter")]
[string]$filter_attribute,
[Parameter (Mandatory = $false)]
[Parameter (ParameterSetName = "name")]
[Parameter (ParameterSetName = "filter")]
[ValidateSet('equal', 'contains')]
[string]$filter_type = "equal",
[Parameter (Mandatory = $false)]
[Parameter (ParameterSetName = "filter")]
[psobject]$filter_value,
[Parameter(Mandatory = $false)]
[switch]$meta,
[Parameter(Mandatory = $false)]
[switch]$skip,
[Parameter(Mandatory = $false)]
[String[]]$vdom,
[Parameter(Mandatory = $false)]
[psobject]$connection = $DefaultFGTConnection
)

Begin {
}

Process {

$uri = 'api/v2/cmdb/application/list'

$invokeParams = @{ }
if ( $PsBoundParameters.ContainsKey('meta') ) {
$invokeParams.add( 'meta', $meta )
}
if ( $PsBoundParameters.ContainsKey('skip') ) {
$invokeParams.add( 'skip', $skip )
}
if ( $PsBoundParameters.ContainsKey('vdom') ) {
$invokeParams.add( 'vdom', $vdom )
}

#Filtering
switch ( $PSCmdlet.ParameterSetName ) {
"name" {
$filter_value = $name
$filter_attribute = "name"
}
default { }
}

#if filter value and filter_attribute, add filter (by default filter_type is equal)
if ( $filter_value -and $filter_attribute ) {
$invokeParams.add( 'filter_value', $filter_value )
$invokeParams.add( 'filter_attribute', $filter_attribute )
$invokeParams.add( 'filter_type', $filter_type )
}

$response = Invoke-FGTRestMethod -uri $uri -method 'GET' -connection $connection @invokeParams
$response.results
}

End {
}
}
111 changes: 111 additions & 0 deletions PowerFGT/Public/cmdb/dnsfilter/profile.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#
# Copyright, Alexis La Goutte <alexis dot lagoutte at gmail dot com>
#
# SPDX-License-Identifier: Apache-2.0
#
function Get-FGTDnsfilterProfile {

<#
.SYNOPSIS
Get list of all Dnsfilter Profile settings

.DESCRIPTION
Get list of all Dnsfilter Profile (name, sdns, ftgd-dns ...)

.EXAMPLE
Get-FGTDnsfilterProfile

Get list of all settings of Dnsfilter Profile

.EXAMPLE
Get-FGTDnsfilterProfile -name myDnsfilterProfile

Get Dnsfilter Profile named myDnsfilterProfile

.EXAMPLE
Get-FGTDnsfilterProfile -name FGT -filter_type contains

Get Dnsfilter Profile contains with *FGT*

.EXAMPLE
Get-FGTDnsfilterProfile -meta

Get list of all settings of Dnsfilter Profile with metadata (q_...) like usage (q_ref)

.EXAMPLE
Get-FGTDnsfilterProfile -skip

Get list of all settings of Dnsfilter Profile (but only relevant attributes)

.EXAMPLE
Get-FGTDnsfilterProfile -vdom vdomX

Get list of all settings of Dnsfilter Profile on vdomX
#>

[CmdletBinding(DefaultParameterSetName = "default")]
Param(
[Parameter (Mandatory = $false, Position = 1, ParameterSetName = "name")]
[string]$name,
[Parameter (Mandatory = $false)]
[Parameter (ParameterSetName = "filter")]
[string]$filter_attribute,
[Parameter (Mandatory = $false)]
[Parameter (ParameterSetName = "name")]
[Parameter (ParameterSetName = "filter")]
[ValidateSet('equal', 'contains')]
[string]$filter_type = "equal",
[Parameter (Mandatory = $false)]
[Parameter (ParameterSetName = "filter")]
[psobject]$filter_value,
[Parameter(Mandatory = $false)]
[switch]$meta,
[Parameter(Mandatory = $false)]
[switch]$skip,
[Parameter(Mandatory = $false)]
[String[]]$vdom,
[Parameter(Mandatory = $false)]
[psobject]$connection = $DefaultFGTConnection
)

Begin {
}

Process {

$uri = 'api/v2/cmdb/dnsfilter/profile'

$invokeParams = @{ }
if ( $PsBoundParameters.ContainsKey('meta') ) {
$invokeParams.add( 'meta', $meta )
}
if ( $PsBoundParameters.ContainsKey('skip') ) {
$invokeParams.add( 'skip', $skip )
}
if ( $PsBoundParameters.ContainsKey('vdom') ) {
$invokeParams.add( 'vdom', $vdom )
}

#Filtering
switch ( $PSCmdlet.ParameterSetName ) {
"name" {
$filter_value = $name
$filter_attribute = "name"
}
default { }
}

#if filter value and filter_attribute, add filter (by default filter_type is equal)
if ( $filter_value -and $filter_attribute ) {
$invokeParams.add( 'filter_value', $filter_value )
$invokeParams.add( 'filter_attribute', $filter_attribute )
$invokeParams.add( 'filter_type', $filter_type )
}

$response = Invoke-FGTRestMethod -uri $uri -method 'GET' -connection $connection @invokeParams
$response.results
}

End {
}
}
Loading