Skip to main content

Clean & sort FortiOS config files.

Project description

FORTICLEAN

Build Tests CodQL Analysis Dependency Review PyPI - Downloads

Description

FortiClean is a CLI tool designed for FortiOS configuration file management for better readability and comparision. Built with Python & leverages the power of the typer library, this utility streamlines the process of:

  • Trimming Trailing Spaces: Say goodbye to unwanted spaces at the end of your config lines that complicate diffs, but do not affect the configuration.
  • Removing Specific Sections: Clean up your config file by specifying & deleting sections do not wish to save. A handy feature for decluttering and maintaining a streamlined configuration setup.
  • Sorting Config Sections & Subsections: Enhance readability & structure by sorting specified config sections for enhanced readbility. It is recommended you do not sort config sections like firewall policy where order matters.

Unlike other network operatin systems, sections where config order does not matter is hapazardly saved in the order the config was entered making automated & manual diff operations challenging

Features

  • Trim spaces at the end of a line
  • Delete config sections
  • Sort config sections
  • Sort config sections 1 level down
  • Colored Logs
  • Use jsonschemea to warn of config file errors
  • Use jsonschema in tests
  • Command line arguments to specify config, path, etc COMING SOON
  • Prevent or WARN on the sorting of sections where order matters COMING SOON

Getting Started

Clone the repo, move to the directory & run one of the below:

Configuration

In order of precedence: 1.) .forticleaner in the directory you are running the script from 2.) .forticleaner in your home directory 3.) Default config file included with the package

Usage

main [OPTIONS] [SRC_FILE_PATH]

Arguments

  • [SRC_FILE_PATH]: Path to the source file

Options

  • -d, --dst_file_path TEXT: Path to the write file [default: sorted_config.cfg]
  • -v, --verbose: Enable level of verbose mode [default: 0]
  • --install-completion: Install completion for the current shell.
  • --show-completion: Show completion for the current shell, to copy it or customize the installation.
  • --help: Show this message and exit.
python3 src/main.py config.cfg

Verbose Mode (1 level)

$ python3 src/main.py config.cfg -v
[13:42:07] INFO     Section 'config vpn certificate local' was DELETED.                                                                               main.py:27
           INFO     Removed trailing space(s) from 0 lines.                                                                                           main.py:40
           INFO     Section 'config system zone' was NOT SORTED                                                                                       main.py:70
           INFO     Section 'config system interface' was NOT SORTED                                                                                  main.py:70
           INFO     Section 'config firewall internet-service-name' was SORTED                                                                        main.py:70

Verbose Mode (2 levels)

$ python3 src/main.py config.cfg -vv
[13:42:48] DEBUG    Config 'src/conf/default.yaml' opened successfully                                                                               utils.py:57
           DEBUG    Key 'FORTIOS_CONFIG_FILENAME_REGEX' NOT in the config file. Defaulting to (.*).cfg.                                              utils.py:63
           DEBUG    File 'config.cfg' opened successfully                                                                                            utils.py:26
           INFO     Section 'config vpn certificate local' was DELETED.                                                                               main.py:27
           INFO     Removed trailing space(s) from 0 lines.                                                                                           main.py:40
           INFO     Section 'config system zone' was NOT SORTED                                                                                       main.py:70
           INFO     Section 'config system interface' was NOT SORTED                                                                                  main.py:70
           INFO     Section 'config firewall internet-service-name' was SORTED                                                                        main.py:70
           DEBUG    File 'sorted_config.cfg' written successfully                                                                                    utils.py:38

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

forticlean-1.0.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

forticlean-1.0.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file forticlean-1.0.0.tar.gz.

File metadata

  • Download URL: forticlean-1.0.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for forticlean-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2cad0257d50fbc9ae7078935c8b2b38cb588475ce0b843d3fb3cc9da05aedb27
MD5 2337ea79babf752b8093e0244ff68f37
BLAKE2b-256 e4b4d3b583d79df0b5141eb87b70f0a64b8995a278c31871122e3d0404f7bc34

See more details on using hashes here.

File details

Details for the file forticlean-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: forticlean-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for forticlean-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 300996487173079d38e421de1e665a86c597f1d1ce9d76590e46e1f5def91f1e
MD5 4c4f9ab4edc95a81a3225e0ff81c70f5
BLAKE2b-256 70df72ca09fb53f9de85523f0a6502e47b2f01ccd56daa66383118263b3dd925

See more details on using hashes here.

Supported by

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