summaryrefslogtreecommitdiff
path: root/python-skilletlib.spec
blob: 8ac3d83c89c1b6cf7481e00deb0ae33305991d3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
%global _empty_manifest_terminate_build 0
Name:		python-skilletlib
Version:	1.2.5
Release:	1
Summary:	Tools for working with PAN-OS Skillets in Python 3
License:	Apache 2.0
URL:		https://github.com/paloaltonetworks/skilletlib
Source0:	https://mirrors.aliyun.com/pypi/web/packages/70/1d/b862db3bba55169edfcd8cb4ca074c79b375f72604189cd3deb134bd1417/skilletlib-1.2.5.tar.gz
BuildArch:	noarch

Requires:	python3-oyaml
Requires:	python3-docker
Requires:	python3-pan-python
Requires:	python3-jinja2
Requires:	python3-pyyaml
Requires:	python3-xmldiff
Requires:	python3-xmltodict
Requires:	python3-requests-toolbelt
Requires:	python3-requests
Requires:	python3-jsonpath-ng
Requires:	python3-passlib
Requires:	python3-GitPython
Requires:	python3-jinja2-ansible-filters
Requires:	python3-jmespath

%description
# Skilletlib
Base Classes and Utilities for working with Skillets in Python 3.7+. Skilletlib encapsulates all the logic necessary to 
execute a skillet in your app or tooling. 

