Docs · WP-CLI · v0.4.3

Run a WordPress security scan from WP-CLI and CI

The same 34 checks as the admin screen, from the command line: a table for humans, JSON for scripts, and an exit code that fails a pipeline when a check fails. Every example on this page was run against a real WordPress 7.1.5 site.

Two commands

CommandWhat it does
wp lockora scanRuns a new scan, stores it (it appears in the admin screen’s history and comparison) and prints the findings.
wp lockora reportPrints the most recent stored scan without scanning again. Errors with No scan has been run yet if there is none.

Both accept the same options:

OptionValuesDefault
--format=<format>table, csv, json, yaml, counttable
--fields=<fields>Any of id, group, status, severity, title, recommendation, evidence (table and CSV only)id,group,status,severity,title,recommendation
--strictExit with status 1 when one or more checks have status failoff

Requirements: WP-CLI, WordPress 6.0+, PHP 7.4+, and the plugin active on the site. Run commands as the user that owns the WordPress files.

What the output looks like

Table output (trimmed)
$ wp lockora scan --fields=id,status,severity,title
Running Lockora security scan...
+----------------------+---------+----------+--------------------------------+
| id                   | status  | severity | title                          |
+----------------------+---------+----------+--------------------------------+
| file_editor          | pass    | medium   | Theme and plugin file editor   |
| debug_display        | fail    | medium   | Debug display                  |
| https                | fail    | high     | HTTPS site URL                 |
| security_headers     | warning | medium   | HTTP security headers          |
| core_file_integrity  | pass    | high     | WordPress core file integrity  |
| wp_content_anomalies | fail    | high     | WP-Content Anomaly Scan        |
| wp_config_salts      | fail    | high     | WordPress authentication salts |
| ...                                                                        |
+----------------------+---------+----------+--------------------------------+
Score: 60/100 (14 passed, 15 warnings, 5 failures). Scanned: 2026-11-22 15:36 UTC.

The table is followed by one summary line. With --format=count the command prints the number of findings (34 on v0.4.3).

Piping scan output into jq? Add --quiet. wp lockora scan prints a Running Lockora security scan... line on standard output before the report, which makes the JSON unparseable; WP-CLI’s global --quiet flag suppresses it. wp lockora report does not print that line.

JSON output (two findings shown)
$ wp lockora report --format=json
{
  "version": "0.4.3",
  "scanned_at": "2026-11-22T15:36:11+00:00",
  "score": 60,
  "counts": { "pass": 14, "warning": 15, "fail": 5 },
  "findings": [
    {
      "id": "core_file_integrity",
      "status": "pass",
      "severity": "high",
      "title": "WordPress core file integrity",
      "recommendation": "Core files match the official WordPress checksum manifest.",
      "evidence": "Checked 3338 core files.",
      "group": "Core Integrity",
      "extra": { "altered": [], "missing": [], "extra": [] },
      "meta": { "checked": 3338, "altered": 0, "missing": 0, "extra": 0 }
    },
    {
      "id": "wp_config_salts",
      "status": "fail",
      "severity": "high",
      "title": "WordPress authentication salts",
      "recommendation": "Generate the missing or placeholder authentication keys and salts in wp-config.php. Existing sessions may be invalidated.",
      "evidence": "3 missing or default value(s): AUTH_KEY, SECURE_AUTH_KEY, LOGGED_IN_KEY.",
      "group": "Configuration",
      "extra": [],
      "meta": []
    }
  ]
}

JSON report reference

FieldTypeNotes
versionstringPlugin version that produced the report
scanned_atstringISO 8601, UTC
scoreinteger0–100, severity-weighted (high 5, medium 3, low 2, info 1; pass 1, warning 0.5, fail 0)
countsobjectpass, warning, fail
findings[]arrayOne object per check
findings[].idstringStable check ID, for example uploads_php_execution. All IDs
findings[].statusstringpass, warning or fail
findings[].severitystringinfo, low, medium or high
findings[].groupstringConfiguration, Runtime, Transport and Headers, Vulnerability Posture, Core Integrity, Filesystem, Access Control, Public Exposure, AI
findings[].title, recommendation, evidencestringHuman-readable text; may change between versions, so match on id
findings[].extra, metaobject or arrayCheck-specific detail, for example file lists for core integrity and the anomaly scan
Useful jq one-liners
# Just the score
wp lockora report --format=json | jq .score

# Every failed check, by ID
wp lockora report --format=json | jq -r '.findings[] | select(.status=="fail") | .id'

# High-severity failures only, with the recommendation
wp lockora report --format=json | jq -r '.findings[] | select(.status=="fail" and .severity=="high") | "\(.id): \(.recommendation)"'

