
Uno strumento di analisi statica per rilevare vulnerabilità di sicurezza nelle applicazioni web Python.
.. image:: https://travis-ci.org/python-security/pyt.svg?branch=master :target: https://travis-ci.org/python-security/pyt
.. image:: https://readthedocs.org/projects/pyt/badge/?version=latest :target: http://pyt.readthedocs.io/en/latest/?badge=latest
.. image:: https://codeclimate.com/github/python-security/pyt/badges/coverage.svg :target: https://codeclimate.com/github/python-security/pyt/coverage
.. image:: https://badge.fury.io/py/python-taint.svg :target: https://badge.fury.io/py/python-taint
.. image:: https://img.shields.io/badge/PRs-welcome-ff69b4.svg :target: https://github.com/python-security/pyt/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+
.. image:: https://img.shields.io/badge/python-v3.6-blue.svg :target: https://pypi.org/project/python-taint/
.. image:: https://img.shields.io/badge/Donate-Charity-orange.svg :target: https://www.againstmalaria.com/donation.aspx
Aggiornamento marzo 2020: Dai un'occhiata al fantastico tutorial Pysa_ che dovrebbe metterti al passo nella ricerca di vulnerabilità di sicurezza nel tuo codice Python.
Pyre_ di Facebook è un progetto fantastico con un futuro luminoso e molte persone intelligenti che ci lavorano.
Ti suggerisco, se non sai molto di analisi dei programmi, di capire come funziona PyT prima di immergerti in Pyre. Oltre ai README nella maggior parte delle directory, ci sono la Tesi di Laurea Magistrale originale e alcune slide_.
Detto questo, sono felice di rivedere le pull request e darti permessi di scrittura se ne fai più di un paio.
Ci sono stati molti grandi contributori a questo progetto; prevedo di lavorare su altri progetti come detect-secrets_ e altri (es. Pyre eventualmente) in futuro se desideri collaborare ancora :)
Se sei un ingegnere della sicurezza con, ad esempio, un codice Python senza annotazioni di tipo, che Pyre non gestirebbe, ti suggerisco di sostituire i tuoi sink con un wrapper sicuro (qualcosa come defusedxml) e di allertare su qualsiasi uso del sink standard. Puoi usare Bandit per farlo, poiché non è richiesta un'analisi del flusso di dati, ma dovrai sfoltire molto a causa dell'alto tasso di falsi positivi.
.. _Pysa tutorial: https://github.com/facebook/pyre-check/tree/master/pysa_tutorial#pysa-tutorial .. _Pyre: https://github.com/facebook/pyre-check .. _README's in most directories: https://github.com/python-security/pyt/tree/master/pyt#how-it-works .. _Master's Thesis: https://projekter.aau.dk/projekter/files/239563289/final.pdf .. _some slides: https://docs.google.com/presentation/d/1JfAykAxR0DcJwwGfHmhrz1RhhKqYsnt5x_GY8CbTp7s .. _detect-secrets: https://github.com/Yelp/detect-secrets/blob/master/CHANGELOG.md#whats-new .. _defusedxml: https://pypi.org/project/defusedxml/ .. _Bandit: https://github.com/PyCQA/bandit
Analisi statica di applicazioni web Python basata su fondamenti teorici (grafi di flusso di controllo, punto fisso, analisi del flusso di dati)
Rileva command injection, SSRF, SQL injection, XSS, directory traversal, ecc.
Molte personalizzazioni possibili
Per uno sguardo alle modifiche recenti, consulta il changelog_.
.. _changelog: https://github.com/python-security/pyt/blob/master/CHANGELOG.md
Esempio di utilizzo e output:
.. image:: https://raw.githubusercontent.com/KevinHock/rtdpyt/master/readme_static_files/pyt_example.png
Prima di continuare, assicurati di aver installato python3.6 o 3.7.
.. code-block:: python
pip install python-taint
✨🍰✨
PyT può anche essere installato dal sorgente. Per farlo, clona il repository, poi esegui:
.. code-block:: python
python3 setup.py install
Presto troverai un README.rst_ in ogni directory della cartella pyt/, inizia da qui_.
.. _README.rst: https://github.com/python-security/pyt/tree/master/pyt .. _start here: https://github.com/python-security/pyt/tree/master/pyt
L'opzione -a determina quali funzioni avranno i loro argomenti contaminati_, per impostazione predefinita è Flask.
Usa l'opzione -t per specificare sorgenti e sink; per impostazione predefinita viene usato questo file_.
Per funzioni da builtins o librerie, es. url_for o os.path.join, usa l'opzione -m per specificare se restituiscono valori contaminati dati input contaminati; per impostazione predefinita viene usato questo file_.
.. _The -a option determines which functions will have their arguments tainted: https://github.com/python-security/pyt/tree/master/pyt/web_frameworks#web-frameworks .. _this file is used: https://github.com/python-security/pyt/blob/master/pyt/vulnerability_definitions/all_trigger_words.pyt .. _default this file is used: https://github.com/python-security/pyt/blob/master/pyt/vulnerability_definitions/blackbox_mapping.json
.. code-block::
usage: python -m pyt [-h] [-a ADAPTOR] [-pr PROJECT_ROOT] [-b BASELINE_JSON_FILE] [-j] [-t TRIGGER_WORD_FILE] [-m BLACKBOX_MAPPING_FILE] [-i] [-o OUTPUT_FILE] [--ignore-nosec] [-r] [-x EXCLUDED_PATHS] [--dont-prepend-root] [--no-local-imports] targets [targets ...]
required arguments: targets source file(s) or directory(s) to be scanned
important optional arguments: -a ADAPTOR, --adaptor ADAPTOR Choose a web framework adaptor: Flask(Default), Django, Every or Pylons
-t TRIGGER_WORD_FILE, --trigger-word-file TRIGGER_WORD_FILE
Input file with a list of sources and sinks
-m BLACKBOX_MAPPING_FILE, --blackbox-mapping-file BLACKBOX_MAPPING_FILE
Input blackbox mapping file
optional arguments: -pr PROJECT_ROOT, --project-root PROJECT_ROOT Add project root, only important when the entry file is not at the root of the project.
-b BASELINE_JSON_FILE, --baseline BASELINE_JSON_FILE
Path of a baseline report to compare against (only
JSON-formatted files are accepted)
-j, --json Prints JSON instead of report.
-i, --interactive Will ask you about each blackbox function call in
vulnerability chains.
-o OUTPUT_FILE, --output OUTPUT_FILE
Write report to filename
--ignore-nosec Do not skip lines with # nosec comments
-r, --recursive Find and process files in subdirectories
-x EXCLUDED_PATHS, --exclude EXCLUDED_PATHS
Separate files with commas
--dont-prepend-root In project root e.g. /app, imports are not prepended
with app.*
--no-local-imports If set, absolute imports must be relative to the
project root. If not set, modules in the same
directory can be imported just by their names.
Usarlo come un utente: python3 -m pyt examples/vulnerable_code/XSS_call.py
Eseguire i test: python3 -m tests
Eseguire un file di test specifico: python3 -m unittest tests.import_test
Eseguire un test specifico: python3 -m unittest tests.import_test.ImportTest.test_import
Unisciti al nostro gruppo Slack: https://pyt-dev.slack.com/ - chiedi un invito: [email protected]
Linee guida_
.. _Guidelines: https://github.com/python-security/pyt/blob/master/CONTRIBUTIONS.md
Crea una directory per contenere l'ambiente virtuale e il progetto
mkdir ~/a_folder
cd ~/a_folder
Clona il progetto nella directory
git clone https://github.com/python-security/pyt.git
Crea l'ambiente virtuale
python3 -m venv ~/a_folder/
Verifica di avere le versioni corrette
python3 --version output di esempio: Python 3.6.0
pip --version output di esempio: pip 9.0.1 from /Users/kevinhock/a_folder/lib/python3.6/site-packages (python 3.6)
Spostati nella directory del progetto
cd pyt
In futuro, digita semplicemente source ~/a_folder/bin/activate per iniziare a sviluppare.