メインコンテンツまでスキップ
バージョン: 最新

GitHub Actions

スキャンするリポジトリに .github/workflows/malware-scan.yml を作成します。

name: Malware scan

on:
push:
pull_request:
schedule:
- cron: '0 0 * * 0'

permissions:
contents: read
security-events: write

jobs:
scan:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Scan for malware
id: amwscan
uses: marcocesarato/PHP-Antimalware-Scanner@master
with:
path: .
mode: lite
report-format: sarif
ignore-paths: '*/cache/*,*/logs/*'

- name: Upload SARIF report
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.amwscan.outputs.report-path }}

既定のスキャンは Lite モードを使い、AMWScan がセキュリティ上の問題を検出するとジョブを失敗させます。最後のステップは、スキャンが失敗した場合も SARIF レポートを Security > Code scanning にアップロードします。

スキャンを設定する

入力既定値用途
path.スキャンするファイルまたはディレクトリ。
modelitefulllitesignaturesexploitsfunctions から選択します。
report-formatsarifhtmltxtjsonsarif で出力します。
report-pathamwscan-reportレポートのパスを設定します。
php-version8.3PHP のバージョンを選択します。
scan-archivesfalseZIP アーカイブ内の項目をスキャンします。
scan-allfalse拡張子に関係なくファイルをスキャンします。
ignore-pathsカンマ区切りのパスまたはパターンを除外します。
disable-checksumfalse対応プラットフォームの整合性チェックを無効にします。
disable-definitions-updatetrueMaltrail 定義のリモート更新を省略します。
fail-on-findingstrue検出結果がある場合にコード 1 を返します。

アクションは exit-codereport-path を出力します。fail-on-findings: false を指定すると、ジョブを失敗させずに結果を収集できます。スキャナーまたはソースのエラーは引き続きコード 2 を返します。

レポートにはローカルパスやコード断片が含まれる場合があります。セキュリティ結果を確認する担当者だけがアーティファクトにアクセスできるようにし、保持期間を制限してください。