See [here](https://live.paloaltonetworks.com/t5/Skillet-District/ct-p/Skillets) for information about Skillets and
what skillets may be available. 


## About Skillets

Skillets are designed to be sharable units of configuration or validation data. They are perfectly suited for 
'Compliance as Code' or 'Infrastructure as Code' type environments. All the 'knowledge' of doing a thing is encapsulated
in the skillet. Skillets strive to be tooling agnostic. A subject matter expert should not have to define best 
practices in multiple domain specific languages. Ideally, this should be expressed once, and executed in a variety of
tools. Skilletlib makes it easy to allow Skillets to be executed in your tooling of choice. 

Skillets are meant to be stored and shared via source control repositories along with the rest of your infrastructure.
This allows complex NGFW configurations and use case specific compliance checks to be executed as part of your 
deployment pipeline.  

## Resources

* [Information on building Skillets and working with the PAN-OS XML API](https://SkilletBuilder.readthedocs.io)

* [Example Skillets](https://github.com/PaloAltoNetworks/skilletlib/tree/master/example_skillets)

* [PAN-OS XML Quickstart](https://strata.pan.dev/docs/apis/xmlapi_qs)

* [PAN-OS Exploring the API](https://docs.paloaltonetworks.com/pan-os/9-0/pan-os-panorama-api/get-started-with-the-pan-os-xml-api/explore-the-api.html)

## Installation

Skilletlib is distributed as a python shared library on [pypi.org](https://pypi.org/project/skilletlib/).

```bash

pip install skilletlib

```


## Example Loading a Skillet

```python

from skilletlib import SkilletLoader

# init SkilletLoader Class
sl = SkilletLoader()

# Load the skillet found in the current directory
skillet = sl.load_skillet_from_path('.')

# Every skillet requires a context, which is a dict containing
# any user-input or other variables to allow customization.
context = dict()

# In this example, our skillet needs a configuration.xml file to be loaded into a variable
# called 'config'
with open('config.xml', 'r') as config:
    context['config'] = config.read()

# execute the skillet and return the results
out = skillet.execute(context)

# Do something interesting with the results, like print it out :-)
print(out)
print('all done')

```


## Loading Skillets from a Git repository

```python

from skilletlib import SkilletLoader
repo_url = 'https://github.com/nembery/Skillets'
repo_branch = 'develop'
directory = '/var/tmp/skillets'
repo_name = 'example skillets'

sl = SkilletLoader()
skillets = sl.load_from_git(repo_url, repo_name, repo_branch, local_dir=directory)

for s in skillets:
    print(s.name)

```

## using Skilletlib to find recent changes in Set CLI Format

```python

import os

# The Panos class is a wrapper around the XML API that provides some convience methods
from skilletlib import Panos

auth = {
    'hostname': os.environ.get('ip_address', ''),
    'api_username': os.environ.get('username', ''),
    'api_password': os.environ.get('password', ''),
    'debug': os.environ.get('debug', True),
}
device = Panos(**auth)

# you can pass negative integers to the 'get_configuration' method to retrive the most to least recent
# running configurations. This is very useful to finding the Set CLI or XML equivelent of GUI configuration 
# changes
previous_config = device.get_configuration(config_source='-1')
latest_config = device.get_configuration(config_source='running')

# The 'generate_set_cli_from_configs' method returns the difference between two config files. In this case,
# we'll use the running config and the most recent running config audit backup. This will give us all the 
# changes made via the most recent commit in Set CLI format
cmds = device.generate_set_cli_from_configs(previous_config, latest_config)

for cmd in cmds:
    print(cmd)



```

## Other projects that use Skilletlib

Here are a couple of examples of other projects that use skilletlib

* [Panhandler](https://github.com/PaloAltoNetworks/panhandler/)
    Panhandler is a tool to manage collections of Skillets and their respective git repositories
* [SLI](https://gitlab.com/panw-gse/as/sli)
    SLI is a CLI interface to Skilletlib. This tool allows rapid testing and prototyping of Skillets
* [SkilletLoader](https://github.com/nembery/skilletLoader/)
    SkilletLoader is a tool to load and test skillets in a CI/CD pipeline via Docker
* [Ansible Skillets](https://github.com/PaloAltoNetworks/panw-gse.skillets)
    Ansible roles and libraries for loading PAN-OS and related skillets via Ansible playbooks
* [Demisto XSOAR Integration](https://github.com/nembery/content/tree/skilletlib/Packs/skilletlib)
    Experimental in development Demisto XSOAR integration
  
    
    
## Other utilities in Skilletlib

Skilletlib also includes a collection of tools and methods called 
'[Panoply](https://www.merriam-webster.com/dictionary/panoply)' which eases working with emphemeral PAN-OS and 
Panorama devices, such as in a CI/CD Pipeline or development environment. 

## Support 

Community Supported

The software and templates in the repo are released under an as-is, best effort,
support policy. This software should be seen as community supported and Palo
Alto Networks will contribute our expertise as and when possible. We do not
provide technical support or help in using or troubleshooting the components of
the project through our normal support options such as Palo Alto Networks
support teams, or ASC (Authorized Support Centers) partners and backline support
options. The underlying product used (the VM-Series firewall) by the scripts or
templates are still supported, but the support is only for the product
functionality and not for help in deploying or using the template or script
itself. Unless explicitly tagged, all projects or work posted in our GitHub
repository (at https://github.com/PaloAltoNetworks) or sites other than our
official Downloads page on https://support.paloaltonetworks.com are provided
under the best effort policy.



%package -n python3-skilletlib
Summary:	Tools for working with PAN-OS Skillets in Python 3
Provides:	python-skilletlib
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-skilletlib
# Skilletlib
Base Classes and Utilities for working with Skillets in Python 3.7+. Skilletlib encapsulates all the logic necessary to 
execute a skillet in your app or tooling. 

See [here](https://live.paloaltonetworks.com/t5/Skillet-District/ct-p/Skillets) for information about Skillets and
what skillets may be available. 


## About Skillets

Skillets are designed to be sharable units of configuration or validation data. They are perfectly suited for 
'Compliance as Code' or 'Infrastructure as Code' type environments. All the 'knowledge' of doing a thing is encapsulated
in the skillet. Skillets strive to be tooling agnostic. A subject matter expert should not have to define best 
practices in multiple domain specific languages. Ideally, this should be expressed once, and executed in a variety of
tools. Skilletlib makes it easy to allow Skillets to be executed in your tooling of choice. 

Skillets are meant to be stored and shared via source control repositories along with the rest of your infrastructure.
This allows complex NGFW configurations and use case specific compliance checks to be executed as part of your 
deployment pipeline.  

## Resources

* [Information on building Skillets and working with the PAN-OS XML API](https://SkilletBuilder.readthedocs.io)

* [Example Skillets](https://github.com/PaloAltoNetworks/skilletlib/tree/master/example_skillets)

* [PAN-OS XML Quickstart](https://strata.pan.dev/docs/apis/xmlapi_qs)

* [PAN-OS Exploring the API](https://docs.paloaltonetworks.com/pan-os/9-0/pan-os-panorama-api/get-started-with-the-pan-os-xml-api/explore-the-api.html)

## Installation

Skilletlib is distributed as a python shared library on [pypi.org](https://pypi.org/project/skilletlib/).

```bash

pip install skilletlib

```


## Example Loading a Skillet

```python

from skilletlib import SkilletLoader

# init SkilletLoader Class
sl = SkilletLoader()

# Load the skillet found in the current directory
skillet = sl.load_skillet_from_path('.')

# Every skillet requires a context, which is a dict containing
# any user-input or other variables to allow customization.
context = dict()

# In this example, our skillet needs a configuration.xml file to be loaded into a variable
# called 'config'
with open('config.xml', 'r') as config:
    context['config'] = config.read()

# execute the skillet and return the results
out = skillet.execute(context)

# Do something interesting with the results, like print it out :-)
print(out)
print('all done')

```


## Loading Skillets from a Git repository

```python

from skilletlib import SkilletLoader
repo_url = 'https://github.com/nembery/Skillets'
repo_branch = 'develop'
directory = '/var/tmp/skillets'
repo_name = 'example skillets'

sl = SkilletLoader()
skillets = sl.load_from_git(repo_url, repo_name, repo_branch, local_dir=directory)

for s in skillets:
    print(s.name)

```

## using Skilletlib to find recent changes in Set CLI Format

```python

import os

# The Panos class is a wrapper around the XML API that provides some convience methods
from skilletlib import Panos

auth = {
    'hostname': os.environ.get('ip_address', ''),
    'api_username': os.environ.get('username', ''),
    'api_password': os.environ.get('password', ''),
    'debug': os.environ.get('debug', True),
}
device = Panos(**auth)

# you can pass negative integers to the 'get_configuration' method to retrive the most to least recent
# running configurations. This is very useful to finding the Set CLI or XML equivelent of GUI configuration 
# changes
previous_config = device.get_configuration(config_source='-1')
latest_config = device.get_configuration(config_source='running')

# The 'generate_set_cli_from_configs' method returns the difference between two config files. In this case,
# we'll use the running config and the most recent running config audit backup. This will give us all the 
# changes made via the most recent commit in Set CLI format
cmds = device.generate_set_cli_from_configs(previous_config, latest_config)

for cmd in cmds:
    print(cmd)



```

## Other projects that use Skilletlib

Here are a couple of examples of other projects that use skilletlib

* [Panhandler](https://github.com/PaloAltoNetworks/panhandler/)
    Panhandler is a tool to manage collections of Skillets and their respective git repositories
* [SLI](https://gitlab.com/panw-gse/as/sli)
    SLI is a CLI interface to Skilletlib. This tool allows rapid testing and prototyping of Skillets
* [SkilletLoader](https://github.com/nembery/skilletLoader/)
    SkilletLoader is a tool to load and test skillets in a CI/CD pipeline via Docker
* [Ansible Skillets](https://github.com/PaloAltoNetworks/panw-gse.skillets)
    Ansible roles and libraries for loading PAN-OS and related skillets via Ansible playbooks
* [Demisto XSOAR Integration](https://github.com/nembery/content/tree/skilletlib/Packs/skilletlib)
    Experimental in development Demisto XSOAR integration
  
    
    
## Other utilities in Skilletlib

Skilletlib also includes a collection of tools and methods called 
'[Panoply](https://www.merriam-webster.com/dictionary/panoply)' which eases working with emphemeral PAN-OS and 
Panorama devices, such as in a CI/CD Pipeline or development environment. 

## Support 

Community Supported

The software and templates in the repo are released under an as-is, best effort,
support policy. This software should be seen as community supported and Palo
Alto Networks will contribute our expertise as and when possible. We do not
provide technical support or help in using or troubleshooting the components of
the project through our normal support options such as Palo Alto Networks
support teams, or ASC (Authorized Support Centers) partners and backline support
options. The underlying product used (the VM-Series firewall) by the scripts or
templates are still supported, but the support is only for the product
functionality and not for help in deploying or using the template or script
itself. Unless explicitly tagged, all projects or work posted in our GitHub
repository (at https://github.com/PaloAltoNetworks) or sites other than our
official Downloads page on https://support.paloaltonetworks.com are provided
under the best effort policy.



%package help
Summary:	Development documents and examples for skilletlib
Provides:	python3-skilletlib-doc
%description help
# Skilletlib
Base Classes and Utilities for working with Skillets in Python 3.7+. Skilletlib encapsulates all the logic necessary to 
execute a skillet in your app or tooling. 

See [here](https://live.paloaltonetworks.com/t5/Skillet-District/ct-p/Skillets) for information about Skillets and
what skillets may be available. 


## About Skillets

Skillets are designed to be sharable units of configuration or validation data. They are perfectly suited for 
'Compliance as Code' or 'Infrastructure as Code' type environments. All the 'knowledge' of doing a thing is encapsulated
in the skillet. Skillets strive to be tooling agnostic. A subject matter expert should not have to define best 
practices in multiple domain specific languages. Ideally, this should be expressed once, and executed in a variety of
tools. Skilletlib makes it easy to allow Skillets to be executed in your tooling of choice. 

Skillets are meant to be stored and shared via source control repositories along with the rest of your infrastructure.
This allows complex NGFW configurations and use case specific compliance checks to be executed as part of your 
deployment pipeline.  

## Resources

* [Information on building Skillets and working with the PAN-OS XML API](https://SkilletBuilder.readthedocs.io)

* [Example Skillets](https://github.com/PaloAltoNetworks/skilletlib/tree/master/example_skillets)

* [PAN-OS XML Quickstart](https://strata.pan.dev/docs/apis/xmlapi_qs)

* [PAN-OS Exploring the API](https://docs.paloaltonetworks.com/pan-os/9-0/pan-os-panorama-api/get-started-with-the-pan-os-xml-api/explore-the-api.html)

## Installation

Skilletlib is distributed as a python shared library on [pypi.org](https://pypi.org/project/skilletlib/).

```bash

pip install skilletlib

```


## Example Loading a Skillet

```python

from skilletlib import SkilletLoader

# init SkilletLoader Class
sl = SkilletLoader()

# Load the skillet found in the current directory
skillet = sl.load_skillet_from_path('.')

# Every skillet requires a context, which is a dict containing
# any user-input or other variables to allow customization.
context = dict()

# In this example, our skillet needs a configuration.xml file to be loaded into a variable
# called 'config'
with open('config.xml', 'r') as config:
    context['config'] = config.read()

# execute the skillet and return the results
out = skillet.execute(context)

# Do something interesting with the results, like print it out :-)
print(out)
print('all done')

```


## Loading Skillets from a Git repository

```python

from skilletlib import SkilletLoader
repo_url = 'https://github.com/nembery/Skillets'
repo_branch = 'develop'
directory = '/var/tmp/skillets'
repo_name = 'example skillets'

sl = SkilletLoader()
skillets = sl.load_from_git(repo_url, repo_name, repo_branch, local_dir=directory)

for s in skillets:
    print(s.name)

```

## using Skilletlib to find recent changes in Set CLI Format

```python

import os

# The Panos class is a wrapper around the XML API that provides some convience methods
from skilletlib import Panos

auth = {
    'hostname': os.environ.get('ip_address', ''),
    'api_username': os.environ.get('username', ''),
    'api_password': os.environ.get('password', ''),
    'debug': os.environ.get('debug', True),
}
device = Panos(**auth)

# you can pass negative integers to the 'get_configuration' method to retrive the most to least recent
# running configurations. This is very useful to finding the Set CLI or XML equivelent of GUI configuration 
# changes
previous_config = device.get_configuration(config_source='-1')
latest_config = device.get_configuration(config_source='running')

# The 'generate_set_cli_from_configs' method returns the difference between two config files. In this case,
# we'll use the running config and the most recent running config audit backup. This will give us all the 
# changes made via the most recent commit in Set CLI format
cmds = device.generate_set_cli_from_configs(previous_config, latest_config)

for cmd in cmds:
    print(cmd)



```

## Other projects that use Skilletlib

Here are a couple of examples of other projects that use skilletlib

* [Panhandler](https://github.com/PaloAltoNetworks/panhandler/)
    Panhandler is a tool to manage collections of Skillets and their respective git repositories
* [SLI](https://gitlab.com/panw-gse/as/sli)
    SLI is a CLI interface to Skilletlib. This tool allows rapid testing and prototyping of Skillets
* [SkilletLoader](https://github.com/nembery/skilletLoader/)
    SkilletLoader is a tool to load and test skillets in a CI/CD pipeline via Docker
* [Ansible Skillets](https://github.com/PaloAltoNetworks/panw-gse.skillets)
    Ansible roles and libraries for loading PAN-OS and related skillets via Ansible playbooks
* [Demisto XSOAR Integration](https://github.com/nembery/content/tree/skilletlib/Packs/skilletlib)
    Experimental in development Demisto XSOAR integration
  
    
    
## Other utilities in Skilletlib

Skilletlib also includes a collection of tools and methods called 
'[Panoply](https://www.merriam-webster.com/dictionary/panoply)' which eases working with emphemeral PAN-OS and 
Panorama devices, such as in a CI/CD Pipeline or development environment. 

## Support 

Community Supported

The software and templates in the repo are released under an as-is, best effort,
support policy. This software should be seen as community supported and Palo
Alto Networks will contribute our expertise as and when possible. We do not
provide technical support or help in using or troubleshooting the components of
the project through our normal support options such as Palo Alto Networks
support teams, or ASC (Authorized Support Centers) partners and backline support
options. The underlying product used (the VM-Series firewall) by the scripts or
templates are still supported, but the support is only for the product
functionality and not for help in deploying or using the template or script
itself. Unless explicitly tagged, all projects or work posted in our GitHub
repository (at https://github.com/PaloAltoNetworks) or sites other than our
official Downloads page on https://support.paloaltonetworks.com are provided
under the best effort policy.



%prep
%autosetup -n skilletlib-1.2.5

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-skilletlib -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Thu Jun 08 2023 Python_Bot <Python_Bot@openeuler.org> - 1.2.5-1
- Package Spec generated