跳转到主要内容

在Web应用程序路由中查找身份验证(authn)和授权(authz)安全漏洞。

项目描述

route-detect

CI Python Versions PyPI Version

在Web应用程序路由中查找身份验证(authn)和授权(authz)安全漏洞

Routes demo

来自 koel 流媒体服务器

Web应用程序HTTP路由身份验证和授权漏洞是目前发现的最常见的安全问题之一。这些行业标准资源强调了问题的严重性

支持的Web框架(括号内的 route-detect ID)

  • Python: Django (django, django-rest-framework), Flask (flask), Sanic (sanic), FastAPI (fastapi)
  • PHP: Laravel (laravel), Symfony (symfony), CakePHP (cakephp)
  • Ruby: Rails* (rails), Grape (grape)
  • Java: JAX-RS (jax-rs), Spring (spring)
  • Go: Gorilla (gorilla), Gin (gin), Chi (chi)
  • JavaScript/TypeScript: Express (express), React (react), Angular (angular)

*Rails支持有限。请参阅此问题获取更多信息。

安装

使用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指向正确的Web应用程序规则

$ 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

如果您不确定要查找哪个框架,可以使用特殊的all ID来检查所有内容

$ semgrep --json --config $(routes which all) --output routes.json path/to/code

如果您有自定义认证或授权逻辑,可以复制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/

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

route_detect-0.8.0.tar.gz (22.7 kB 查看哈希值)

上传时间

构建分布

route_detect-0.8.0-py3-none-any.whl (29.9 kB 查看哈希值)

上传时间 Python 3

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面