Created
September 6, 2025 16:20
-
-
Save szepeviktor/44559190fc0c26d0d00dbf4fbe3499de to your computer and use it in GitHub Desktop.
Wordfence plugin vulnerability check in small shell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| wget -O wordfence-vulnerabilities.json "https://www.wordfence.com/api/intelligence/v2/vulnerabilities/production" | |
| wp plugin list --skip-update-check --status=active --fields=name,version \ | |
| | tail -n +2 \ | |
| | while read -r PLUGIN VERSION; do | |
| UPDATE="$(jq -r --arg slug "${PLUGIN}" \ | |
| '[.. | objects | select(."type"=="plugin" and ."slug"==$slug) | ."patched_versions"[]?] | if length>0 then map(split(".") | map(tonumber)) | max | join(".") else empty end' \ | |
| wordfence-vulnerabilities.json | |
| )" | |
| EARLIER="$(printf '%s\n%s\n' "${VERSION}" "${UPDATE}" | sort -V | head -n 1)" | |
| if [ -z "${UPDATE}" ] || [ "${UPDATE}" == "${VERSION}" ] || [ "${EARLIER}" != "${VERSION}" ]; then | |
| continue | |
| fi | |
| echo "${PLUGIN} v${VERSION} has a vulnerability, update to v${UPDATE}" | |
| echo "wp plugin update ${PLUGIN}" | |
| done | |
| echo "wp plugin list" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Needs WP-CLI, wget and jq