
The tool to check the availability or syntax of domain, IP or URL.¶





PyFunceble is the little sister of Funceble which was archived on 13th March 2018.
EOL of PyFunceble 3.x. Please do read more about this in the EOL chapter.
Its main objective is to provide the availability of domains, IPs and since recently URL by generating an accurate result based on results from WHOIS, NSLOOKUP and HTTP status codes.
PyFunceble provides some useful features for continuous testing.
As an example, its auto-continue system coupled with its auto-save system
allows it to run nice and smoothly under Travis CI without even reaching
Travis CI time restriction. In the other side, its internal inactive database
system let INACTIVE
and INVALID
caught domains, IPs or URLs
being automatically retested over time on next run.
What can PyFunceble do?¶
- Test the availability of a domain.
- Test the availability of an IPv4.
- Test the availability of an IPv6.
- Test the availability of a URL.
- Test the availability of a domain/DNS name in a private or local network.
- Test the availability of an IPv4 in a private or local network.
- Test the availability of an IPv6 in a private or local network.
- Test the availability of a URL in a private or local network.
- Test the syntax of a domain.
- Test the syntax of an IPv4.
- Test the syntax of an IPv6.
- Test the syntax of a URL.
- Test the AlienVault’s reputation of an IPv4.
- Test of domain or IP which are present into an Adblock formatted file.
- Test from a given raw link.
- Test using multiprocessing (from CLI only).
- Save test result(s) in file(s) (hosts file, plain text and/or JSON format).
- Save test result in a SQL database.
- Show test result(s) on screen.
- Show percentage of each status (
ACTIVE
,INACTIVE
,INVALID
) - Sort outputs hierarchically.
- “Mining” of domain or IP which are related to the tested element.
- Auto-continuation of tests in case of system crash or script stop.
- Filtering of a file content.
- This feature will let us for example test all blogspot domain of the given file no matter the content of the file.
- Set the user-agent to use for the tests.
- Give some analytic depending of the HTTP status code (
ACTIVE
,POTENTIALLY_ACTIVE
,POTENTIALLY_INACTIVE
,SUSPICIOUS
). - Retest overtime of
INACTIVE
andINVALID
domains. - Print the execution time on screen and file.
- Customisation of the different option via command-line arguments or configuration file.
- Continuous tests under Travis CI or GitLab CI/CI
- … with the help of an auto saving and database system.
- Set the branch to push the result to. For the autosaving system.
- Set the minimal time before we autosave in order to avoid CI/CD limitation.
- Set a command to execute at the end of the test.
- Set the commit message for the autosaving system.
- … and a lot more!
Contributors¶
Thanks to those awesome peoples for their awesome and crazy idea(s), contribution(s) and or issue report which made or make PyFunceble a better tool.
_______ _ _ _ _
|__ __| | | | | | | |
| | | |__ __ _ _ __ | | _____ | |_ ___ _ _ ___ _ _ | |
| | | '_ \ / _` | '_ \| |/ / __| | __/ _ \ | | | |/ _ \| | | | | |
| | | | | | (_| | | | | <\__ \ | || (_) | | |_| | (_) | |_| | |_|
|_| |_| |_|\__,_|_| |_|_|\_\___/ \__\___/ \__, |\___/ \__,_| (_)
__/ |
|___/
- Avinash Reddy - @AvinashReddy3108
- Daniel - @dnmTX
- hawkeye116477 - @hawkeye116477
- Imre Kristoffer Eilertsen - @DandelionSprout
- jawz101 - @jawz101
- kowith337 - @kowith337
- Mitchell Krog - @mitchellkrogza
- NeolithEra - @NeolithEra
- Odyseus - @Odyseus
- opav - @opav
- Reza Rizqullah - @ybreza
- rusty-snake - @rusty-snake
- ScriptTiger - @ScriptTiger
- sjhgvr - @sjhgvr
- speedmann - @speedmann
- spirillen - @spirillen
- The Unknown - @AnonymousPoster
- WaLLy3K - @WaLLy3K
- xxcriticxx - @xxcriticxx
- ZeroDot1 - @ZeroDot1
Special Thanks¶
Thanks to those awesome organization(s), tool(s) and or people(s) for
- Their awesome documentation
- Their awesome repository
- Their awesome tool/software/source code
- Their breaking reports
- Their contributions
- Their current work/purpose
- Their promotion of Py-Funceble
- Their support
- Their testings reports
which helped and/or still help me build, test and or make PyFunceble a better tool.
_______ _ _ _ _
|__ __| | | | | | | |
| | | |__ __ _ _ __ | | _____ | |_ ___ _ _ ___ _ _ | |
| | | '_ \ / _` | '_ \| |/ / __| | __/ _ \ | | | |/ _ \| | | | | |
| | | | | | (_| | | | | <\__ \ | || (_) | | |_| | (_) | |_| | |_|
|_| |_| |_|\__,_|_| |_|_|\_\___/ \__\___/ \__, |\___/ \__,_| (_)
__/ |
|___/
- Adam Warner - @PromoFaux
- Adblock Plus - @adblockplus
- asciinema - @asciinema
- Bob Halley - @rthalley (DNSPython)
- Chris Griffith - @cdgriffith (Box)
- Daniel - @dnmTX
- Jonathan Hartley - @tartley (colorama)
- IANA - ICANN (Root Zone Database)
- Kenneth Reitz - @kennethreitz (requests)
- Mitchell Krog - @mitchellkrogza
- Mohammad Fares - @faressoft (Terminalizer)
- Pi-Hole - @pi-hole
- Public Suffix List - @publicsuffix
- Reza Rizqullah - @ybreza
- Saurabh Kumar - @theskumar (python-dotenv)
- ScriptTiger - @ScriptTiger
- SMed79 - @SMed79
- spirillen - @spirillen
- The YAML Project - @yaml (pyyaml)
- yWorks - (yEd Graph Editor)
Supporting the project¶
PyFunceble, Dead-Hosts, and all other analogue projects are powered by my free time and a lot of coffee!
If you like this project and/or it have helped you. Please consider buying me more coffee.
GitHub Sponsor¶
@funilrys is part of the GitHub Sponsor program!
GitHub will match all donation for the coming months!

License¶
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Code of Conduct¶
Our Pledge¶
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
Our Standards¶
Examples of behavior that contributes to creating a positive environment include:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others’ private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting
Our Responsibilities¶
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
Scope¶
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
Enforcement¶
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at contact@funilrys.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project’s leadership.
Attribution¶
This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4.
They use-d PyFunceble!¶
Just a list of tool/repository/code/infrastructure which uses or used PyFunceble!
- .pl-host-file
- add.2o7Net
- add.Dead
- add.Risk
- add.Spam
- adfilt
- Asads-Hosts
- Badd-Boyz-Hosts
- Badger Sett
- blacklist
- CoinBlockerLists
- cookies_filters
- DNS test
- Facebook Zero Hosts Block
- finnish-easylist-addition
- Frellwits-filter-lists
- Google AdService and ID.Google tracking hosts
- KADhosts
- MobileAdTrackers
- My Privacy DNS
- Phishing-URL-Testing-Database-of-Link-Statuses
- Phishing.Database
- polish-adblock-filters
- polish-pihole-filters
- pornhosts
- Stop.Google.Analytics.Ghost.Spam.HOWTO
- The-Big-List-of-Hacked-Malware-Web-Sites
- Top-Attacking-IP-Addresses-Against-Wordpress-Sites
- Ultimate.Hosts.Blacklist // Ultimate-Hosts-Blacklist
- UncheckyAds
Frequently Asked Questions¶
How to speed up the test process?¶
Warning
Beware, when talking about speed a lot a thing have to be taken in consideration. Indeed here is a non exaustive list of things which fluctuate testing speed.
- Bandwidth.
- DNS Server response time.
- CPU.
- ISP blocking a big amount of connection to the outside world.
- Our databases management (do not apply for MySQL and MariaDB format).
- Amount of data to test.
- …
I have multiple CPU¶
Simply use the -m | --multiprocess
argument to activate
the usage of multiple processes.
You should in addition to the -m
specify the -p | --processes
argument.
If -p | --processes
is avoided, the script will use the number of
available CPU cores.
You might therefore which to specify the number of simultaneous processes to be used, otherwise your will be “unable” to use the computer/server for other things while running PyFunceble as all of your CPU threads is used by PyFunceble.
Note
A good number for -p
is your number of CPU_cores -1
, to leave room for orther processes to work.
Unless you have a dedicated installation for this work.
Inside a Unix based system, you can use this code snippet to see how many CPU and cores you have.
$: lscpu | grep -E '^Thread|^Core|^Socket|^CPU\('
or
$: nproc --ignore=1
This will count the number of CPU threads subtracted 1 to use for DB,
SQL. If you runs PyFunceble on your workstation you might subtract 2
threads, or you computer will be pretty "dead"
See also ``man nproc`` or ``nproc --help``
Warning
DO NOT try to exceed your total number of CPU cores with (-p | --processes
),
if you want to keep your machine somehow alive and healthy.
I do not have multiple CPU¶
In case you only have a single core, you should disable the usage of
the WHOIS lookup by adding the --no-whois
to your command line
or switching the value of no_whois
to True
in your
configuration file.
As example:
$ PyFunceble --no-whois -d example.net
This action will speed up the script because it only
use the equivalent of nslookup
and the
HTTP status code
to determine the availability status.
Warning
PyFunceble request the WHOIS record in order to avoid specific false
positive cases.
If the usage of WHOIS request is disabled, all domains which are still
registered but not assigned to an IP address, would be flagged as
INACTIVE
.
It’s not a problem if you keep/use the database system because the domain will be retested over time. But please keep in mind, that without the database system, the accuracy of the result is not guaranteed.
Known issues¶
This is the list of issues which are not or will not be fixed (yet…).
- Under Travis CI the coloration may not be shown.
- Under GitLab CI/CD the coloration may not be shown.
Ubuntu 20.04.1 LTS Focal¶
In Ubunto release 20.04 they have removed a package name
libffi.so.6
and upgraded it with version libffi.so.7
This means PyFunceble will trow an error like:
ImportError: libffi.so.6: cannot open shared object file: No such file or directory
The fix for this issue is then rather simple, add a softlink between the
versions with ln -s
The complete line in my case was:
sudo ln -s /usr/lib/x86_64-linux-gnu/libffi.so.7 /usr/lib/x86_64-linux-gnu/libffi.so.6
However, the right way to do this is by first locate where your’s
libffi.so.7
is by
find /usr/lib/ -type f -iname 'libffi.so.*'
and then apply the
softlink to libffi.so.7
PyFunceble v3.2.x¶
Changed in version 3.2.x.
Deprecated since version 4.0.0.a1.
When you are using the HTTP status code module you might experience the
following error corsed by urllib3
HTTPSConnectionPool(host='pyfunceble-not-resolved', port=443
Workaround: Enable the Cert check verify-ssl-certificate
Discovered an issue?¶
Want to talk with @funilrys about it? Contact @funilrys on Keybase.
Want to make it public? Fill out a new issue.
Don’t want to fill out an issue on GitHub? Let’s discuss it on our issues team on Keybase.
Need help?¶
Do you need help with the usage of PyFunceble? We can help!
Want to talk with @funilrys about it? Contact @funilrys on Keybase.
Otherwise, let’s discuss it on our support team on Keybase!
Need information?¶
You can get information and discuss about PyFunceble on our main Keybase team. @Funilrys (me) will do his best to keep it up-to-date with some information about the development and other news about PyFunceble.
If you need more information, the support team or issues team, is the place to ask!
Dead-Hosts¶
Why Dead-Hosts?¶
We are conscient that PyFunceble may run for days. We would therefore offer you, to have your list. Request for Dead-Hosts testing.
How do Dead-Hosts work?¶
Dead-Hosts is like a wrapper of PyFunceble. Indeed, we use Travis CI containers in order to test lists with PyFunceble.
Once a list is set up inside our infrastructure, PyFunceble will
test the list regularly and the Dead-Hosts infrastructure will produce a
clean.list
file which represents the list of domains/IP/URL
which remains or became ACTIVE
.
In addition, if needed, we can set up a list of GitHub username to @ping once a new test is finished.
Do you want your list to be tested at Dead-Hosts ? You can request it !
History of Dead-Hosts¶
The project started on 3rd March 2017 at funilrys/dead-hosts.
The original idea was to test Funceble against hosts file in order to find bugs inside Funceble but also letting me (@funilrys) have a shorter hosts file.
On 23rd January 2018, I (@funilrys) decided to shut funilrys/dead-hosts down, as it became impossible to test all members of the project without having to wait for weeks. I then decided it was time to move on to another level.
That was the beginning of Dead-Hosts.
Today Dead-Hosts’s is objective to provide project and lists to maintainers or individuals, with the help of PyFunceble, to provide more information about their favourite project/list or domains, IP or URL.
Installation¶
EOL of any version 3.x¶
Development of PyFunceble version 3.x have reached the End Of Life. This means any errors recurring in any version below PyFunceble version 4.0.0 will no longer be fixed, but we will still be here to help you with a number of workarounds that might be required to have these releases working for you, until the final stable release of PyFunceble version 4.0.0.
If you are new to PyFunceble, the team will recommend you to start by using and installing the pre-release of PyFunceble 4.0.0
You can read more about how this is done in the docs at: https://pyfunceble.readthedocs.io/en/dev/installation/index.html#development-version
You should know that if you are going to install version 4.0.0 through pip, you should use one of the following lines. Note the –pre flag
pip3 install --user --pre pyfunceble-dev
python3.9 -m pip install --user --pre pyfunceble-dev
In case you would like to install PyFunceble system-wide, you have to omit
the –user flag from the lines above, and you should probably be using
your sudo account to do this, In that case don’t forget the -H
flag…
Install PyFunceble-dev 4.x systemwide with sudo.
sudo -H pip3 install --user --pre pyfunceble-dev
sudo -H python3.9 -m pip install --user --pre pyfunceble-dev
We will also like to point you attention to the requirement section of: https://pyfunceble.readthedocs.io/en/dev/installation/index.html#requirements, where there is a pending PR (#196), which will correct the required python version to python version 3.7
Requirements¶
Here is the list of requirements:
- Python 3.6.11+
alembic
colorama
cryptography
dnspython
domain2idna
inflection
PyMySQL
python-box
python-dotenv
PyYAML
requests
setuptools
sqlalchemy
Python 3.6.11+¶
The specification 3.6.11+
is because we test PyFunceble (daily)
in all (3.x
) versions from 3.6.11
.
Otherwise, more semantically, PyFunceble is written for all Python 3.6+ version.
alembic
¶
As we want to automate database (MySQL/MariaDB) schema migration, we
chose alembic
for the job.
colorama
¶
As we use some coloration, colorama
is required.
cryptography
¶
As we use some cryptography algorithm for message hashing as example,
cryptography
is required.
dnspython
¶
As we use it to do the DNS lookups, dnspython
is required.
domain2idna
¶
As we propose the conversion of domains to IDNA, domain2idna
is required.
Note
domain2idna
is maintained and developed by
Nissar Chababy (@funilrys), the developer of PyFunceble.
Its source code can be found on GitHub.
inflection
¶
We don’t necessarily want to reinvent the wheel while generating the (database) tables name from our schama descriptions. This tool is a relief!
PyMySQL
¶
As we propose the MariaDB
or MySQL
database types,
PyMySQL
is required.
python-box
¶
As we use python-box
for a better code access to the configuration, it is required.
python-dotenv
¶
As we are able to load dotenv files, python-dotenv
is required.
PyYAML
¶
As our configuration file is written in .yaml
, PyYAML
is required.
requests
¶
As we use requests
multiple times to communicate with webservices, requests
is required.
setuptools
¶
As we use install_requires=xx
inside our setup.py
, setuptools
is required.
sqlalchemy
¶
As we don’t want to maintain several RAW SQL files, we use sqlalchemy
for the database communication and manipulation.
Stable version¶
Using pip
¶
From PyPi¶
$ pip3 install --user PyFunceble
Note
We recommend the --user
flag which installs the required dependencies at the user level. More information about it can be found on pip documentation.
Warning
We do not recommend the --user
flag when using PyFunceble
into containers like - for example - Travis CI.
From GitHub¶
$ pip3 install --user git+https://github.com/funilrys/PyFunceble.git@master#egg=PyFunceble
Note
We recommend the --user
flag which installs the required dependencies at the user level. More information about it can be found on pip documentation.
Warning
We do not recommend the --user
flag when using PyFunceble
into containers like - for example - Travis CI.
Using the AUR (for Arch Linux users)¶
The package can be found at https://aur.archlinux.org/packages/pyfunceble/.
With makepkg¶
$ wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=pyfunceble
$ makepkg
$ sudo pacman -U pyfunceble*.tar.xz
With your favorite AUR helper¶
Warning
We do not recommend any AUR helper but keep in mind that some AUR helpers are “better” than other. For more information about your current (or any other) AUR helper please report to the ArchWiki page.
$ yourFavoriteAurHelper -S pyfunceble
Using docker (hub)¶
The image description can be found at https://hub.docker.com/r/pyfunceble/pyfunceble
$ docker pull pyfunceble/pyfunceble
Using conda
¶
Our repository is located at https://anaconda.org/pyfunceble/pyfunceble
conda install -c conda-forge -c pyfunceble pyfunceble=3
Pure Python method¶
Execute the following and enjoy PyFunceble!
$ git clone https://github.com/funilrys/PyFunceble.git
$ cd PyFunceble
$ python3 setup.py test
$ python3 setup.py install # Avoid this if you want to uninstall one day.
$ pip3 install --user -e .
Note
We recommend the --user
flag which installs the required dependencies at the user level. More information about it can be found on pip documentation.
Warning
We do not recommend the --user
flag when using PyFunceble
into containers like - for example - Travis CI.
Development version¶
The development version of PyFunceble represents the dev
branch.
It’s intended for the development of next features
but is always at a usable state.
Indeed, We should not push to the dev
branch until
we are sure that the new commit does not break or introduce
critical issue under PyFunceble.
For development¶
Execute the following and let’s hack PyFunceble!
Note
We highly recommend you to develop PyFunceble under a virtualenv
.
$ git clone https://github.com/funilrys/PyFunceble.git
$ cd PyFunceble
$ git checkout dev
$ virtualenv venv
$ source venv/bin/activate
$ pip3 install -e .
Note
After installing with:
$ source venv/bin/activate
$ pip3 install -e .
- you only need to update the repository.
- you don’t have to rerun the
pip
command.
For usage¶
Using pip
¶
Execute one of the following and enjoy PyFunceble!
From PyPi¶
$ pip3 install --user PyFunceble-dev
Note
We recommend the --user
flag which installs the required dependencies at the user level. More information about it can be found on pip documentation.
Warning
We do not recommend the --user
flag when using PyFunceble
into containers like - for example - Travis CI.
From GitHub¶
$ pip3 install --user git+https://github.com/funilrys/PyFunceble.git@dev#egg=PyFunceble
Note
We recommend the --user
flag which installs the required dependencies at the user level. More information about it can be found on pip documentation.
Warning
We do not recommend the --user
flag when using PyFunceble
into containers like - for example - Travis CI.
Using the AUR (for Arch Linux users)¶
The package can be found at https://aur.archlinux.org/packages/pyfunceble-dev/.
With makepkg¶
$ wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=pyfunceble-dev
$ makepkg
$ sudo pacman -U pyfunceble-dev*.tar.xz
With your favorite AUR helper¶
Warning
We do not recommend any AUR helper but keep in mind that some AUR helpers are “better” than other. For more information about your current (or any other) AUR helper please report to the ArchWiki page.
$ yourFavoriteAurHelper -S pyfunceble-dev
Using docker (hub)¶
The image description can be found at https://hub.docker.com/r/pyfunceble/pyfunceble-dev
$ docker pull pyfunceble/pyfunceble-dev
Using conda
¶
Our repository is located at https://anaconda.org/pyfunceble/pyfunceble-dev
conda install -c conda-forge -c pyfunceble pyfunceble-dev=3
Pure Python method¶
Execute the following and enjoy PyFunceble!
$ git clone https://github.com/funilrys/PyFunceble.git
$ cd PyFunceble && git checkout dev
$ python3 setup.py test
$ python3 setup.py install # Avoid this if you want to uninstall one day.
$ pip3 install --user -e .
Note
We recommend the --user
flag which installs the required dependencies at the user level. More information about it can be found on pip documentation.
Warning
We do not recommend the --user
flag when using PyFunceble
into containers like - for example - Travis CI.
Update¶
Stable version¶
Using pip
¶
IMPORTANT INFORMATION for master >= 3.3.0
¶
When you update from version before 3.3.0
to newer release, there will be made a SQL
conversion of the databases table layout.
This can take up a sagnificent amount of time
based on the size of the Database.
The table layout converion is being made to:
1. Minimize the total size
2. Optimize the sql flow and minimizing the
read/write to save disk I/O
3. Minimize the number of SQL queries being made
It have been seen taking days to convert these
tables on very large installations.
From PyPi¶
$ pip3 install --user --upgrade PyFunceble
Note
We recommend the --user
flag which installs the required dependencies at the user level. More information about it can be found on pip documentation.
Warning
We do not recommend the --user
flag when using PyFunceble
into containers like - for example - Travis CI.
From GitHub¶
$ pip3 install --user --upgrade git+https://github.com/funilrys/PyFunceble.git@master#egg=PyFunceble
Note
We recommend the --user
flag which installs the required dependencies at the user level. More information about it can be found on pip documentation.
Warning
We do not recommend the --user
flag when using PyFunceble
into containers like - for example - Travis CI.
Using the AUR (for Arch Linux users)¶
With makepkg¶
$ wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=python-pyfunceble
$ makepkg
$ sudo pacman -U python-pyfunceble*.tar.xz
With your favorite AUR helper¶
Warning
We do not recommend any AUR helper but keep in mind that some AUR helpers are “better” than other. For more information about your current (or any other) AUR helper please report to the ArchWiki page.
$ yourFavoriteAurHelper -Syu python-pyfunceble
Using docker (hub)¶
The image description can be found at https://hub.docker.com/r/pyfunceble/pyfunceble
$ docker pull pyfunceble/pyfunceble
Using conda
¶
Our repository is located at https://anaconda.org/pyfunceble/pyfunceble
conda update -c conda-forge -c pyfunceble pyfunceble
Pure Python method¶
Execute the following and enjoy PyFunceble!
$ cd PyFunceble
$ git checkout master && git fetch origin && git merge origin/master
$ python3 setup.py test
$ python3 setup.py install # Avoid this if you want to uninstall one day.
$ pip3 install --user --upgrade -e .
Note
We recommend the --user
flag which installs the required dependencies at the user level. More information about it can be found on pip documentation.
Warning
We do not recommend the --user
flag when using PyFunceble
into containers like - for example - Travis CI.
Development version¶
IMPORTANT INFORMATION for dev >= 3.2.11
¶
When you update from dev@<=3.2.10 or master@<=3.2.2
to newer release, there will be made a SQL
conversion of the databases table layout.
This can take up a sagnificent amount of time
based on the size of the Database.
The table layout converion is being made to:
1. Minimize the total size
2. Optimize the sql flow and minimizing the
read/write to save disk I/O
3. Minimize the number of SQL queries being made
It have been seen taking days to convert these
tables on very large installations.
For development¶
$ cd PyFunceble && git checkout dev
$ git fetch origin && git merge origin/dev
Note
As you previously installed with
$ . venv/bin/activate && pip3 install -e .
Only code/repository update is required.
For usage¶
Using pip
¶
From PyPi¶
$ pip3 install --user --upgrade PyFunceble-dev
Note
We recommend the --user
flag which installs the required dependencies at the user level. More information about it can be found on pip documentation.
Warning
We do not recommend the --user
flag when using PyFunceble
into containers like - for example - Travis CI.
From GitHub¶
$ pip3 install --user --upgrade git+https://github.com/funilrys/PyFunceble.git@dev#egg=PyFunceble
Note
We recommend the --user
flag which installs the required dependencies at the user level. More information about it can be found on pip documentation.
Warning
We do not recommend the --user
flag when using PyFunceble
into containers like - for example - Travis CI.
Using the AUR (for Arch Linux users)¶
With makepkg¶
$ wget https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=python-pyfunceble-dev
$ makepkg
$ sudo pacman -U python-pyfunceble-dev*.tar.xz
With your favorite AUR helper¶
Warning
We do not recommend any AUR helper but keep in mind that some AUR helpers are “better” than other. For more information about your current (or any other) AUR helper please report to the ArchWiki page.
$ yourFavoriteAurHelper -Syu python-pyfunceble-dev
Using docker (hub)¶
The image description can be found at https://hub.docker.com/r/pyfunceble/pyfunceble-dev
$ docker pull pyfunceble/pyfunceble-dev
Using conda
¶
Our repository is located at https://anaconda.org/pyfunceble/pyfunceble-dev
conda update -c conda-forge -c pyfunceble pyfunceble-dev
Pure Python method¶
Execute the following and enjoy PyFunceble!
$ cd PyFunceble && git checkout dev
$ git fetch origin && git merge origin/dev
$ python3 setup.py test
$ python3 setup.py install # Avoid this if you want to uninstall one day.
$ pip3 install --user --upgrade -e .
Note
We recommend the --user
flag which installs the required dependencies at the user level. More information about it can be found on pip documentation.
Warning
We do not recommend the --user
flag when using PyFunceble
into containers like - for example - Travis CI.
Configuration¶
Location¶
Problematics¶
- How can we create a more efficient way to work with configuration?
- How can we make the configuration file(s) available globally so that PyFunceble can be run everywhere in the user workspace?
To answer those problematics, we moved the configuration location elsewhere in the place where most users expect to have their configuration file(s).
Repository clone¶
If you cloned the repository and you’re trying to test from a cloned directory (the one with for example CONTRIBUTING.md
) we consider the configuration directory as the current one.
Note
This behavior allows us to not modify the way we develop PyFunceble.
Travis CI¶
Under Travis CI, we search or initiate the configuration at the directory we are currently located.
Warning
We don’t care about the distribution, as long as the TRAVIS_BUILD_DIR
environment variable is set, we search or initiate the configuration in the current directory.
Note
If you want to force the directory where we should work, you can initiate the PYFUNCEBLE_CONFIG_DIR
environment variable with the path where we should work.
GitLab CI/CD¶
Under GitLab CI/CD, we search or initiate the configuration at the directory we are currently located.
Warning
We don’t care about the distribution, as long as the PROJECT_CI
and GITLAB_CI
environment variables are set,
we search or initiate the configuration in the current directory.
Note
If you want to force the directory where we should work, you can initiate the PYFUNCEBLE_CONFIG_DIR
environment variable with the path where we should work.
Linux and MacOS (Darwin Kernel)¶
Under Linux and MacOS, we look for the following directories in their order. If any configuration directory is found, the system proposes you to install them automatically on the first configuration file.
~/.config/PyFunceble
~/.PyFunceble
${PWD}
Note
If the parent directory does not exist, we move to the next possible location in the given order.
This means that under most Linux distributions and MacOS versions, we consider ~/.config/PyFunceble
as the configuration location.
But if the ~/.config
directory does not exist, we fallback to ~/.PyFunceble
as the configuration location.
Windows¶
As mentioned by Pat Altimore’s Blog, we used the Per user configuration files synchronized across domain joined machines via Active Directory Roaming
section in order to understand what we should do to find our configuration directory.
Under Windows, we look for the following directories in their order. If any configuration directory is found, the system proposes you to install them automatically on the first configuration file.
%APPDATA%\PyFunceble
(environnement variable)%CD%
Note
%CD%
is explained by the set command (set /?
):
%CD% - expands to the current directory string.
Note
If the parent directory does not exist, we move to the next possible location in the given order.
This means that under most Windows versions, we consider %APPDATA%\PyFunceble
- also know as C:\Users\userName\AppData\Roaming\PyFunceble
- as the configuration location.
But if the %APPDATA%
directory does not exist, we fall back to the current directory as the configuration location.
Custom location¶
Sometimes, you may find yourself in a position where you absolutely do not want PyFunceble to use its default configuration location.
For that reason, if you set your desired configuration location along with the PYFUNCEBLE_CONFIG_DIR
environment variable, we take that location as the (default) configuration location.
Autoconfiguration¶
Sometimes, you may find yourself in a position that you do not or you can’t answer the question which asks you if you would like to install the default configuration file.
For that reason, if you set PYFUNCEBLE_AUTO_CONFIGURATION
as an environment variable with what you want an assignment, we do not ask that question. We simply do what we have to do without asking anything.
Indexes¶
This page will try to detail each configuration available into .PyFunceble.yaml
along with the location of where we are looking for the configuration file.
adblock
¶
Type:
boolean
Default value:
False
Description: Enable / disable the adblock format decoding.
Note
If this index is set to True
, every time we read a given file, we try to extract the elements that are present.
We basically only decode the adblock format.
Note
If this index is set to False
, every time we read a given file, we will consider one line as an element to test.
aggressive
¶
Type:
boolean
Default value:
False
Description: Enable / disable some aggressive settings.
Warning
This option is available but please keep in mind that the some settings which it enable are experimental.
auto_continue
¶
Type:
boolean
Default value:
True
Description: Enable / disable the auto continue system.
command
¶
Type:
string
Default value:
""
Description: Set the command to run before each commit (except the final one).
Note
The parsed command is called only if auto_continue
and ci
are set to True
.
command_before_end
¶
Type:
string
Default value:
""
Description: Set the command to run before the final commit.
Note
The parsed command is called only if auto_continue
and ci
are set to True
.
Note
Understand by final commit the commit which will deliver the last element we have to test.
cooldow_time
¶
Type::
float
Default value:
null
Description: Set the cooldown time to apply between each test.
Note
This index take only effect from the CLI. Not from the API.
custom_ip
¶
Type:
string
Default value:
"0.0.0.0"
Description: Set the custom IP to use when we generate a line in the hosts file format.
Note
This index has no effect if generate_hosts
is set to False
.
days_between_db_retest
¶
Type:
integer
Default value:
1
Description: Set the number of day(s) between each retest of the
INACTIVE
andINVALID
elements which are present intoinactive_db.json
.
Note
This index has no effect if inactive_database
is set to False
.
days_between_inactive_db_clean
¶
Type:
integer
Default value:
28
Description: Set the numbers of days since the introduction of a subject into
inactive-db.json
for it to qualifies for deletion.
Note
This index has no effect if inactive_database
is set to False
.
db_type
¶
Type:
string
Default value:
json
Available values:
json
,mariadb
,mysql
Description: Set the database type to use everytime we create a database.
Note
This feature is applied to the following subsystems:
- Autocontinue physically located (JSON) at
output/continue.json
. - InactiveDB physically located (JSON) at
[config_dir]/inactive_db.json
. - Mining physically located (JSON) at
[config_dir]/mining.json
. - WhoisDB physically located (JSON) at
[config_dir]/whois.json
.
debug
¶
Type:
boolean
Default value:
False
Description: Enable / disable the generation of debug file(s).
Note
This index has no effect if logs
is set to False
Warning
Do not touch this index unless you a have good reason to.
Warning
Do not touch this index unless you have been invited to.
dns_lookup_over_tcp
¶
Type:
boolean
Default value:
False
Description: Make all DNS lookup with TCP instead of UDP.
dns_server
¶
Type:
None
orlist
Default value:
null
Description: Set the DNS server(s) to work with.
Note
When a list is given the following format is expected.
dns_server:
- dns1.example.org
- dns2.example.org
Note
You can specify a port number to use to the DNS server if needed.
As example:
- 127.0.1.53:5353
Warning
We expect a DNS server(s). If no DNS server(s) is given. You’ll almost for certain get all
results as INACTIVE
This could happens in case you use --dns -f
filter
¶
Type:
string
Default value:
""
Description: Set the element to filter.
Note
This index should be initiated with a regular expression.
generate_complements
¶
Type:
boolean
Default value:
False
Description: Enable / disable the generation and test of the complements.
Note
A complement is for example example.org
if www.example.org
is given and vice-versa.
generate_hosts
¶
Type:
boolean
Default value:
True
Description: Enable / disable the generation of the hosts file(s).
generate_json
¶
Type:
boolean
Default value:
False
Description: Enable / disable the generation of the JSON file(s).
header_printed
¶
Type:
boolean
Default value:
False
Description: Say to the system if the header has been already printed or not.
Warning
Do not touch this index unless you have a good reason to.
hierarchical_sorting
¶
Type:
boolean
Default value:
False
Description: Say to the system if we have to sort the list and the outputs in a hierarchical order.
iana_whois_server
¶
Type:
string
Default value:
whois.iana.org
Description: Set the server to call to get the
whois
referer of a given element.
Note
This index is only used when generating the iana-domains-db.json
file.
Warning
Do not touch this index unless you a have good reason to.
idna_conversion
¶
Type:
boolean
Default value:
False
Description: Tell the system to convert all domains to IDNA before testing.
Note
We use domain2idna for the conversion.
inactive_database
¶
Type:
boolean
Default value:
True
Description: Enable / Disable the usage of a database to store the
INACTIVE
andINVALID
element to retest overtime.
less
¶
Type:
boolean
Default value:
True
Description: Enable / Disable the output of every information of screen.
local
¶
Type:
boolean
Default value:
False
Description: Enable / Disable the execution of the test(s) in a local or private network.
logs
¶
Type:
boolean
Default value:
True
Description: Enable / Disable the output of all logs.
maximal_processes
¶
Type:
integer
Default value:
25
Description: Set the number of maximal simultaneous processes to use/create/run.
Warning
If you omit the --processes
argument,
we overwrite the default with the number of available CPU.
mining
¶
Type:
boolean
Default value:
True
Description: Enable / Disable the mining subsystem.
multiprocess
¶
Type:
boolean
Default value:
False
Description: Enable / Disable the usage of multiple processes instead of the default single process.
multiprocess_merging_mode
¶
Type:
string
Default value:
end
Available values:
end
,live
Description: Set the multiprocess merging mode.
Note
With the end
value, the merging of cross process data is made at the very end of the current instance.
Note
With the live
value, the merging of cross process data is made after the processing of the maximal number of process.
Which means that if you allow 5 processes, we will run 5 tests, merge, run 5 tests, merge and so on until the end.
no_files
¶
Type:
boolean
Default value:
False
Description: Enable / Disable the generation of any file(s).
no_special
¶
Type:
boolean
Default value:
False
Description: Enable / Disable the usage of the SPECIAL rules - which are discribes in the source column section.
no_whois
¶
Type:
boolean
Default value:
False
Description: Enable / Disable the usage of
whois
in the tests.
plain_list_domain
¶
Type:
boolean
Default value:
False
Description: Enable / Disable the generation of the plain list of elements sorted by statuses.
Warning
Do not touch this index unless you a have good reason to.
print_dots
¶
Type:
boolean
Default value:
False
Description: Enable / Disable the printing of dots (
.
) for the skipped subjects.
Note
The idea is to not given the impression that we hang. Because most of the time, we don’t.
quiet
¶
Type:
boolean
Default value:
False
Description: Enable / Disable the generation of output on the screen.
referer
¶
Type:
string
Default value:
""
Description: Set the referer of the element that is currently under test.
Warning
Do not touch this index unless you a have good reason to.
reputation
¶
Type:
boolean
Default value:
False
Description: Enable / disable the reputation (only) testing.
Warning
If this index is set to True
, we ONLY check for reputation, not availability nor syntax.
rpz
¶
Type:
boolean
Default value:
False
Description: Enable / Disable the test of RPZ policies when testing for syntax.
Warning
This is not taken into consideration if syntax
is set to False
.
shadow_file
¶
Type:
boolean
Default value:
False
Description: Enable / Disable the usage and generation of a shadow file before a the test of a file.
Note
The shadow file, will just contain the actual list of subjects to test.
show_execution_time
¶
Type:
boolean
Default value:
False
Description: Enable / disable the output of the execution time.
show_percentage
¶
Type:
boolean
Default value:
True
Description: Enable / disable the output of the percentage of each status.
simple
¶
Type:
boolean
Default value:
False
Description: Enable / disable the simple output mode.
Note
If this index is set to True
, the system will only return the result inf format: tested.element STATUS
.
split
¶
Type:
boolean
Default value:
True
Description: Enable / disable the split of the results files.
Note
Understand with “results files” the mirror of what is shown on screen.
store_whois_record
¶
Type:
boolean
Default value:
False
Description: Enable / disable the storage of the WHOIS record into the WHOIS DB.
Warning
This does not disable the WHOIS DB functionality. It just not storing the full
WHOIS
reply in the database.
syntax
¶
Type:
boolean
Default value:
False
Description: Enable / disable the syntax (only) testing.
Warning
If this index is set to True
, we ONLY check for syntax, not availability nor reputation.
timeout
¶
Type:
integer
Default value:
5
Description: Set the timeout to apply everytime it’s possible to set one.
ci
¶
Type:
boolean
Default value:
False
Description: Enable / disable the CI autosaving system.
Warning
Do not activate this index unless you are using PyFunceble under a supported CI environment/platform.
ci_autosave_commit
¶
Type:
string
Default value:
"PyFunceble - AutoSave"
Description: Set the default commit message we want to use when have to commit (save) but our tests are not yet completed.
ci_autosave_final_commit
¶
Type:
string
Default value:
"PyFunceble - Results"
Description: Set the default final commit message we want to use when we all tests are finished.
ci_autosave_minutes
¶
Type:
integer
Default value:
15
Description: Set the minimum of minutes we have to run before to automatically save our test results.
Note
As many services are setting a rate limit per IP, it’s a good idea to set this value between 1
and 15
minutes.
ci_distribution_branch
¶
Type:
string
Default value:
master
Description: Set the git branch where we are going to push our results.
Note
The difference between this and ci_branch
is the fact
that this branch will get the result only when the test were finished
under the given ci_branch
.
As example, this allow us to have 2 branches:
proceessing
(ci branch), for the tests with PyFunceble.master
(ci distribution branch), for the distribution of the results of PyFunceble.
ci_branch
¶
Type:
string
Default value:
master
Description: Set the git branch where we are going to push our results.
unified
¶
Type:
boolean
Default value:
False
Description: Enable / Disable the generation of the unified results.
Note
This index has no effect if split
is set to True
.
use_reputation_data
¶
Type:
boolean
Default value:
False
Description: Enable / Disable the usage of reputation data while testing the availability of a given subject.
Warning
This only have an effect when used along with the availability test.
verify_ssl_certificate
¶
Type:
boolean
Default value:
False
Description: Enable / Disable the verification of the SSL/TLS certificate when testing for URL.
Warning
If you set this index to True
, you may get false positive result.
Indeed if the certificate is not registered to the CA or is simply invalid and the domain is still alive, you will always get INACTIVE
as output.
whois_database
¶
Type:
boolean
Default value:
True
Description: Enable / Disable the usage of the whois database to avoid/bypass whois server requests rate limit.
wildcard
¶
Type:
boolean
Default value:
False
Description: Enable / Disable the test of wildcards when testing for syntax.
Warning
This is not taken into consideration if syntax
is set to False
.
user_agent
¶
Type:
dict
Description: Configures the user agent.
user_agent[browser]
¶
Type:
string
Default value:
chrome
Description: Sets the browser to get the get the latest user agent from. Available values:
chrome
,edge
,firefox
,ie
,opera
,safari
Warning
This option is not taken in consideration if user_agent[custom]
is
not set to null
.
user_agent[platform]
¶
Type:
string
Default value:
linux
Description: Sets the platform to get the get the latest user agent for. Available values:
linux
,macosx
,win10
Warning
This option is not taken in consideration if user_agent[custom]
is
not set to null
.
user_agent[custom]
¶
Type:
string
Default value:
null
Description: Sets the user agent to use.
Warning
Setting this index will overwrite the choices made into
user_agent[platform]
and user_agent[browser]
.
outputs
¶
Type:
dict
Description: Set the needed output tree/names.
Warning
If you choose to change anything please consider deleting our output/
directory and the dir_structure*.json
files.
outputs[default_files]
¶
Type:
dict
Description: Set the default name of some important files.
outputs[default_files][dir_structure]
¶
Type:
string
Default value:
dir_structure.json
Description: Set the default filename of the file which has the structure to re-construct.
Note
This index has no influence with dir_structure_production.json
outputs[default_files][iana]
¶
Type:
string
Default value:
iana-domains-db.json
Description: Set the default filename of the file which has the formatted copy of the IANA root zone database.
outputs[default_files][inactive_db]
¶
Type:
string
Default value:
inactive_db.json
Description: Set the default filename of the file which will save the list of elements to retest overtime.
outputs[default_files][results]
¶
Type:
string
Default value:
results.txt
Description: Set the default filename of the file which will save the formatted copy of the public suffix database.
outputs[default_files][public_suffix]
¶
Type:
string
Default value:
public-suffix.json
Description: Set the default filename of the file which will save the mirror of what is shown on screen.
outputs[default_files][mining]
¶
Type:
string
Default value:
mining.json
Description: Set the default filename of the file which will save the temporary list of mined subject to test.
outputs[default_files][whois_db]
¶
Type:
string
Default value:
whois_db.json
Description: Set the default filename of the file which will save the whois information for caching.
outputs[domains]
¶
Type:
dict
Description: Set the default name of some important files related to the
plain_list_domain
index.
outputs[domains][directory]
¶
Type:
string
Default value:
domains/
Description: Set the default directory where we have to save the plain list of elements for each status.
outputs[domains][filename]
¶
Type:
string
Default value:
list
Description: Set the default filename of the file which will save the plain list of elements.
outputs[hosts]
¶
Type:dict
Description: Set the default name of some important files related to the
generate_hosts
index.
outputs[hosts][directory]
¶
Type:
string
Default value:
hosts/
Description: Set the default directory where we have to save the hosts files of the elements for each status.
outputs[hosts][filename]
¶
Type:
string
Default value:
hosts
Description: Set the default filename of the file which will save the hosts files of the elements.
outputs[json]
¶
Type:dict
Description: Set the default name of some important files related to the
generate_json
index.
outputs[json][directory]
¶
Type:
string
Default value:
json
Description: Set the default directory where we have to save the JSON files of the elements for each status.
outputs[json][filename]
¶
Type:
string
Default value:
dump.json
Description: Set the default filename of the file which will save the JSON files of the elements.
outputs[complements]
¶
Type:dict
Description: Set the default name of some important files/directories related to the
generate_complements
index.
outputs[complements][directory]
¶
Type:
string
Default value:
complements
Description: Set the default directory where we have to save the complements related files sorted by status.
outputs[analytic]
¶
Type:dict
Description: Set the default name of some important files and directories related to the
generate_hosts
index.
outputs[analytic][directories]
¶
Type:
dict
Description: Set the default name of some important directories related to the
http_codes[active]
index.
outputs[analytic][directories][parent]
¶
Type:
string
Default value:
Analytic/
Description: Set the default directory where we are going to put everything related to the HTTP analytic.
outputs[analytic][directories][potentially_down]
¶
Type:
string
Default value:
POTENTIALLY_INACTIVE/
Description: Set the default directory where we are going to put all potentially inactive data.
outputs[analytic][directories][potentially_up]
¶
Type:
string
Default value:
POTENTIALLY_INACTIVE/
Description: Set the default directory where we are going to put all potentially active data.
outputs[analytic][directories][up]
¶
Type:
string
Default value:
POTENTIALLY_INACTIVE/
Description: Set the default directory where we are going to put all active data.
outputs[analytic][directories][suspicious]
¶
Type:
string
Default value:
SUSPICIOUS/
Description: Set the default directory where we are going to put all suspicious data.
outputs[analytic][filenames]
¶
Type:
dict
Description: Set the default name of some important files related to the
http_codes[active]
index and the HTTP analytic subsystem.
outputs[analytic][filenames][potentially_down]
¶
Type:
string
Default value:
down_or_potentially_down
Description: Set the default filename where we are going to put all potentially inactive data.
outputs[analytic][filenames][potentially_up]
¶
Type:
string
Default value:
potentially_up
Description: Set the default filename where we are going to put all potentially active data.
outputs[analytic][filenames][up]
¶
Type:
string
Default value:
active_and_merged_in_results
Description: Set the default filename where we are going to put all active data.
outputs[analytic][filenames][suspicious]
¶
Type:
string
Default value:
suspicious_and_merged_in_results
Description: Set the default filename where we are going to put all suspicious data.
outputs[logs]
¶
Type:
dict
Description: Set the default name of some important files and directories related to the
logs
index.
outputs[logs][directories]
¶
Type:dict
Description: Set the default name of some important directories related to the
logs
index.
outputs[logs][directories][date_format]
¶
Type:
string
Default value:
date_format/
Description: Set the default directory where we are going to put everything related to the data when the dates are in the wrong format.
outputs[logs][directories][no_referer]
¶
Type:
string
Default value:
no_referer/
Description: Set the default directory where we are going to put everything related to the data when no referer is found.
outputs[logs][directories][parent]
¶
Type:
string
Default value:
no_referer/
Description: Set the default directory where we are going to put everything related to the data when no referer is found.
outputs[logs][directories][percentage]
¶
Type:
string
Default value:
percentage/
Description: Set the default directory where we are going to put everything related to percentages.
outputs[logs][directories][whois]
¶
Type:
string
Default value:
whois/
Description: Set the default directory where we are going to put everything related to whois data.
Note
This is the location of all files when the debug
index is set to True
.
outputs[logs][filenames]
¶
Type:
dict
Description: Set the default filenames of some important files related to the
logs
index.
outputs[logs][filenames][auto_continue]
¶
Type:
string
Default value:
continue.json
Description: Set the default filename where we are going to put the data related to the auto continue subsystem.
Note
This file is allocated if the auto_continue
is set to True
.
outputs[logs][filenames][execution_time]
¶
Type:
string
Default value:
execution.log
Description: Set the default filename where we are going to put the data related to the execution time.
Note
This file is allocated if the show_execution_time
is set to True
.
outputs[logs][filenames][percentage]
¶
Type:
string
Default value:
percentage.txt
Description: Set the default filename where we are going to put the data related to the percentage.
Note
This file is allocated if the show_percentage
is set to True
.
outputs[main]
¶
Type:
string
Default value:
""
Description: Set the default location where we have to generate the
parent_directory
directory and its dependencies.
outputs[parent_directory]
¶
Type:
string
Default value:
output/
Description: Set the directory name of the parent directory which will contain all previously nouned directories.
status
¶
Type:
dict
Description: Set the needed, accepted and status name.
status[list]
¶
Type:
dict
Description: Set the needed and accepted status name.
Warning
All status should be in lowercase.
status[list][valid]
¶
Type:
list
Default value:
["valid","syntax_valid","valid_syntax"]
Description: Set the accepted
VALID
status.
Note
This status is only shown if the syntax
index is activated.
status[list][up]
¶
Type:
list
Default value:
["up","active"]
Description: Set the accepted
ACTIVE
status.
status[list][generic]
¶
Type:
list
Default value:
["generic"]
Description: Set the accepted
generic
status.
Note
This status is the one used to say the system that we have to print the complete information on the screen.
status[list][http_active]
¶
Type:
list
Default value:
["http_active"]
Description: Set the accepted status for the
outputs[analytic][filenames][up]
index.
status[list][down]
¶
Type:
list
Default value:
["down","inactive", "error"]
Description: Set the accepted status
INACTIVE
index.
status[list][invalid]
¶
Type:
list
Default value:
["ouch","invalid"]
Description: Set the accepted status
INVALID
index.
status[list][potentially_down]
¶
Type:
list
Default value:
["potentially_down", "potentially_inactive"]
Description: Set the accepted status for the
outputs[analytic][filenames][potentially_down]
index.
status[list][potentially_up]
¶
Type:
list
Default value:
["potentially_up", "potentially_active"]
Description: Set the accepted status for the
outputs[analytic][filenames][potentially_up]
index.
status[list][suspicious]
¶
Type:
list
Default value:
["strange", "hum", "suspicious"]
Description: Set the accepted status for the
outputs[analytic][filenames][suspicious]
index.
status[official]
¶
Type:
dict
Description: Set the official status name.
Note
Those status are the ones that are printed on the screen.
Warning
After any changes here please delete dir_structure.json
and the output/
directory.
status[official][up]
¶
Type:
string
Default value:
ACTIVE
Description: Set the returned status for the
ACTIVE
case.
status[official][down]
¶
Type:
string
Default value:
INACTIVE
Description: Set the returned status for the
INACTIVE
case.
status[official][invalid]
¶
Type:
string
Default value:
INVALID
Description: Set the returned status for the
INVALID
case.
status[official][valid]
¶
Type:
string
Default value:
VALID
Description: Set the returned status for the
VALID
case.
Note
This status is only shown if the syntax
index is activated.
http_codes
¶
Type:
dict
Description: Handle the interpretation of each status codes when we do and generate our analytic data.
http_codes[active]
¶
Type:
boolean
Default value:
True
Description: Enable / Disable the usage of the HTTP status code extraction.
http_codes[list]
¶
Type:
dict
Description: Categorize the http status code as mentioned in the documentation related to the
HTTP Code
column.
http_codes[list][up]
¶
Type:
list
- Default value:
- 100 - 101 - 200 - 201 - 202 - 203 - 204 - 205 - 206Description: List the HTTP status codes which are considered as
ACTIVE
.
http_codes[list][potentially_down]
¶
Type:
list
- Default value:
- 400 - 402 - 403 - 404 - 409 - 410 - 412 - 414 - 415 - 416Description: List the HTTP status code which are considered as
INACTIVE
orPOTENTIALLY_INACTIVE
.
http_codes[list][potentially_up]
¶
Type:
list
- Default value:
- 000 - 300 - 301 - 302 - 303 - 304 - 305 - 307 - 403 - 405 - 406 - 407 - 408 - 411 - 413 - 417 - 500 - 501 - 502 - 503 - 504 - 505Description: List the HTTP status code which are considered as
ACTIVE
orPOTENTIALLY_ACTIVE
.
links
¶
Type:
dict
Description: Set the list of links which can be used/called by the system when needed.
Note
The objective of this index is to avoid hardcoded links when the configuration file is readable.
links[api_date_format]
¶
Type:
string
Default value:
https://pyfunceble.funilrys.com/api/date-format
Description: Set the link to use when we share logs.
links[api_no_referer]
¶
Type:
string
Default value:
https://pyfunceble.funilrys.com/api/no-referer
Description: Set the link to use when we share logs.
links[config]
¶
Type:
string
Default value:
https://raw.githubusercontent.com/funilrys/PyFunceble/3.x/.PyFunceble_production.yaml
Description: Set the upstream link to the configuration file.
links[dir_structure]
¶
Type:
string
Default value:
https://raw.githubusercontent.com/funilrys/PyFunceble/3.x/dir_structure_production.json
Description: Set the upstream link to the directory structure dump file.
links[iana]
¶
Type:
string
Default value:
https://raw.githubusercontent.com/funilrys/PyFunceble/3.x/iana-domains-db.json
Description: Set the upstream link to the IANA zone file configuration file.
links[psl]
¶
Type:
string
Default value:
https://raw.githubusercontent.com/funilrys/PyFunceble/3.x/public-suffix.json
Description: Set the upstream link to the public suffix database file.
links[repo]
¶
Type:
string
Default value:
https://github.com/funilrys/PyFunceble
Description: Set the upstream link to the repository.
links[requirements]
¶
Type:
string
Default value:
https://raw.githubusercontent.com/funilrys/PyFunceble/3.x/requirements.txt
Description: Set the upstream link to the
requirements.txt
file.
Usage¶
From a terminal¶
--help
¶
Show the help message and exit.
-v
| --version
¶
Show the version of PyFunceble and exit.
Source¶
-d "something"
| --domain "something"
¶
Test one or more domains, separated by spaces.
Note
This argument takes 1 or more values.
As example:
$ PyFunceble -d example.org example.net
Note
When this option is used, no output files are generated.
-url "something"
| --url "something"
¶
Test one or more full URL, separated by spaces.
Note
When we test the availability of a URL, we (only) check the HTTP status code of the given URL.
Note
This argument takes 1 or more values.
As example:
$ PyFunceble -u https://example.org https://example.com
-f "something"
| --file "something"
¶
Read a local or remote (RAW link) file and test all domains inside it. If remote (RAW link) file is given, PyFunceble will download it, and test the content of the given RAW link as if it was a locally stored file.
Note
The system understands the following format:
- plain list of subjects.
- hosts file format.
-uf "something"
| --url-file "something"
¶
Read a local or remote (RAW link) file and test all (full) URLs inside it. If remote (RAW link) file is given, PyFunceble will download it, and test the content of the given RAW link as if it was a locally stored file.
Note
We consider one line as one URL to test.
Note
This argument test if a URL which is inside the given file is available. It ONLY tests full URLs.
As example:
$ PyFunceble -uf `https://raw.githubusercontent.com/funilrys/PyFunceble/3.x/examples/lists/url`
will download the given URL and test for its content assuming that each line represents a URL to test.
Warning
A test with this argument consists of the comparison of the status code. No WHOIS record will be requested nor DNS Lookup will be done.
Source filtering, decoding, conversion and expansion¶
-ad
| --adblock
¶
Switch the decoding of the adblock format.
Default value:
False
If this argument is activated the system will extract all domains or IP from the given adblock file.
--complements
¶
Switch the value of the generation and test of the complements. A complement is for example
example.org
ifwww.example.org
is given and vice-versa.Default value:
False
--filter "something"
¶
Domain to filter (regex).
Want to test all blogspot
from your list? This argument allows you to
do that!
Note
This argument should be a regex expression.
--idna
¶
Switch the value of the IDNA conversion.
Default value:
False
This argument allows the conversion of the domains using domain2idna
--mining
¶
Switch the value of the mining subsystem usage.
Default value:
False
Want to find domain or URL linked to a domain in your list? This argument will exactly do that.
Test control¶
-c
| --auto-continue
| --continue
¶
Switch the value of the auto continue mode.
Default value:
True
This argument activates or deactivates the auto-continue subsystem. Indeed, as we can automatically continue if the script has been stopped, this switch allows us to disable or enable the usage of that specific subsystem.
--cooldown-time
¶
Switch the value of the cool-down time to apply between each test.
Default value:
None
This argument applies a number of seconds to sleep before/between each test.
--http
¶
Switch the value of the usage of HTTP code.
Default value:
True
You don’t want to take the result of the HTTP code execution into consideration? This argument allows you to disable that!
Note
If activated the subsystem will bypass the HTTP status code extraction logic-representation.rst
--local
¶
Switch the value of the local network testing.
Default value:
False
Want to run a test over a local or private network? This argument will disable the limitation which does not apply to private networks.
-ns
| --no-special
¶
Switch the value of the usage of the SPECIAL rules.
Default value:
False
Don’t want to use/apply the SPECIAL rules - which are explained in the source column section? This argument disables them all.
-nw
| --no-whois
¶
Switch the value of the usage of WHOIS to test the domain’s status.
Default value:
False
Don’t want to use or take into consideration the results from whois
?
This argument allows you to disable it!
--reputation
¶
Switch the value of the reputation test mode.
Default value:
False
Warning
This will disable all other forms of test,
will check against AlienVault’s reputation data
and output its result into output/*/{MALICIOUS,SANE}/*
.
--rpz
¶
Switch the value of the RPZ policies test.
Default value:
False
--shadow-file
| --shadow
¶
Switch the value of the usage and generation of a shadow file before a file test starts.
A shadow file is a file which only contain the actual list of subject to test. For its generation we check each subjects as we normally do on-the-fly.
Default value:
False
Note
The shadow file, will just contain the actual list of subjects to test.
--syntax
¶
Switch the value of the syntax test mode.
Default value:
False
Warning
This will disable all other forms of test,
will validate the syntax of a given test subject,
and output its results in plain format into
output/domains/{VALID,INVALID}/list
-t "something"
| --timeout "something"
¶
Switch the value of the timeout in seconds.
Default value:
5
This argument will set the default timeout to apply everywhere it is possible to set a timeout.
--use-reputation-data
¶
Switch the value of the reputation data usage.
Default value:
False
Warning
This only affects when used along with the availability test.
-ua "something"
| --user-agent "something"
¶
Set the user-agent to use and set every time we interact with everything which is not the logs sharing system.
-vsc
| --verify-ssl-certificate
¶
Switch the value of the verification of the SSL/TLS certificate when testing for URL.
Default value:
False
Warning
If you activate the verification of the SSL/TLS certificate, you may get false-positive results.
Indeed if the certificate is not registered to the CA or is simply invalid and the domain is still alive, you will always get
INACTIVE
as output.
--wildcard
¶
Switch the value of the wildcards test.
Default value:
False
DNS (resolver) control¶
--dns
¶
Set one or more specific DNS servers to use during the test. Separated by spaces.
Default value:
Follow OS DNS
==>None
Warning
We expect a DNS server(s). If no DNS server(s) is given. You’ll almost for
certain get all results as INACTIVE
This could happen in case you use --dns -f
Note
You can specify a port number to use to the DNS server if needed.
As example:
- 127.0.1.53:5353
--dns-lookup-over-tcp
¶
Make all DNS queries through TCP instead of UDP.
Default value:
False
Databases¶
-db
| --database
¶
Switch the value of the usage of a database to store inactive domains of the currently tested list.
Default value:
True
This argument will disable or enable the usage of a database which saves all
INACTIVE
and INVALID
domain of the given file over time.
Note
The database is retested every x day(s), where x is the number set in
-dbr "something"
.
--database-type
¶
Tell us the type of database to use. You can choose between the following:
json
,mariadb
,mysql
.Default value:
json
This argument let us use different types of database.
Note
This feature is applied to the following subsystems:
- Autocontinue physically located (JSON) at
output/continue.json
. - InactiveDB physically located (JSON) at
[config_dir]/inactive_db.json
. - Mining physically located (JSON) at
[config_dir]/mining.json
. - WhoisDB physically located (JSON) at
[config_dir]/whois.json
.
-dbr "something"
| --days-between-db-retest "something"
¶
Set the numbers of days between each retest of domains present into the database of INACTIVE and INVALID domains.
Default value:
1
Note
This argument is only used if -db
or
inactive_database : true
(under .PyFunceble.yaml
) are
activated.
-dbc "something"
| --days-between-db-clean
¶
Set the numbers of days since the introduction of a subject into inactive-db.json for it to qualifies for deletion.
Default value:
28
Note
This argument is only used if -db
or
inactive_database : true
(under .PyFunceble.yaml
) are
activated.
-wdb
| --whois-database
¶
Switch the value of the usage of a database to store whois data to avoid whois servers rate limit.
Default value:
True
Output control¶
-a
| --all
¶
Output all available information on the screen.
Default value:
False
When activated:
Domain Status Expiration Date Source HTTP Code
----------------------------- ----------- ----------------- ---------- ----------
pyfunceble.readthedocs.io ACTIVE Unknown NSLOOKUP 302
When deactivated:
Domain Status HTTP Code
----------------------------- ----------- ----------
pyfunceble.readthedocs.io ACTIVE 302
--dots
¶
Output dots (
.
) tostdout
instead of giving the impression that we hang on.Default value:
False
-ex
| --execution
¶
Switch the default value of the execution time showing.
Default value:
False
Want to know the execution time of your test? Well, this argument will let you know!
--hierarchical
¶
Switch the value of the hierarchical sorting of the tested file.
Default value:
True
This argument will output the result listed in a hierarchical order.
-h
| --host
¶
Switch the value of the generation of hosts file.
Default value:
True
This argument will let the system know if it has to generate the hosts file version of each status.
-ip "something"
¶
Change the IP to print in the hosts files with the given one.
Default value:
0.0.0.0
--json
¶
Switch the value of the generation of the JSON formatted list of domains.
Default value:
False
--less
¶
When activated:
Domain Status HTTP Code
------------------------------------------------------ ----------- ----------
pyfunceble.readthedocs.io ACTIVE 302
When deactivated:
Domain Status Expiration Date Source HTTP Code
---------------------------- ----------- ----------------- ---------- ----------
pyfunceble.readthedocs.io ACTIVE Unknown NSLOOKUP 302
-nf
| --no-files
¶
Switch the value of the production of output files.
Default value:
False
Want to disable the production of the outputted files? This argument is for you!
-nl
| --no-logs
¶
Switch the value of the production of logs files in the case we encounter some errors.
Default value:
False
Don’t want any logs to go out of PyFunceble? This argument disables every log subsystem.
-nu
| --no-unified
¶
Switch the value of the production unified logs under the output directory.
Default value:
True
This argument disables the generation of result.txt.
--percentage
¶
Switch the value of the percentage output mode.
Default value:
True
This argument will disable or enable the generation of the percentage of each status.
--plain
¶
Switch the value of the generation of the plain list of domains.
Default value:
False:
Want to get a list with all domains for each status? The activation of this argument does the work while testing!
-q
| --quiet
¶
Run the script in quiet mode.
Default value:
False
You prefer to run a program silently? This argument is for you!
-s
| --simple
¶
Switch the value of the simple output mode.
Default value:
False
Want as less as possible data on screen? This argument returns as less as possible on screen!
--split
¶
Switch the value of the split of the generated output.
Default value:
True
Want to get the logs (copy of what you see on screen) on different files? This argument is suited to you!
--store-whois
¶
Switch the value of the WHOIS record storage in the WHOIS DB.
Default value:
False
The difference between False
or True
is whether
we are saving a full dump of the WHOIS reply into the database.
If you for some reason believes you need to fill up your database with a complete dump of the whois reply, this is the right value to switch on.
Warning
Before switching this value, you should read these comments carefully…
You can test the amount of data by running whois mypdns.org
from your Linux terminal, to see an example of what will be stored
in the database.
You’re hearby warned…
Multiprocessing¶
-m
| --multiprocess
¶
Switch the value of the usage of multiple processes.
Default value:
False
Want to speed up the test time? This argument will allow the usage of multiple processes for testing.
--multiprocess-merging-mode
¶
Sets the multiprocess merging mode. You can choose between the following live|ends.
Default value:
end
Note
With the end
value, the merging of cross-process data is made at
the very end of the current instance.
Note
With the live
value, the merging of cross-process data is made
after the processing of the maximal number of processes.
Which means that if you allow 5 processes, we will run 5 tests, merge, run 5 tests, merge and so on until the end.
-p
| --processes
¶
Set the number of simultaneous processes to use while using multiple processes.
Default value:
25
Warning
DO not try to exceed your number of CPU if you want to keep your machine somehow alive and healthy!!
Note
If omitted, the number of available CPU cores will be used instead.
CI / CD¶
--autosave-minutes
¶
Update the minimum of minutes before we start committing to upstream under the CI mode.
Default value:
15
--ci
¶
Switch the value of the CI mode.
Default value:
False
Note
If you combine this argument with the --quiet
argument, the test
will output a dotted line, where each dot (.
) represent one test
result or input which was skipped because it was previously tested.
Want to use PyFunceble under a supporter CI infrastructure/network? This argument is suited for your needs!
--ci-branch
¶
Switch the branch name where we are going to push the temporary results.
Default value:
master
Note
Currently the branch need to exist, but there are being worked on a path
to have PyFunceble to create the sub-branch and finally merge it into the
--ci-distribution-branch
--ci-distribution-branch
¶
Switch the branch name where we are going to push the final results.
Default value:
master
Note
The difference between this and --ci-branch
is the fact
that this branch will get the (final) result only when the test is finished
under the given --ci-branch
.
As an example, this allows us to have 2 branches:
proceessing
(CI branch), for the tests with PyFunceble.master
(CI distribution branch), for the distribution of the results of PyFunceble.
--cmd
“something”¶
Pass a command before each commit (except the final one).
Default value:
''
Note
In this example, something
should be a script or a program which
have to be executed when we reached the end of the given file.
Note
This argument is only used if --ci
or ci: true
(under
.PyFunceble.yaml
) are activated.
--cmd-before-end "something"
¶
Pass a command before the results (final) commit under the CI mode.
Default value:
''
Note
In this example, something
should be a script or a program which
have to be executed when we reached the end of the given file.
Note
This argument is only used if --ci
or ci: true
(under
.PyFunceble.yaml
) are activated.
--commit-autosave-message "something"
¶
Replace the default autosave commit message.
Default value:
PyFunceble - AutoSave
This argument allows us to set a custom commit message which is going to be used as a commit message when saving.
Note
This argument is only used if --ci
or ci: true
(under
.PyFunceble.yaml
) are used.
Note
This argument is only used if we have to split the work into multiple processes because a list is too long or the timeout is reached.
Warning
Please avoid the usage of [ci skip]
here.
--commit-results-message "something"
¶
Replace the default results (final) commit message.
Default value:
PyFunceble - Results
Note
This argument is only used if --ci
or ci: true
(under
.PyFunceble.yaml
) are used.
Note
This argument is only used if we reached the end of the list we are or have to test.
Unique actions¶
--clean
¶
Clean all files under the output directory.
As it is sometimes needed to clean our output/
directory, this
argument does the job automatically.
Warning
This argument delete everything which are .keep
or
.gitignore
--clean-all
¶
Clean all files under the output directory along with all file generated by PyFunceble.
Warning
This deletes almost everything we generated without any warning.
Note
We don’t delete the whois database file/table because they are (almost) static data which are shared across launches in your environment.
Warning
If you plan to clean manually do not delete the whois database file or table as it will make your test finish under a much longer time as usual for you.
Warning
If you don’t combine this argument alongside with the --database-type
argument or its configurable equivalent, this argument will only clean the
JSON formatted databases.
--directory-structure
¶
Generate the directory and files that are needed and which does not exist in the current directory.
Want to start without anything? This argument generates the output directory automatically for you!
Note
In case of a file or directory not found issue, it’s recommended to remove
the dir_structure.json
along with the output/ directory before
using this argument.
Global overview¶
usage: PyFunceble [-d DOMAIN [DOMAIN ...]] [-u URL [URL ...]] [-f FILE]
[-uf URL_FILE] [-ad] [--complements] [--filter FILTER]
[--idna] [--mining] [-c] [--cooldown-time COOLDOWN_TIME]
[--http] [--local] [-ns] [-nw] [--reputation] [--rpz]
[--shadow-file] [--syntax] [-t TIMEOUT]
[--use-reputation-data] [-ua USER_AGENT] [-vsc] [--wildcard]
[--dns DNS [DNS ...]] [--dns-lookup-over-tcp] [-db]
[--database-type DATABASE_TYPE]
[-dbr DAYS_BETWEEN_DB_RETEST] [-dbc DAYS_BETWEEN_DB_CLEAN]
[-wdb] [-a] [-ex] [--hierarchical] [-h] [-ip IP] [--json]
[--less] [-nf] [-nl] [-nu] [--percentage] [--plain] [--dots]
[-q] [--share-logs] [-s] [--split] [--store-whois] [-m]
[--multiprocess-merging-mode MULTIPROCESS_MERGING_MODE]
[-p PROCESSES] [--autosave-minutes AUTOSAVE_MINUTES] [--ci]
[--ci-branch CI_BRANCH]
[--ci-distribution-branch CI_DISTRIBUTION_BRANCH]
[--cmd CMD] [--cmd-before-end CMD_BEFORE_END]
[--commit-autosave-message COMMIT_AUTOSAVE_MESSAGE]
[--commit-results-message COMMIT_RESULTS_MESSAGE] [--clean]
[--clean-all] [--directory-structure] [--help] [-v]
PyFunceble - The tool to check the availability or syntax of domain, IP or URL.
optional arguments:
--help Show this help message and exit.
-v, --version Show the version of PyFunceble and exit.
Source:
-d DOMAIN [DOMAIN ...], --domain DOMAIN [DOMAIN ...]
Test one or more domains, separated by spaces.
When this option is used, no output files are generated.
-u URL [URL ...], --url URL [URL ...]
Test one or more full URL, separated by spaces.
-f FILE, --file FILE Read a local or remote (RAW link) file and test all domains inside it.
If remote (RAW link) file is given, PyFunceble will download it,
and test the content of the given RAW link as if it was a locally stored file.
-uf URL_FILE, --url-file URL_FILE
Read a local or remote (RAW link) file and test all (full) URLs inside it.
If remote (RAW link) file is given, PyFunceble will download it,
and test the content of the given RAW link as if it was a locally stored file.
This argument test if an URL is available. It ONLY test full URLs.
Source filtering, decoding, conversion and expansion:
-ad, --adblock Switch the decoding of the adblock format.
Configured value: False
--complements Switch the value of the generation and test of the complements.
A complement is for example `example.org` if `www.example.org` is given and vice-versa.
Configured value: False
--filter FILTER Domain to filter (regex).
--idna Switch the value of the IDNA conversion.
Configured value: False
--mining Switch the value of the mining subsystem usage.
Configured value: False
Test control:
-c, --auto-continue, --continue
Switch the value of the auto continue mode.
Configured value: True
--cooldown-time COOLDOWN_TIME
Switch the value of the cooldown time to apply between each test.
Configured value: None
--http Switch the value of the usage of HTTP code.
Configured value: True
--local Switch the value of the local network testing.
Configured value: True
-ns, --no-special Switch the value of the usage of the SPECIAL rules.
Configured value: False
-nw, --no-whois Switch the value of the usage of WHOIS to test the domain's status.
Configured value: False
--reputation Switch the value of the reputation test mode.
Configured value: False
--rpz Switch the value of the RPZ policies test.
When used, RPZ policies will be properly tested.
--shadow-file, --shadow
Switch the value of the usage and generation of a shadow file before a file test starts.
A shadow file is a file which only contain the actual list of subject to test. For its generation we check each subjects as we normally do on-the-fly.
Configured value: False
--syntax Switch the value of the syntax test mode.
Configured value: False
-t TIMEOUT, --timeout TIMEOUT
Switch the value of the timeout in seconds.
Configured value: 5
--use-reputation-data
Switch the value of the reputation data usage.
Configured value: False
-ua USER_AGENT, --user-agent USER_AGENT
Set the user-agent to use and set every time we interact with everything which
is not the logs sharing system.
-vsc, --verify-ssl-certificate
Switch the value of the verification of the SSL/TLS certificate when testing for URL.
Configured value: False
--wildcard Switch the value of the wildcards test.
When used, wildcards will be properly tested.
DNS (resolver) control:
--dns DNS [DNS ...] Set one or more DNS server(s) to use during testing. Separated by spaces.
To specify a port number for the DNS server you append it as :port [ip:port].
If no port is specified, the default DNS port (53) is used.
Configured value: OS (declared) DNS server
--dns-lookup-over-tcp
Make all DNS queries with TCP.
Configured value: False
Databases:
-db, --database Switch the value of the usage of a database to store inactive domains of the currently tested list.
Configured value: True
--database-type DATABASE_TYPE
Tell us the type of database to use.
You can choose between the following: `json | mariadb | mysql`
Configured value: 'json'
-dbr DAYS_BETWEEN_DB_RETEST, --days-between-db-retest DAYS_BETWEEN_DB_RETEST
Set the numbers of days between each retest of domains present into inactive-db.json.
Configured value: 1
-dbc DAYS_BETWEEN_DB_CLEAN, --days-between-db-clean DAYS_BETWEEN_DB_CLEAN
Set the numbers of days since the introduction of a subject into inactive-db.json for it to qualifies for deletion.
Configured value: 28
-wdb, --whois-database
Switch the value of the usage of a database to store whois data to avoid whois servers rate limit.
Configured value: True
Output control:
-a, --all Output all available information on the screen.
Configured value: True
-ex, --execution Switch the default value of the execution time showing.
Configured value: False
--hierarchical Switch the value of the hierarchical sorting of the tested file.
Configured value: False
-h, --host Switch the value of the generation of hosts file.
Configured value: True
-ip IP Change the IP to print in the hosts files with the given one.
Configured value: '0.0.0.0'
--json Switch the value of the generation of the JSON formatted list of domains.
Configured value: False
--less Output less informations on screen.
Configured value: False
-nf, --no-files Switch the value of the production of output files.
Configured value: False
-nl, --no-logs Switch the value of the production of logs files in the case we encounter some errors.
Configured value: False
-nu, --no-unified Switch the value of the production unified logs under the output directory.
Configured value: False
--percentage Switch the value of the percentage output mode.
Configured value: True
--plain Switch the value of the generation of the plain list of domains.
Configured value: False
--dots Prints dots to stdout instead of giving the impression that we hang on.
Configured value: False
-q, --quiet Run the script in quiet mode.
Configured value: False
--share-logs Switch the value of the sharing of logs.
Configured value: False
-s, --simple Switch the value of the simple output mode.
Configured value: False
--split Switch the value of the split of the generated output files.
Configured value: True
--store-whois Switch the value of the WHOIS record storage in the WHOIS DB.
Configured value: False
Multiprocessing:
-m, --multiprocess Switch the value of the usage of multiple processes.
Configured value: False
--multiprocess-merging-mode MULTIPROCESS_MERGING_MODE
Sets the multiprocess merging mode.
You can choose between the following: `live|ends`.
Configured value: 'end'
-p PROCESSES, --processes PROCESSES
Set the number of simultaneous processes to use while using multiple processes.
If omited, the number of available CPU cores will be used instead.
Configured value: 25
CI / CD:
--autosave-minutes AUTOSAVE_MINUTES
Update the minimum of minutes before we start committing to upstream under the CI mode.
Configured value: 15
--ci Switch the value of the CI mode.
Configured value: False
--ci-branch CI_BRANCH
Switch the branch name where we are going to push the temporary results.
Configured value: 'master'
--ci-distribution-branch CI_DISTRIBUTION_BRANCH
Switch the branch name where we are going to push the final results.
Configured value: 'master'
--cmd CMD Pass a command to run before each commit (except the final one) under the CI mode.
Configured value: ''
--cmd-before-end CMD_BEFORE_END
Pass a command to run before the results (final) commit under the CI mode.
Configured value: ''
--commit-autosave-message COMMIT_AUTOSAVE_MESSAGE
Replace the default autosave commit message.
Configured value: None
--commit-results-message COMMIT_RESULTS_MESSAGE
Replace the default results (final) commit message.
Configured value: None
Unique actions:
--clean Clean all files under the output directory.
--clean-all Clean all files under the output directory along with all file generated by PyFunceble.
--directory-structure
Generate the directory and files that are needed and which does not exist in the current directory.
For an in-depth usage, explanation and examples of the arguments, you should read the documentation at https://pyfunceble.readthedocs.io/en/master/
Crafted with ♥ by Nissar Chababy (@funilrys) with the help of https://pyfunceble.github.io/contributors.html && https://pyfunceble.github.io/special-thanks.html
From a GitLab CI/CD environment¶
As we offer an argument named --ci
which will
autosave in a GitLab CI/CI environment, this document try to
describe hot it works!
Configuration¶
Personal Access Token¶
A personal access token is needed in order for PyFunceble to automatically push the results.
You should get a personal GitLab access token with
the read_repository
and write_repository
scopes.
Once created and copied in a safe place, create a new masked variable
named GL_TOKEN
inside the CI/CD settings of your project.
The value of the variable should be the newly generated personal
access token.
.gitlab-ci.yml
¶
Note
This part only present a commented .gitlab-ci.yml
.
This is just an example do not take the following as
necessarly true.
You’re invited to submit changes if something stated in this document is wrong.
# Python needed, so we use the python image.
image: python:latest
variables:
# This is the Git name we have to set. (git config user.name)
GIT_EMAIL: "dead-hosts@funilrys.com"
# This is the Git Email we have to set. (git config user.email)
GIT_NAME: "GitLab CI/CD"
before_script:
# We install the development version of PyFunceble.
# If you prefer the stable version replace `pyfunceble-dev`
# with `pyfunceble`.
- pip3 install PyFunceble-dev
run:
script:
# Let's say we want our results and our PyFunceble
# infrastructure to be saved in a directory called `PyFunceble-tests`
# We move inside it.
- cd PyFunceble-tests
# We test the file `my_awesome_list` which is located inside the current directory.
# Note: we precise the `--ci` argument here,
# but you work without it if you set `ci: true` inside your `.PyFunceble.yaml`
- PyFunceble --ci -f my_awesome_list --plain
From a Travis CI container¶
As we offer an argument named --ci
to activate
the usage of PyFunceble in a Travis CI instance,
we document here what you need to know!
Configuration¶
Note
This part only present a commented .travis.yml
so that you can understand where to start.
If you need more practical examples, feel free to report to one of Dead-Hosts repositories which use PyFunceble with Travis CI.
env:
global:
# The following is your encrypted GitHub API key.
# Indeed as we are going to push to the repository, this is needed.
#- GH_TOKEN: # This can be set in the travis-ci https://travis-ci.com/repo/settings as 'Environment Variables'
# or as below: secure: encrypted code
- secure: QQdKFquFFojFT9XJ1XZp4EMoDTVoXFgqZq8XU+sCVf+pJQR6d/oKBp8rnSTCnZizWOQXUjGXUUxUpSG/dYGyBLjo3rH3rsn9ciZHVfubxbwK860w4sqibl4DvhCv2rdsFtvzXnhm4P9OL3i+krKdewh9fxpNyUU58qOgfnS7mK9FcFhb8z5ak2sxU2XRZedwm6Ro0oyVKs8kFkL4YaADfNyAHlGTfr9rVmE52WXQXQENktb9gFgR2A8ZnmLy0BCMZGkPDShJnjRDWD4DErtasLmLQvWpzOBwdbVJTY6U9KDRXVNdC9lp5E5Ba/dc0y36q6vjfgJR+QchetOtHgNbKYbLB8c26Di90OZCFJsxMNcl1Wct4qFPXkFGvjXrISW6pbdPL5Plto0Ig3iLiulhYOPVArysMIk9ymtSXP+WE7VWX01LQ1fEkIoSfeVZ2caTnCmTsoHVGRRe978CojKaT7yU45kb15hcyDrzptQ8EP2hfxeh5F7KtueQ6Rsb9LFDZMkMDKflZn6a+bRhESlmWWmYB9stzGzTurQA1E1bcSACJ8A8hG5nHBzZYJ2S+OY0PE7UdyOJ0JK0qe/67d+F9ocQdIoFpDDTdgIjHerQnD2wRg1aKPzLDb4jJTpqgr5ssPrqUAKl3st7gyaAZzCEADPDnIBDjOJS+mFWbx9DKgc=
# This is the Git name we have to set. (git config user.name)
- GIT_NAME: Travis CI
# This is the Git Email we have to set. (git config user.email)
- GIT_EMAIL: dead-hosts@funilrys.com
# This is the language we use.
language: python
# This is the python version we are going to use for the tests.
# Note: you can add any 3.x version to the list.
python:
- "3.8"
# The following will tell Travis CI to ends as fast as possible.
matrix:
fast_finish: true
# Here we are setting what Travis CI have to cache.
cache:
# We are caching pip3 as we use it to install PyFunceble
- pip3
install:
# We install the development version of PyFunceble. If you prefer the stable version replace
# `pyfunceble-dev` with `pyfunceble`.
- pip3 install pyfunceble-dev
# Our tests start here.
script:
# Let's say we want our results and our PyFunceble infrastructure to be saved in a directory
# called `PyFunceble-tests`
# We move inside it.
- cd PyFunceble-tests
# We test the file `my_awesome_list` which is located inside the current directory.
# Note: we precise the `--ci` argument here,
# but you work without it if you set `travis: true` inside your `.PyFunceble.yaml`
- PyFunceble --ci -f my_awesome_list --plain
# The following initiate email notification logic.
notifications:
# As we want to get a mail on failure and on status change, we set the following.
on_success: change
on_failure: always
Getting a GitHub token¶
For the secure
index of the .travis.yml
file, you have to generate a new GitHub token.
After you got your token, please write it or save it in a safe place as you’re going to need it every time you’re going to interact with Travis CI.
Note
The scope to set is public_repo
but you can also set others depending on your needs.
Encrypting the token for future usage under the Travis CIs’ containers¶
To encrypt the token simply replace and execute the following according to your personal case.
$ travis encrypt 'GH_TOKEN=theGeneratedToken' -r 'The content of TRAVIS_REPO_SLUG' --add
Warning
Please do not execute the following explicitly without replacing theGeneratedToken
with your previously generated GitHub token and The content of TRAVIS_REPO_SLUG
with
your repository slug.
Note
The usage of --add
ensure that the travis
program automatically add the secure
index to the .travis.yml
file.
Using the PyFunceble (Python) API¶
If you are working with a python script, module or even class, you can integrate PyFunceble to your main logic by importing it and using its API (cf: API Documentation).
This section will present some example of the way you can interact with PyFunceble from anything written in Python.
Get the availability of domains or IP¶
Note
This example can be found in our examples repository.
Todo
Add IPs in the loop.
"""
This is an example which respond to the following problematic(s):
* How can I get the avaibility of a domain or IP with PyFunceble ?
"""
# We want some coloration so we import the tool do to that :)
from PyFunceble import initiate_colorama, Fore, Style
# We import the tool to print the colored CLI logo.
from PyFunceble.cli_core import CLICore
# We import the configuration loader.
from PyFunceble import load_config
# We import the test method of the PyFunceble API.
from PyFunceble import test as PyFunceble
# We initiate the list of domains we are going to test.
DOMAINS = [
"google.com",
"tweeetttter.com",
"github.com",
"examplessss.ooooorgg",
"twitter.com",
"forest-jump"
]
# We initiate colorama.
initiate_colorama(True)
# We load our configuration.
#
# Note: We need this to print the logo but if you
# doesn't need the logo, you can ignore this.
load_config(generate_directory_structure=False)
# We print the PyFunceble logo.
CLICore.colorify_logo(home=True)
def print_result(subject, status):
"""
Given the subject and its status, we print it to STDOUT.
:param str subject: The subject we are going to print.
:param str status: The status of the domain.
"""
if status == "ACTIVE":
print(f"{Fore.GREEN + Style.BRIGHT}{domain} is {status}")
elif status == "INACTIVE":
print(f"{Fore.RED + Style.BRIGHT}{domain} is {status}")
else:
print(f"{Fore.CYAN + Style.BRIGHT}{domain} is {status}")
for domain in DOMAINS:
# We loop through the list of domain.
# And we print the domain and status with the right coloration!
print_result(domain, PyFunceble(domain))
Get the availability of URL¶
Note
This example can be found in our examples repository.
"""
This is an example which respond to the following problematic(s):
* How can I get the avaibility of an URL with PyFunceble ?
"""
# We want some coloration so we import the tool do to that :)
from PyFunceble import initiate_colorama, Fore, Style
# We import the tool to print the colored CLI logo.
from PyFunceble.cli_core import CLICore
# We import the configuration loader.
from PyFunceble import load_config
# We import the test method of the PyFunceble API.
from PyFunceble import url_test as PyFunceble
# We initiate the list of URLs we are going to test.
URLS = [
"https://google.com",
"http://tweeetttter.com",
"ftp://github.com",
"http://examplessss.ooooorgg",
"http://twitter.com",
]
# We initiate colorama.
initiate_colorama(True)
# We load our configuration.
#
# Note: We need this to print the logo but if you
# doesn't need the logo, you can ignore this.
load_config(generate_directory_structure=False)
# We print the PyFunceble logo.
CLICore.colorify_logo(home=True)
def print_result(subject, status):
"""
Given the subject and its status, we print it to STDOUT.
:param str subject: The subject we are going to print.
:param str status: The status of the domain.
"""
if status == "ACTIVE":
print(f"{Fore.GREEN + Style.BRIGHT}{domain} is {status}")
elif status == "INACTIVE":
print(f"{Fore.RED + Style.BRIGHT}{domain} is {status}")
else:
print(f"{Fore.CYAN + Style.BRIGHT}{domain} is {status}")
for url in URLS:
# We loop through the list of domain.
# And we print the domain and status with the right coloration!
print_result(url, PyFunceble(url))
Complete dataset while getting the avaibility of domains, IPs or URL¶
While using our API, you can request to see/get everything with the help of the complete=True
argument.
You’ll then get the following dict
as output.
{
"_status": None, # If some extra rules are applied, this index will keep the status before the extra rules was applied.
"_status_source": None, # If some extra rules are applied, this index will keep the source before the extra rules was applied.
"domain_syntax_validation": None, # The domain syntax validation status.
"expiration_date": None, # The expiration date of the tested subject (if found).
"http_status_code": None, # The status code of the tested subejct.
"ip4_syntax_validation": None, # The IPv4 syntax validation status.
"dns_lookup": [], # The DNS Lookup output.
"status_source": None, # The (final) source which gave us the status.
"status": None, # The (final) status returned by PyFunceble.
"tested": None, # The tested subject.
"url_syntax_validation": None, # The url syntax validation status.
"whois_record": None, # The whois record (if found).
"whois_server": None, # The whois server we use to get the whois record (if found).
}
Set custom configuration index while getting the avaibility of domains, IPs or URL¶
While using PyFunceble, you might want to set or overwritte a default behaviour.
You can do that in 2 ways. Globally or locally.
Globally¶
To set globally simply initiate the configuration loader and parse your custom configuration along with the initialization.
As example, you can do it like follow:
# We import the configuration loader.
from PyFunceble import load_config
# We set our list of indexes to overwritte.
OUR_PYFUNCEBLE_CONFIG = {"share_logs":False, "no_files": True}
# We load our configuration and parse our custom indexes.
load_config(generate_directory_structure=False, custom=OUR_PYFUNCEBLE_CONFIG)
## We can then play with PyFunceble and/or other business logic ...
Locally¶
To set globally simply parse your configuration along with the test method.
As example, you can do it like follow:
# We import the test method.
from PyFunceble import test as AvailabilityTest
# We set our list of indexes to overwritte.
OUR_PYFUNCEBLE_CONFIG = {"share_logs":False, "no_files": True}
# We get the status and parse our configuration.
status = AvailabilityTest("hello.world", config=OUR_PYFUNCEBLE_CONFIG)
## We can then manipulate the status and/or other business logic ...
Check the syntax of domains¶
Note
This example can be found in our examples repository.
"""
This is an example which respond to the following problematic(s):
* How can I check the syntax of a domain with PyFunceble ?
"""
# We want some coloration so we import the tool do to that :)
from PyFunceble import initiate_colorama, Fore, Style
# We import the tool to print the colored CLI logo.
from PyFunceble.cli_core import CLICore
# We import the configuration loader.
from PyFunceble import load_config
# We import the test method of the PyFunceble API.
from PyFunceble import is_domain as PyFunceble
# We initiate the list of domains we are going to test.
DOMAINS = [
"google.com",
"tweeetttter.com",
"github.com",
"examplessss.ooooorgg",
"twitter.com",
"forest-jump",
]
# We initiate colorama.
initiate_colorama(True)
# We load our configuration.
#
# Note: We need this to print the logo but if you
# doesn't need the logo, you can ignore this.
load_config(generate_directory_structure=False)
# We print the PyFunceble logo.
CLICore.colorify_logo(home=True)
def print_syntax_result(subject, status):
"""
Given the subject and its validation, we print it to STDOUT.
:param str subject: The subject we are going to print.
:param bool status: The validation state.
"""
if status is True:
print(f"{Fore.GREEN + Style.BRIGHT}{subject} is VALID")
else:
print(f"{Fore.CYAN + Style.BRIGHT}{subject} is INVALID")
for domain in DOMAINS:
# We loop through the list of domain.
# And we print the domain and status with the right coloration!
print_syntax_result(domain, PyFunceble(domain))
Check the syntax of IPv4s¶
Note
This example can be found in our examples repository.
"""
This is an example which respond to the following problematic(s):
* How can I check the syntax of an IPv4/IPv6 with PyFunceble ?
"""
# We want some coloration so we import the tool do to that :)
from PyFunceble import initiate_colorama, Fore, Style
# We import the tool to print the colored CLI logo.
from PyFunceble.cli_core import CLICore
# We import the configuration loader.
from PyFunceble import load_config
# We import the test method of the PyFunceble API.
from PyFunceble import is_ip as PyFunceble
# We initiate the list of IPs we are going to test.
IPS = ["216.58.207.46", "257.58.207.46"]
# We initiate colorama.
initiate_colorama(True)
# We load our configuration.
#
# Note: We need this to print the logo but if you
# doesn't need the logo, you can ignore this.
load_config(generate_directory_structure=False)
# We print the PyFunceble logo.
CLICore.colorify_logo(home=True)
def print_syntax_result(subject, status):
"""
Given the subject and its validation, we print it to STDOUT.
:param str subject: The subject we are going to print.
:param bool status: The validation state.
"""
if status is True:
print(f"{Fore.GREEN + Style.BRIGHT}{subject} is VALID")
else:
print(f"{Fore.CYAN + Style.BRIGHT}{subject} is INVALID")
for ip in IPS:
# We loop through the list of IP.
# And we print the IP and status with the right coloration!
print_syntax_result(ip, PyFunceble(ip))
Check the syntax of URLs¶
Note
This example can be found in our examples repository.
"""
This is an example which respond to the following problematic(s):
* How can I check the syntax of an URL with PyFunceble ?
"""
# We want some coloration so we import the tool do to that :)
from PyFunceble import initiate_colorama, Fore, Style
# We import the tool to print the colored CLI logo.
from PyFunceble.cli_core import CLICore
# We import the configuration loader.
from PyFunceble import load_config
# We import the test method of the PyFunceble API.
from PyFunceble import is_url as PyFunceble
# We initiate the list of URLs we are going to test.
URLS = [
"https://google.com",
"http://tweeetttter.com",
"htp://github.com",
"httpp://examplessss.ooooorgg",
"https:///twitter.com",
"http:forest-jump",
]
# We initiate colorama.
initiate_colorama(True)
# We load our configuration.
#
# Note: We need this to print the logo but if you
# doesn't need the logo, you can ignore this.
load_config(generate_directory_structure=False)
# We print the PyFunceble logo.
CLICore.colorify_logo(home=True)
def print_syntax_result(subject, status):
"""
Given the subject and its validation, we print it to STDOUT.
:param str subject: The subject we are going to print.
:param bool status: The validation state.
"""
if status is True:
print(f"{Fore.GREEN + Style.BRIGHT}{subject} is VALID")
else:
print(f"{Fore.CYAN + Style.BRIGHT}{subject} is INVALID")
for url in URLS:
# We loop through the list of URL.
# And we print the URL and status with the right coloration!
print_syntax_result(url, PyFunceble(url))
Responses¶
Status¶
Give us the test result/status of the tested element.
Note
The API equivalent is status
.
ACTIVE¶
This status is returned when one of the following cases is met:
We can extract the expiration date from
PyFunceble.lookup.whois.WhoisLookup.request()
.Note
We don’t check if the extracted date is in the past. Indeed, if we start to do the registry work, it becomes a never ending work for us.
PyFunceble.lookup.dns.DNSLookup.request()
does not return{}
.Note
We don’t read nor interpret the returned data.
As the request
PyFunceble.lookup.dns.DNSLookup.request()
method already handle everything, we don’t need to read the given data.We just check that it is not an empty dictionary.
PyFunceble.lookup.dns.DNSLookup.request()
returns{}
,PyFunceble.lookup.whois.WhoisLookup.request()
provides nothing exploitable, butPyFunceble.lookup.http_code.HTTPCode.get()
returned something which is not the default value (XXX
).
INACTIVE¶
This status is returned when all the following cases are met:
- We could not extract the expiration date from
PyFunceble.lookup.whois.WhoisLookup.request()
. PyFunceble.lookup.dns.DNSLookup.request()
returns nothing.PyFunceble.lookup.http_code.HTTPCode.get()
is not in the list ofACTIVE
status codes.
INVALID¶
This status is returned when all the following cases are met:
The Domain/IP does not match/pass our syntax checker.
The domain extension is unregistered in the IANA Root Zone Database, our internal list nor in the Public Suffix List.
Note
Understand by this that the extension is not present:
- in the
iana-domains-db.json
file - in the
public-suffix.json
file - in the
PyFunceble.check.Check.SPECIAL_USE_DOMAIN_NAMES_EXTENSIONS
attribute.
- in the
VALID¶
This status is returned when we are checking for syntax. It is the equivalent of ACTIVE
but for syntax checking.
MALICIOUS¶
This status is returned when we are checking for the reputation.
SANE¶
This status is returned when we are checking for the reputation.
Source¶
Give us the source of the status.
Note
The API equivalent is status_source
.
HTTP Code¶
This source is returned when all the following cases are met:
- We can’t extract the expiration date from
PyFunceble.lookup.whois.WhoisLookup.request()
. - The
INACTIVE
status is the one returned by other methods. PyFunceble.lookup.http_code.HTTPCode.get()
outputs is different from the default one (XXX
) and the other methods gives theINACTIVE
status.
SYNTAX¶
This source is always returned when the domain has the status INVALID
or in the case that we are only checking for syntax instead of availability.
The usage of this source comes from the comparison of the element against our domain, IP or URL syntax validation system.
DNSLOOKUP¶
This source is always returned when the taken decision of the status of the domain/IP comes from PyFunceble.lookup.dns.DNSLookup.request()
outputs.
SPECIAL¶
As PyFunceble
grows, I thought that a bit of filtering for special cases would be great.
So I introduced the SPECIAL source.
Note
Please consider all 3 digits number that are listed in this section as the HTTP status code catched by PyFunceble.lookup.http_code.HTTPCode.get()
.
Warning
Do not want those rules ? You can use the following to disable them.
-ns|--no-special
arguments from the CLI.no_special: True
into your local configuration file.
*.000webhostapp.com
¶
- All
410
are returned asINACTIVE
.
*.blogspot.*
¶
- All
404
are returned asINACTIVE
- All
301
which are blocked by Google or does not exist are returned asINACTIVE
- All
302
which are blocked by Google are returned asINACTIVE
*.canalblog.com
¶
- All
404
are returned asINACTIVE
*.github.io
¶
- All
404
are returned asINACTIVE
*.hpg.com.br
¶
- All
404
are returned asINACTIVE
*.liveadvert.com
¶
- All
404
are returned asINACTIVE
*.skyrock.com
¶
- All
404
are returned asINACTIVE
*.tumblr.com
¶
- All
404
are returned asINACTIVE
*.wix.com
¶
- All
404
are returned asINACTIVE
*.wordpress.com
¶
- All
301
which matchdoesn’t exist
are returned asINACTIVE
IP with range¶
- All IPv4 with a range (for example
0.0.0.0/24
) are returned asACTIVE
- All IPv6 with a range (for example
2001:db8::/43
) are returned asACTIVE
Reputation¶
Note
If the --use-reputation-data
argument is activated
or the use_reputation_data
index of your
configuration file is active, the following apply.
- All IPv4 and IPv6 which are present into the AlienVault public
reputation data are returned as
ACTIVE
_status
(API)¶
This index has the same proprieties as status
but before any extra rules were applied.
_status_source
(API)¶
This index has the same proprieties as status_source
but before any extra rules were applied.
dns_lookup
(API)¶
Provides the output of the DNS lookup.
Format 1: Normal DNS Lookup¶
The first and most common output will be like follow:
{
"A": ["string"],
"AAAA": ["string"],
"CNAME": ["string"],
"NS": ["string"],
"PTR": ["string"]
}
where each list item represents the response from the DNS server.
Format 2: get_hosts_by_addr
(local subjects?)¶
For the system to not miss something, it will try to execute the socket.gethostbyaddr()
(for IP) and socket.gethostbyname()
(for the rest).
In both cases, the result will be like follow:
{
"hostname": "string",
"aliases": ["string"],
"ips": ["string"]
}
HTTP Code¶
Note
The API equivalent is http_status_code
.
Note
This section reflects exactly what the code does. So any changes made here should also be reported to the code or at least the configuration file.
Note
A XXX
in this column means that it was impossible to catch the HTTP status code from the web server.
Note
The Status Codes we give to PyFunceble to test with can be fully customized in your own .PyFunceble.yaml
.
As active¶
Note
While testing for domain and IP, a subject which has an HTTP code listed below, will be saved/logged into the output/Analytic/ACTIVE
directory.
Warning
While testing for domain and IP, a subject which has an HTTP code listed below and a global status INACTIVE
or INVALID
will get its status
updated to ACTIVE
.
Warning
While testing for URL, if the extracted HTTP code is in the following list, the global status will be ACTIVE
.
- 100 - Continue
- 101 - Switching Protocols
- 200 - OK
- 201 - Created
- 202 - Accepted
- 203 - Non-Authoritative Information
- 204 - No Content
- 205 - Reset Content
- 206 - Partial Content
As potentially active¶
Note
While testing for domain and IP, a subject which has an HTTP code listed below, will be saved/logged into the output/Analytic/POTENTIALLY_ACTIVE
directory.
Warning
While testing for domain and IP, a subject which has an HTTP code listed below and a global status INACTIVE
or INVALID
will get its status
updated to ACTIVE
.
Warning
While testing for URL, if the extracted HTTP code is in the following list, the global status will be ACTIVE
.
- 000
- 300 - Multiple Choices
- 301 - Moved Permanently
- 302 - Found
- 303 - See Other
- 304 - Not Modified
- 305 - Use Proxy
- 307 - Temporary Redirect
- 403 - Forbidden
- 405 - Method Not Allowed
- 406 - Not Acceptable
- 407 - Proxy Authentication Required
- 408 - Request Timeout
- 411 - Length Required
- 413 - Request Entity Too Large
- 417 - Expectation Failed
- 500 - Internal Server Error
- 501 - Not Implemented
- 502 - Bad Gateway
- 503 - Service Unavailable
- 504 - Gateway Timeout
- 505 - HTTP Version Not Supported
As inactive or potentially inactive¶
Note
While testing for domain and IP, a subject which has an HTTP code listed below, will be saved/logged into the output/Analytic/POTENTIALLY_INACTIVE
directory.
Warning
While testing for URL, if the extracted HTTP code is in the following list, the global status will be INACTIVE
.
- 400 - Bad Request
- 401 - Unauthorized
- 402 - Payment Required (Not in use but may be seen in the future)
- 404 - Not Found
- 409 - Conflict
- 410 - Gone
- 412 - Precondition Failed
- 414 - Request-URI Too Long
- 415 - Unsupported Media Type
- 416 - Requested Range Not Satisfiable
Expiration Date¶
Give us the expiration date of the tested element.
Note
The API equivalent is expiration_date
.
Unknown (CLI)¶
Unknown
is returned when we could not extract the expiration date from PyFunceble.lookup.whois.WhoisLookup.request()
outputs.
None
(API)¶
None
is returned when we could not extract the expiration date from PyFunceble.lookup.whois.WhoisLookup.request()
outputs.
A date¶
Only if we could extract the expiration date from PyFunceble.lookup.whois.WhoisLookup.request()
, the date becomes formatted like 02-jan-2017
.
whois_record
(API)¶
Give us the WHOIS record.
Warning
You may get DATE EXTRACTED FROM WHOIS DATABASE
as response when it’s
coming from the JSON database.
The reason behind this is that we don’t want to grow the size of the JSON file.
whois_server
(API)¶
Give us the WHOIS server we contacted in order to get the WHOIS record.
domain_syntax_validation
(API)¶
The domain_syntax_validation
provides the response we got while trying to validate (with PyFunceble.check.Check.is_domain()
) the given subject.
The response will be True
for the case of a successful validation, False
otherwise, and None
for the case that the validation was not executed.
subdomain_syntax_validation
(API)¶
The subdomain_syntax_validation
provides the response we got while trying to validate (with PyFunceble.check.Check.is_subdomain()
) the given subject.
The response will be True
for the case of a successful validation, False
otherwise, and None
for the case that the validation was not executed.
url_syntax_validation
(API)¶
The url_syntax_validation
provides the response we got while trying to validate (with PyFunceble.check.Check.is_url()
) the given subject.
The response will be True
for the case of a successful validation, False
otherwise, and None
for the case that the validation was not executed.
ipv4_syntax_validation
(API)¶
The ipv4_syntax_validation
provides the response we got while trying to validate (with PyFunceble.check.Check.is_ipv4()
) the given subject.
The response will be True
for the case of a successful validation, False
otherwise, and None
for the case that the validation was not executed.
ipv6_syntax_validation
(API)¶
The ipv6_syntax_validation
provides the response we got while trying to validate (with PyFunceble.check.Check.is_ipv6()
) the given subject.
The response will be True
for the case of a successful validation, False
otherwise, and None
for the case that the validation was not executed.
ipv4_range_syntax_validation
(API)¶
The ipv4_range_syntax_validation
provides the response we got while trying to validate (with PyFunceble.check.Check.is_ipv4_range()
) the given subject.
The response will be True
for the case of a successful validation, False
otherwise, and None
for the case that the validation was not executed.
ipv6_range_syntax_validation
(API)¶
The ipv6_range_syntax_validation
provides the response we got while trying to validate (with PyFunceble.check.Check.is_ipv6_range()
) the given subject.
The response will be True
for the case of a successful validation, False
otherwise, and None
for the case that the validation was not executed.
API Documentation¶
Enpoints¶
Note
This section document what you can call directly when you use PyFunceble as an imported module.
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
PyFunceble.
dns_lookup
(subject, dns_server=None, complete=False, lifetime=3)[source]¶ Make a DNS lookup of the given subject.
Parameters: Returns: A dict with following index if the given subject is not registered into the given DNS server. (More likely local subjects).
{ "hostname": "", "aliases": [], "ips": [] }
A dict with following index for everything else (and if found).
{ "A": [], "AAAA": [], "CNAME": [], "MX": [], "NS": [], "TXT": [], "PTR": [] }
Return type:
-
PyFunceble.
get_complements
(subject, include_given=False)[source]¶ Provides the complements of the given subject(s).
A complement is for example
example.com
ifwww.example.com
is given and vice-versa.Parameters: Return type:
-
PyFunceble.
ipv4_syntax_check
(ip)[source]¶ Check the syntax of the given IPv4.
Parameters: ip (str|list) – The IPv4 to check the syntax for. Returns: The syntax validity. Return type: bool|dict
-
PyFunceble.
is_domain
(subject)[source]¶ Check if the given subject is a syntactically valid domain.
Parameters: subject (str|list) – The subject to check the syntax from. Returns: The syntax validity. Return type: bool|dict
-
PyFunceble.
is_domain_malicious
(subject)[source]¶ Checks if the given domain is malicious.
Parameters: subject (str) – The subject to work with. Return type: bool
-
PyFunceble.
is_ip
(subject)[source]¶ Checks if the given subject is a syntactivally valid IPv4 or IPv6.
Parameters: subject (str|list) – The subject to check the syntax from. Returns: The syntax validity. Return type: bool|dict
-
PyFunceble.
is_ip_range
(subject)[source]¶ Check if the given subject is a syntactically valid IPv4 or IPv6 range.
Parameters: subject (str|list) – The subject to check the syntax from. Returns: The IPv4 range state. Return type: bool|dict
-
PyFunceble.
is_ipv4
(subject)[source]¶ Check if the given subject is a syntactically valid IPv4.
Parameters: subject (str|list) – The subject to check the syntax from. Returns: The syntax validity. Return type: bool|dict
-
PyFunceble.
is_ipv4_malicious
(subject)[source]¶ Checks if the given IPv4 is malicious.
Return type: bool
-
PyFunceble.
is_ipv4_range
(subject)[source]¶ Check if the given subject is a syntactically valid IPv4 range.
Parameters: subject (str|list) – The subject to check the syntax from. Returns: The IPv4 range state. Return type: bool|dict
-
PyFunceble.
is_ipv6
(subject)[source]¶ Checks if the given subject is syntactivally valid IPv6.
Parameters: subject (str, list) – The subject to check the syntax from. Returns: The syntax validity. Return type: bool|dict
-
PyFunceble.
is_subdomain
(subject)[source]¶ Check if the given subject is a syntactically valid subdomain.
Parameters: subject (str|list) – The subject to check the syntax from. Returns: The syntax validity. Return type: bool|dict
-
PyFunceble.
is_url
(subject)[source]¶ Check if the given subject is a syntactically valid URL.
Parameters: subject (str|list) – The subject to check the syntax from. Returns: The syntax validity. Return type: bool|dict
-
PyFunceble.
is_url_malicious
(subject)[source]¶ Checks if the given URL is malicious.
Parameters: subject (str) – The subject to work with. Return type: bool
-
PyFunceble.
load_config
(generate_directory_structure=False, custom=None, sanity_check=False)[source]¶ Load the configuration.
Parameters: Note
If
config
is given, the givendict
overwrite the last value of the given indexes in the configuration.It’s actually something like following:
pyfunceble.configuration.update(config_given_by_user)
-
PyFunceble.
syntax_check
(domain)[source]¶ Check the syntax of the given domain.
Parameters: domain (str|list) – The domain to check the syntax from. Returns: The syntax validity. Return type: bool|dict
-
PyFunceble.
test
(subject, complete=False, config=None)[source]¶ Test the availability of the given subject (domain or IP).
Parameters: Returns: The status or the informations of the domain.
Return type: str|dict
Note
If
config
is given, the givendict
overwrite the last value of the given indexes in the configuration.It’s actually something like following:
pyfunceble.configuration.update(config_given_by_user)
Note
If
complete
is set toTrue
, we return the following indexes.{ "_status_source": None, "_status": None, "dns_lookup": [], "domain_syntax_validation": None, "expiration_date": None, "given": None, "http_status_code": None, "ipv4_range_syntax_validation": None, "ipv4_syntax_validation": None, "ipv6_range_syntax_validation": None, "ipv6_syntax_validation": None, "status": None, "status_source": None, "subdomain_syntax_validation": None, "tested": None, "url_syntax_validation": None, "whois_record": None, "whois_server": None, }
-
PyFunceble.
url_syntax_check
(url)[source]¶ Check the syntax of the given URL.
Parameters: url (str|list) – The URL to check the syntax for. Returns: The syntax validity. Return type: bool|dict
-
PyFunceble.
url_test
(subject, complete=False, config=None)[source]¶ Test the availability of the given subject (URL).
Parameters: Returns: The status or the informations of the URL.
Return type: str|dict
Note
If
config
is given, the givendict
overwrite the last value of the given indexes in the configuration.It’s actually something like following:
pyfunceble.configuration.update(config_given_by_user)
Note
If
complete
is set toTrue
, we return the following indexes.{ "_status_source": None, "_status": None, "dns_lookup": [], "domain_syntax_validation": None, "expiration_date": None, "given": None, "http_status_code": None, "ipv4_range_syntax_validation": None, "ipv4_syntax_validation": None, "ipv6_range_syntax_validation": None, "ipv6_syntax_validation": None, "status": None, "status_source": None, "subdomain_syntax_validation": None, "tested": None, "url_syntax_validation": None, "whois_record": None, "whois_server": None, }
File generation while using the API¶
You may want to test using the API but still want the result structured normally like a CLI usage. For that case simply add the following.
Global configuration load¶
import PyFunceble
OUR_CUSTOM_PYFUNCEBLE_CONFIGURATION = {"api_file_generation": True}
PyFunceble.load_config(
generate_directory_structure=True, custom=OUR_CUSTOM_PYFUNCEBLE_CONFIGURATION
)
# The output directory is then generated, and the file(s) too.
# You logic or whatever you want.
Local configuration load¶
import PyFunceble
OUR_CUSTOM_PYFUNCEBLE_CONFIGURATION = {"api_file_generation": True}
print(
"google.com is "
f"{PyFunceble.test('google.com', config=OUR_CUSTOM_PYFUNCEBLE_CONFIGURATION)}"
)
# The output directory is then generated, and the file(s) too.
Components¶
AdBlock/Filter list decoding¶
Warning
This component is not activated by default.
Why do we need it?¶
As some people may want to test the content of their AdBlock/Filter list, we offer a way to decode them!
How does it work?¶
Note
Want to read the code ? It’s here PyFunceble.converter.adblock.AdBlock.get_converted()
!
We keep it simple by trying to comply with the Adblock Plus filters explained documentation. For us, the relevant parts are the one which defines/explains which domains are being blocked from a given rule.
Note
A more aggressive extraction might be planned in the future.
How to use it?¶
You can simply change
adblock: False
to
adblock: True
into your personal .PyFunceble.yaml
or use the --adblock
argument from the CLI to activate it.
Autocontinue¶
Why do we need it?¶
The auto-continue logic was mainly created for one purpose: Testing long files inside Travis CI. As Travis CI has a time limit of 45 minutes, it became vital for us to be able to stop and continue the test from where we were under those 45 minutes. That’s how it started.
Today, - and it might be controversial - it is used by most people who aren’t under a Travis CI container to continue when the machine or tool crashes.
How does it work?¶
Note
Want to read the code ? It’s here PyFunceble.engine.auto_continue.AutoContinue()
!
We log every subject already tested previously and remove them when the same file path is given again.
How to use it?¶
It is activated by default but if not simply change
auto_continue: False
to
auto_continue: True
into your personal .PyFunceble.yaml
or use the --auto-continue
argument from the CLI to reactivate it.
Autosave¶
Warning
This component is not activated by default.
Why do we need it?¶
This component comes along with the auto-continue one. Indeed, after constructing the logic to auto-continue we needed something to autosave.
How does it work?¶
Note
Want to read the code ? It’s here PyFunceble.engine.auto_save.AutoSave()
!
After a given amount of minutes, we stop the tool, generate the percentage, run a given command (if found), commit all the changes we made to the repository and finally, push to the git repository.
How to use it?¶
For Travis CI and GitLab CI/CD¶
The following (from the configuration) or their equivalent from the CLI are required.
ci: False
ci_autosave_commit: "Your awesome commit message"
ci_autosave_final_commit: "Your awesome final commit message"
ci_autosave_minutes: 15
ci_branch: master
Note
If you give the command
index something, we will run it at the end of each commits except the last one.
The command on the last commit is executed based on the given command_before_end
index.
Certificate verification¶
Warning
This component is not activated by default.
Why do we need it?¶
You might sometime be sure that every URL tested with PyFunceble have a valid certificate. This what it’s all about!
How does it work?¶
If the certificate is not valid (catched with requests
). An INACTIVE
status is returned (if this component is activated of course)
How to use it?¶
Simply change
verify_ssl_certificate: False
to
auto_verify_ssl_certificatecontinue: True
into your personal .PyFunceble.yaml
or use the --verify-ssl-certificate
argument from the CLI to activate it.
Cleaning¶
Why do we need it?¶
Because we constantly need to clean files which are not needed before starting a new test, we embedded our cleaning logic.
How does it work?¶
Note
Want to read the code ? It’s here PyFunceble.output.clean.Clean()
!
It has an internal map of what has to be deleted and how.
How to clean?¶
For a simple clean, run PyFunceble with the --clean
argument.
For a complete cleaning, run PyFunceble with the --clean-all
argument.
Differences between simple and complete cleaning?¶
The --clean
logic cleans the output/
directory along with the pyfunceble_tested
table
when the mariadb
or mysql
database type are choosen.
The --clean-all
deletes all files generated along with the content of all database tables
when the mariadb
or mysql
database type are choosen.
Warning
--clean-all
does not delete the following files (even if generated by us):
.pyfunceble-env
whois_db.json
Warning
--clean-all
does not delete the content of the following tables:
pyfunceble_whois
Complements Generation¶
Warning
This component is not activated by default.
Why do we need it?¶
Let’s say we have example.org
but www.example.org
(or vice-versa) is not into my list.
This component (if activated) let us test www.example.org
(or vice-versa) even if it’s not
into the given list.
How does it work?¶
Note
Want to read the code ? It’s here PyFunceble.get_complements()
!
At the end of the normal test process, we generate the list of complements and test them.
How to use it?¶
You can simply change
generate_complements: False
to
generate_complements: True
into your personal .PyFunceble.yaml
or use the --complements
argument from the CLI to activate it.
Configuration¶
Why do we need it?¶
As we wanted to be hybrid and allow different modes and options, we introduced the configuration logic.
How does it work?¶
Note
Want to read the configuration loader code ? It’s here PyFunceble.config.load.Load()
!
We first look for the .PyFunceble.yaml
. If not found, we get/generate it.
Then we parse it to the system.
Note
Because we also wanted to get rid of the configuration for an end-user point of view, almost all configuration indexed can be updated from the CLI.
In that case, we update the configuration with the different argument you gives us before parsing it to the system.
Note
If in the future a new configuration key is introduced, you will be asked to choose if you want to merge it into your .PyFunceble.yaml
.
In that case, we get a copy of the new one and keep/set all previously set indexes. Which means that you don’t have to care about reconfiguring previously set indexes.
How to configure?¶
Update the .PyFunceble.yaml
file or use the CLI.
Custom DNS Server¶
Why do we need it?¶
Some times the testing environment is setup to use DNS-server which isn’t suited for running a PyFunceble test of actually expired or active domains or urls. This could by example be your own DNS-Firewall.
To avoid these situations, the program allows you to setup test DNS-Server.
How does it work?¶
Thanks to python-dns
we can parse the given DNS server.
How to use it?¶
By default, PyFunceble will use the system-wide DNS settings. This can be changed with the ability to configure which DNS-Servers you like PyFunceble to use doing the test.
You set this up with the CLI command --dns
or insert it into your
personal .PyFunceble.yaml
dns_server: null
to
dns_server:
- "8.8.8.8"
- "8.8.8.8"
Since v3.0.0
it is possible to assign a specific port to use with the
DNS-Server.
Hint
–dns 95.216.209.53:53 116.203.32.67:53 9.9.9.9:853
Warning
If you don’t append a port number, the default DNS port (53) will be used.
Custom User-Agent¶
Why do we need it?¶
As we need to be one in a middle of a connection to a webserver, the custom user agent is there for that!
How does it work?¶
We set the user-agent every time we request something with the http
and https
protocols.
If a custom user agent is given, it will be used.
Otherwise, every 24 hours, we update our user-agents.json file which will be fetched by your local version to determine the user-agent to use.
How to use it?¶
Simply choose your browser and platform or provide us your custom one!
user_agent:
browser: chrome
platform: linux
custom: null
into your personal .PyFunceble.yaml
or use the --user-agent
(custom UA) argument from the CLI.
Available Browser¶
Here is a list of available and accepted browsers at this time.
chrome
edge
firefox
ie
opera
safari
Available Platform¶
Here is a list of available and accepted platform at this time.
linux
macosx
win10
What if we don’t give a custom User-Agent?¶
If you don’t set a custom User-Agent, we will try to get the latest one for the chosen browser and platform.
Databases¶
Why do we use “databases”?¶
We use databases to store data while we run the tests. When globally talking about databases, we are indirectly talking about the following subsystems.
- Autocontinue
- InactiveDB
- Mining
- WhoisDB
Warning
There is a difference between what we are talking here and the
--database
argument which only enable/disable the InactiveDB
subsystem.
How do we manage them?¶
They consist of simple JSON files which are read and updated on the fly.
Warnings around Database (self) management¶
Warning
If you plan to delete everything and still manage to use PyFunceble in the
future, please use the --clean-all
argument.
Indeed, it will delete everything which is related to what we generated, except things like the whois database file/table which saves (almost) static data which can be reused in the future.
Deleting, for example, the whois database file/table will just make your test run for a much longer time if you retest subject that used to be indexed into the whois database file/table.
Databases types¶
Since PyFunceble 2.0.0
(equivalent of >=1.18.0.dev
),
we offer multiple database types which are (as per configuration) json
(default), mariadb
and mysql
.
Why different database types?¶
With the introduction of the multiprocessing logic, it became natural to introduce other database format as it’s a nightmare to update a JSON formatted file.
In order to write or use a JSON formatted database, we have to load it and overwrite it completely. It’s great while working with a single CPU/process but as soon as we get out of that scope it become unmanageable.
How to use the mysql
or mariadb
format?¶
Create a new user, password and database (optional) for PyFunceble to work with.
Create a
.pyfunceble-env
file at the root of your configuration directory.Complete it with the following content (example)
PYFUNCEBLE_DB_CHARSET=utf8mb4 PYFUNCEBLE_DB_HOST=localhost PYFUNCEBLE_DB_NAME=PyFunceble PYFUNCEBLE_DB_PASSWORD=Hello,World! PYFUNCEBLE_DB_PORT=3306 PYFUNCEBLE_DB_USERNAME=pyfunceble
Note
Since version
2.4.3.dev
it is possible to use the UNIX socket for thePYFUNCEBLE_DB_HOST
environment variable.The typical location for
mysqld.sock
is/var/run/mysqld/mysqld.sock
.This have been done to make
1. It easier to use the
socket
in conjunction with a supported CI environment/platform.- Leaving more space on the IP-stack on local DB installations.
3. The
UNIX:SOCKET
is usually faster than the IP connection on local runs.PYFUNCEBLE_DB_CHARSET=utf8mb4 PYFUNCEBLE_DB_HOST=/var/run/mysqld/mysqld.sock PYFUNCEBLE_DB_NAME=PyFunceble PYFUNCEBLE_DB_PASSWORD=Hello,World! PYFUNCEBLE_DB_PORT=3306 PYFUNCEBLE_DB_USERNAME=pyfunceble
Switch the
db_type
index of your configuration file tomysql
ormariadb
.Play with PyFunceble!
Note
If the environment variables are not found, you will be asked to prompt the information.
Directory Structure¶
Why do we need it?¶
As we wanted the end-user to be able to work from everywhere into the filesystem,
we created a logic which will create and keep the output/
directory which complies
with our code.
How does it work?¶
Note
Want to read the code ? It’s here PyFunceble.output.constructor.Constructor()
!
After each version, the maintainer does a --production
which will prepare the repository
for production.
That has the side effect to map the maintainer version of the output/
directory into a file called dir_structure_production.json
.
Once pushed, on the end-user side, when testing for file, that file is downloaded into
a file called dir_structure.json
which is then used to restore/create a
a perfect copy of the output directory the maintainer had when pushing the new
version.
Note
If you find yourself in a case that a directory is not found, please try first to
delete the dir_structure*.json
files to force a resynchronization.
How to generate it manually?¶
You can’t. But using the --dir-structure
argument will do the job on purpose.
DNS Lookup¶
Why do we need it?¶
As our main purpose is to check the availability of the given subjects, we make a DNS lookup to determine it.
How does it work?¶
Note
Want to read the code ? It’s here PyFunceble.lookup.dns.DNSLookup.request()
!
For domains¶
In order:
- Request the
NS
record. - If not found, request the
A
record. - If not found, request the
AAAA
record. - If not found, request the
CNAME
record. - If not found, request the
DNAME
record.
Warning
If none is found, we call the UNIX/C equivalent of getaddrinfo()
.
For IP¶
We request the PTR
record for the IP.
Warning
If none is found, we call the UNIX/C equivalent of gethostbyaddr()
.
Environment variables¶
Dotenv files¶
Since PyFunceble 2.0.0
(equivalent of PyFunceble-dev >=1.18.0
), we load (thanks to python-dotenv) the content of
the following files into the (local) list of environment variables.
.env
(current directory).pyfunceble-env
(current directory).env
(configuration directory).pyfunceble-env
(configuration directory)
To quote the python-dotenv documentation, a .env
should look like the following:
# a comment and that will be ignored.
REDIS_ADDRESS=localhost:6379
MEANING_OF_LIFE=42
MULTILINE_VAR="hello\nworld"
What do we use and why ?¶
Here is the list of environment variables we use and how we use them if they are set.
Environment Variable | How do we use it? |
DEBUG_PYFUNCEBLE |
Same as PYFUNCEBLE_DEBUG it’s just present for retro-compatibility. |
DEBUG_PYFUNCEBLE_ON_SCREEN |
Same as PYFUNCEBLE_DEBUG_ON_SCREEN it’s just present for retro-compatibility. |
PYFUNCEBLE_AUTO_CONFIGURATION |
Tell us if we have to install/update the configuration file automatically. |
PYFUNCEBLE_DB_CHARSET |
Tell us the MySQL charset to use. |
PYFUNCEBLE_DB_HOST |
Tell us the host or the Unix socket (absolute file path) of the MySQL database. |
PYFUNCEBLE_DB_NAME |
Tell us the name of the MySQL database to use. |
PYFUNCEBLE_DB_PASSWORD |
Tell us the MySQL user password to use. |
PYFUNCEBLE_DB_PORT |
Tell us the MySQL connection port to use. |
PYFUNCEBLE_DB_USERNAME |
Tell us the MySQL user-name to use. |
PYFUNCEBLE_DEBUG |
Tell us to log everything into the output/logs/*.log files. |
PYFUNCEBLE_DEBUG_ON_SCREEN |
Tell us to log everything to stdout |
PYFUNCEBLE_CONFIG_DIR |
Tell us the location of the directory to use as the configuration directory. |
PYFUNCEBLE_OUTPUT_DIR |
Same as PYFUNCEBLE_CONFIG_DIR it’s just present for retro-compatibility. |
PYFUNCEBLE_OUTPUT_LOCATION |
Tell us where we should generate the output/ directory. |
APPDATA |
Used under Windows to construct/get the configuration directory if PYFUNCEBLE_CONFIG_DIR is not found. |
GH_TOKEN |
Tell us the GitHub token to set into the repository configuration when using PyFunceble under Travis CI. |
GL_TOKEN |
Tell us the GitLab token to set into the repository configuration when using PyFunceble under GitLab CI/CD. |
GIT_EMAIL |
Tell us the git.email configuration to set when using PyFunceble under any supported CI environment. |
GIT_NAME |
Tell us the git.name configuration to set when using PyFunceble under any supported CI environment. |
TRAVIS_BUILD_DIR |
Used to confirm that we are running under a Travis CI container. |
GITLAB_CI |
Used to confirm that we are running under a GitLab CI/CD environment. |
GITLAB_USER_ID |
Used to confirm that we are running under a GitLab CI/CD environment. |
Execution time¶
Warning
This component is not activated by default.
Why do we need it?¶
As it is always nice to see how long we worked, we added this logic!
How does it work?¶
Note
Want to read the code ? It’s here PyFunceble.cli.execution_time.ExecutionTime()
!
It shows the exection time on screen (stdout
) and at the end of the output/logs/percentage/percentage.txt
file if show_percentage
is activated.
How to use it?¶
You can simply change
show_execution_time: False
to
show_execution_time: True
into your personal .PyFunceble.yaml
or use the --execution
argument from the CLI to activate it.
List filtering¶
Warning
This component is not activated by default.
Why do we need it?¶
While testing for file, you may find yourself in a situation where you only want to test subject which matches a given pattern. That’s what this component do.
How does it work?¶
We scan the list against the given pattern/regex and only test those who match it.
How to use it?¶
You can simply change
filter: ""
to
filter: "\.org"
(for example)
into your personal .PyFunceble.yaml
or use the --filter
argument from the CLI.
IANA Root Zone Database¶
Why do we need it?¶
We use it to check if an extension is valid/exists.
How does it work?¶
Note
Want to read the parser code ? It’s here PyFunceble.lookup.iana.IANA()
!
The root zone database is saved into the iana-domains-db.json
file.
It is formatted like below and is automatically merged for the end-user before
each test run.
{
"extension": "whois_server"
}
In-app, while testing for a domain, we check if the extension is listed there before doing some extra verifications.
If not, domain(s) will be flagged as INVALID
.
How to generate it manually?¶
You can’t and should not as we are automatically generating it every 24 hours.
But using the --iana
argument will do the job on purpose.
Test in/for local hostnames, IPs, components¶
Warning
This component is not activated by default.
Why do we need it?¶
As we may need to test for local hostnames, IPs, components in a local network, this component allows a less aggressive way of syntax validation.
How does it work?¶
We simply use a less aggressive syntax validation so that everything you give us is being tested.
How to use it?¶
Simply change
local: False
to
local: True
into your personal .PyFunceble.yaml
or use the --local
argument from the CLI to activate it.
Logs Sharing¶
Warning
This component is not activated by default.
Why do we need it?¶
We chose to initiate the logs sharing as some actions can really be random when working with millions of domains.
The idea and purpose of this feature are ONLY to make PyFunceble a better tool.
Mining¶
Warning
This component is not activated by default.
Why do we need it?¶
Sometimes you might, for example, want to get the list of domain(s) / URL(s) in a redirecting loop. This feature reveals them.
How does it work?¶
Note
Want to read the code ? It’s here PyFunceble.engine.mining.Mining()
!
We access the given domain/URL and get the redirection history which we then test once we finished the normal test.
Note
This component might evolve with time.
How to use it?¶
You can simply change
mining: False
to
mining: True
into your personal .PyFunceble.yaml
or use the --mining
argument from the CLI to activate it.
Multiprocessing¶
Warning
This component is not activated by default.
Why do we need it?¶
Many people around the web who talked about PyFunceble were talking about one thing: We take time to run.
This component allows you to use more than one process if your machine has multiple CPU.
Note
If you use this component you have to consider some limits:
- Your connection speed.
- Your machine.
You might not even see a speed if one of both is slow or very slow.
The following might not be touched by the limits but it really depends:
- URL availability test.
- Syntax test.
- Test with DNS LOOKUP only - without WHOIS.
How does it work?¶
We test multiple subjects at the same time over several processes (1 process = 1 subject tested) and generate our results normally.
Note
While using the JSON format for the database you might have to wait a bit at the very end as we need to merge all data we generated across the past created processes.
Therefore, we recommend using the MySQL/MariaDB format which will get rid of that as everything is saved/synchronized at an almost real-time scale.
How to use it?¶
Number of processes to create¶
Simply update the default value of
maximal_processes: 25
Warning
If you do not explicitly set the --processes
argument,
we overwrite the default to the number of available CPU.
Warning
If this value is less than 2
, the system will
automatically deactivate the multiprocessing.
Merging mode¶
2 merging cross process (data) merging mode are available:
end
live
With the end
mode, we merge all data at the very end of the current instance.
With the live
mode, we merge all data while testing.
Simply update the default value of
multiprocess_merging_mode: end
to the mode you want.
Outputed Files¶
Note
This section does not cover the logs files.
Why do we need it?¶
We need a way to deliver our results.
How does it work?¶
After testing a given subject, we generate its output file based on what’s needed.
Host format¶
This is the default output file.
A line is formatted like 0.0.0.0 example.org
.
Note
A custom IP can be set with the help of the custom_ip
index or the -ip
argument from the CLI.
Don’t need it? Simply change
generate_hosts: True
to
generate_hosts: False
into your personal .PyFunceble.yaml
or use the --hosts
argument from the CLI to deactivate it.
Plain format¶
A line is formatted like example.org
.
.
Need it? Simply change
plain_list_domain: False
to
plain_list_domain: True
into your personal .PyFunceble.yaml
or use the --plain
argument from the CLI to activate it.
JSON format¶
Need it? Simply change
generate_json: False
to
generate_json: True
into your personal .PyFunceble.yaml
or use the --json
argument from the CLI to activate it.
Percentage¶
Warning
This component is activated by default while testing files.
Note
The percentage doesn’t show up - by design - while testing for single domains (whilst using --domain
).
Why do we need it?¶
We need it in order to get information about the amount of data we just tested.
How does it work?¶
Note
Want to read the code ? It’s here PyFunceble.output.percentage.Percentage()
!
Regularly or at the very end of a test we get the number of subjects for each status along with the number of tested subjects.
We then generate and print the percentage calculation on the screen (stdout
) and into output/logs/percentage/percentage.txt
How to use it?¶
It is activated by default, but if not please update
show_percentage: False
to
show_percentage: True
into your personal .PyFunceble.yaml
or use the --percentage
argument from the CLI to reactivate it.
The Public Suffix List¶
Why do we need it?¶
We use it in the process of checking the validity of domains.
How does it work?¶
Note
Want to read the parser code ? It’s here PyFunceble.lookup.publicsuffix.PublicSuffix()
!
The copy of the public suffix list we use is saved into the public-suffix.json
file.
It is formatted like below and is automatically merged for the end-user before
each test run.
{
"extension": [
"suffix1.extension",
"suffix2.extension",
"suffix3.extension"
]
}
In-app, while testing for domain(s), we use it in order to know if we are checking for a subdomain or not.
How to generate it manually?¶
You can’t and should not as we are automatically generating it every 24 hours.
But, using the --public-suffix
argument will do the job on purpose.
Sorting¶
Note
While using the multiprocessing option, the data are tested as given.
Why do we need it?¶
Because sorted is better, we sort by default!
How does it work?¶
Note
Want to read the code ? It’s here: Sort()
!
Alphabetically¶
This is the default one. The default python sorted()
function is used for that purpose.
Hierarchically¶
The objective of this is to provide sorting by service/domains.
Note
This is a simplified version of what we do.
- Let’s say we have
aaa.bbb.ccc.tdl
. Note
The TDL part is determined. Indeed we first look at the IANA Root Zone database, then at the Public Suffix List.
- Let’s say we have
Let’s split the points. We then get a list
[aaa, bbb, ccc, tdl]
Put the TDL first. It will gives us
[tdl, aaa, bbb, ccc]
Reverse everything after the TDL. It will gives us
[tdl, ccc, bbb, aaa]
.Get the string to use for sorting. It will gives us
tdl.ccc.bbb.aaa
.
How to activate the hierarchical sorting?¶
Simply change
hierarchical_sorting: False
to
hierarchical_sorting: True
into your personal .PyFunceble.yaml
or use the --hierarchical
argument from the CLI to activate it.
Whois Lookup¶
Note
While testing using PyFunceble, subdomains, IPv4 and IPv6 are not used against our whois lookup logic.
Why do we need it?¶
As our main purpose is to check the availability of the given subjects, we make a WHOIS lookup (if authorized) to determine it.
How does it work?¶
Note
Want to read the code ? It’s here PyFunceble.lookup.whois.WhoisLookup()
!
For us the only relevant part is the extraction of the expiration date. Indeed, it’s an indicator if a domains is still owned by someone, we use it first to get the availability of domains.
How to use it?¶
It is activated by default but if not simply change
no_whois: True
to
no_whois: False
into your personal .PyFunceble.yaml
or use the --no-whois
argument from the CLI to reactivate it.
Contribute¶
Submit changes¶
Before anything, please keep in mind the following. If one or more of those conditions are not filled. Your Pull Request to PyFunceble may not be merged.
The master
branch is used only for releasing a new or stable version of the code.
That’s why we require that all contributions/modifications must be done under the dev
or a new branch.
In order to gain some time and also understand what you are working on, your pull requests submission as long as your commit descriptions should be clear and complete as much as possible. We do an exception to commit with minor changed but big changes should have a complete description. Please ensure to use the following method when committing a big change.
Coding conventions¶
Format¶
- We should format our code with Black, The uncompromising Python code formatter.
- We should write docstrings for every public method, function and classes. It does not have to be elaborate. Just explain what it simply does!
$ black PyFunceble && black tests
Linting¶
Our code should pass a pylint
check without any issue (exit 0).
$ pylint PyFunceble && pylint tests
Coverage¶
Our code should have at least 60% of coverage.
Note
Coverage unrelevant code/files can be muted.
$ coverage run setup.py test && coverage report -m
Distribution¶
Our code should be shipped (after each commit) with a new version and a new version.yaml
file.
That file should ALWAYS be generated with the following.
Note
An exception is granted for detached branch (not dev
nor master
)
and no code changes.
$ # Prepare our files, :code:`version.yaml` and code for production/dev usage.
$ PyFunceble --production
Commit¶
All your commits should be - when possible - be signed with PGP. (More information can be found on GitHub documentation)
Please note the usage of -S
into the commit command which means that we sign the commit.
The commit message may be formatted like follow:
Note
An exception is granted for no code changes.
- ::
Short explanation (max 79 char).
Paragraphs with some details/context (if needed).
Git Hook¶
If one may want to automate the process.
Here is a git hook (as proposition) to be set into .git/hooks/pre-commit
.
#!/usr/bin/env bash
# We print what's going on.
set -x
# We stop on error.
set -e
# We get top level path.
rootDirectory="$(git rev-parse --show-toplevel)"
# We construct our list of directories.
ourDirectories="${rootDirectory}/PyFunceble ${rootDirectory}/tests"
if [[ ! -z "$(git status --porcelain | awk '{ if ($NF > 0 && substr($1,1,1) != "?" && $2 ~ '/\.py/' ) print $2}')" ]]
then
hash find
hash isort
hash black
hash pylint
hash coverage
for directory in $(echo ${ourDirectories})
do
# We sort the imports.
find "${directory}" -name "*.py" -exec isort {} \;
# We format the code.
black "${directory}"
# We lint the code.
pylint "${directory}"
done
cd "${rootDirectory}"
coverage run setup.py test
fi
set +e
set +x
exit 0
Code Documentation¶
Logic representation¶
Don’t have time to review the code and want to know exactly what PyFunceble does in general? This flowchart is there for you!
Note
This is a simplified version of what we do.
Note
The diagrams were generated with the help of yEd Graph Editor.
Domain testing¶

IP testing¶

URL testing¶

Check¶
Problematic¶
How can we efficiently check the syntax of IP, domains, and URL?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the syntax checker interface.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
class
PyFunceble.check.
Check
(subject)[source]¶ Provides our syntax checkers.
Parameters: subject (str) – The subject (URL, IP or domain) to check. -
SPECIAL_USE_DOMAIN_NAMES_EXTENSIONS
= ['onion']¶ Specifies the extension which are specified as “Special-Use Domain Names” and supported by our project.
Type: list See also
- RFC6761
- IANA Special-Use Domain Names assignments.
- RFC7686
-
is_domain
(subdomain_check=False)[source]¶ Checks if the given subject is a valid domain.
Parameters: subdomain_check (bool) – Activates the subdomain checking.
Returns: The validity. Return type: bool
-
is_ip
()[source]¶ Checks if the given subject is a valid IPv4 or IPv6.
Returns: The validity. Return type: bool
-
is_ip_range
()[source]¶ Checks if the given subject is a valid IPv4 or IPv6 range.
Returns: The validity. Return type: bool
-
is_ipv4
()[source]¶ Checks if the given subject is a valid IPv4.
Returns: The validity. Return type: bool
-
is_ipv4_range
()[source]¶ Checks if the given subject is a valid IPv4 range.
Returns: The validity. Return type: bool
-
is_ipv6
()[source]¶ Checks if the given subject is a valid IPv6.
Returns: The validity. Return type: bool
-
is_ipv6_range
()[source]¶ Checks if the given subject is a valid IPv6 range.
Returns: The validity. Return type: bool
-
is_reserved_ip
()[source]¶ Checks if the given subject is a reserved IPv4 or IPv6.
Returns: The validity. Return type: bool
-
is_reserved_ipv4
()[source]¶ Checks if the given subject is a reserved IPv4.
Note
This method has been written on basis of the following links:
Returns: The validity. Return type: bool
-
is_reserved_ipv6
()[source]¶ Checks if the given subject is a reserved IPv6.
Returns: The validity. Return type: bool
-
is_subdomain
()[source]¶ Checks if the given subject is a valid subdomain.
Returns: The validity. Return type: bool
-
Exceptions¶
Problematic¶
How can we provide our very own exceptions ?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides our exceptions.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
exception
PyFunceble.exceptions.
ConfigurationFileNotFound
[source]¶ Describes a missing configuration file.
-
exception
PyFunceble.exceptions.
NoConversionMade
[source]¶ Describes the fact that a conversion was expected but none was made.
-
exception
PyFunceble.exceptions.
NoDownloadDestinationGiven
[source]¶ Describes the fact that the download destination was not declared.
-
exception
PyFunceble.exceptions.
NoDownloadLinkGiven
[source]¶ Describes the fact that no download link was declared.
-
exception
PyFunceble.exceptions.
NoExtractionMade
[source]¶ Describes the fact that an extraction was expected but none was made.
-
exception
PyFunceble.exceptions.
PleaseUpdatePyFunceble
[source]¶ Describes the impossiblity to continue with an older version.
-
exception
PyFunceble.exceptions.
PyFuncebleExternalException
[source]¶ Describes an exception which is caused by an external input.
-
exception
PyFunceble.exceptions.
PyFuncebleInternalException
[source]¶ Describes an exception which is caused by our own logic.
-
exception
PyFunceble.exceptions.
UnknownSubject
[source]¶ Describes the fact that an unknown subject is inputed.
-
exception
PyFunceble.exceptions.
UserAgentBrowserNotFound
[source]¶ Describes the fact that we could not find a valid browser to work with.
-
exception
PyFunceble.exceptions.
UserAgentNotFound
[source]¶ Describes the fact that we could not find a user agent to work with.
Abstracts¶
Problematic¶
How can we work with abstracted data and information which are not directly related to our project main logic?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the abtracted logics/data.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Infrastructure()
¶
-
class
PyFunceble.abstracts.infrastructure.
Infrastructure
[source]¶ Provides some infrastructure related abstractions.
-
CI_MIGRATION_TRIGGER_FILE
= '.trigger'¶ Sets the name of the file to write into for the case that we are migrating to sqlalchemy from inside a CI engine.
Type: str
-
CONFIGURATION_FILENAME
= '.PyFunceble.yaml'¶ Sets the name of the user editable configuration file.
Type: str
-
DEFAULT_CONFIGURATION_FILENAME
= '.PyFunceble_production.yaml'¶ Sets the name of the default configuration file.
Type: str
-
DOWN_FILENAME
= '.pyfunceble_intern_downtime.json'¶ Sets the name of our own download time record file.
Type: str
-
HASHES_FILENAME
= 'hashes_tracker.json'¶ Sets the name of the file which will save the hashes of the files we are testing.
-
IPV4_REPUTATION_FILENAME
= 'ipv4_reputation.data'¶ Sets the name of our own copy of the IPv4 reputation data file.
Type: str
-
PROD_CONFIG_LINK
= 'https://raw.githubusercontent.com/funilrys/PyFunceble/3.x/.PyFunceble_production.yaml'¶ Sets the link to the production configuration file.
Type: str
-
USER_AGENT_FILENAME
= 'user_agents.json'¶ Sets the name of our own copy of the user agents file.
-
Package()
¶
Platform()
¶
-
class
PyFunceble.abstracts.platform.
Platform
[source]¶ Provides an easy way to get the current platform.
-
CYGWIN
= ['cygwin', 'cygwin_nt-10.0']¶ Provides the list of supporter cygwin platform.
Type: lsit
-
classmethod
is_cygwin
()[source]¶ Checks if the current platform is in our cygwin list.
Return type: bool
-
Version()
¶
-
class
PyFunceble.abstracts.package.
Version
[source]¶ Provides a simple way to compare our own versions.
-
classmethod
compare
(upstream)[source]¶ Compares the given versions with the local one.
Parameters: Returns: True
: local < upstreamNone
: local == upstreamFalse
: local > upstream
Return type:
-
classmethod
literally_compare
(local, upstream)[source]¶ Compares the given versions, literally.
Parameters: Returns: True
: local == upstreamFalse
: local != upstream
Return type:
-
classmethod
CLI¶
Problematic¶
How can we easily work and distribute some CLI related logic?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the CLI entry points.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Dispatcher()
¶
-
class
PyFunceble.cli.dispatcher.
Dispatcher
(preset, domain_or_ip=None, file_path=None, url_file_path=None, url_to_test=None, generate_results_only=False, generate_all_results_only=False)[source]¶ Dispatches to one of the other brain.
Note
We are talking about
brain
because, eachPyFunceble.core.*
is a unique brain which has it’s own function ;-)Sometimes, 2 brains depends from the other one. But that’s great because working together is always great ;-)
Parameters: - preset (
Preset
) – An instance of the configuration preset. - domain_or_ip (list) – A list of subject to test.
- file_path (str) –
A file path or a link.
Note
If a file path is given, we read and test its content.
Note
If a link is given, we download it’s content and test it.
Warning
If given, we consider each line to be an adblock filter, a host file format or a subject to test.
- url_file_path (str) –
A file path or a link.
Note
If a file path is given, we read and test its content.
Note
If a link is given, we download it’s content and test it.
Warning
If given, we consider each line to be a URL to test.
- url_to_test (str) – A list of URL to test.
-
classmethod
dispatch_file_test
(file_path, generate_results_only, generate_all_results_only)[source]¶ Dispatches to the brain in charge of file testing.
Parameters: - file_path (str) – The file path to test.
- generate_results_only (bool) – Tell us to only regenerate from the data stored into the MariaDB/MySQL databases.
- generate_all_results_only (bool) –
Tell us to only regenerate from the data stored into the MariaDB/MySQL databases.
Note
The difference with
generate_results_only
is that it includes the retested which status didn’t changed.
- preset (
ExecutionTime()
¶
-
class
PyFunceble.cli.execution_time.
ExecutionTime
(action='start', last=False)[source]¶ Sets and returns the execution time of the program.
Parameters: Checks the execution authorization.
Returns: The authorization status. Return type: bool
-
classmethod
calculate
(start=None, end=None)[source]¶ Calculates the difference between starting and ending time.
Parameters: Returns: A dict with following as index.
days
hours
minutes
seconds
as index.
Return type:
-
format_execution_time
(start=None, end=None)[source]¶ Formats the calculated time into a human readable format.
Parameters: Returns: A human readable date.
Return type:
Config¶
Problematic¶
- How can we make personalization more simple?
- How can we automatically merge the new configuration with the local one?
- How can we link some configuration endpoints with the real logic.
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the configuration logics.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Load()
¶
Merge()
¶
Preset()
¶
-
class
PyFunceble.config.preset.
Preset
[source]¶ Checks or update the global configuration based on some events.
-
classmethod
_Preset__are_we_allowed_to_overwrite
(index)¶ Checks if we are allowed to overwrite an index.
-
classmethod
maximal_processes
()[source]¶ Ensures that the number of maximal processes is alway >= 2. If not, we don’t authorize the multiprocessing.
-
classmethod
switch
(variable, custom=False)[source]¶ Switches
PyFunceble.CONFIGURATION
variables to their opposite.Parameters: - variable (str|bool) – The variable name to switch. The variable should be an index our configuration system. If we want to switch a bool variable, we should parse it here.
- custom (bool) – Let us know if have to switch the parsed variable instead of our configuration index.
Returns: The opposite of the configuration index or the given variable.
Return type: Raises: Exception
When the configuration is not valid. In other words, if the PyFunceble.CONFIGURATION[variable_name] is not a bool.
-
classmethod
Converter¶
Problematic¶
How can we convert some data into something else or something our system understand.
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the converters.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
ConverterBase()
¶
AdBlock()
¶
-
class
PyFunceble.converter.adblock.
AdBlock
(data_to_convert, aggressive=False)[source]¶ Converts an adblock filter line to a list os subject to test.
-
_AdBlock__decode_v1
(data)¶ Decodes the v1.
Parameters: data (str) – A string to decode. Return type: list
-
_AdBlock__decode_v2
(data)¶ Decodes the v2.
Parameters: data (str) – A string to decode. Return type: list
-
_AdBlock__decode_v3
(data)¶ Decodes the v3.
Parameters: data (str) – A string to decode. Return type: list
-
_AdBlock__decode_v4
(data)¶ Decodes the v4.
Parameters: data (str) – A string to decode. Return type: list
-
extract_base
(subject)[source]¶ Extracts the base of the given element.
- As an example:
- given
"hello.world/?is=beautiful"
returns"hello.world"
Parameters: subject – The subject to work with.
-
extract_from_options
(options)[source]¶ Exctracts the relevant data from the list of options.
Parameters: options (list) – The list of options of a rule. Returns: The list of domains. Return type: list
-
format_decoded
(decoded, result=None)[source]¶ Formats the extracted adblock line in order to be compatible with what the system understand.
Parameters: Returns: The list of domains or IP compatible with the system.
Return type:
-
Digit2Digits()
¶
File()
¶
InternalUrl()
¶
-
class
PyFunceble.converter.internal_url.
InternalUrl
(data_to_convert)[source]¶ Converter of the internal URLs.
Note
The internal URLs are actually the URL that has nothing to do with what we are going to test.
They are only relevant for the software itself.
Parameters: data_to_convert (str) – The data to convert
Core¶
Problematic¶
How can we get started?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the core interfaces.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
APICore()
¶
-
class
PyFunceble.core.api.
APICore
(subject, complete=False, configuration=None, db_file_name='api_call', is_parent=True)[source]¶ Provides the logic and interface for the tests from the API.
Parameters: -
_APICore__inactive_database_management
(subject, status)¶ Given the subject and status, we add or remove the subject from the inactive database.
-
availability
(subject_type)[source]¶ Make an availability check.
Parameters: subject_type (str) – Should be one of the following.
domain
url
-
reputation
(subject_type)[source]¶ Make a reputation check.
Parameters: subject_type (str) – Should be one of the following.
domain
url
-
CLICore()
¶
-
class
PyFunceble.core.cli.
CLICore
[source]¶ Provides some methods which are dedicated for the CLI.
-
classmethod
_CLICore__check_deprecated
(upstream_version)¶ Checks if the local version is deprecated.
-
classmethod
_CLICore__check_force_update
(upstream_version)¶ Checks if we need to force the update.
If it’s the case, we will stop the tool.
-
classmethod
_CLICore__print_messages
(upstream_version)¶ Looks at the messages and prints the one that needs to be printed.
-
classmethod
colorify_logo
(home=False)[source]¶ Print the colored logo based on global results.
Parameters: home (bool) – Tell us if we have to print the initial coloration.
-
classmethod
compare_version_and_print_messages
()[source]¶ Compares the local with the upstream version.
-
classmethod
get_simple_coloration
(status)[source]¶ Given a status we give the coloration for the simple mode.
Parameters: status (str) – An official status output.
-
classmethod
logs_sharing
()[source]¶ Prints an information message when the logs sharing is activated.
-
classmethod
FileCore()
¶
-
class
PyFunceble.core.file.
FileCore
(file, file_content_type='domain')[source]¶ Brain of PyFunceble for file testing.
Parameters: -
_FileCore__run_single_test
(subject, ignore_inactive_db_check=False)¶ Run a test for a single subject.
-
_FileCore__test_line
(line, ignore_inactive_db_check=False)¶ Tests a given line.
-
cleanup
(auto_continue_db, auto_save, test_completed=False)[source]¶ Runs the logic to run at the end of all test.
-
construct_and_get_shadow_file
(file_stream, ignore_inactive_db_check=False)[source]¶ Provides a path to a file which contain the list to file.
The idea is to do a comparison between what we already tested and what we still have to test.
-
classmethod
download_link
(input_file)[source]¶ Downloads the file if it is an URL and return the name of the new file to test.
-
generate_files_of_status
(status, include_entries_without_changes=False)[source]¶ Generates the status file of all subjects of the given status.
Parameters:
-
post_test_treatment
(test_output, file_content_type, complements_test_started=False, auto_continue_db=None, inactive_db=None, mining=None, whois_db=None)[source]¶ Do the post test treatment.
-
OurProcessWrapper()
¶
-
class
PyFunceble.core.multiprocess.
OurProcessWrapper
(*args, **kwargs)[source]¶ Wrapper of Process. The object of this class is just to overwrite
Process.run()
in order to catch exceptions.Note
This class takes the same arguments as
Process
.-
exception
¶ Provides a way to check if an exception was send.
-
MultiprocessCore()
¶
-
class
PyFunceble.core.multiprocess.
MultiprocessCore
(file, file_content_type='domain')[source]¶ Brain of PyFunceble for file testing with multiple processes.s.
Parameters: -
_MultiprocessCore__check_exception
(processes, manager_data)¶ Checks if an exception is present into the given pool of processes.
:param list processes. A list of running processes.
-
_MultiprocessCore__merge_processes_data
(manager_data, tracker=None)¶ Reads all results and put them at the right location.
-
_MultiprocessCore__process_end_merging
(finished, manager_data, tracker)¶ Processes the end merging.
-
_MultiprocessCore__process_live_merging
(finished, manager_data, tracker)¶ Processes the live merging.
-
_MultiprocessCore__run_multiprocess_test
(stream, manager, ignore_inactive_db_check=False, tracker=None)¶ Tests the content of the given file.
-
_MultiprocessCore__start_process
(subject, manager_data, ignore_inactive_db_check=False)¶ Starts a new process.
-
construct_and_get_shadow_file
(file_stream, ignore_inactive_db_check=False)[source]¶ Provides a path to a file which contain the list to file.
The idea is to do a comparison between what we already tested and what we still have to test.
-
SimpleCore()
¶
Database¶
Problematic¶
How can we store our most relevant information?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the database interfaces.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
InactiveDB()
¶
-
class
PyFunceble.database.inactive.
InactiveDB
(filename, parent_process=False)[source]¶ Provides the inactive database logic and interface.
Parameters: filename (str) – The name of the file we are processing. -
_merge
()[source]¶ Merges the database with the older one which has already been set into the database.
Provides the execution authorization.
-
classmethod
datetime
()[source]¶ Gets the timestamp where we are going to save our current list.
Returns: The timestamp to append with the currently tested element. Return type: int|str
-
WhoisDB()
¶
-
class
PyFunceble.database.whois.
WhoisDB
(parent_process=False)[source]¶ Provides the WHOIS database interface and logic.
-
add
(subject, expiration_date, server, record=None)[source]¶ Adds the given subject and expiration date to the database.
Parameters:
Provides the operation authorization.
-
get_expiration_date
(subject)[source]¶ Gets the expiration date of the given subject.
Parameters: subject (str) – The subject we are working with. Returns: The expiration date from the database. Return type: tuple
-
is_time_older
(subject)[source]¶ Checks if the expiration time of the given subject is older.
Parameters: subject (str) – The subject we are working with. Note
Of course, we imply that the subject is in the database.
-
Downloader¶
Problematic¶
How can we easily download one of our static files ?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the downloaders of all our static files.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
DownloaderBase()
¶
-
class
PyFunceble.downloader.base.
DownloaderBase
[source]¶ Provides the downloader base.
-
get_downtime
()[source]¶ Provides the download timestamp of the current
DOWN_TIME_INDEX
.Return type: dict, None
-
ConfigDownloader()
¶
DirectoryStructureDownloader()
¶
IANADownloader()
¶
IPv4ReputationDownloader()
¶
Engine¶
Problematic¶
- How to auto continue?
- How to auto save?
- How to implement a proper debugger?
- How to get subjects related to a tested subject?
- How to work with different database types?
- How to sort our outputs?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the engine interfaces.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
AutoContinue()
¶
-
class
PyFunceble.engine.auto_continue.
AutoContinue
(filename, parent_process=False)[source]¶ Provides the auto-continue subsystem.
-
_AutoContinue__generate_complements
()¶ Generates the complements from the given list of tested.
-
_AutoContinue__get_or_generate_complements_json
()¶ Gets or generates the complements while working with as JSON formatted database.
-
_AutoContinue__get_or_generate_complements_mysql
()¶ Gets or generates the complements while working with as MySQL/MariaDB formatted database.
Provides the execution authorization.
-
AutoSave()
¶
Logger()
¶
-
class
PyFunceble.engine.logger.
Logger
(debug=False, on_screen=False, output_directory=None)[source]¶ Provides our logging logic.
-
_Logger__get_handler
(handler_type)¶ Provides a handler for of the given type.
-
_Logger__init_loggers
()¶ Initiates all loggers.
-
_Logger__set_output_directory
(output_directory)¶ Shares the given output directory.
Note
If the given output directory does not exists, we create it.
Parameters: output_directory (string) – The output directory.
Provides the operation authorization.
-
format_to_apply
= '[%(asctime)s::%(levelname)s::%(origin_path)s:%(origin_line)s@%(origin_func)s](PID%(process)s:%(processName)s): %(message)s'¶ The format to apply.
-
classmethod
get_origin_info
()[source]¶ Returns the information about where the logger was triggered.
Returns: A tuple, which is composed of the following. (trigger file path, trigger line, trigger function/method name)
Return type: tuple
-
root_logger_format
= '[%(asctime)s::%(levelname)s](PID%(process)s:%(processName)s): %(message)s'¶ The format to parse to the root logger (if used).
-
Mining()
¶
-
class
PyFunceble.engine.mining.
Mining
(filename, parent_process=False)[source]¶ Manages the minig subsystem.
Provides the operation authorization.
-
classmethod
get_history
(url, verify=None)[source]¶ Gets the history of the given url.
Parameters: url (str) – An URL to call. Returns: The list of links. Return type: list
-
list_of_mined
()[source]¶ Provides the list of mined domains so that they can be tested.
Returns: The list of mined domains. The returned format is the following:
[ (index_to_delete_after_test, mined), (index_to_delete_after_test, mined), (index_to_delete_after_test, mined) ]
Return type: list
-
mine
(subject, subject_type)[source]¶ Searches for domain or URL related to the original URL or domain. If some are found, we add them into the database.
Parameters:
Sort()
¶
-
class
PyFunceble.engine.sort.
Sort
[source]¶ Provides some sorting presets which we can parse to
PyFunceble.helpers.list.List.custom_format
.-
classmethod
_Sort__get_url_base
(element)¶ Provides the URL base if needed.
-
classmethod
hierarchical
(element)[source]¶ The idea behind this method is to sort a list of domain hierarchically.
Parameters: element (str) – The element we are currently reading. Returns: The formatted element. Return type: str Note
For a domain like
aaa.bbb.ccc.tdl
.A normal sorting is done in the following order:
aaa
bbb
ccc
tdl
This method allow the sorting to be done in the following order:
tdl
ccc
bbb
aaa
-
classmethod
Extractor¶
Problematic¶
How can we extract data from other data?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the extractors.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
ExtractorBase()
¶
ExpirationDate()
¶
-
class
PyFunceble.extractor.expiration_date.
ExpirationDate
(data)[source]¶ Provides a way to extract the expiration date from a given WHOIS record.
Parameters: data (str) – The WHOIS record.s -
_ExpirationDate__extract_it
()¶ Try to extract the expiration date from the given data.
-
_ExpirationDate__format_it
(data)¶ Formats the given data.
-
_ExpirationDate__format_management
(index, matched)¶ A format management helper.
Note
Please note that the second value of the case represent the groups in order
[day,month,year]
.This means that a
[2,1,0]
will be for example for a date in format2017-01-02
where01
is the month.Parameters: Returns: A list representing the expiration date. The list can be “decoded” like
[day, month, year]
Return type: list|None
-
Helpers¶
Problematic¶
How can we avoid writing the same thing every time?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the helpers.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Command()
¶
-
class
PyFunceble.helpers.
Command
(command, encoding='utf-8')[source]¶ Shell command execution.
Parameters: -
_decode_output
(to_decode)[source]¶ Decode the output of a shell command in order to be readable.
Parameters: to_decode (bytes) – Output of a command to decode. Returns: The decoded output. Return type: str
-
run
(rstrip=True)[source]¶ Run the given command and yield each line(s) one by one.
Note
The difference between this method and
execute()
is thatexecute()
wait for the process to end in order to return its output while this method return each line one by one - as they are outputed.Parameters: rstrip (bool) – Deactivates the rstrip of the output.
-
Dict()
¶
-
class
PyFunceble.helpers.
Dict
(main=None)[source]¶ Simplify some
dict
manipulation.Parameters: main (dict) – The main dict
to work with.Raises: TypeError – When main
is not a dict nor a list (tolarated).-
classmethod
from_json
(json_str, return_dict_on_error=True)[source]¶ Converts a given JSON string to dict/list.
Parameters: return_dict_on_error (bool) – Return a dict instead of a NoneType. Return type: dict|list
-
classmethod
from_json_file
(file_path, encoding='utf-8', return_dict_on_error=True)[source]¶ Reads the given file path and convert it’s content to dict/list (tolarated).
Parameters: Return type: dict|list
-
classmethod
from_yaml
(yaml_str)[source]¶ Converts the given YAML string to dict/list.
Parameters: yaml_str (str) – The YAML string to convert. Return type: dict|list
-
classmethod
from_yaml_file
(file_path, encoding='utf-8')[source]¶ Converts a given YAML formatted file, into dict/list.
Parameters: Return type: dict|list
-
has_same_keys_as
(to_check, loop=False)[source]¶ A dirty solution which checks keys are presents in both given
dict
.Parameters: Return type:
-
remove_key
(key_to_remove)[source]¶ Remove a given key from a given dictionary.
Parameters: key_to_remove (list|str) – The key(s) to delete. Returns: The dict without the given key(s). Return type: dict|None
-
rename_key
(key_to_rename, strict=True)[source]¶ Rename the given keys from the given dictionary.
Parameters: Returns: The well formatted dict.
Return type: dict|None
-
to_json
(ensure_ascii=False, indent=4, sort_keys=True)[source]¶ Converts a given dict to JSON and return the json string.
Parameters: Return type:
-
to_json_file
(file_path, ensure_ascii=False, indent=4, sort_keys=True, encoding='utf-8')[source]¶ Converts the given
dict
to JSON and save the result into a given file path.Parameters:
-
to_yaml
(encoding='utf-8', default_flow_style=False, indent=4, allow_unicode=True, sort_keys=True)[source]¶ Converts the given dict/list to the YAML format and return the result.
Parameters: Return type: dict|list
-
classmethod
Directory()
¶
-
class
PyFunceble.helpers.
Directory
(dir_path=None)[source]¶ Simplify the directories manipulation.
:param str dir_path the path to work with.
-
create
(dir_path=None)[source]¶ Creates the given directory path.
Returns: The output of self.exists
after the directory creation.Return type: bool
-
delete
(dir_path=None)[source]¶ Deletes the given directory path.
Returns: not self.exists
after the directory deletion.Rtypt: bool
-
Download()
¶
-
class
PyFunceble.helpers.
Download
(url, verify_certificate=True, retry=3)[source]¶ Simplification of the downloads.
Parameters: -
text
(destination=None)[source]¶ Download the body of the given url.
Note
if
destination
is set toNone
, we only return the output.Otherwise, we save the output into the given destination, but we also return the output.
Parameters: destination (str) – The download destination.
Return type: str:
Raises: - Exception – When the status code is not 200.
- NoInternetConnection – When no connection could be made.
-
File()
¶
-
class
PyFunceble.helpers.
File
(file_path=None)[source]¶ Simplify the file manipulations.
Parameters: file_path (str) – The file path to work with. -
copy
(destination)[source]¶ Copy the globaly given file path to the given destination.
Parameters: destination (str) – The destination of the copy.
-
delete
(file_path=None)[source]¶ Deletes the given file path if it exists.
Parameters: file_path (str) – The file path to check.
Note
If
None
is given, we report to the globally given file path.Returns: The non existance state of the file. Return type: bool
-
exists
(file_path=None)[source]¶ Checks if the given file path exists.
Parameters: file_path (str) – The file path to check.
Note
If
None
is given, we report to the globally given file path.Return type: bool
-
get_size
(file_path=None)[source]¶ Provides the size (in bytes) of the given file path.
Parameters: file_path (str) – The file path to check.
Note
If
None
is given, we report to the globally given file path.Return type: int
-
move
(destination)[source]¶ Move the globally given file path to the given destination.
Parameters: destination (str) – The destination of the file.
-
read
(file_path=None, encoding='utf-8')[source]¶ Read the given file path and return it’s content.
Parameters: Return type:
-
Hash()
¶
-
class
PyFunceble.helpers.
Hash
(algo='sha512_224')[source]¶ Simplify the hashing of data or file content.
Parameters: algo (str) – The algorithm to use for hashing. Raises: ValueError – When the given algo is not known.
List()
¶
-
class
PyFunceble.helpers.
List
(main, remove_empty=False)[source]¶ Simplify the list manipulation.
Parameters: -
custom_format
(key_method, reverse=False)[source]¶ Return a well formatted list. With the key_method as a function/method to format the elements before sorting.
Parameters: - key_method (function|method) – A function or method to use to format the readed element before sorting.
- reverse (bool) – Tell us if we have to reverse the list.
Returns: A sorted list.
Return type:
-
Merge()
¶
-
class
PyFunceble.helpers.
Merge
(main)[source]¶ Simplify the merging of dict and list.
Parameters: main (str, tuple, bool, int, dict, list, float) – The main data to work with. -
_Merge__dict
(origin, strict=True)¶ Process the dict merging.
Parameters: strict (bool) – Activates the strict mode. Return type: dict
-
Regex()
¶
-
class
PyFunceble.helpers.
Regex
(regex, escape=False)[source]¶ Simplify the regex matching and usage.
Parameters: -
get_matching_list
(data)[source]¶ Returns the strings which does the match the regex in the given data.
-
get_not_matching_list
(data)[source]¶ Returns the strings which does not the match the regex in the given data.
-
match
(data, rematch=False, group=0, return_match=True)[source]¶ Checks if the given data match the given regex string.
Parameters:
-
Lookup¶
Problematic¶
How can we look for information about a given subject ?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the lookup interfaces.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
DNSLookup()
¶
-
class
PyFunceble.lookup.dns.
DNSLookup
(dns_server=None, lifetime=3, tcp=False)[source]¶ DNS lookup interface.
Parameters: -
_DNSLookup__get_dns_servers_from
(inputed_dns)¶ Given a list or an input representing dns servers, we ensure that we have a list of a string which represent an IP.
Parameters: input (str, list, tuple) – The inputed DNS server(s). Returns: The list of dns server to use. Return type: list
-
classmethod
_DNSLookup__get_resolver
(dns_server)¶ Provides the configured dns resolver.
-
_DNSLookup__request_complete_not_ip
(subject, tcp=None)¶ Requests and provides the complete DNS spectrum.
Return type: dict
-
_DNSLookup__request_ip
(subject, tcp=None)¶ Handle the request for a subject which is an IP.
Parameters: Return type: Raises: ValueError – When a non string
subject
is given.
-
_DNSLookup__request_not_ip
(subject, complete=False, tcp=None)¶ Handle the request for a subject which is not an IP.
Return type: dict Raises: ValueError – When a non string subject
is given.
-
_get_server_and_port_from
(inputed_dns)[source]¶ Given a list or an input representing dns server, we split the server from the port.
Parameters: inputed_dns – The inputed DNS server(s). Returns: A tuple with: (The DNS, the port)
Return type: tuple
-
a_record
(subject, tcp=None)[source]¶ Return the A record of the given subject (if found).
Parameters: Returns: A list of A record(s).
Return type: Raises: ValueError – When a non string
subject
is given.
-
aaaa_record
(subject, tcp=None)[source]¶ Return the AAAA record of the given subject (if found).
Parameters: Returns: A list of A record(s).
Return type: Raises: ValueError – When a non string
subject
is given.
-
cname_record
(subject, tcp=None)[source]¶ Return the CNAME record of the given subject (if found).
Parameters: Returns: A list of CNAME record(s).
Return type: Raises: ValueError – When a non string
subject
is given.
-
dname_record
(subject, tcp=None)[source]¶ Return the DNAME record of the given subject (if found).
Parameters: Returns: A list of DNAME record(s).
Return type: Raises: ValueError – When a non string
subject
is given.
-
classmethod
get_addr_info
(subject)[source]¶ Get and return the information of the given subject (address).
Parameters: subject (str) – The subject we are working with. Returns: A list of address. Return type: list, None Raises: ValueError – When a non string subject
is given.
-
classmethod
get_host_by_addr
(subject)[source]¶ Get and return the host of the given subject (address).
Parameters: subject (str) – The subject we are working with. Returns: A dict in the following format or None
.{ "hostname": "", "aliases": [], "ips": [] }
Return type: dict, None Raises: ValueError – When a non string subject
is given.
-
classmethod
is_record_present_in_result
(to_check, result, allow_empty=False)[source]¶ Checks if the given record type is in the result.
Parameters: Return type:
-
mx_record
(subject, tcp=None)[source]¶ Return the MX record of the given subject (if found).
Parameters: subject (str) – The subject we are working with. Returns: A list of MX record(s). Return type: list, None Raises: ValueError – When a non string subject
is given.
-
ns_record
(subject, tcp=None)[source]¶ Return the NS record of the given subject (if found).
Parameters: Returns: A list of NS record(s).
Return type: Raises: ValueError – When a non string
subject
is given.
-
ptr_record
(subject, reverse_name=True, tcp=None)[source]¶ Return the PTR record of the given subject (if found).
Parameters: Returns: A list of PTR record(s).
Return type: Raises: ValueError – When a non string
subject
is given.
-
request
(subject, complete=False, tcp=None)[source]¶ Perform a DNS lookup/requests.
Parameters: Returns: A dict with following index if the given subject is not registered into the given DNS server. (More likely local subjects).
{ "hostname": "", "aliases": [], "ips": [] }
A dict with following index for everything else (and if found).
{ "nameservers: [], "A": [], "AAAA": [], "CNAME": [], "DNAME": [], "MX": [], "NS": [], "TXT": [], "PTR": [] }
Return type: Raises: ValueError – When a non string
subject
is given.
-
txt_record
(subject, tcp=None)[source]¶ Return the TXT record of the given subject (if found).
Parameters: Returns: A list of TXT record(s).
Return type: Raises: ValueError – When a non string
subject
is given.
-
HTTPCode()
¶
-
class
PyFunceble.lookup.http_code.
HTTPCode
(subject, subject_type)[source]¶ Get and return the HTTP code status of a given domain.
Parameters: - subject (str) – The subject we are working with.
- _type (subject) –
The type of the subject we are working with. Should be one of the following.
url
domain
file_url
file_domain
ipv6
Iana()
¶
PublicSuffix()
¶
Referer()
¶
-
class
PyFunceble.lookup.referer.
Referer
(subject)[source]¶ Get the WHOIS server (referer) of the current domain extension according to the IANA database.
Parameters: subject (str) – The subject we are working with. -
get
()[source]¶ Return the referer aka the WHOIS server of the current domain extension.
Returns: - [0]
None
if there is no referer. - [0]
False
if the extension is unknown which implicitly means - that the subject is
INVALID
- [0]
- [0]
str
The resolved IP to use. - [1]
str
,None
the domain referer.
Return type: tuple - [0]
-
HostSSLAdapter()
¶
-
class
PyFunceble.lookup.requests.
HostSSLAdapter
(pool_connections=10, pool_maxsize=10, max_retries=0, pool_block=False)[source]¶ Extends the build-in HTTP Adapter for urllib3 for our needs.
-
_HostSSLAdapter__resolve_with_cache
(hostname)¶ Resolve the IP of the given hostname.
Parameters: hostname (str) – The hostname to resolve. Returns: The IP of the host name or the hostname itself. Return type: None, str
-
classmethod
resolve
(hostname)[source]¶ Resolve the IP of the given hostname.
Parameters: hostname (str) – The hostname to resolve. Returns: The IP of the host name or the hostname itself. Return type: None, str
-
send
(request, **kwargs)[source]¶ Overwrite the upstream :code:send` method.
We basically do the same. We only ensure that we request the IP from the chosen DNS record.
Parameters: - request – The
PreparedRequest
being sent. - stream – (optional) Whether to stream the request content.
- timeout (float or tuple or urllib3 Timeout object) – (optional) How long to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple.
- verify – (optional) Either a boolean, in which case it controls whether we verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use
- cert – (optional) Any user-provided SSL certificate to be trusted.
- proxies – (optional) The proxies dictionary to apply to the request.
Return type: - request – The
-
HostAdapter()
¶
-
class
PyFunceble.lookup.requests.
HostAdapter
(pool_connections=10, pool_maxsize=10, max_retries=0, pool_block=False)[source]¶ Extends the build-in HTTP Adapter for urllib3 for our needs.
-
_HostAdapter__resolve_with_cache
(hostname)¶ Resolve the IP of the given hostname.
Parameters: hostname (str) – The hostname to resolve. Returns: The IP of the host name or the hostname itself. Return type: None, str
-
send
(request, **kwargs)[source]¶ Overwrite the upstream :code:send` method.
We basically do the same. We only ensure that we request the IP from the chosen DNS record.
Parameters: - request – The
PreparedRequest
being sent. - stream – (optional) Whether to stream the request content.
- timeout (float or tuple or urllib3 Timeout object) – (optional) How long to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple.
- verify – (optional) Either a boolean, in which case it controls whether we verify the server’s TLS certificate, or a string, in which case it must be a path to a CA bundle to use.
- cert – (optional) Any user-provided SSL certificate to be trusted.
- proxies – (optional) The proxies dictionary to apply to the request.
Return type: - request – The
-
IPv4Reputation
¶
Requests()
¶
-
class
PyFunceble.lookup.requests.
Requests
(max_retries=None)[source]¶ Handles all usage of
requests
.Parameters: url (str) – The URL to work with. -
delete
(url, **kwargs)[source]¶ Sends a DELETE request. Returns
Response
object.Parameters: - url – URL for the new
Request
object. - kwargs – Optional arguments that
request
takes.
Return type: - url – URL for the new
-
exceptions
= <module 'requests.exceptions' from '/home/docs/checkouts/readthedocs.org/user_builds/pyfunceble/envs/3.x/lib/python3.7/site-packages/requests/exceptions.py'>¶
-
get
(url, **kwargs)[source]¶ Sends a GET request. Returns
Response
object.Parameters: - url – URL for the new
Request
object. - kwargs – Optional arguments that
request
takes.
Return type: - url – URL for the new
-
head
(url, **kwargs)[source]¶ Sends a HEAD request. Returns
Response
object.Parameters: - url – URL for the new
Request
object. - kwargs – Optional arguments that
request
takes.
Return type: - url – URL for the new
-
options
(url, **kwargs)[source]¶ Sends a OPTIONS request. Returns
Response
object.Parameters: - url – URL for the new
Request
object. - kwargs – Optional arguments that
request
takes.
Return type: - url – URL for the new
-
patch
(url, **kwargs)[source]¶ Sends a PATCH request. Returns
Response
object.Parameters: - url – URL for the new
Request
object. - kwargs – Optional arguments that
request
takes.
Return type: - url – URL for the new
-
post
(url, **kwargs)[source]¶ Sends a POST request. Returns
Response
object.Parameters: - url – URL for the new
Request
object. - kwargs – Optional arguments that
request
takes.
Return type: - url – URL for the new
-
Output¶
Problematic¶
How can we generate or work with outputs ?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the output related interfaces.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Clean()
¶
-
class
PyFunceble.output.clean.
Clean
(clean_all=False, file_path=None)[source]¶ Provide the cleaning logic.
Note
By cleaning we mean the cleaning of the
output
directory.Parameters: - list_to_test (list|None) – The list of domains we are testing.
- clean_all (bool) – Tell the subsystem if we need to clean all. Which include, of course, the output directory but also all other file(s) generated by our system.
- file_path (str) –
The path to the file we tested.
Note
This is only relevant if you use the MariaDB/MySQL database.
Constructor()
¶
-
class
PyFunceble.output.constructor.
Constructor
(production=False)[source]¶ Basically a backup/reconstructor of our
output
directory.Parameters: production (bool) – Tell the subsystem if we are preparing for production which imply the execution of the backup insteam of of the “reconstructore” mode. -
classmethod
_create_directory
(directory, loop=False)[source]¶ Creates the given directory if it does not exists.
Parameters:
-
_get_structure
()[source]¶ Get the structure we are going to work with.
Returns: The structure we have to work with. Return type: dict
-
_restore_replace
()[source]¶ Check if we need to replace “.gitignore” to “.keep”.
Returns: The replacement status. Return type: bool
-
_update_structure_from_config
(structure)[source]¶ Update the paths according to configs.
Parameters: structure (dict) – The read structure.
-
classmethod
Generate()
¶
-
class
PyFunceble.output.generate.
Generate
(subject, subject_type, status, source=None, expiration_date=None, http_status_code=None, whois_server='Unknown', filename=None, ip_validation=False, end=False)[source]¶ Generate different sort of files.
Parameters: - subject (str) – The subject we are working with.
- subject_type (str) – The type of the subject.
- status (str) – The catched status.
- source (str) – The source of the given status.
- expiration_date (str) – The expiration date of the domain (if catched).
- http_status_code (str|int) – The HTTP status code.
- whois_server (str) – The whois server.
- filename (str) – The name of the file we are testing.
- ip_validation (bool) – The IP validation check of the currently written subject.
-
_Generate___get_info_files_destinations
(output_hosts, output_domains, output_json)¶ Given the output directory, this method return several paths.
Note
The given output directories have to be partially completed.
Indeed, we only do
output % final_location
.Returns: The following paths: ( hosts_destination, plain_destination, json_destination, splited_destination )
Return type: tuple
Provide the authorization for the generation of info files.
Basically here is what we check:
- We are not testing as an imported module.
and
- The hosts file generation is activated.
or
- The plain list generation is activated.
or
- The “api_file_generation” was set into the CONFIGURATION.
-
_analytic_host_file_directory
()[source]¶ Return the analytic directory to write depending of the matched status.
-
analytic_file
(new_status, old_status=None)[source]¶ Generate
Analytic/*
files based on the given old and new statuses.Parameters:
-
file_production
¶ Check if we are allowed to produce a file based from the given information.
Returns: The state of the production. True: We do not produce file. False: We do produce file. Return type: bool
-
info_files
()[source]¶ Generate the hosts file, the plain list, the JSON file and the splitted files.
Logs()
¶
-
class
PyFunceble.output.logs.
Logs
(output=None)[source]¶ Provide a clean and unique way to work with logs. Indeed, it’s not good to have logs spread around the code :smile:
Parameters: output (str) – A path to the JSON file we are going to write. -
classmethod
_get_content
(file)[source]¶ Get and return the content of the given log file.
Parameters: file (str) – The file we have to get the content from. :return The content of the given file. :rtype: dict
-
classmethod
_write_content
(content, file)[source]¶ Write the content into the given file.
Parameters:
-
classmethod
Percentage()
¶
Prints()
¶
-
class
PyFunceble.output.prints.
Prints
(to_print, template, output_file=None, only_on_file=False)[source]¶ Print data on screen and into a file if needed. Template Possibilities: Percentage, Less, HTTP and any status you want.
Parameters: -
_Prints__get_print_size
()¶ Provides the size of the element to print.
-
_colorify
(data)[source]¶ Retun colored string.
Parameters: data (str) – The string to colorify. Returns: A colored string. Return type: str
-
classmethod
_size_from_header
(header)[source]¶ Get the size of each columns from the header.
Parameters: header (dict) – The header template we have to get the size from. Returns: The maximal size of the each data to print. Return type: list
-
before_header
()[source]¶ Print informations about PyFunceble and the date of generation of a file into a given path, if doesn’t exist.
-
data
()[source]¶ Management and input of data to the table.
Raises: Exception
When self.data_to_print is not a list.
-
data_constructor
(size)[source]¶ Construct the table of data according to given size.
Parameters: size (list) – The maximal length of each string in the table.
Returns: A dict with all information about the data and how to which what maximal size to print it.
Return type: OrderedDict
Raises: Exception
If the data and the size does not have the same length.
-
header
(do_not_print=False)[source]¶ Management and creation of templates of header. Please consider as “header” the title of each columns.
Parameters: do_not_print (bool) – Tell us if we have to print the header or not.
-
Status¶
Problematic¶
How can we gather, manage and provide a status for a given subject ?
Documentation¶
The tool to check the availability or syntax of domain, IP or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
Provides the status interfaces.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 Nissar Chababy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
GathererBase()
¶
Status()
¶
-
class
PyFunceble.status.status.
Status
(subject)[source]¶ The status object.
Provides the result of one of the status gatherer.
Parameters: subject (str) – The subject which we describe.
Variables: - _status_source (str) – The status source before the application of our extra rules (if activated).
- _status (str) – The status before the application of our extra rules (if activated).
- dns_lookup (list) – The result of the DNS Lookup logic.
- domain_syntax_validation (bool) – The domain syntax validation status.
- expiration_date (str) – The expiration date of the subject.
- http_status_code (str) – The HTTP status code of the subject.
- ipv4_range_syntax_validation (bool) – The IPv4 range validation status.
- ipv4_syntax_validation (bool) – The IPv4 syntax validation status.
- ipv6_range_syntax_validation (bool) – The IPv6 range validation status.
- ipv6_syntax_validation (bool) – The IPv6 syntax validation status.
- status_source (str) – The final status source.
- status (str) – The final status.
- subdomain_syntax_validation (bool) – The subdomain syntax validation status.
- tested (str) – The tested subject.
- url_syntax_validation (bool) – The URL syntax validation status.
- whois_server (str) – The WHOIS server we contact-ed to get the WHOIS record.
- whois_record (str) – The WHOIS record.
Availability: DomainAndIp()
¶
-
class
PyFunceble.status.availability.domain_and_ip.
DomainAndIp
(subject, filename=None, whois_db=None, inactive_db=None)[source]¶ Gather the availability of the given IP or Domain.
-
_DomainAndIp__gather
()¶ Process the gathering.
-
_DomainAndIp__gather_expiration_date
()¶ Gather the expiration date.
-
_DomainAndIp__gather_extra_rules
()¶ Handle the lack of WHOIS record.
-
Availability: ExtraRules()
¶
-
class
PyFunceble.status.availability.extra_rules.
ExtraRules
(status_obj, subject_type, http_status_code)[source]¶ Manage some extra rules.
Parameters: - status_obj (
PyFunceble.status.status.Status
) – The status obj to handle. - subject_type (str) –
The type of the subject we are working with. Should be one of the following.
domain
url
- http_status_code (str|int) – The extracted status code.
-
_ExtraRules__blogspot
()¶ Handle the blogspot SPECIAL case.
Returns: (new status, new source)
orNone
if there is any change to apply.Return type: tuple|None
-
_ExtraRules__handle_http_code
(previous_state)¶ Handle the HTTP Code status escalation.
Parameters: previous_state (str) – The previously catched status. Returns: (new status, new source)
orNone
if there is any change to apply.Return type: tuple|None
-
_ExtraRules__handle_ip_range
()¶ Handle the IP range status escalation.
Returns: (new status, new source)
orNone
if there is any change to apply.Return type: tuple|None
-
_ExtraRules__handle_potentially_inactive
(previous_state)¶ Handle the potentially inactive case.
Parameters: previous_state (str) – The previously catched status. Returns: (new status, new source)
orNone
if there is any change to apply.Return type: tuple|None
-
_ExtraRules__handle_potentially_up
()¶ Handle the potentially up case.
Returns: (new status, new source)
orNone
if there is any change to apply.Return type: tuple|None
-
_ExtraRules__handle_reputation
()¶ Handle the reputation escalation.
Returns: (new status, new source)
orNone
if there is any change to apply.Return type: tuple|None
-
classmethod
_ExtraRules__http_status_code_up
()¶ Set what we return for the HTTP Code status escalation.
Returns: (new status, new source)
Return type: tuple
-
classmethod
_ExtraRules__special_down
()¶ Set what we return for the SPECIAL status de-escalation.
Returns: (new status, new source)
Return type: tuple
-
_ExtraRules__special_down_404
()¶ Set what we return for the SPECIAL status de-escalation when the 404 status code is caught.
Returns: (new status, new source)
Return type: tuple
-
_ExtraRules__special_down_410
()¶ Set what we return for the SPECIAL status de-escalation when the 410 status code is caught.
Returns: (new status, new source)
Return type: tuple
-
classmethod
_ExtraRules__special_up
()¶ Set what we return for the SPECIAL status escalation.
Returns: (new status, new source)
Return type: tuple
-
_ExtraRules__wordpress_dot_com
()¶ Handle the wordpress.com SPECIAL case.
Returns: (new status, new source)
orNone
if there is any change to apply.Return type: tuple|None
- status_obj (