跳到主要内容
版本:最新版本

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.要扫描的文件或目录。
modelite选择 fulllitesignaturesexploitsfunctions
report-formatsarif写入 htmltxtjsonsarif
report-pathamwscan-report设置报告路径。
php-version8.3选择 PHP 版本。
scan-archivesfalse扫描 ZIP 归档中的条目。
scan-allfalse扫描文件时不按扩展名筛选。
ignore-paths排除以逗号分隔的路径或通配符模式。
disable-checksumfalse禁用受支持平台的完整性检查。
disable-definitions-updatetrue跳过远程 Maltrail 定义更新。
fail-on-findingstrue发现问题时返回代码 1

该 Action 提供 exit-codereport-path 输出。设置 fail-on-findings: false 可收集结果而不让作业失败。扫描器或源错误仍会返回代码 2

报告可能包含本地路径和代码片段。请仅向负责检查安全结果的人员开放归档访问权限,并限制保留时间。