
Una herramienta de análisis estático para detectar vulnerabilidades de seguridad en aplicaciones 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
Actualización de marzo de 2020: Por favor, ve al increíble tutorial de Pysa_ que debería ponerte al día en la búsqueda de vulnerabilidades de seguridad en tu base de código Python.
Pyre_ de Facebook es un proyecto increíble que tiene un futuro brillante y mucha gente inteligente trabajando en él.
Sugeriría, si no sabes mucho sobre análisis de programas, que entiendas cómo funciona PyT antes de sumergirte en Pyre. Junto con los README en la mayoría de los directorios, están la Tesis de Maestría original y algunas diapositivas_.
Dicho esto, estoy feliz de revisar pull requests y darte permisos de escritura si haces más de unas pocas.
Hubo muchos grandes contribuidores en este proyecto, planeo trabajar en otros proyectos como detect-secrets_ y otros (ej. Pyre eventualmente) en el futuro si te gustaría colaborar más :)
Si eres un ingeniero de seguridad con, por ejemplo, una base de código Python sin anotaciones de tipo, que Pyre no manejará, te sugiero que reemplaces tus sinks con un wrapper seguro (algo como defusedxml), y alertes sobre cualquier uso del sink estándar. Puedes usar Bandit para hacer esto ya que no se requiere análisis de flujo de datos, pero tendrás que recortarlo mucho, debido a la alta tasa de falsos positivos.
.. _tutorial de Pysa: https://github.com/facebook/pyre-check/tree/master/pysa_tutorial#pysa-tutorial .. _Pyre: https://github.com/facebook/pyre-check .. _README en la mayoría de los directorios: https://github.com/python-security/pyt/tree/master/pyt#how-it-works .. _Tesis de Maestría: https://projekter.aau.dk/projekter/files/239563289/final.pdf .. _algunas diapositivas: 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
Análisis estático de aplicaciones web Python basado en fundamentos teóricos (grafos de flujo de control, punto fijo, análisis de flujo de datos)
Detectar inyección de comandos, SSRF, inyección SQL, XSS, directory traversal, etc.
Mucha personalización posible
Para ver los cambios recientes, consulta el changelog_.
Ejemplo de uso y salida:
.. image:: https://raw.githubusercontent.com/KevinHock/rtdpyt/master/readme_static_files/pyt_example.png
Antes de continuar, asegúrate de tener instalado python3.6 o 3.7.
.. code-block:: python
pip install python-taint
✨🍰✨
PyT también se puede instalar desde el código fuente. Para hacerlo, clona el repositorio y luego ejecuta:
.. code-block:: python
python3 setup.py install
Pronto encontrarás un README.rst_ en cada directorio dentro de la carpeta pyt/, comienza aquí_.
.. _README.rst: https://github.com/python-security/pyt/tree/master/pyt .. _comienza aquí: https://github.com/python-security/pyt/tree/master/pyt
La opción -a determina qué funciones tendrán sus argumentos contaminados_, por defecto es Flask.
Usa la opción -t para especificar fuentes y sinks, por defecto se usa este archivo_.
Para funciones de builtins o bibliotecas, por ejemplo url_for o os.path.join, usa la opción -m para especificar si devuelven valores contaminados dados inputs contaminados, por defecto se usa este archivo_.
.. _La opción -a determina qué funciones tendrán sus argumentos contaminados: https://github.com/python-security/pyt/tree/master/pyt/web_frameworks#web-frameworks .. _se usa este archivo: https://github.com/python-security/pyt/blob/master/pyt/vulnerability_definitions/all_trigger_words.pyt .. _defecto se usa este archivo: 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.
Usándolo como un usuario python3 -m pyt examples/vulnerable_code/XSS_call.py
Ejecutando las pruebas python3 -m tests
Ejecutando un archivo de prueba individual python3 -m unittest tests.import_test
Ejecutando una prueba individual python3 -m unittest tests.import_test.ImportTest.test_import
Únete a nuestro grupo de Slack: https://pyt-dev.slack.com/ - pide una invitación: [email protected]
Directrices_
.. _Directrices: https://github.com/python-security/pyt/blob/master/CONTRIBUTIONS.md
Crea un directorio para contener el entorno virtual y el proyecto
mkdir ~/a_folder
cd ~/a_folder
Clona el proyecto en el directorio
git clone https://github.com/python-security/pyt.git
Crea el entorno virtual
python3 -m venv ~/a_folder/
Verifica que tengas las versiones correctas
python3 --version salida de ejemplo Python 3.6.0
pip --version salida de ejemplo pip 9.0.1 from /Users/kevinhock/a_folder/lib/python3.6/site-packages (python 3.6)
Cambia al directorio del proyecto
cd pyt
En el futuro, solo escribe source ~/a_folder/bin/activate para empezar a desarrollar.