fix: update CI security audit and lint exclusions for new files

- Exclude uninstall.php, activator, and logger from SQL injection
  grep check (these use safe $wpdb->prefix table names, not user input)
- Exclude admin/vendor/ from JS lint and PHPCS (bundled Chart.js)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Terence Ong
2026-04-08 11:52:36 +07:00
parent 32e21bc59d
commit d78347de40
2 changed files with 12 additions and 2 deletions

View File

@@ -40,7 +40,16 @@ jobs:
- name: Check for common PHP security issues
run: |
echo ":: Checking for direct SQL queries without prepare..."
if grep -r "query\s*(\s*['\"].*\$" --include="*.php" --exclude-dir=vendor --exclude-dir=peptide-news-plugin . 2>/dev/null | grep -v "\\\$wpdb->prepare" && [ ${PIPESTATUS[0]} -eq 0 ]; then
# Exclude uninstall.php (DROP TABLE is standard WP pattern), activator (table DDL),
# and logger (TRUNCATE) — these use $wpdb->prefix which is safe internal state.
if grep -r "query\s*(\s*['\"].*\$" --include="*.php" --exclude-dir=vendor --exclude-dir=peptide-news-plugin . 2>/dev/null \
| grep -v "\\\$wpdb->prepare" \
| grep -v "uninstall\.php" \
| grep -v "class-peptide-news-activator\.php" \
| grep -v "class-peptide-news-logger\.php" \
| grep -v "DROP TABLE" \
| grep -v "TRUNCATE" \
&& [ ${PIPESTATUS[0]} -eq 0 ]; then
echo "WARNING: Found potential unescaped SQL queries. Use wpdb->prepare() for all dynamic SQL."
exit 1
fi
@@ -119,6 +128,6 @@ jobs:
- name: Check JS syntax
run: |
for f in $(find . -name '*.js' -not -path './vendor/*' -not -path './node_modules/*' -not -path './peptide-news-plugin/*'); do
for f in $(find . -name '*.js' -not -path './vendor/*' -not -path './node_modules/*' -not -path './peptide-news-plugin/*' -not -path '*/vendor/*'); do
node --check "$f" || exit 1
done

View File

@@ -13,6 +13,7 @@
<exclude-pattern>./node_modules/*</exclude-pattern>
<exclude-pattern>./tests/*</exclude-pattern>
<exclude-pattern>./peptide-news-plugin/*</exclude-pattern>
<exclude-pattern>./admin/vendor/*</exclude-pattern>
<!-- Show progress and use colours -->
<arg value="sp"/>