{ "info": { "author": "Callum Ray", "author_email": "callumray@hotmail.co.uk", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: POSIX", "Programming Language :: Python :: 3" ], "description": "# pyufw\nA python wrapper for UFW (Uncomplicated FireWall), a wrapper for iptables.\n\n## Install\npyufw is avaliable from PyPi. You can download it using pip:\n```console\n$ pip3 install pyufw\n```\nAlso make sure ufw is installed. Depending on your distribution the package may be named `ufw` or `python-ufw`. \n\n## Documentation\nYour script will have to be run with root privilages. Upon importing the module the ufw security checks will start and you may see some warning messages. The following checks will commence:\n * is setuid or setgid (for non-Linux systems)\n * checks that script is owned by root\n * checks that every component in absolute path are owned by root\n * warn if script is group writable\n * warn if part of script path is group writable\n\n```python\nimport pyufw as ufw\n```\n\n#### Enable the firewall\nEnables the ufw firewall and enables on boot.\n```python\nufw.enable()\n```\n\n#### Disable the firewall\nDisables the ufw firewall and disables on boot.\n```python\nufw.disable()\n```\n\n#### Reset the firewall\nReturns the firewall to it's install defaults. `incoming=deny, outgoing=allow, routed=reject` \nThe default rules are:\n * `allow SSH`\n * `allow to 224.0.0.251 app mDNS`\n```python\nufw.reset()\n```\n\n#### Get status\nRetuns a dict. Status is either `'active'` or `'inactive'`. If the firewall is active the default policies and rules list will also be included.\n```python\nufw.status()\n```\n```python\n{ \n 'status':'active',\n 'default':{ \n 'incoming':'deny',\n 'outgoing':'allow',\n 'routed':'reject'\n },\n 'rules':{ \n 1:'allow out on tun0',\n 2:'allow in on tun0'\n }\n}\n```\n```python\n{\n 'status': 'inactive'\n}\n```\n\n#### Set defaults\nSet the default policies for `incoming`, `outgoing` and `routed`. Policies to choose from are `allow`, `deny` and `reject`.\n```python\nufw.default(incoming='deny', outgoing='allow', routed='reject')\n```\n\n#### Add rule\nAdd or Insert a rule. To insert a rule you can specify a rule number but this is optional. \nCheck out `man ufw` for rule syntax. \nReturns the raw iptables rule added (incase your interested)\n```python\nufw.add(\"allow 22\")\nufw.add(\"allow 22\", number=3)\n```\n```python\n\"allow -p all --dport 22 -j ACCEPT both\"\n```\n\n#### Delete rule\nDelete a rule. You can specify the rule itself, the rule number or the string `*` to delete all rules.\n```python\nufw.delete(\"allow 22\")\nufw.delete(3)\nufw.delete('*')\n```\n\n#### Get rules\nGet a list of the current rules. Returns a dict with the rule numbers as the index.\n```python\nufw.get_rules()\n```\n```python\n{ \n 1:'allow out on tun0',\n 2:'allow in on tun0',\n 3:'allow 22'\n}\n```\n\n#### Show listening\nReturns an array of listening ports, applications and rules that apply. \nArray contains a series of tuples of the following structure: \n`(str transport, str listen_address, int listen_port, str application, dict rules)`\n```python\nufw.show_listening()\n```\n```python\n[\n ('tcp', '*', '22', 'openssh', {\n 3: 'allow 22'\n }), \n ('tcp', '*', '57621', 'spotify', {}), \n ('udp', '*', '1900', 'spotify', {}), \n ('udp', '224.0.0.251', '5353', 'chrome', {}), \n ('udp', '224.0.0.251', '5353', 'chrome', {}), \n ('udp', '*', '68', 'dhclient', {})\n]\n```\n\n#### Set Logging\nSet the ufw logging level. Choose from: `'on', 'off', 'low', 'medium', 'high', 'full'`.\nCheck out `man ufw` for more info on logging.\n```python\nufw.set_logging('on')\n```\n\n#### Get raw iptables output\nThe following resources mirror the ufw cli commands and return the same unformatted string outputs. Maybe more useful for debugging.\n```python\nufw.show_raw()\nufw.show_builtins()\nufw.show_before_rules()\nufw.show_user_rules()\nufw.show_logging_rules()\n```\n\n### Similar cool projects\n * https://gitlab.com/dhj/easyufw\n\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/5tingray/pyufw", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pyufw", "package_url": "https://pypi.org/project/pyufw/", "platform": "", "project_url": "https://pypi.org/project/pyufw/", "project_urls": { "Homepage": "https://github.com/5tingray/pyufw" }, "release_url": "https://pypi.org/project/pyufw/0.0.3/", "requires_dist": null, "requires_python": ">=3", "summary": "A Python wrapper for UFW", "version": "0.0.3" }, "last_serial": 5842285, "releases": { "0.0.3": [ { "comment_text": "", "digests": { "md5": "4c8550fce1ad4b6df766d6e7a72e11c9", "sha256": "23d5820bd14a50ee4a2c2a0592adf16e097d8d384737e8a3c9343e25ca072a90" }, "downloads": -1, "filename": "pyufw-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "4c8550fce1ad4b6df766d6e7a72e11c9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 5964, "upload_time": "2019-09-17T15:28:16", "url": "https://files.pythonhosted.org/packages/6e/ad/23dea0a58dee4b6ee32bbdbdec440b74dcc531e7fdde9caa81504ace1879/pyufw-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "79102813d86cb57293c2d04b61408e45", "sha256": "385b3338b664a056b711f59578e6c57d144887b89e497ed229a94780a2001cdb" }, "downloads": -1, "filename": "pyufw-0.0.3.tar.gz", "has_sig": false, "md5_digest": "79102813d86cb57293c2d04b61408e45", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 5120, "upload_time": "2019-09-17T15:28:20", "url": "https://files.pythonhosted.org/packages/7e/96/a8ebb11384cba47bc2cd5032da337cd8e478b17872cdc8ef2343fc0c5632/pyufw-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4c8550fce1ad4b6df766d6e7a72e11c9", "sha256": "23d5820bd14a50ee4a2c2a0592adf16e097d8d384737e8a3c9343e25ca072a90" }, "downloads": -1, "filename": "pyufw-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "4c8550fce1ad4b6df766d6e7a72e11c9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 5964, "upload_time": "2019-09-17T15:28:16", "url": "https://files.pythonhosted.org/packages/6e/ad/23dea0a58dee4b6ee32bbdbdec440b74dcc531e7fdde9caa81504ace1879/pyufw-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "79102813d86cb57293c2d04b61408e45", "sha256": "385b3338b664a056b711f59578e6c57d144887b89e497ed229a94780a2001cdb" }, "downloads": -1, "filename": "pyufw-0.0.3.tar.gz", "has_sig": false, "md5_digest": "79102813d86cb57293c2d04b61408e45", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 5120, "upload_time": "2019-09-17T15:28:20", "url": "https://files.pythonhosted.org/packages/7e/96/a8ebb11384cba47bc2cd5032da337cd8e478b17872cdc8ef2343fc0c5632/pyufw-0.0.3.tar.gz" } ] }