Skip to main content

Network Engineer-friendly CLI for Palo Alto Networks Security Content Management

Project description

Strata Cloud Manager CLI

Banner Image Build Status PyPI version Python versions License

Command-line interface for Palo Alto Networks Strata Cloud Manager.

NOTE: Please refer to the GitHub Pages documentation site for all examples

Table of Contents

Features

  • Consistent Command Structure: Intuitive command pattern that follows standard CLI conventions.
  • Comprehensive Object Management: Create, read, update, and delete configuration objects like addresses, address groups, security zones, and security rules.
  • Bulk Operations: Load and manage objects in bulk using YAML files.
  • Mock Mode: Test commands without making actual API calls to validate configurations.
  • Authentication Management: Multiple authentication methods including environment variables and configuration files.
  • Extensive Documentation: Comprehensive examples for all supported operations.

Installation

Requirements:

  • Python 3.10 or higher

Install the package via pip:

pip install pan-scm-cli

Usage

Authentication

Configure authentication using one of the following methods:

Environment Variables

# Linux/macOS
export SCM_CLIENT_ID="your_client_id"
export SCM_CLIENT_SECRET="your_client_secret"
export SCM_TSG_ID="your_tenant_service_group_id"

# Windows PowerShell
$env:SCM_CLIENT_ID = "your_client_id"
$env:SCM_CLIENT_SECRET = "your_client_secret"
$env:SCM_TSG_ID = "your_tenant_service_group_id"

Configuration File

Create a config file at ~/.scm-cli/config.yaml:

client_id: "your_client_id"
client_secret: "your_client_secret"
tsg_id: "your_tenant_service_group_id"

Command Structure

The CLI follows a consistent command pattern:

scm-cli <action> <object-type> <object> [options]

Where:

  • <action>: set, delete, or load
  • <object-type>: objects, network, security, or deployment
  • <object>: Specific object type (e.g., address, address-group, security-zone)

Example Commands

Managing Address Objects

# Create a new address object
scm-cli set objects address --folder Shared --name web-server --ip-netmask 192.168.1.100/32 --description "Web server in DMZ"

# List all address objects in a folder
scm-cli set objects address --list --folder Shared

# Delete an address object
scm-cli delete objects address --folder Shared --name web-server

Managing Address Groups

# Create a static address group
scm-cli set objects address-group --folder Shared --name web-servers --type static --members "web-server-1,web-server-2"

# Create a dynamic address group
scm-cli set objects address-group --folder Shared --name dynamic-endpoints --type dynamic --filter "'endpoint' and 'corporate'"

# Delete an address group
scm-cli delete objects address-group --folder Shared --name web-servers

Managing Security Zones

# Create a security zone
scm-cli set network security-zone --folder Shared --name DMZ --mode layer3 --enable-user-id true

# List all security zones
scm-cli set network security-zone --list --folder Shared

Managing Security Rules

# Create a security rule
scm-cli set security rule --folder Shared --name "Allow-Web" \
  --source-zones "Trust" --destination-zones "DMZ" \
  --source-addresses "any" --destination-addresses "web-servers" \
  --applications "web-browsing,ssl" --services "application-default" \
  --action allow --log-end true

# List all security rules
scm-cli set security rule --list --folder Shared

Bulk Operations

Create a YAML file with multiple objects:

# addresses.yaml
addresses:
  - name: web-server-1
    description: "Web server 1"
    ip_netmask: 192.168.1.100/32
    tags:
      - web
      - production

  - name: web-server-2
    description: "Web server 2"
    ip_netmask: 192.168.1.101/32
    tags:
      - web
      - production

Load the objects:

scm-cli load objects address --folder Shared --file addresses.yaml

Development

Setup

  1. Clone the repository:

    git clone https://github.com/cdot65/pan-scm-cli.git
    cd pan-scm-cli
    
  2. Install dependencies and pre-commit hooks:

    make setup
    

    Alternatively, you can install manually:

    poetry install
    poetry run pre-commit install
    

Code Quality

This project uses ruff for linting and formatting:

# Run linting checks
make lint

# Format code
make format

# Auto-fix linting issues when possible
make fix

Pre-commit Hooks

We use pre-commit hooks to ensure code quality before committing:

# Run pre-commit hooks on all files
make pre-commit-all

The following checks run automatically before each commit:

  • ruff linting and formatting
  • Trailing whitespace removal
  • End-of-file fixer
  • YAML/JSON syntax checking
  • Large file detection
  • Python syntax validation
  • Merge conflict detection
  • Private key detection

Contributing

We welcome contributions! To contribute:

  1. Fork the repository.
  2. Create a new feature branch (git checkout -b feature/your-feature).
  3. Make your changes, ensuring all linting and tests pass.
  4. Commit your changes (git commit -m 'Add new feature').
  5. Push to your branch (git push origin feature/your-feature).
  6. Open a Pull Request.

Ensure your code adheres to the project's coding standards and includes tests where appropriate.

License

This project is licensed under the Apache 2.0 License. See the LICENSE file for details.

Support

For support and questions, please refer to the SUPPORT.md file in this repository.


Detailed documentation is available on our GitHub Pages documentation site.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pan_scm_cli-0.2.1.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pan_scm_cli-0.2.1-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file pan_scm_cli-0.2.1.tar.gz.

File metadata

  • Download URL: pan_scm_cli-0.2.1.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for pan_scm_cli-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a3fec0d6eb8b9249914f183b5587f641020499b6aabcf793b98c74b641121718
MD5 ac698668796c1aa24723844a1ba679e2
BLAKE2b-256 9249e5e25d51b6a35593b5c8eb07b4047142541575918cfd684fdde029cff201

See more details on using hashes here.

File details

Details for the file pan_scm_cli-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pan_scm_cli-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 23.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for pan_scm_cli-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cfefcbf6fe49e5f5af50f6927177eb9f14204ec94c81e1a2bf7101bf602d3531
MD5 f9693c5605d3e83dd379648e9edd3137
BLAKE2b-256 50db72658c51025f5637d732f4be840484653cfe091f64516a8de3c102700ac9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page