Skip to main content
Version: v0.20

GitHub Actions

Create .github/workflows/malware-scan.yml in the repository you want to scan:

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 }}

The default scan checks the repository in Lite mode and fails the job when it finds a security issue. The final step uploads the SARIF report to Security > Code scanning even when the scan step fails.

Configure the scan

InputDefaultPurpose
path.File or directory to scan.
modeliteSelect full, lite, signatures, exploits, or functions.
report-formatsarifWrite html, txt, json, or sarif.
report-pathamwscan-reportSet the report path; AMWScan adds the format extension when needed.
php-version8.3Select the PHP runtime used by the action.
scan-archivesfalseInspect entries in ZIP archives within resource limits.
scan-allfalseScan files regardless of extension.
ignore-pathsEmptyExclude comma-separated paths or wildcard patterns.
disable-checksumfalseDisable supported platform and framework checksum checks.
disable-definitions-updatetrueSkip remote Maltrail definition updates.
fail-on-findingstrueReturn exit code 1 when the scan has findings.

The action exposes exit-code and report-path outputs. Set fail-on-findings: false to collect findings without failing the job; scanner and source errors still fail with exit code 2.

Keep an HTML report

Use an artifact when your team wants to inspect the standalone HTML report instead of uploading SARIF:

- name: Scan for malware
id: amwscan
uses: marcocesarato/PHP-Antimalware-Scanner@master
with:
report-format: html

- name: Upload scan report
if: always()
uses: actions/upload-artifact@v4
with:
name: amwscan-report
path: ${{ steps.amwscan.outputs.report-path }}
retention-days: 30

Reports can contain local paths and matched code. Restrict artifact access and retention to the people who review security findings.