Package: presidio-cli
Presidio CLICLI tool that analyzes text for PII Entities withMicrosoft Presidio framework.PrerequisitiesPythonversion: 3.8, 3.9, 3.10pipenvapp installed:# check if app is installedpipenv--version# install, if not availablepipinstallpipenvInstallpresidio-cliin a virtual envInstall from Python Package Indexinstall in current python envpython-mpipinstallpresidio-cliinstall required apps and presidio-cli in virtual environmentpipenvinstallpresidio-cliInstall from source# clone from gitgitclonehttps://github.com/insightsengineering/presidio-clicdpresidio-cli# install required apps and presidio-clipipenvinstall--deploy--devInstall language models forspaCyLoad models for the English (en) language using the command presented below. For further information please visit sectionmodels.python-mspacydownloaden_core_web_sm
python-mspacydownloaden_core_web_lgConfiguration file syntaxThe default configuration is taken from the.presidioclifile in a current directory.Configuration file supports the following parameters in a yaml file:language - by default only models and recognizers forenare available.
The list oflanguagescan be extended.entities - limit list of recognized entities to be listed in parameter. It is mapped directly topresidio framework.
List ofsupported entitiesignore - list of ignored files/folders/directories based on pattern. It is recommended to ignoreVersion Controlfiles, for example.gitNote: a file requires at least one parameter to be set.An example of yaml configuration file content:---language:enignore:|.git*.cfgentities:-PERSON-CREDIT_CARD-EMAIL_ADDRESSRun the Presidio CLIRun the Presidio CLI to executePresidio Analyzerwith specified configuration: language, threshold, entities and ignore pre-configured files/paths.Configuration from a fileAn example of running script with configuration from a file.There are two example.yamlconfiguration files in theconfdirectory:default.yaml- ignore the.gitdirectorylimited.yaml- limit list of entities used to only 3 of them, ignore.gitdirectory and.cfgfiles.# run with default configuration (file `.presidiocli`) in the current directorypresidio.# run with configuration limited.yaml in the "tests" directorypresidio-cpresidio_cli/conf/limited.yamltests/# run with configuration limited.yaml in single file only tests/test_analyzer.pypresidio-cpresidio_cli/conf/limited.yamltests/test_analyzer.pyConfiguration as a parameterAn example of using configuration as data in parameter:# ignore paths .git and *.cfgpresidio-d"ignore: |.git*.cfg"tests/# limit list of entities to CREDIT_CARDpresidio-d"entities:- CREDIT_CARD"tests/# equivalent to use -c parameterpresidio-d"$(catpresidio_cli/conf/limited.yaml)"tests/Formatting outputOutput can be formatted using-for--formatparameter. The default format isauto.Available formats:standard - standard output formatpresidio-d"entities:- PERSON"-fstandardtests/conftest.py# resulttests/conftest.py34:580.85PERSON37:330.85PERSONgithub - similar to diff function in githubpresidio-d"entities:- PERSON"-fgithubtests/conftest.py# result::group::tests/conftest.py
::0.85file=tests/conftest.py,line=34,col=58::34:58[PERSON]::0.85file=tests/conftest.py,line=37,col=33::37:33[PERSON]::endgroup::colored - standard output format but with colorsparsable - easy to parse automaticalypresidio-d"entities:- PERSON"-fparsabletests/conftest.py# result{"entity_type":"PERSON","start":57,"end":62,"score":0.85,"analysis_explanation":null}{"entity_type":"PERSON","start":32,"end":37,"score":0.85,"analysis_explanation":null}auto - default format, switches automatically between those 2 modes:github, if run on github - environment variablesGITHUB_ACTIONSandGITHUB_WORKFLOWare setcolored, otherwiseList of all parametersSimply run the following to get a list of all available options for the CLI:presidio--help