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.