Skip to content

Detect packages which might have been typosquatted based on string similarity level calculated from a dataset of popular packages.

License

Notifications You must be signed in to change notification settings

vin01/squatdetect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

squatdetect

Detect packages which might have been typosquatted based on string similarity level calculated from a dataset of popular packages.

usage: squatdetect.py [-h] [--type [{pip,gem}]] [--packages PACKAGES [PACKAGES ...]]
                      [--confidence {1,2,3,4,5,6,7,8,9}]

Detect packages which might have been typosquatted based on string similarity
level calculated from a dataset of popular packages.
It can be coupled with shell aliases/functions to prevent installing
typosquatted packages which might happen just because we often mistype.
No magic, just stdlib :)

For example:

function pip3 {
if [[ -n "$1" ]] && [[ "$1" = 'install' ]]; then
  ~/.local/bin/squatdetect.py --packages "${@: -1}" | grep 'might be impersonating' && return
fi
$(which pip3) "$@"
}

function gem {
if [[ -n "$1" ]] && [[ "$1" = 'install' ]]; then
  ~/.local/bin/squatdetect.py --packages "${@: -1}" --type gem | grep 'might be impersonating' && return
fi
$(which gem) "$@"
}

options:
  -h, --help            show this help message and exit
  --type [{pip,gem}]    Package type. Default: pip
  --packages PACKAGES [PACKAGES ...]
                        Package(s) to check, if no packages are specified, all installed packages will be checked
  --confidence {1,2,3,4,5,6,7,8,9}
                        Level of confidence to be set. Default: 8

Example

python3 squatdetect.py --packages baeutifulsoup4
**baeutifulsoup4** might be impersonating beautifulsoup4 (92.857143% similar)
**baeutifulsoup4** might be impersonating beautifulsoup (88.888889% similar)

with shell override to prevent on installation:

$ pip3 install baeutifulsoup4
**baeutifulsoup4** might be impersonating beautifulsoup4 (92.857143% similar)
**baeutifulsoup4** might be impersonating beautifulsoup (88.888889% similar)
$

Supported package types

Misc

About

Detect packages which might have been typosquatted based on string similarity level calculated from a dataset of popular packages.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages