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

Panorama instance single select on new incident layouts #49

Merged
merged 1 commit into from
Oct 21, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"XDRBuiltInField": false,
"XsiamIncidentFieldExtraData": {
"incidentsFilter": null,
"slaGoals": null,
"slaTimer": null,
"timerConditions": null
},
"aliasTo": "",
"aliases": null,
"associatedToAll": false,
"associatedTypes": [
"PAN-OS Network Operations - Device Upgrade",
"PAN-OS Network Operations - Upgrade Assurance"
],
"autoCompleteTags": null,
"breachScript": "",
"cacheVersn": 0,
"caseInsensitive": true,
"cliName": "panosnetworkoperationspanoramainstancename",
"closeForm": false,
"columns": null,
"content": false,
"defaultRows": null,
"definitionId": "",
"description": "The XSOAR PAN-OS integration instance used in playbook",
"editForm": true,
"fieldCalcScript": "GetPanoramaInstances",
"fromServerVersion": "",
"group": 0,
"hidden": false,
"id": "incident_panosnetworkoperationspanoramainstancename",
"ipVersion": "",
"isReadOnly": false,
"itemVersion": "",
"locked": false,
"mergeStrategy": "",
"name": "PAN-OS Network Operations - Panorama Instance Name",
"neverSetAsRequired": false,
"openEnded": false,
"orgType": "singleSelect",
"ownerOnly": false,
"packID": "",
"packName": "",
"placeholder": "",
"pretty_name": "PAN-OS Network Operations - Panorama Instance Name",
"required": false,
"runScriptAfterUpdate": false,
"script": "",
"selectValues": [
""
],
"selectValuesMap": null,
"sla": 0,
"system": false,
"systemAssociatedTypes": null,
"template": "",
"threshold": 72,
"toServerVersion": "",
"type": "singleSelect",
"unmapped": false,
"unsearchable": false,
"useAsKpi": false,
"validatedError": "",
"validationRegex": "",
"version": -1,
"x2_fields": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@
"isVisible": true
},
{
"fieldId": "incident_panosnetworkoperationspanoramainstance",
"fieldId": "incident_panosnetworkoperationspanoramainstancename",
"isVisible": true
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@
"isVisible": true
},
{
"fieldId": "incident_panosnetworkoperationspanoramainstance",
"fieldId": "incident_panosnetworkoperationspanoramainstancename",
"isVisible": true
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
description: Upgrades a single or HA pair of PAN-OS firewalls.
dirtyInputs: true
id: PAN-OS Network Operations - Device Upgrade
inputSections:
- description: Generic group for inputs
inputs:
- target_device
- peer_device
- target_version
- panorama_instance
name: General (Inputs group)
inputs:
- description: Target Firewall for upgrade
key: target_device
Expand All @@ -19,7 +28,17 @@ inputs:
required: false
value:
simple: ${incident.panosnetworkoperationsupgradetargetversion}
- description: Instance name for Panorama Integration to use
key: panorama_instance
playbookInputQuery: null
required: false
value:
simple: ${incident.panosnetworkoperationspanoramainstancename}
name: PAN-OS Network Operations - Device Upgrade
outputSections:
- description: Generic group for outputs
name: General (Outputs group)
outputs: []
outputs: []
starttaskid: "0"
tasks:
Expand Down Expand Up @@ -49,7 +68,7 @@ tasks:
{
"position": {
"x": 520,
"y": -3250
"y": -3070
}
}
"40":
Expand Down Expand Up @@ -374,6 +393,9 @@ tasks:
- "59"
note: false
quietmode: 0
scriptarguments:
instance:
simple: ${inputs.panorama_instance}
separatecontext: false
skipunavailable: false
task:
Expand All @@ -396,16 +418,16 @@ tasks:
"y": -1930
}
}
version: 9
version: 10
view: |-
{
"linkLabelsPosition": {},
"paper": {
"dimensions": {
"height": 1945,
"height": 1765,
"width": 610,
"x": 520,
"y": -3250
"y": -3070
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,30 @@ description: Runs a series of tests based on the upgrade assurance commands and
if any fail - also generates reports and other information that is useful in the
assurance process.
id: PAN-OS Network Operations - Upgrade Assurance
inputSections:
- description: Generic group for inputs
inputs:
- target
- panorama_instance
name: General (Inputs group)
inputs:
- description: Target firewall - helpful if running this playbook in a loop.
key: target
playbookInputQuery: null
required: true
value:
simple: ${incident.panosnetworkoperationstarget}
- description: Instance name for Panorama Integration to use
key: panorama_instance
playbookInputQuery: null
required: false
value:
simple: ${incident.panosnetworkoperationspanoramainstancename}
name: PAN-OS Network Operations - Upgrade Assurance
outputSections:
- description: Generic group for outputs
name: General (Outputs group)
outputs: []
outputs: []
starttaskid: "0"
tasks:
Expand All @@ -21,7 +37,7 @@ tasks:
isoversize: false
nexttasks:
'#none#':
- "9"
- "11"
note: false
quietmode: 0
separatecontext: false
Expand All @@ -39,7 +55,7 @@ tasks:
{
"position": {
"x": 450,
"y": 50
"y": -370
}
}
"6":
Expand Down Expand Up @@ -251,16 +267,93 @@ tasks:
"y": 880
}
}
version: 29
"11":
conditions:
- condition:
- - left:
iscontext: true
value:
simple: incident.panosnetworkoperationspanoramainstance
operator: isNotEmpty
right:
value: {}
label: yes
continueonerrortype: ""
id: "11"
ignoreworker: false
isautoswitchedtoquietmode: false
isoversize: false
nexttasks:
'#default#':
- "12"
yes:
- "9"
note: false
quietmode: 0
separatecontext: false
skipunavailable: false
task:
brand: ""
id: 7a614239-695e-4796-8ab7-377f82056013
iscommand: false
name: Is Panorama Instance Set?
type: condition
version: -1
taskid: 7a614239-695e-4796-8ab7-377f82056013
timertriggers: []
type: condition
view: |-
{
"position": {
"x": 450,
"y": -220
}
}
"12":
continueonerrortype: ""
id: "12"
ignoreworker: false
isautoswitchedtoquietmode: false
isoversize: false
nexttasks:
'#none#':
- "9"
note: false
quietmode: 0
scriptarguments:
instance:
simple: ${inputs.panorama_instance}
separatecontext: false
skipunavailable: false
task:
brand: ""
description: "This will set the Panorama instance field (panosnetworkoperationspanoramainstance) if it isn't already set. "
id: d191eeb8-f8e3-4299-8244-3c0ccf7c9470
iscommand: false
name: Set Panorama Instance
script: SetPanoramaInstance
type: regular
version: -1
taskid: d191eeb8-f8e3-4299-8244-3c0ccf7c9470
timertriggers: []
type: regular
view: |-
{
"position": {
"x": 450,
"y": 20
}
}
version: 30
view: |-
{
"linkLabelsPosition": {},
"paper": {
"dimensions": {
"height": 925,
"height": 1345,
"width": 790,
"x": 450,
"y": 50
"y": -370
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import demistomock as demisto # noqa: F401
from CommonServerPython import * # noqa: F401
from typing import Dict, Any
import traceback


def get_panorama_instances() -> Dict[str, Any]:
"""
Get instances of Panorama integration for SingleSelect field.

:rtype: ``dict``
:return: dict with the ids as options for SingleSelect field e.g
{"hidden": False, "options": sorted(panorama_instance_names)}
"""
res = demisto.executeCommand("GetInstanceName", {
"integration_name": "Panorama",
"return_all_instances": True
})
if is_error(res):
return_error(get_error(res))

if not res:
raise DemistoException('Got an empty list object after executing the command !GetPanoramaInstances')

panorama_instances = res[0].get('Contents', [])

panorama_instance_names = []
# panorama_instances is a list of dict(instanceName, integrationName)
for instance in panorama_instances:
panorama_instance_names.append(instance.get('instanceName'))

return {"hidden": False, "options": sorted(panorama_instance_names)}


def main():
try:
result = get_panorama_instances()
return_results(result)

except Exception as ex:
demisto.error(traceback.format_exc()) # print the traceback
return_error(f'Failed to execute GetPanoramaInstances. Error: {str(ex)}')


''' ENTRY POINT '''

if __name__ in ('__main__', '__builtin__', 'builtins'):
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
comment: Gets all instances of Panorama integration, in the output format of a single select field.
commonfields:
id: GetPanoramaInstances
version: -1
dockerimage: demisto/python3:3.11.10.111526
enabled: true
engineinfo: {}
mainengineinfo: {}
name: GetPanoramaInstances
pswd: ''
runas: DBotWeakRole
runonce: false
script: ''
scripttarget: 0
subtype: python3
tags:
- field-display
type: python
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
args = demisto.args()
integration = args.get('integration')
field_name = args.get('field')
instance_name = args.get('instance')
override = argToBoolean(args.get('override'))

# find the current field value
Expand All @@ -27,8 +28,12 @@
if data.get('brand', '') == integration and data.get('state', '') == 'active':
instance_names.append(name)

# if multiple active instances, join to preserve the default 'using' behavior
instance_names = ','.join(instance_names)
# if a specific instance is requested expilicitly
if instance_name and instance_name in instance_names:
instance_names = instance_name
else:
# if multiple active instances, join to preserve the default 'using' behavior
instance_names = ','.join(instance_names)

if not current_value or override:
execute_command('setIncident', {field_name: instance_names})
Expand Down
Loading
Loading