PHPバージョン監査は、特定のPHPバージョンを、定期的に更新されたCVEエクスプロイト、新しいリリース、および終了日のリストに対して簡単に確認するための利便性ツールです。
PHPバージョンの監査はそうではありません。エクスプロイト検出/緩和、ベンダー固有のバージョントラッキング、PHPリリースとセキュリティエクスプロイトに関する情報を提供するための代替品です。
- 特徴
- 例
- 使用法
- Docker
- cli
- 直接招待
- JSONルール
- オプション
- 出力
- プロジェクトの目標
- 謝辞とライセンス
--fail-securityのようなCLIフラグを使用します。 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拡張機能付き)が必要です。詳細については、更新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経由でパッケージをインストールします。
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.