Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Asterisk PBX configuration syntax checker

Asterisklint is a suite of tools to check syntax of your Asterisk PBX configuration files.

Alright, enough talking. Some examples please.

Invocation

$ asterisklint
usage: asterisklint [-h] COMMAND
asterisklint: error: the following arguments are required: COMMAND

$ asterisklint ls
builtin:
  ls                    List available commands.

/usr/lib/python/dist-packages:
  dialplan-check        Do sanity checks on dialplan. Takes 'extensions.conf'
                        as argument. Suppress error classes using ALINT_IGNORE.
  dialplan-show         Show dialplan like Asterisk does with CLI command
                        "dialplan show". Takes 'extensions.conf' as argument.
  modules-show          Show which modules, apps and functions are used by the
                        dialplan. Takes 'extensions.conf' as argument.

Place custom commands in ~/.asterisklint/asterisklint/commands.

Take this little dialplan snippet, that we’ll call extensions.conf:

[default]
exten => _8[2-9]x,1,NoOp
 same => n,GoSub(somewhere,s,1(argument1,argument2)
 same => n,Payback(audiofile)

Now run the dialplan-check command on it:

$ ALINT_IGNORE=H_DP_ \
    asterisklint dialplan-check extensions.conf
extensions.conf:2 H_PAT_NON_CANONICAL: pattern '_8[2-9]x' is not in the canonical form '_8NX'
extensions.conf:3 W_APP_BAD_CASE: app 'GoSub' does not have the proper Case 'Gosub'
extensions.conf:3 W_APP_BALANCE: app data 'somewhere,1,s(argument1,argument2' looks like unbalanced parentheses/quotes/curlies
extensions.conf:4 E_APP_MISSING: app 'Payback' does not exist, dialplan will halt here!

It had a lot to complain about that little snippet. But it was right. We even suppressed two hints about a missing [general] and [global] context using ALINT_IGNORE.

Not everything it checks is documented, and it does not check everything that we like yet. But it’s a start. Bug reports are welcome. Feature requests prefer to be accompanied by a patch :-)

Try out modules-show if you use autoload=no in your modules.conf.

All commands show help if asked:

$ asterisklint modules-show --help
usage: asterisklint modules-show [-h] EXTENSIONS_CONF

Show which modules, apps and functions are used by the dialplan. Useful when
you use autoload=no in your modules.conf. Beware that you do need more modules
than just these listed.

positional arguments:
  EXTENSIONS_CONF  path to extensions.conf

optional arguments:
  -h, --help       show this help message and exit

Installation

Installation is a matter of python3 setup.py install. Or, for more convenience, install a PyPI uploaded version through pip3(1):

The dialplan-check comes in handy as a git commit hook, for example .git/hooks/pre-commit:

TODO

  • Improve documentation as needed.

  • Expression parsing.

  • Function argument parsing.

  • Recursive includes probably make asterisklint run out of stack.

  • Goto/Gosub-visiting to check for missing contexts/destinations/prios/labels.

  • Add app-check command to do dialplan checks of individual lines.

  • Add expr-check command to do expression ($[…]) checks.

  • Before 1.0, start adding versioning – including semver – so users can depend on a stable API from their custom scripts. Also version the scripts (commands) so they won’t talk to older/newer libs if that poses a problem.

BUGS

  • The library is very much in flux. Don’t expect it to stabilize any time soon. Pay attention to versions!

  • Multiline comments (;– … –;) are unsupported. Does anyone use those?

  • Limits aren’t checked (dialplan lines are limited at 255 or 8191 bytes for LOW_MEMORY and normal mode respectively).

  • The function loader doesn’t read func_odbc. So you may get lots of E_FUNC_MISSING for your custom functions. Suppress those with ALINT_IGNORE=E_FUNC_MISSING for now.

Author

Walter Doekes, OSSO B.V. 2015

0.1.0rc6 (2015-12-18)

  • Initial release.

  • The following commands are available: dialplan-check, dialplan-show, modules-show

Metadata

Release files for asterisklint 0.1.0rc6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asterisklint 0.1.0rc6
File Size Uploaded Provenance Actions
asterisklint-0.1.0rc6.tar.gz 51.9 kB Without provenance Details for asterisklint-0.1.0rc6.tar.gz

Release files / asterisklint-0.1.0rc6.tar.gz

Download URL asterisklint-0.1.0rc6.tar.gz
Size 51.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a0268df15ecd1c63f494f22f2f58be41cb5788cdee81c2f373121b84f764eaeb
BLAKE2b-256 checksum
How to use checksums
76a1a75e71aba15163e81dec405d7cf7b74b0d835f99b6bd7ae086fd02925288
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for asterisklint 0.1.0rc6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page