
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
2020년 3월 업데이트: Pysa 튜토리얼_을 확인해 보세요. 이 튜토리얼을 통해 Python 코드베이스에서 보안 취약점을 찾는 방법을 빠르게 익힐 수 있습니다.
페이스북의 Pyre는 훌륭한 프로젝트로, 밝은 미래와 많은 똑똑한 사람들이 참여하고 있습니다. 프로그램 분석에 대해 잘 모르신다면, Pyre에 깊이 들어가기 전에 PyT가 어떻게 작동하는지 이해하는 것을 추천합니다. 대부분의 디렉터리에 있는 README 외에도 원본 석사 학위 논문_과 일부 슬라이드_가 있습니다. 그렇지만 저는 풀 리퀘스트를 검토하고, 몇 개 이상 기여하신다면 쓰기 권한을 드리는 것을 기쁘게 생각합니다.
이 프로젝트에는 많은 훌륭한 기여자들이 있었습니다. 앞으로 detect-secrets_ 및 다른 프로젝트(예: 결국 Pyre)에서도 함께 작업하고 싶다면, 저는 그런 프로젝트들에서도 작업할 계획입니다 :)
예를 들어, Pyre가 처리하지 못하는 타입 어노테이션이 없는 Python 코드베이스를 가진 보안 엔지니어라면, 싱크를 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_가 있을 것입니다. 여기서 시작_하세요.
.. _README.rst: https://github.com/python-security/pyt/tree/master/pyt .. _start here: https://github.com/python-security/pyt/tree/master/pyt
-a 옵션은 인수가 오염될 함수를 결정하며_, 기본값은 Flask입니다.
-t 옵션을 사용하여 소스와 싱크를 지정합니다. 기본적으로 이 파일_이 사용됩니다.
내장 함수 또는 라이브러리의 함수(예: url_for 또는 os.path.join)의 경우 -m 옵션을 사용하여 오염된 입력이 주어졌을 때 오염된 값을 반환하는지 여부를 지정합니다. 기본적으로 이 파일_이 사용됩니다.
.. _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
슬랙 그룹에 참여하세요: 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를 입력하여 개발을 시작하면 됩니다.