pan-scm-cli 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pan_scm_cli-0.3.0/PKG-INFO +766 -0
- pan_scm_cli-0.3.0/README.md +748 -0
- {pan_scm_cli-0.2.0 → pan_scm_cli-0.3.0}/pyproject.toml +31 -21
- {pan_scm_cli-0.2.0 → pan_scm_cli-0.3.0}/src/scm_cli/__init__.py +2 -2
- pan_scm_cli-0.3.0/src/scm_cli/client.py +80 -0
- pan_scm_cli-0.3.0/src/scm_cli/commands/README.md +376 -0
- pan_scm_cli-0.3.0/src/scm_cli/commands/command-styling.md +675 -0
- pan_scm_cli-0.3.0/src/scm_cli/commands/deployment.py +320 -0
- pan_scm_cli-0.3.0/src/scm_cli/commands/network.py +495 -0
- pan_scm_cli-0.3.0/src/scm_cli/commands/objects.py +6131 -0
- pan_scm_cli-0.3.0/src/scm_cli/commands/security.py +530 -0
- pan_scm_cli-0.3.0/src/scm_cli/main.py +151 -0
- pan_scm_cli-0.3.0/src/scm_cli/utils/__init__.py +29 -0
- pan_scm_cli-0.3.0/src/scm_cli/utils/config.py +144 -0
- pan_scm_cli-0.3.0/src/scm_cli/utils/sdk_client.py +4370 -0
- pan_scm_cli-0.3.0/src/scm_cli/utils/validators.py +1328 -0
- pan_scm_cli-0.2.0/PKG-INFO +0 -272
- pan_scm_cli-0.2.0/README.md +0 -252
- pan_scm_cli-0.2.0/src/scm_cli/commands/deployment.py +0 -155
- pan_scm_cli-0.2.0/src/scm_cli/commands/network.py +0 -144
- pan_scm_cli-0.2.0/src/scm_cli/commands/objects.py +0 -274
- pan_scm_cli-0.2.0/src/scm_cli/commands/security.py +0 -156
- pan_scm_cli-0.2.0/src/scm_cli/main.py +0 -67
- pan_scm_cli-0.2.0/src/scm_cli/utils/__init__.py +0 -1
- pan_scm_cli-0.2.0/src/scm_cli/utils/config.py +0 -81
- pan_scm_cli-0.2.0/src/scm_cli/utils/sdk_client.py +0 -656
- pan_scm_cli-0.2.0/src/scm_cli/utils/validators.py +0 -196
- {pan_scm_cli-0.2.0 → pan_scm_cli-0.3.0}/LICENSE +0 -0
- {pan_scm_cli-0.2.0 → pan_scm_cli-0.3.0}/src/scm_cli/commands/__init__.py +0 -0
- {pan_scm_cli-0.2.0 → pan_scm_cli-0.3.0}/src/scm_cli/tests/__init__.py +0 -0
|
@@ -0,0 +1,766 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: pan-scm-cli
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: CICD and Network Engineer-friendly CLI tool for Palo Alto Networks Strata Cloud Manager
|
|
5
|
+
Author: Calvin Remsburg
|
|
6
|
+
Author-email: dev@cdot.io
|
|
7
|
+
Requires-Python: >=3.12,<3.14
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
11
|
+
Requires-Dist: dynaconf (>=3.2.11,<4.0.0)
|
|
12
|
+
Requires-Dist: pan-scm-sdk (==0.3.39)
|
|
13
|
+
Requires-Dist: pydantic (>=2.11.5,<3.0.0)
|
|
14
|
+
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
|
15
|
+
Requires-Dist: typer (>=0.15.4,<0.16.0)
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# Strata Cloud Manager CLI
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
[](https://github.com/cdot65/pan-scm/actions/workflows/code-quality.yml)
|
|
22
|
+
[](https://badge.fury.io/py/pan-scm)
|
|
23
|
+
[](https://pypi.org/project/pan-scm/)
|
|
24
|
+
[](https://github.com/cdot65/pan-scm/blob/main/LICENSE)
|
|
25
|
+
|
|
26
|
+
A powerful command-line interface for managing Palo Alto Networks Strata Cloud Manager configurations. Built on the [pan-scm-sdk](https://github.com/cdot65/pan-scm-sdk), this tool provides network engineers with a consistent, user-friendly CLI experience for automating and managing SCM resources.
|
|
27
|
+
|
|
28
|
+
> **NOTE**: Please refer to the [GitHub Pages documentation site](https://cdot65.github.io/pan-scm/) for all
|
|
29
|
+
> examples
|
|
30
|
+
|
|
31
|
+
## Table of Contents
|
|
32
|
+
|
|
33
|
+
- [Strata Cloud Manager CLI](#strata-cloud-manager-cli)
|
|
34
|
+
- [Table of Contents](#table-of-contents)
|
|
35
|
+
- [Features](#features)
|
|
36
|
+
- [Installation](#installation)
|
|
37
|
+
- [Usage](#usage)
|
|
38
|
+
- [Authentication](#authentication)
|
|
39
|
+
- [Method 1: Environment Variables (Highest Priority)](#method-1-environment-variables-highest-priority)
|
|
40
|
+
- [Method 2: Config File in Home Directory](#method-2-config-file-in-home-directory)
|
|
41
|
+
- [Method 3: Local Project Configuration (Development)](#method-3-local-project-configuration-development)
|
|
42
|
+
- [Verifying Authentication](#verifying-authentication)
|
|
43
|
+
- [Command Structure](#command-structure)
|
|
44
|
+
- [Example Commands](#example-commands)
|
|
45
|
+
- [Managing Address Objects](#managing-address-objects)
|
|
46
|
+
- [Managing Address Groups](#managing-address-groups)
|
|
47
|
+
- [Managing Security Zones](#managing-security-zones)
|
|
48
|
+
- [Managing Security Rules](#managing-security-rules)
|
|
49
|
+
- [Managing Bandwidth Allocations](#managing-bandwidth-allocations)
|
|
50
|
+
- [Bulk Operations](#bulk-operations)
|
|
51
|
+
- [Development](#development)
|
|
52
|
+
- [Setup](#setup)
|
|
53
|
+
- [Code Quality](#code-quality)
|
|
54
|
+
- [Pre-commit Hooks](#pre-commit-hooks)
|
|
55
|
+
- [Contributing](#contributing)
|
|
56
|
+
- [License](#license)
|
|
57
|
+
- [Support](#support)
|
|
58
|
+
- [Project Status](#project-status)
|
|
59
|
+
|
|
60
|
+
## Features
|
|
61
|
+
|
|
62
|
+
- **Consistent Command Structure**: Intuitive command pattern that follows standard CLI conventions.
|
|
63
|
+
- **Comprehensive Object Management**: Create, read, update, and delete configuration objects including:
|
|
64
|
+
- Address objects (IP/netmask, FQDN, IP range, wildcard)
|
|
65
|
+
- Address groups (static and dynamic)
|
|
66
|
+
- Applications (custom application definitions with security attributes)
|
|
67
|
+
- Application groups (logical grouping of applications)
|
|
68
|
+
- Application filters (dynamic application selection based on criteria)
|
|
69
|
+
- Dynamic user groups (tag-based user grouping)
|
|
70
|
+
- External dynamic lists (EDLs for threat intelligence integration)
|
|
71
|
+
- HIP objects (Host Information Profiles for endpoint compliance)
|
|
72
|
+
- HIP profiles (HIP object combinations for policy enforcement)
|
|
73
|
+
- HTTP server profiles (Log forwarding and integration configurations)
|
|
74
|
+
- Services (Network service definitions with protocol and port configurations)
|
|
75
|
+
- Service groups (Logical grouping of services for policy management)
|
|
76
|
+
- Syslog server profiles (External syslog server configurations for log forwarding)
|
|
77
|
+
- Tags (Organizational labels with color categorization)
|
|
78
|
+
- Security zones (layer3, layer2, virtual-wire, tap modes)
|
|
79
|
+
- Security rules with full policy configuration
|
|
80
|
+
- Bandwidth allocation profiles
|
|
81
|
+
- **Bulk Operations**: Load and manage objects in bulk using YAML files for efficient configuration management:
|
|
82
|
+
- Container override support for all load commands (folder/snippet/device)
|
|
83
|
+
- Migrate objects between locations during import
|
|
84
|
+
- Dry run mode to preview changes before applying
|
|
85
|
+
- **Backup and Restore**: Export existing configurations to YAML files and restore them later:
|
|
86
|
+
- Support for all container types (folder, snippet, device)
|
|
87
|
+
- Automatic filename generation with timestamps
|
|
88
|
+
- Exact match filtering to backup only direct objects
|
|
89
|
+
- **Mock Mode**: Test commands without making actual API calls, perfect for validation and development.
|
|
90
|
+
- **Flexible Authentication**: Multiple authentication methods with automatic fallback:
|
|
91
|
+
- Environment variables (production-ready)
|
|
92
|
+
- Home directory config (~/.scm/config.yaml)
|
|
93
|
+
- Local development config (.secrets.yaml)
|
|
94
|
+
- **Input Validation**: Built-in Pydantic validation ensures data integrity before API calls.
|
|
95
|
+
- **Comprehensive Error Handling**: Clear, actionable error messages with detailed logging options.
|
|
96
|
+
- **Extensive Documentation**: Full MkDocs-based documentation with interactive CLI examples.
|
|
97
|
+
|
|
98
|
+
## Installation
|
|
99
|
+
|
|
100
|
+
**Requirements**:
|
|
101
|
+
|
|
102
|
+
- Python 3.10 or higher
|
|
103
|
+
|
|
104
|
+
Install the package via pip:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pip install pan-scm
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Usage
|
|
111
|
+
|
|
112
|
+
### Authentication
|
|
113
|
+
|
|
114
|
+
The SCM CLI uses dynaconf to manage authentication credentials. Configure authentication using one of the following methods (in order of precedence):
|
|
115
|
+
|
|
116
|
+
#### Method 1: Environment Variables (Highest Priority)
|
|
117
|
+
|
|
118
|
+
For production use or scripting, set environment variables:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Linux/macOS
|
|
122
|
+
export SCM_CLIENT_ID="your_client_id"
|
|
123
|
+
export SCM_CLIENT_SECRET="your_client_secret"
|
|
124
|
+
export SCM_TSG_ID="your_tenant_service_group_id"
|
|
125
|
+
|
|
126
|
+
# Windows PowerShell
|
|
127
|
+
$env:SCM_CLIENT_ID = "your_client_id"
|
|
128
|
+
$env:SCM_CLIENT_SECRET = "your_client_secret"
|
|
129
|
+
$env:SCM_TSG_ID = "your_tenant_service_group_id"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
These environment variables will be automatically detected and used with highest priority.
|
|
133
|
+
|
|
134
|
+
#### Method 2: Config File in Home Directory
|
|
135
|
+
|
|
136
|
+
For a more permanent configuration, create a config file in your home directory:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Create the config directory if it doesn't exist
|
|
140
|
+
mkdir -p ~/.scm
|
|
141
|
+
|
|
142
|
+
# Create and edit the config file
|
|
143
|
+
cat > ~/.scm/config.yaml << EOL
|
|
144
|
+
client_id: "your_client_id"
|
|
145
|
+
client_secret: "your_client_secret"
|
|
146
|
+
tsg_id: "your_tenant_service_group_id"
|
|
147
|
+
EOL
|
|
148
|
+
|
|
149
|
+
# Secure the file with restrictive permissions
|
|
150
|
+
chmod 600 ~/.scm/config.yaml
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
This method is used when environment variables are not set.
|
|
154
|
+
|
|
155
|
+
#### Method 3: Local Project Configuration (Development)
|
|
156
|
+
|
|
157
|
+
> **⚠️ SECURITY WARNING**
|
|
158
|
+
>
|
|
159
|
+
> Storage of credentials in project files poses security risks. Consider these best practices:
|
|
160
|
+
>
|
|
161
|
+
> - **NEVER commit credential files to version control**
|
|
162
|
+
> - **Use environment variables for production environments**
|
|
163
|
+
> - **Protect local credential files with appropriate file permissions**
|
|
164
|
+
> - **Regularly rotate your credentials**
|
|
165
|
+
|
|
166
|
+
For local development, follow these steps:
|
|
167
|
+
|
|
168
|
+
1. Copy the example configuration file to create a local secrets file:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
cp example-config.yaml .secrets.yaml
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
2. Edit the `.secrets.yaml` file with your actual credentials:
|
|
175
|
+
|
|
176
|
+
```yaml
|
|
177
|
+
default:
|
|
178
|
+
scm_client_id: "your_client_id"
|
|
179
|
+
scm_client_secret: "your_client_secret"
|
|
180
|
+
scm_tsg_id: "your_tenant_service_group_id"
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
3. Secure the file with restrictive permissions:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# On Linux/macOS
|
|
187
|
+
chmod 600 .secrets.yaml
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
> **Note**: The `.secrets.yaml` file is excluded from version control in `.gitignore` to prevent accidental exposure of credentials.
|
|
191
|
+
|
|
192
|
+
#### Verifying Authentication
|
|
193
|
+
|
|
194
|
+
To verify your authentication configuration:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Test with actual credentials
|
|
198
|
+
scm test-auth
|
|
199
|
+
|
|
200
|
+
# Test in mock mode (doesn't require real credentials)
|
|
201
|
+
scm test-auth --mock
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Command Structure
|
|
205
|
+
|
|
206
|
+
The CLI follows a consistent command pattern:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
scm <action> <object-type> <object> [options]
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Where:
|
|
213
|
+
|
|
214
|
+
- `<action>`: Operation to perform
|
|
215
|
+
- `set`: Create or update an object
|
|
216
|
+
- `delete`: Remove an object
|
|
217
|
+
- `load`: Bulk import from YAML file
|
|
218
|
+
- `show`: Display existing objects
|
|
219
|
+
- `backup`: Export configurations to YAML file
|
|
220
|
+
- `test-auth`: Verify authentication configuration
|
|
221
|
+
- `<object-type>`: Resource category
|
|
222
|
+
- `objects`: Address objects and address groups
|
|
223
|
+
- `network`: Security zones
|
|
224
|
+
- `security`: Security rules
|
|
225
|
+
- `deployment`: Bandwidth allocations
|
|
226
|
+
- `<object>`: Specific resource type (e.g., `address`, `address-group`, `security-zone`, `rule`, `bandwidth`)
|
|
227
|
+
|
|
228
|
+
Global options available for all commands:
|
|
229
|
+
|
|
230
|
+
- `--mock`: Run in mock mode without API calls
|
|
231
|
+
- `--folder`: Specify the folder location (default: "Shared")
|
|
232
|
+
- `--list`: List all objects of the specified type
|
|
233
|
+
|
|
234
|
+
### Example Commands
|
|
235
|
+
|
|
236
|
+
#### Managing Address Objects
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
# Create a new address object
|
|
240
|
+
scm set objects address --folder Shared --name web-server --ip-netmask 192.168.1.100/32 --description "Web server in DMZ"
|
|
241
|
+
|
|
242
|
+
# List all address objects in a folder
|
|
243
|
+
scm show objects address --folder Shared --list
|
|
244
|
+
|
|
245
|
+
# Show a specific address object
|
|
246
|
+
scm show objects address --folder Shared --name web-server
|
|
247
|
+
|
|
248
|
+
# Delete an address object
|
|
249
|
+
scm delete objects address --folder Shared --name web-server
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### Managing Address Groups
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# Create a static address group
|
|
256
|
+
scm set objects address-group --folder Shared --name web-servers --type static --members "web-server-1,web-server-2"
|
|
257
|
+
|
|
258
|
+
# Create a dynamic address group
|
|
259
|
+
scm set objects address-group --folder Shared --name dynamic-endpoints --type dynamic --filter "'endpoint' and 'corporate'"
|
|
260
|
+
|
|
261
|
+
# List all address groups in a folder
|
|
262
|
+
scm show objects address-group --folder Shared --list
|
|
263
|
+
|
|
264
|
+
# Show a specific address group
|
|
265
|
+
scm show objects address-group --folder Shared --name web-servers
|
|
266
|
+
|
|
267
|
+
# Delete an address group
|
|
268
|
+
scm delete objects address-group --folder Shared --name web-servers
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
#### Managing Security Zones
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# Create a security zone
|
|
275
|
+
scm set network security-zone --folder Shared --name DMZ --mode layer3 --enable-user-id true
|
|
276
|
+
|
|
277
|
+
# List all security zones
|
|
278
|
+
scm set network security-zone --list --folder Shared
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
#### Managing Security Rules
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
# Create a security rule
|
|
285
|
+
scm set security rule --folder Shared --name "Allow-Web" \
|
|
286
|
+
--source-zones "Trust" --destination-zones "DMZ" \
|
|
287
|
+
--source-addresses "any" --destination-addresses "web-servers" \
|
|
288
|
+
--applications "web-browsing,ssl" --services "application-default" \
|
|
289
|
+
--action allow --log-end true
|
|
290
|
+
|
|
291
|
+
# List all security rules
|
|
292
|
+
scm set security rule --list --folder Shared
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
#### Managing Bandwidth Allocations
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
# Create a bandwidth allocation profile
|
|
299
|
+
scm set deployment bandwidth --folder Shared --name "Branch-100Mbps" \
|
|
300
|
+
--egress-guaranteed 50 --egress-burstable 100
|
|
301
|
+
|
|
302
|
+
# List all bandwidth profiles
|
|
303
|
+
scm set deployment bandwidth --list --folder Shared
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
#### Managing Applications
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
# Create a custom application
|
|
310
|
+
scm set objects application --folder Shared --name custom-app \
|
|
311
|
+
--category business-systems --subcategory database \
|
|
312
|
+
--technology client-server --risk 3 \
|
|
313
|
+
--ports "tcp/8080,tcp/8443" --description "Custom business application"
|
|
314
|
+
|
|
315
|
+
# List all applications
|
|
316
|
+
scm show objects application --folder Shared --list
|
|
317
|
+
|
|
318
|
+
# Show specific application details
|
|
319
|
+
scm show objects application --folder Shared --name custom-app
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
#### Managing Application Groups
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
# Create an application group
|
|
326
|
+
scm set objects application-group --folder Shared --name business-apps \
|
|
327
|
+
--members "salesforce,ms-365,custom-app"
|
|
328
|
+
|
|
329
|
+
# List all application groups
|
|
330
|
+
scm show objects application-group --folder Shared --list
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
#### Managing Application Filters
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
# Create an application filter for high-risk apps
|
|
337
|
+
scm set objects application-filter --folder Shared --name high-risk-filter \
|
|
338
|
+
--category "file-sharing,peer-to-peer" --risk 4 --risk 5 \
|
|
339
|
+
--has-known-vulnerabilities --transfers-files
|
|
340
|
+
|
|
341
|
+
# List all application filters
|
|
342
|
+
scm show objects application-filter --folder Shared --list
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
#### Managing Dynamic User Groups
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
# Create a dynamic user group based on tags
|
|
349
|
+
scm set objects dynamic-user-group --folder Shared --name it-admins \
|
|
350
|
+
--filter "'IT' and 'Admin'" --description "IT administrators group"
|
|
351
|
+
|
|
352
|
+
# List all dynamic user groups
|
|
353
|
+
scm show objects dynamic-user-group --folder Shared --list
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
#### Managing External Dynamic Lists
|
|
357
|
+
|
|
358
|
+
```bash
|
|
359
|
+
# Create a predefined IP blocklist
|
|
360
|
+
scm set objects external-dynamic-list --folder Shared \
|
|
361
|
+
--name paloalto-bulletproof --type predefined_ip \
|
|
362
|
+
--url "panw-bulletproof-ip-list"
|
|
363
|
+
|
|
364
|
+
# Create a custom IP blocklist with hourly updates
|
|
365
|
+
scm set objects external-dynamic-list --folder Shared \
|
|
366
|
+
--name custom-threats --type ip \
|
|
367
|
+
--url "https://example.com/threats.txt" --recurring hourly
|
|
368
|
+
|
|
369
|
+
# List all external dynamic lists
|
|
370
|
+
scm show objects external-dynamic-list --folder Shared --list
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
#### Managing HIP Objects
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
# Create a HIP object for Windows patch management
|
|
377
|
+
scm set objects hip-object --folder Shared --name windows-security-compliance \
|
|
378
|
+
--description "Windows security compliance check" \
|
|
379
|
+
--patch-management-vendor-name "Microsoft Corporation" \
|
|
380
|
+
--patch-management-product-name "Windows" \
|
|
381
|
+
--patch-management-criteria-is-installed yes \
|
|
382
|
+
--patch-management-missing-patches check-not-exist
|
|
383
|
+
|
|
384
|
+
# Create a HIP object for disk encryption
|
|
385
|
+
scm set objects hip-object --folder Shared --name disk-encryption-check \
|
|
386
|
+
--disk-encryption-vendor-name "BitLocker" \
|
|
387
|
+
--disk-encryption-product-name "BitLocker Drive Encryption" \
|
|
388
|
+
--disk-encryption-criteria-is-installed is \
|
|
389
|
+
--disk-encryption-state is
|
|
390
|
+
|
|
391
|
+
# List all HIP objects
|
|
392
|
+
scm show objects hip-object --folder Shared --list
|
|
393
|
+
|
|
394
|
+
# Show specific HIP object details
|
|
395
|
+
scm show objects hip-object --folder Shared --name windows-security-compliance
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
#### Managing HIP Profiles
|
|
399
|
+
|
|
400
|
+
```bash
|
|
401
|
+
# Create a HIP profile with multiple match criteria
|
|
402
|
+
scm set objects hip-profile --folder Shared --name secure-endpoints \
|
|
403
|
+
--match '{"windows-security-compliance": {"is": true}, "disk-encryption-check": {"is": true}}' \
|
|
404
|
+
--description "Profile for fully compliant Windows endpoints"
|
|
405
|
+
|
|
406
|
+
# List all HIP profiles
|
|
407
|
+
scm show objects hip-profile --folder Shared --list
|
|
408
|
+
|
|
409
|
+
# Show specific HIP profile details
|
|
410
|
+
scm show objects hip-profile --folder Shared --name secure-endpoints
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
#### Managing HTTP Server Profiles
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
# Create an HTTP server profile for syslog forwarding
|
|
417
|
+
scm set objects http-server-profile --folder Shared --name syslog-collector \
|
|
418
|
+
--servers '[{"name": "primary-syslog", "address": "syslog.example.com", "protocol": "HTTPS", "port": 443, "http_method": "POST"}]' \
|
|
419
|
+
--description "Primary syslog collector"
|
|
420
|
+
|
|
421
|
+
# Create an HTTP server profile with authentication
|
|
422
|
+
scm set objects http-server-profile --folder Shared --name splunk-hec \
|
|
423
|
+
--servers '[{"name": "splunk-server", "address": "10.0.1.100", "protocol": "HTTPS", "port": 8088, "http_method": "POST", "username": "hec_user", "password": "secure_token"}]'
|
|
424
|
+
|
|
425
|
+
# List all HTTP server profiles
|
|
426
|
+
scm show objects http-server-profile --folder Shared --list
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
#### Managing Services
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
# Create a basic TCP service
|
|
433
|
+
scm set objects service --folder Shared --name custom-web \
|
|
434
|
+
--protocol tcp --port "8080,8443" --description "Custom web service"
|
|
435
|
+
|
|
436
|
+
# Create a UDP service
|
|
437
|
+
scm set objects service --folder Shared --name custom-dns \
|
|
438
|
+
--protocol udp --port 5353 --description "Custom DNS service"
|
|
439
|
+
|
|
440
|
+
# Create a TCP service with timeout overrides
|
|
441
|
+
scm set objects service --folder Shared --name database-service \
|
|
442
|
+
--protocol tcp --port "3306-3310" --timeout 7200 --halfclose-timeout 120 \
|
|
443
|
+
--description "Database cluster ports with extended timeout"
|
|
444
|
+
|
|
445
|
+
# List all services
|
|
446
|
+
scm show objects service --folder Shared --list
|
|
447
|
+
|
|
448
|
+
# Show specific service details
|
|
449
|
+
scm show objects service --folder Shared --name custom-web
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
#### Managing Service Groups
|
|
453
|
+
|
|
454
|
+
```bash
|
|
455
|
+
# Create a service group
|
|
456
|
+
scm set objects service-group --folder Shared --name web-services \
|
|
457
|
+
--members "http,https,web-browsing,ssl"
|
|
458
|
+
|
|
459
|
+
# Create a service group with tags
|
|
460
|
+
scm set objects service-group --folder Shared --name database-services \
|
|
461
|
+
--members "mysql,mssql,oracle,postgresql" --tag "database,backend"
|
|
462
|
+
|
|
463
|
+
# List all service groups
|
|
464
|
+
scm show objects service-group --folder Shared --list
|
|
465
|
+
|
|
466
|
+
# Show specific service group details
|
|
467
|
+
scm show objects service-group --folder Shared --name web-services
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
#### Managing Syslog Server Profiles
|
|
471
|
+
|
|
472
|
+
```bash
|
|
473
|
+
# Create a syslog server profile with TCP
|
|
474
|
+
scm set objects syslog-server-profile --folder Shared --name central-syslog \
|
|
475
|
+
--servers '[{"name": "syslog-primary", "server": "10.0.1.50", "port": 514, "transport": "TCP", "format": "BSD", "facility": "LOG_USER"}]' \
|
|
476
|
+
--description "Central syslog collection"
|
|
477
|
+
|
|
478
|
+
# Create a syslog profile with UDP and custom format
|
|
479
|
+
scm set objects syslog-server-profile --folder Shared --name compliance-syslog \
|
|
480
|
+
--servers '[{"name": "compliance-server", "server": "syslog.compliance.local", "port": 6514, "transport": "UDP", "format": "IETF", "facility": "LOG_LOCAL7"}]'
|
|
481
|
+
|
|
482
|
+
# List all syslog server profiles
|
|
483
|
+
scm show objects syslog-server-profile --folder Shared --list
|
|
484
|
+
|
|
485
|
+
# Show specific syslog profile details
|
|
486
|
+
scm show objects syslog-server-profile --folder Shared --name central-syslog
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
#### Managing Tags
|
|
490
|
+
|
|
491
|
+
```bash
|
|
492
|
+
# Create a tag with color
|
|
493
|
+
scm set objects tag --folder Shared --name production \
|
|
494
|
+
--color "Red" --comments "Production environment resources"
|
|
495
|
+
|
|
496
|
+
# Create multiple tags for categorization
|
|
497
|
+
scm set objects tag --folder Shared --name database --color "Blue"
|
|
498
|
+
scm set objects tag --folder Shared --name frontend --color "Green"
|
|
499
|
+
scm set objects tag --folder Shared --name critical --color "Orange"
|
|
500
|
+
|
|
501
|
+
# List all tags
|
|
502
|
+
scm show objects tag --folder Shared --list
|
|
503
|
+
|
|
504
|
+
# Show specific tag details
|
|
505
|
+
scm show objects tag --folder Shared --name production
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
#### Bulk Operations
|
|
509
|
+
|
|
510
|
+
Create a YAML file with multiple objects:
|
|
511
|
+
|
|
512
|
+
```yaml
|
|
513
|
+
# addresses.yaml
|
|
514
|
+
addresses:
|
|
515
|
+
- name: web-server-1
|
|
516
|
+
description: "Web server 1"
|
|
517
|
+
ip_netmask: 192.168.1.100/32
|
|
518
|
+
folder: Development
|
|
519
|
+
tags:
|
|
520
|
+
- web
|
|
521
|
+
- production
|
|
522
|
+
|
|
523
|
+
- name: web-server-2
|
|
524
|
+
description: "Web server 2"
|
|
525
|
+
ip_netmask: 192.168.1.101/32
|
|
526
|
+
folder: Development
|
|
527
|
+
tags:
|
|
528
|
+
- web
|
|
529
|
+
- production
|
|
530
|
+
|
|
531
|
+
- name: db-server
|
|
532
|
+
description: "Database server"
|
|
533
|
+
fqdn: db.example.com
|
|
534
|
+
folder: Production
|
|
535
|
+
tags:
|
|
536
|
+
- database
|
|
537
|
+
- production
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
Load the objects:
|
|
541
|
+
|
|
542
|
+
```bash
|
|
543
|
+
# Load objects with their original locations from the file
|
|
544
|
+
scm load objects address --file addresses.yml
|
|
545
|
+
|
|
546
|
+
# Override all objects to load into a specific folder
|
|
547
|
+
scm load objects address --file addresses.yml --folder Shared
|
|
548
|
+
|
|
549
|
+
# Override to a snippet location
|
|
550
|
+
scm load objects address --file addresses.yml --snippet DNS-Best-Practice
|
|
551
|
+
|
|
552
|
+
# Override to a device location
|
|
553
|
+
scm load objects address --file addresses.yml --device fw-austin-01
|
|
554
|
+
|
|
555
|
+
# Verify in mock mode first
|
|
556
|
+
scm load objects address --file addresses.yml --folder Shared --mock
|
|
557
|
+
|
|
558
|
+
# Dry run to preview changes
|
|
559
|
+
scm load objects address --file addresses.yml --dry-run
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
All load commands support container overrides, allowing you to:
|
|
563
|
+
|
|
564
|
+
- Migrate objects between folders/snippets/devices
|
|
565
|
+
- Test configurations in different locations
|
|
566
|
+
- Standardize object locations during bulk imports
|
|
567
|
+
|
|
568
|
+
See the `examples/` directory for more bulk operation templates, including:
|
|
569
|
+
|
|
570
|
+
- Complete RFC 1918 private network setup (`rfc1918-addresses.yml` and `rfc1918-address-group.yml`)
|
|
571
|
+
- Multi-folder configuration examples across ngfw-shared, Texas, and Austin folders
|
|
572
|
+
- Security zone configurations for different network modes
|
|
573
|
+
- Pre and post rulebase security rule examples
|
|
574
|
+
- Application definitions with security attributes (`applications.yml`)
|
|
575
|
+
- Application group configurations (`application-groups.yml`)
|
|
576
|
+
- Application filter criteria (`application-filters.yml`)
|
|
577
|
+
- Dynamic user group filter expressions (`dynamic-user-groups.yml`)
|
|
578
|
+
- External dynamic list configurations for all EDL types (`external-dynamic-lists.yml`)
|
|
579
|
+
- HIP object configurations for endpoint compliance (`hip-objects.yml`)
|
|
580
|
+
- HIP profile configurations for policy enforcement (`hip-profiles.yml`)
|
|
581
|
+
- HTTP server profile configurations for log forwarding (`http-server-profiles.yml`)
|
|
582
|
+
- Service configurations with protocol and port definitions (`services.yml`)
|
|
583
|
+
- Service group configurations for logical service organization (`service-groups.yml`)
|
|
584
|
+
- Syslog server profile configurations for external logging (`syslog-server-profiles.yml`)
|
|
585
|
+
- Tag configurations for resource categorization (`tags.yml`)
|
|
586
|
+
|
|
587
|
+
#### Backup and Restore Operations
|
|
588
|
+
|
|
589
|
+
Export existing configurations to YAML files. All backup commands support multiple container types (folder, snippet, device) with automatic filename generation:
|
|
590
|
+
|
|
591
|
+
```bash
|
|
592
|
+
# Backup from different container types
|
|
593
|
+
scm backup objects address --folder Austin
|
|
594
|
+
# Creates: address_folder_austin_20240115_143022.yaml
|
|
595
|
+
|
|
596
|
+
scm backup objects tag --snippet DNS-Best-Practice
|
|
597
|
+
# Creates: tag_snippet_dns-best-practice_20240115_143022.yaml
|
|
598
|
+
|
|
599
|
+
scm backup objects service --device austin-01
|
|
600
|
+
# Creates: service_device_austin-01_20240115_143022.yaml
|
|
601
|
+
|
|
602
|
+
# Custom output filename
|
|
603
|
+
scm backup objects address-group --folder Texas --file my-groups.yaml
|
|
604
|
+
# Creates: my-groups.yaml
|
|
605
|
+
|
|
606
|
+
# All object types support folder/snippet/device parameters
|
|
607
|
+
scm backup objects address --folder Austin
|
|
608
|
+
scm backup objects address-group --folder Texas
|
|
609
|
+
scm backup objects application --folder Texas
|
|
610
|
+
scm backup objects application-group --folder Texas
|
|
611
|
+
scm backup objects application-filter --folder Texas
|
|
612
|
+
scm backup objects dynamic-user-group --folder Texas
|
|
613
|
+
scm backup objects external-dynamic-list --folder Texas
|
|
614
|
+
scm backup objects hip-object --folder Texas
|
|
615
|
+
scm backup objects hip-profile --folder Texas
|
|
616
|
+
scm backup objects http-server-profile --folder Texas
|
|
617
|
+
scm backup objects service --folder Texas
|
|
618
|
+
scm backup objects service-group --folder Texas
|
|
619
|
+
scm backup objects syslog-server-profile --folder Texas
|
|
620
|
+
scm backup objects tag --folder Texas
|
|
621
|
+
|
|
622
|
+
# Network and security backups also support all container types
|
|
623
|
+
scm backup network security-zone --folder ngfw-shared
|
|
624
|
+
scm backup network security-zone --snippet DNS-Best-Practice
|
|
625
|
+
scm backup network security-zone --device austin-01
|
|
626
|
+
|
|
627
|
+
scm backup security rule --folder Austin --rulebase pre
|
|
628
|
+
scm backup security rule --snippet DNS-Best-Practice --rulebase post
|
|
629
|
+
|
|
630
|
+
# Bandwidth allocations are global (no container parameter needed)
|
|
631
|
+
scm backup deployment bandwidth-allocation
|
|
632
|
+
# Creates: bandwidth-allocations.yaml
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
Note: Not all container types are supported by the SDK for all object types. When using snippet or device parameters, the CLI will show an appropriate error message if the SDK doesn't support that container type yet.
|
|
636
|
+
|
|
637
|
+
Restore configurations from backup files:
|
|
638
|
+
|
|
639
|
+
```bash
|
|
640
|
+
# Restore addresses (preview first with --dry-run)
|
|
641
|
+
scm load objects address --file address-austin.yaml --dry-run
|
|
642
|
+
scm load objects address --file address-austin.yaml
|
|
643
|
+
|
|
644
|
+
# Restore address groups
|
|
645
|
+
scm load objects address-group --file address-group-texas.yaml
|
|
646
|
+
|
|
647
|
+
# Restore security zones
|
|
648
|
+
scm load network security-zone --file security-zone-ngfw-shared.yaml
|
|
649
|
+
|
|
650
|
+
# Restore security rules
|
|
651
|
+
scm load security rule --file rule-austin-pre.yaml
|
|
652
|
+
|
|
653
|
+
# Restore bandwidth allocations
|
|
654
|
+
scm load deployment bandwidth-allocation --file bandwidth-allocations.yaml
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
The backup feature uses the `exact_match=True` parameter to only export objects that are directly defined in the specified folder, excluding inherited objects from parent folders.
|
|
658
|
+
|
|
659
|
+
## Development
|
|
660
|
+
|
|
661
|
+
### Setup
|
|
662
|
+
|
|
663
|
+
1. Clone the repository:
|
|
664
|
+
|
|
665
|
+
```bash
|
|
666
|
+
git clone https://github.com/cdot65/pan-scm.git
|
|
667
|
+
cd pan-scm
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
2. Install dependencies and pre-commit hooks:
|
|
671
|
+
|
|
672
|
+
```bash
|
|
673
|
+
make setup
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
Alternatively, you can install manually:
|
|
677
|
+
|
|
678
|
+
```bash
|
|
679
|
+
poetry install
|
|
680
|
+
poetry run pre-commit install
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
### Code Quality
|
|
684
|
+
|
|
685
|
+
This project uses [ruff](https://github.com/astral-sh/ruff) for linting and formatting, along with comprehensive quality checks:
|
|
686
|
+
|
|
687
|
+
```bash
|
|
688
|
+
# Run all quality checks (lint, format, type checking, tests)
|
|
689
|
+
make quality
|
|
690
|
+
|
|
691
|
+
# Individual checks
|
|
692
|
+
make lint # Run flake8 and yamllint
|
|
693
|
+
make format # Format code with ruff
|
|
694
|
+
make fix # Auto-fix linting issues with ruff
|
|
695
|
+
|
|
696
|
+
# Testing
|
|
697
|
+
make tests # Run the full test suite
|
|
698
|
+
pytest -v # Run tests with verbose output
|
|
699
|
+
pytest -k "test_name" # Run specific tests by pattern
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
### Pre-commit Hooks
|
|
703
|
+
|
|
704
|
+
We use pre-commit hooks to ensure code quality before committing:
|
|
705
|
+
|
|
706
|
+
```bash
|
|
707
|
+
# Run pre-commit hooks on all files
|
|
708
|
+
make pre-commit-all
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
The following checks run automatically before each commit:
|
|
712
|
+
|
|
713
|
+
- ruff linting and formatting
|
|
714
|
+
- Trailing whitespace removal
|
|
715
|
+
- End-of-file fixer
|
|
716
|
+
- YAML/JSON syntax checking
|
|
717
|
+
- Large file detection
|
|
718
|
+
- Python syntax validation
|
|
719
|
+
- Merge conflict detection
|
|
720
|
+
- Private key detection
|
|
721
|
+
|
|
722
|
+
## Contributing
|
|
723
|
+
|
|
724
|
+
We welcome contributions! To contribute:
|
|
725
|
+
|
|
726
|
+
1. Fork the repository.
|
|
727
|
+
2. Create a new feature branch (`git checkout -b feature/your-feature`).
|
|
728
|
+
3. Make your changes, ensuring all quality checks pass:
|
|
729
|
+
|
|
730
|
+
```bash
|
|
731
|
+
make quality # Run all checks
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
4. Add tests for new functionality in the `tests/` directory.
|
|
735
|
+
5. Update documentation if adding new features.
|
|
736
|
+
6. Commit your changes (`git commit -m 'Add new feature'`).
|
|
737
|
+
7. Push to your branch (`git push origin feature/your-feature`).
|
|
738
|
+
8. Open a Pull Request.
|
|
739
|
+
|
|
740
|
+
Ensure your code adheres to the project's coding standards and includes tests where appropriate. See [CONTRIBUTING.md](./docs/about/contributing.md) for detailed guidelines.
|
|
741
|
+
|
|
742
|
+
## License
|
|
743
|
+
|
|
744
|
+
This project is licensed under the Apache 2.0 License. See the [LICENSE](./LICENSE) file for details.
|
|
745
|
+
|
|
746
|
+
## Support
|
|
747
|
+
|
|
748
|
+
- **Documentation**: [GitHub Pages site](https://cdot65.github.io/pan-scm/)
|
|
749
|
+
- **Issues**: [GitHub Issues](https://github.com/cdot65/pan-scm/issues)
|
|
750
|
+
- **Discussions**: [GitHub Discussions](https://github.com/cdot65/pan-scm/discussions)
|
|
751
|
+
- **Examples**: See the `examples/` directory for configuration templates
|
|
752
|
+
|
|
753
|
+
## Project Status
|
|
754
|
+
|
|
755
|
+
This project is actively maintained and uses:
|
|
756
|
+
|
|
757
|
+
- Python 3.12+ with Poetry for dependency management
|
|
758
|
+
- pan-scm-sdk v0.3.39 for API interactions
|
|
759
|
+
- Dynaconf for flexible configuration management
|
|
760
|
+
- Pydantic for robust input validation
|
|
761
|
+
- Comprehensive test coverage with pytest
|
|
762
|
+
|
|
763
|
+
---
|
|
764
|
+
|
|
765
|
+
_Detailed documentation is available on our [GitHub Pages documentation site](https://cdot65.github.io/pan-scm/)._
|
|
766
|
+
|