Its possible you can use a show-access-rulebase with the filter option, but I find it easier to just loop through the rulebase.
Here's a sample powershell script to list rules with "Any" src/dst/svc
[string]$BaseUri = "https://10.10.2.1/web_api"
[string]$domain = "domainname" # Only used for MDS servers
[string]$user = "username"
[string]$pass = "password"
[string]$layer= "demo-policy Network"
$loginData = @{
"user" = $user
"password" = $pass
"domain" = $domain # Only used for MDS servers
} | ConvertTo-Json
Write-Output "Invoking Login"
$login = Invoke-RestMethod -Method Post -Uri "$BaseUri/login" -Body $loginData -Headers @{ "content-type" = "application/json" }
$headers = @{
"content-type" = "application/json"
"x-chkp-sid" = $login.sid
}
# Get RuleBase
Write-Output "Getting rulebase"
$body = @{
"name" = $layer
} | ConvertTo-Json
$rules = Invoke-RestMethod -Method Post -Uri "$BaseUri/show-access-rulebase" -Body $body -Headers $headers
foreach ($y in $rules.rulebase.rulebase) {
$body = @{
"uid" = $($y.uid)
"layer" = $layer
} |ConvertTo-Json
$rule = Invoke-RestMethod -Method Post -Uri "$BaseUri/show-access-rule" -Body $body -Headers $headers
if ($($rule.source.name) -like "Any") {
Write-output "Any Source, Rulename: $($rule.name), Rule UID: $($rule.uid), Source: $($rule.source.Name), Destination: $($rule.destination.Name), Service: $($rule.service.Name), Action: $($rule.action.Name)"
}
elseif ($($rule.destination.name) -like "Any") {
Write-output "Any Destination, Rulename: $($rule.name), Rule UID: $($rule.uid), Source: $($rule.source.Name), Destination: $($rule.destination.Name), Service: $($rule.service.Name), Action: $($rule.action.Name)"
}
elseif ($($rule.service.name) -like "Any") {
Write-output "Any Service, Rulename: $($rule.name), Rule UID: $($rule.uid), Source: $($rule.source.Name), Destination: $($rule.destination.Name), Service: $($rule.service.Name), Action: $($rule.action.Name)"
}
}
Write-Output "Disconnect session $($login.uid)"
$null = Invoke-RestMethod -Method Post -Uri "$BaseUri/disconnect" -Headers $headers -Body (@{ "uid" = $login.uid } | ConvertTo-Json)