{"id":13798003,"url":"https://github.com/ossobv/asterisklint","last_synced_at":"2025-05-05T18:32:31.345Z","repository":{"id":53471009,"uuid":"42016518","full_name":"ossobv/asterisklint","owner":"ossobv","description":"Asterisk PBX configuration syntax checker","archived":false,"fork":false,"pushed_at":"2022-11-25T08:47:04.000Z","size":711,"stargazers_count":66,"open_issues_count":25,"forks_count":12,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-26T04:05:06.302Z","etag":null,"topics":["asterisk","asterisk-dialplan","asterisk-pbx","cli","library","linter"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ossobv.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-06T19:42:30.000Z","updated_at":"2025-04-20T18:50:46.000Z","dependencies_parsed_at":"2023-01-22T07:00:27.444Z","dependency_job_id":null,"html_url":"https://github.com/ossobv/asterisklint","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ossobv%2Fasterisklint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ossobv%2Fasterisklint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ossobv%2Fasterisklint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ossobv%2Fasterisklint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ossobv","download_url":"https://codeload.github.com/ossobv/asterisklint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252553141,"owners_count":21766836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asterisk","asterisk-dialplan","asterisk-pbx","cli","library","linter"],"created_at":"2024-08-04T00:00:37.750Z","updated_at":"2025-05-05T18:32:30.816Z","avatar_url":"https://github.com/ossobv.png","language":"Python","funding_links":[],"categories":["Auditing"],"sub_categories":[],"readme":"|AsteriskLint|\n==============\n\n*Asterisk PBX configuration syntax checker*\n\nAsteriskLint is a suite of tools to check syntax of your Asterisk PBX\nconfiguration files.\n\nAlright, enough talking. Some examples please!\n\nFor an online example see `\u003chttps://asterisklint.osso.pub/\u003e`_. For CLI\nexamples, keep reading:\n\n\nInvocation\n----------\n\n.. code-block:: console\n\n    $ asterisklint\n    usage: asterisklint [-h] COMMAND\n    asterisklint: error: the following arguments are required: COMMAND\n\n    $ asterisklint ls\n    builtin:\n      ls                    List available commands.\n\n    /usr/lib/python/dist-packages:\n      dialplan-check        Do sanity checks on dialplan. Takes 'extensions.conf'\n                            as argument. Suppress error classes using ALINT_IGNORE.\n      dialplan-show         Show dialplan like Asterisk does with CLI command\n                            \"dialplan show\". Takes 'extensions.conf' as argument.\n      func_odbc-check       Do sanity checks on func_odbc.conf. Takes\n                            'func_odbc.conf' as argument. Suppress error classes\n                            using ALINT_IGNORE.\n      ident-scan            Report similarly named contexts, labels and variables.\n                            Takes 'extensions.conf' as argument. All parse errors\n                            are suppressed.\n      modules-show          Show which modules, apps and functions are used by the\n                            dialplan. Takes 'extensions.conf' as argument.\n\n    Place custom commands in ~/.asterisklint/asterisklint/commands.\n\n\nTake this little dialplan snippet, that we'll call ``extensions.conf``::\n\n    [default]\n    exten =\u003e _8[2-9]x,1,NoOp\n     same =\u003e n,GoSub(somewhere,s,1(argument1,argument2)\n     same =\u003e n,Payback(audiofile)\n\nNow run the ``dialplan-check`` command on it:\n\n.. code-block:: console\n\n    $ ALINT_IGNORE=H_DP_ asterisklint dialplan-check extensions.conf\n    extensions.conf:2 H_PAT_NON_CANONICAL: pattern '_8[2-9]x' is not in the canonical form '_8NX'\n    extensions.conf:3 W_APP_BAD_CASE: app 'GoSub' does not have the proper Case 'Gosub'\n    extensions.conf:3 W_APP_BALANCE: app data '1(argument1,argument2' looks like unbalanced parentheses/quotes/curlies\n    extensions.conf:4 E_APP_MISSING: app 'Payback' does not exist, dialplan will halt here!\n    extensions.conf:3 E_DP_GOTO_NOCONTEXT: context not found for goto to somewhere, s, 1\n\nIt had a lot to complain about that little snippet. But it was right. We\neven suppressed two hints about a missing ``[general]`` and ``[global]``\ncontext using ``ALINT_IGNORE``.\n\nNot everything it checks is documented, and it does not check everything\nthat we like yet. But it's a start. Bug reports are welcome. Feature requests\nprefer to be accompanied by a patch :-)\n\nTry out ``modules-show`` if you use ``autoload=no`` in your ``modules.conf``.\n\nAll commands show help if asked:\n\n.. code-block:: console\n\n    $ asterisklint modules-show --help\n    usage: asterisklint modules-show [-h] [--func-odbc FUNC_ODBC_CONF]\n                                     [EXTENSIONS_CONF]\n\n    Show which modules, apps and functions are used by the dialplan. Useful when\n    you use autoload=no in your modules.conf. Beware that you do need more modules\n    than just these listed.\n\n    positional arguments:\n      EXTENSIONS_CONF       path to extensions.conf\n\n    optional arguments:\n      -h, --help            show this help message and exit\n      --func-odbc FUNC_ODBC_CONF\n                            path to func_odbc.conf, will be read automatically if\n                            found in same the same dir as extensions.conf; set\n                            empty to disable\n\n\nInstallation\n------------\n\nInstallation is a matter of ``python3 setup.py install``. Or, for more\nconvenience, install a PyPI uploaded version through ``pip3(1)``:\n\n.. code-block:: console\n\n    $ sudo pip3 install asterisklint\n    ...\n    Successfully installed asterisklint\n\n\nThe ``dialplan-check`` comes in handy as a git commit hook, for example\n``.git/hooks/pre-commit``:\n\n.. code-block:: sh\n\n    #!/bin/sh\n    export ALINT_IGNORE=  # adjust as needed\n\n    asterisklint dialplan-check PATH/TO/extensions.conf\n    ret=$?\n    if test $ret -ne 0; then\n        echo \u003e\u00262\n        echo 'One or more dialplan syntax errors. Please fix before committing.' \u003e\u00262\n        exit $ret\n    fi\n\n    exit 0\n\n\nTODO\n----\n\n* Expression parsing.\n* Web: state is kept between requests:\n\n  - on 500-error, the next user may get older errors (because of the\n    messagedef singleton)\n  - the BackGround/Background hack is stored between requests\n\n* Log/store Set'd variables and compare against Read variables. Also log\n  variables Set through the ARRAY() function. (And HASH?)\n* Fix various includes issues:\n\n  - Recursive #includes probably make asterisklint run out of stack.\n  - Add checks for recursive dialplan-includes.\n  - Scan for missing dialplan-includes.\n\n* Trim CALLERID match (as used in FreePBX dialplan).\n* Func_odbc parsing improvements:\n\n  - check for missing synopsis/syntax (compare syntax to ARGn count)\n  - check for correct usage of VAL (write only) and ARG and missing SQL_ESC\n  - yield the odbc functions instead of contexts like it does now\n\n  (See more in func_odbc.py.)\n* Add ``app-check`` command to do dialplan checks of individual lines.\n* Add ``expr-check`` command to do expression (``$[...]``) checks.\n  E.g. add::\n\n    exten =\u003e X!,1,Set(boolean=$[\"\" \u003c555\u003e = 1234])\n    ; Set(boolean=$[${CALLERID(all)} = 1234])\n    ; incorrectly using 'all', should use 'num'\n    ==\u003e syntax error, unexpected '=', expecting '-' or '!' or '(' or '\u003ctoken\u003e'\n\n* Allow multiline variables using += (key=val; key+=more-val).\n* Investigate whether exten=\u003es,n(label)... exten=\u003es,label+10... is valid.\n* For the Goto/Gosub-visiting:\n\n  - Attempt to match contexts by regex if there are $VARs involved?\n  - Allow a \"noqa\" style exceptions to be placed in a comment?\n\n* Improve documentation as needed.\n* Before 1.0, start adding versioning -- including semver -- so users can\n  depend on a stable API from their custom scripts. Also version the scripts\n  (commands) so they won't talk to older/newer libs if that poses a problem.\n\n\nBUGS\n----\n\n* The library is very much in flux. Don't expect it to stabilize any time\n  soon. Pay attention to versions!\n* Multiline comments (``;-- ... --;``) are unsupported. Does anyone use those?\n* Limits aren't checked (dialplan lines are limited at 255 or 8191 bytes\n  for LOW_MEMORY and normal mode respectively).\n* The library/suite is Python3 only. Right now the effort to make it Python2\n  compatible is larger than the demand. In the future Python2 compatibility\n  will become even less relevant.\n\n\nAuthor\n------\n\nWalter Doekes, OSSO B.V. 2015-2020\n\n\n.. |AsteriskLint| image:: assets/asterisklint_head.png\n    :alt: AsteriskLint\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fossobv%2Fasterisklint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fossobv%2Fasterisklint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fossobv%2Fasterisklint/lists"}