php version audit
1.0.0
PHP版本审核是一种便利工具,可轻松检查给定的PHP版本,以定期更新的CVE漏洞,新版本和寿命日期的列表。
PHP版本审核不是:利用检测/缓解措施,特定于供应商的版本跟踪,替代了通知PHP版本和安全性利用的替代品。
- 特征
- 例子
- 用法
- Docker
- CLI
- 直接调用
- JSON规则
- 选项
- 输出
- 项目目标
- 致谢和许可证
--fail-security设置故障退出代码。 docker run --rm -t lightswitch05/php-version-audit:latest --version=8.0.12
{
"auditVersion": "8.0.12",
"hasVulnerabilities": true,
"hasSecuritySupport": true,
"hasActiveSupport": true,
"isLatestPatchVersion": false,
"isLatestMinorVersion": false,
"isLatestVersion": false,
"latestPatchVersion": "8.0.14",
"latestMinorVersion": "8.1.1",
"latestVersion": "8.1.1",
"activeSupportEndDate": "2022-11-26T00:00:00+0000",
"securitySupportEndDate": "2023-11-26T00:00:00+0000",
"rulesLastUpdatedDate": "2022-01-18T02:13:52+0000",
"vulnerabilities": {
"CVE-2021-21707": {
"id": "CVE-2021-21707",
"baseScore": 5.3,
"publishedDate": "2021-11-29T07:15:00+0000",
"lastModifiedDate": "2022-01-04T16:12:00+0000",
"description": "In PHP versions 7.3.x below 7.3.33, 7.4.x below 7.4.26 and 8.0.x below 8.0.13, certain XML parsing functions, like simplexml_load_file(), URL-decode the filename passed to them. If that filename contains URL-encoded NUL character, this may cause the function to interpret this as the end of the filename, thus interpreting the filename differently from what the user intended, which may lead it to reading a different file than intended."
}
}
}
使用Docker运行是使用PHP版本审核的首选和最简单的方法。
使用Docker检查PHP的特定版本:
docker run --rm -t lightswitch05/php-version-audit:latest --version=8.1.1
使用Docker检查主机的PHP版本:
docker run --rm -t lightswitch05/php-version-audit:latest --version=$(php -r 'echo phpversion();')
在HTTPS代理(用于限制网络)后面运行。需要带有您值得信赖的证书(带有.crt扩展名)的目录的音量安装 - 有关更多详细信息,请参见Update-Ca认证。
docker run --rm -t -e https_proxy='https://your.proxy.server:port/' --volume /full/path/to/trusted/certs/directory:/usr/local/share/ca-certificates lightswitch05/php-version-audit:latest --version=8.1.1
不使用Docker?没问题。这是另外几个步骤,但直接运行也很容易。
通过作曲家安装软件包:
composer require lightswitch05/php-version-audit:~1.0
执行PHP脚本,检查PHP的运行时版:
./vendor/bin/php-version-audit
如果发现任何CVE,则产生出口代码:
./vendor/bin/php-version-audit --fail-security
是否要与PHP版本审核集成?这当然是可能的。一个单词谨慎,这是一个很早的版本。我没有任何破坏更改的计划,但是如果有新功能可以实现,我也不承诺将接口保持原样。 Docker/CLI当然是直接调用的首选方法。
$phpVersionAudit = new lightswitch05PhpVersionAuditApplication(phpversion(), false);
$phpVersionAudit->hasVulnerabilities(); #=> true
$phpVersionAudit->getLatestPatchVersion(); #=> '8.1.1'
用于驱动PHP版本审核的数据会自动定期更新,并在GitHub页面上托管。这是PHP版本审核的真正肉类和番茄,您可以将其直接消耗供其他工具中使用。如果您选择执行此操作,请通过提供适当的归因通知来尊重项目许可。另外,我要求任何实施方式阅读lastUpdatedDate ,如果它已经过时(2周以上),则失败了。由于它会自动更新,因此不应该发生这种情况...但是我们都知道软件有多脆弱。
使用Curl和JQ直接从规则中获取最新的PHP 8.1发行版:
curl -s https://www.github.developerdan.com/php-version-audit/rules-v1.json | jq '.latestVersions["8.1"]'
usage: php-version-audit [--help] [--version=PHP_VERSION]
[--fail-security] [--fail-support]
[--fail-patch] [--fail-latest]
[--no-update] [--silent]
[--v]
optional arguments:
--help show this help message and exit.
--version set the PHP Version to run against. Defaults to the runtime version. This is required when running with docker.
--fail-security generate a 10 exit code if any CVEs are found, or security support has ended.
--fail-support generate a 20 exit code if the version of PHP no longer gets active (bug) support.
--fail-patch generate a 30 exit code if there is a newer patch-level release.
--fail-latest generate a 40 exit code if there is a newer release.
--no-update do not download the latest rules. NOT RECOMMENDED!
--silent do not write any error messages to STDERR.
--v Set verbosity. v=warnings, vv=info, vvv=debug. Default is error. All logging writes to STDERR.