# Files the anomaly scan flagged in uploads
wp lockora report --format=json | jq -r '.findings[] | select(.id=="wp_content_anomalies") | .extra["executable uploads"][]?'

How --strict decides pass or fail

--strict exits with status 1 when counts.fail is greater than zero and prints Error: N check(s) failed. Warnings never fail the run. Without --strict the command exits 0 whatever it finds.

Know your baseline first. Some checks fail on almost every fresh install: https on a local site, wp_config_salts if the installer left placeholders, and, in v0.4.3, mu_plugins_directory when wp-content/mu-plugins does not exist. Run wp lockora scan once, fix or accept those, and only then make --strict a required CI step. To gate on high severity only, use the jq filter below instead of --strict.

# Fail only on high-severity failures
wp lockora scan --quiet --format=json > lockora.json
test "$(jq '[.findings[] | select(.status=="fail" and .severity=="high")] | length' lockora.json)" -eq 0

GitHub Actions

Scan a staging site after each deploy over SSH and keep the JSON report as a build artifact. Store the SSH key as a repository secret.

name: WordPress security audit
on:
  workflow_dispatch:
  push:
    branches: [main]
  schedule:
    - cron: "17 5 * * 1"   # Mondays 05:17 UTC

jobs:
  lockora:
    runs-on: ubuntu-latest
    steps:
      - name: Run Lockora scan on staging
        env:
          SSH_KEY: ${{ secrets.STAGING_SSH_KEY }}
          SSH_TARGET: deploy@staging.example.com
          WP_PATH: /var/www/staging
        run: |
          install -m 600 /dev/null key && printf '%s\n' "$SSH_KEY" > key
          ssh -i key -o StrictHostKeyChecking=accept-new "$SSH_TARGET" \
            "wp --path=$WP_PATH lockora scan --quiet --format=json" > lockora.json
          jq '{score, counts}' lockora.json
          jq -r '.findings[] | select(.status=="fail") | "::error title=\(.id)::\(.recommendation)"' lockora.json
          test "$(jq .counts.fail lockora.json)" -eq 0

      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: lockora-report
          path: lockora.json

The ::error lines turn every failed check into an annotation on the run. Using WP-CLI’s built-in SSH alias instead? wp @staging lockora scan --strict works the same way.

GitLab CI

lockora_audit:
  stage: test
  image: alpine:3.20
  before_script:
    - apk add --no-cache openssh-client jq
    - install -m 600 /dev/null key && printf '%s\n' "$STAGING_SSH_KEY" > key
  script:
    - ssh -i key -o StrictHostKeyChecking=accept-new deploy@staging.example.com
        "wp --path=/var/www/staging lockora scan --quiet --format=json" > lockora.json
    - jq '{score, counts}' lockora.json
    - test "$(jq .counts.fail lockora.json)" -eq 0
  artifacts:
    when: always
    paths: [lockora.json]
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

Scheduled scans with cron

Lockora has no built-in scheduler yet, so use the server’s crontab. This runs a scan every night, keeps the history visible in the admin screen, and emails you only when a check fails:

# crontab -e   (as the user that owns the WordPress files)
23 3 * * * cd /var/www/example.com && wp lockora scan --strict --format=count >/dev/null 2>/tmp/lockora.err || mail -s "Lockora: checks failed on example.com" you@example.com < /tmp/lockora.err

For many sites at once, loop over WP-CLI aliases and collect each score:

for site in @client-a @client-b @client-c; do
  printf '%s\t' "$site"
  wp "$site" lockora scan --quiet --format=json | jq -r '"\(.score)\t\(.counts.fail) failed"'
done

Running an agency portfolio? See Lockora for agencies.

Hooks for integrations

Every scan, from the admin screen or WP-CLI, fires lockora_scan_completed with the new report and the previous one. Use it to post results to Slack, a dashboard or a ticket system:

add_action( 'lockora_scan_completed', function ( array $report, array $previous ) {
    $failed = array_filter( $report['findings'], fn( $f ) => 'fail' === $f['status'] );
    if ( $failed && ( $previous['score'] ?? 101 ) > $report['score'] ) {
        wp_remote_post( MY_WEBHOOK_URL, array(
            'body' => wp_json_encode( array(
                'site'  => home_url(),
                'score' => $report['score'],
                'fail'  => array_values( wp_list_pluck( $failed, 'id' ) ),
            ) ),
        ) );
    }
}, 10, 2 );

To inject findings from another vulnerability source, filter lockora_vulnerability_findings; entries are validated before they are scored. Filters for the wp-content scan are listed on the features page.