php version audit
php version audit是一种便利工具,可轻松检查给定的PHP版本,以定期更新的CVE漏洞,新版本和寿命日期的列表。
php version audit不是:利用检测/缓解措施,特定于供应商的版本跟踪,替代了通知PHP版本和安全性利用的替代品。
- 特征
- 例子
- 用法
- Docker
- CLI
- 直接调用
- JSON规则
- 选项
- 输出
- 项目目标
- 致谢和许可证
特征:
- 列表给定版本的PHP已知CVE
- 检查PHP的运行时版本或提供版本
- 显示给定版本的PHP的寿命日期
- 显示具有可配置特异性的给定版本的PHP的新版本(最新/次要/补丁)
- 补丁:7.3.0-> 7.3.33
- 次要:7.3.0-> 7.4.27
- 最新:7.3.0-> 8.1.1
- 规则每天自动更新两次。信息直接来自php.net-您永远不会等待像我这样的人在获取最新补丁信息之前合并拉动请求。
- 多个接口:CLI(通过PHP作曲家),Docker,直接代码导入
- 易于与CI/CD工作流一起使用。所有Docker/CLI输出均以JSON格式使用您喜欢的工具(例如JQ)消费。
- 可配置的出口条件。如果给定版本的PHP具有已知的CVE或不再接收安全更新,则使用CLI标志(例如
--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
使用Docker运行是使用php version audit首选和最简单的方法。
使用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
CLI
不使用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 version audit集成?这当然是可能的。一个单词谨慎,这是一个很早的版本。我没有任何破坏更改的计划,但是如果有新功能可以实现,我也不承诺将接口保持原样。 Docker/CLI当然是直接调用的首选方法。
$phpVersionAudit = new lightswitch05\\PhpVersionAudit\\Application(phpversion(), false);
$phpVersionAudit->hasVulnerabilities(); #=> true
$phpVersionAudit->getLatestPatchVersion(); #=> \'8.1.1\'
JSON规则
用于驱动php version audit数据会自动定期更新,并在GitHub页面上托管。这是php version audit的真正肉类和番茄,您可以将其直接消耗供其他工具中使用。如果您选择执行此操作,请通过提供适当的归因通知来尊重项目许可。另外,我要求任何实施方式阅读lastUpdatedDate ,如果它已经过时(2周以上),则失败了。由于它会自动更新,因此不应该发生这种情况…但是我们都知道软件有多脆弱。
使用Curl和JQ直接从规则中获取最新的PHP 8.1发行版:
curl -s https://www.github.dev*elop**erdan.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.
输出
- 审核:字符串 – 正在审核的PHP版本。
- HASVULNEBINAL:BOOL-如果审计是否有任何已知的CVE。
- hassecuritysupport:bool-如果审计仍在收到安全更新。
- HASACTIVESUPPORT:BOOL-如果审计仍在接收主动支持(错误更新)。
- IslatestPatchVersion:bool-如果审核是最新的补丁级版本(8.0.x)。
- Islatestminorversion:bool-如果审计是最新的次要版本(8.xx)。
- Islatestversion:bool-如果审核是最新版本(xxx)。
- 最新数据:字符串 – 用于审核的最新补丁级版本。
- 最新消息:字符串 – 最新的审计次要版本。
- 最新文章:字符串 – 最新的PHP版本。
- ActiveSupportendDate:字符串| null -ISO8601格式的日期,用于审核的主动支持(错误修复)。
- SecuritySupporTendDate:String -ISO8601格式的日期,用于审核的安全支持结束。
- RulesLastupDatedDate:String -ISO8601格式的日期,该日期是自动更新的最后一次(每天两次)。
- 漏洞:对象 – 已知会影响CVE的详细信息的CVE。最近发现的CVE的CVE细节可能无效。
项目目标:
- 始终使用更新到日期的信息,如果它变得过于陈旧,则会失败。由于该工具旨在帮助其用户保持知识,因此如果它过时,则必须失败。
- 如果请求的信息不可用,则会失败。前任。获取PHP 6.0版的支持结束日期或5.7.0。同样,由于该工具旨在帮助其用户保持知识,因此如果请求的信息不可用,则必须失败。
- 在开放和封闭的网络中工作(只要该工具是最新的)。
- 最小的足迹和依赖性。
- 最古老的支持版本的PHP的运行时支持。如果您使用此工具具有不支持版本的PHP,那么您已经有了该工具可以给您的所有答案:是的,您有漏洞并且已经过时了。当然,这仅是为了运行时,该项目仍然是提供有关任何合理版本的PHP的信息的目标。
致谢和许可证
- 该项目以Apache许可证2.0发布。
- 无法验证或保证该项目提供的信息的准确性。所有功能仅作为方便提供,不应用于可靠性,准确性或守时性。
- 该徽标是使用Colin Viebrock的PHP徽标作为基本图像创建的,它在Creative Commons Attribution-Share-Share Share 4.0 International下发布。徽标已从其原始形式进行了修改,以包括覆盖图形。
- Colin Viebrock不认可该项目和修改后的PHP徽标的使用。
- PHP组不认可此项目和PHP名称的使用。
- CVE的详细信息和描述将从国家标准和技术研究所的国家脆弱性数据库中下载。该项目和CVE信息的使用不受NIST或NVD的认可。 CVE详细信息仅是方便的。信息的准确性无法验证。
- PHP发布的详细信息和支持日期来自Changelogs(4、5、7、8),以及支持的版本和EOL日期。信息的准确性无法验证。
