
ค้นหาข้อบกพร่องด้านความปลอดภัย (Authn) และ Authn) และการอนุญาต (Authz) ในเส้นทางแอปพลิเคชันเว็บ:
เส้นทางจาก koel Streaming Server
เว็บแอปพลิเคชัน HTTP Route Authn และ Authz Bugs เป็นปัญหาด้านความปลอดภัยที่พบบ่อยที่สุดในปัจจุบัน ทรัพยากรมาตรฐานอุตสาหกรรมเหล่านี้เน้นความรุนแรงของปัญหา:
Frameworks เว็บที่รองรับ (รหัส route-detect ในวงเล็บ):
django , django-rest-framework ), Flask ( flask ), Sanic ( sanic ), Fastapi ( fastapi )laravel ), Symfony ( symfony ), cakephp ( cakephp )rails ), องุ่น ( grape )jax-rs ), ฤดูใบไม้ผลิ ( spring )gorilla ), จิน ( gin ), ไค ( chi )express ), React ( react ), Angular ( angular )* การสนับสนุนทางรถไฟมี จำกัด โปรดดูปัญหานี้สำหรับข้อมูลเพิ่มเติม
ใช้ pip เพื่อติดตั้ง route-detect :
$ python -m pip install --upgrade route-detect
คุณสามารถตรวจสอบว่า route-detect ได้รับการติดตั้งอย่างถูกต้องด้วยคำสั่งต่อไปนี้:
$ echo 'print(1 == 1)' | semgrep --config $(routes which test-route-detect) -
Scanning 1 file.
Findings:
/tmp/stdin
routes.rules.test-route-detect
Found '1 == 1', your route-detect installation is working correctly
1┆ print(1 == 1)
Ran 1 rule on 1 file: 1 finding.
route-detect ให้คำสั่ง routes CLI และใช้ semgrep เพื่อค้นหาเส้นทาง
ใช้คำสั่งย่อย which เพื่อชี้ semgrep ที่กฎแอปพลิเคชันเว็บที่ถูกต้อง:
$ semgrep --config $(routes which django) path/to/django/code
ใช้คำสั่งย่อย viz เพื่อแสดงข้อมูลเส้นทางในเบราว์เซอร์ของคุณ:
$ semgrep --json --config $(routes which django) --output routes.json path/to/django/code
$ routes viz --browser routes.json
หากคุณไม่แน่ใจว่ากรอบใดที่จะมองหาคุณสามารถใช้ ID พิเศษ all เพื่อตรวจสอบทุกอย่าง:
$ semgrep --json --config $(routes which all) --output routes.json path/to/code
หากคุณมี Authn Authn หรือ Authz Logic คุณสามารถคัดลอกกฎของ route-detect :
$ cp $(routes which django) my-django.yml
จากนั้นคุณสามารถแก้ไขกฎได้ตามความจำเป็นและเรียกใช้ตามที่กล่าวมาข้างต้น:
$ semgrep --json --config my-django.yml --output routes.json path/to/django/code
$ routes viz --browser routes.json
route-detect ใช้ poetry สำหรับการพึ่งพาและการจัดการการกำหนดค่า
ก่อนดำเนินการต่อให้ติดตั้งการพึ่งพาโครงการด้วยคำสั่งต่อไปนี้:
$ poetry install --with dev
ผ้าสำลีไฟล์โครงการทั้งหมดด้วยคำสั่งต่อไปนี้:
$ poetry run pre-commit run --all-files
เรียกใช้การทดสอบ Python ด้วยคำสั่งต่อไปนี้:
$ poetry run pytest --cov
เรียกใช้การทดสอบกฎ Semgrep ด้วยคำสั่งต่อไปนี้:
$ poetry run semgrep --test --config routes/rules/ tests/test_rules/