neturalise-link
What are the objectives?
- Remove trackers
- Remove referrers
- Identify malicious intent
- Verify URL validity
- Improve URL load speeds
How does it work?
Having imported neutralise-link you may use the neutralise function which takes a URL string as the argument.
The function is designed to return either a string URL or None. It is recommended to use the returned URL value in place of the original URL as this is the neutralised version of the URL.
By default, the function will return None in two cases:
- The link is invalid
- The link is deemed malicious
You may override the 2nd case by calling the function with the optional parameter,
safe=false.
You may also skip the validity check by calling the function with the optional parameter,
check_valid=false. This is recommended if you do not need to check for URL validity as it leads to significantly faster performance, but at the potential risk of returning impure URLs (i.e. URLs that have been redirected).
Example Code
from neutralise_link import neutralise
def main(url: str) -> str:
"""Validate user URL input for storing."""
url = neutralise(url=url, safe=True, check_valid=True)
if not url:
print("URL is malformed or malicious.")
print("URL is safe and in its pure form.")
Contributing
Prerequisites
- Have python 3.10 installed on system (e.g. using anaconda/homebrew)
Environment Setup
- Set up a virtual environment using
python -m venv venv - Activate the virtual environment using
source venv/bin/activate - Install development dependencies using
pip install -r requirements.txt
Running tests
It is important to ensure that ALL tests pass before submitting a PR.
python -m unittest discover -s tests
It is also imperative that coverage is above 90% before submitting a PR. Validate this by running:
coverage run -m tests.test_neutralise && coverage report && coverage html
Building the package
-
Navigate to root directory of the project and run:
python -m build -
Install the package found in
neutralise-link/dist/in your repo usingpip installfollowed by the relative path of the.tar.gzpackage file located in the project. For example:
pip install dist/neutralise_link-0.1.0.tar.gz
Uploading to PyPI
Ensure that the package is built and the dist directory is populated. Then run:
python -m twine upload dist/*
Metadata
Release files for neutralise-link 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| neutralise_link-0.1.3.tar.gz | 18.9 kB | Without provenance | Details for neutralise_link-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| neutralise_link-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for neutralise_link-0.1.3-py3-none-any.whl |
Total release size: 40.2 kB
Release files / neutralise_link-0.1.3.tar.gz
| Download URL | neutralise_link-0.1.3.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f3d019c1e7462e12ab55a8f7e3a0c6d8427faba44d103a026d40e6592adef1a
|
|
BLAKE2b-256 checksum How to use checksums |
715b8b9d64311ed12728c3a6df15240afaae8640aa1f59d30d42e4e1c31fda75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.11
|
Release files / neutralise_link-0.1.3-py3-none-any.whl
| Download URL | neutralise_link-0.1.3-py3-none-any.whl |
|---|---|
| Size | 21.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a180b54aa38e3de716f9c81e45a1bc3d08029f27e6b2b0482d266f2ad7c39321
|
|
BLAKE2b-256 checksum How to use checksums |
17348cc74eab8a7a44f47c5bae247bff6190686919206770a02155edaa07eee9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.11
|
Security for neutralise-link 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.