
.. 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
2020年3月更新: Pythonコードベースのセキュリティ脆弱性を迅速に見つけられる素晴らしい Pysa tutorial_ をご覧ください。
Pyre_ はFacebookの素晴らしいプロジェクトで、明るい未来と多くの優秀な人々が取り組んでいます。Pyreに飛び込む前に、まずPyTの仕組みを理解することをお勧めします。README's in most directories_ に加えて、元の Master's Thesis_ と some slides_ もあります。
とはいえ、プルリクエストのレビューは喜んで行います。また、いくつか以上の貢献をしていただければ書き込み権限を付与します。
このプロジェクトには多くの素晴らしいコントリビューターがいました。今後は detect-secrets_ のような他のプロジェクト(例:最終的にはPyreなど)にも取り組む予定ですので、引き続き一緒に作業したい方はぜひ :)
もし、型アノテーションのないPythonコードベースを持っていて、Pyreでは対応できないセキュリティエンジニアであれば、シンクを安全なラッパー(defusedxml_ のようなもの)に置き換え、標準シンクの使用を警告することを提案します。データフロー解析は不要なので Bandit_ を使用してこれを行うことができますが、偽陽性率が高いため、大幅に削る必要があります。
.. _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
理論的基盤(制御フローグラフ、不動点、データフロー解析)に基づくPythonウェブアプリケーションの静的解析
コマンドインジェクション、SSRF、SQLインジェクション、XSS、ディレクトリトラバーサルなどを検出します。
多くのカスタマイズが可能
最近の変更については、changelog_ をご覧ください。
.. _changelog: https://github.com/python-security/pyt/blob/master/CHANGELOG.md
使用例と出力:
.. image:: https://raw.githubusercontent.com/KevinHock/rtdpyt/master/readme_static_files/pyt_example.png
続行する前に、python3.6 または 3.7 がインストールされていることを確認してください。
.. code-block:: python
pip install python-taint
✨🍰✨
PyTはソースからもインストールできます。その場合は、リポジトリをクローンしてから以下を実行してください。
.. code-block:: python
python3 setup.py install
近々、pyt/ フォルダ内のすべてのディレクトリに README.rst_ が追加される予定です。start here_ から始めてください。
.. _README.rst: https://github.com/python-security/pyt/tree/master/pyt .. _start here: https://github.com/python-security/pyt/tree/master/pyt
The -a option determines which functions will have their arguments tainted_ であり、デフォルトではFlaskです。
-t オプションを使用してソースとシンクを指定します。デフォルトでは this file is used_ です。
組み込み関数やライブラリの関数(例:url_for や os.path.join)については、-m オプションを使用して、汚染された入力に対して汚染された値を返すかどうかを指定します。デフォルトでは default this file is used_ です。
.. _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.
ユーザーとして使用する場合: python3 -m pyt examples/vulnerable_code/XSS_call.py
テストの実行: python3 -m tests
個別のテストファイルの実行: python3 -m unittest tests.import_test
個別のテストの実行: python3 -m unittest tests.import_test.ImportTest.test_import
Slackグループに参加: https://pyt-dev.slack.com/ - 招待リクエスト: [email protected]
Guidelines_
.. _Guidelines: https://github.com/python-security/pyt/blob/master/CONTRIBUTIONS.md
仮想環境とプロジェクトを保持するディレクトリを作成
mkdir ~/a_folder
cd ~/a_folder
プロジェクトをディレクトリにクローン
git clone https://github.com/python-security/pyt.git
仮想環境を作成
python3 -m venv ~/a_folder/
正しいバージョンがインストールされていることを確認
python3 --version sample output Python 3.6.0
pip --version sample output pip 9.0.1 from /Users/kevinhock/a_folder/lib/python3.6/site-packages (python 3.6)
プロジェクトディレクトリに移動
cd pyt
今後は、開発を始めるには source ~/a_folder/bin/activate と入力するだけです。