From de703b41376575219e5251b1b5f4da92c59fc5a0 Mon Sep 17 00:00:00 2001 From: vytisbulkevicius Date: Tue, 7 Apr 2026 12:43:58 +0300 Subject: [PATCH 01/13] Add WordPress Plugin Check GitHub Action for PRs --- .github/workflows/plugin-check.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/plugin-check.yml diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml new file mode 100644 index 0000000..e9625c3 --- /dev/null +++ b/.github/workflows/plugin-check.yml @@ -0,0 +1,22 @@ +name: WordPress Plugin Check + +on: + pull_request: + types: [opened, synchronize, reopened] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + plugin-check: + name: WordPress.org Guidelines Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: wordpress/plugin-check-action@v1 + with: + categories: plugin_repo,security,performance,general + ignore-warnings: false + ignore-errors: false From c06daead2fc546630423116802bdb46956472af5 Mon Sep 17 00:00:00 2001 From: vytisbulkevicius Date: Tue, 7 Apr 2026 13:06:41 +0300 Subject: [PATCH 02/13] Add composer install and results summary step --- .github/workflows/plugin-check.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml index e9625c3..fa9b5d1 100644 --- a/.github/workflows/plugin-check.yml +++ b/.github/workflows/plugin-check.yml @@ -15,8 +15,26 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install Composer dependencies + run: composer install --no-dev --optimize-autoloader + - uses: wordpress/plugin-check-action@v1 + id: plugin-check with: categories: plugin_repo,security,performance,general ignore-warnings: false ignore-errors: false + + - name: Plugin Check Summary + if: always() + run: | + RESULTS_FILE="${RUNNER_TEMP}/plugin-check-results.txt" + echo "## WordPress Plugin Check Results" >> $GITHUB_STEP_SUMMARY + if [ -s "$RESULTS_FILE" ]; then + echo '```' >> $GITHUB_STEP_SUMMARY + cat "$RESULTS_FILE" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + else + echo "No results file found or file is empty." >> $GITHUB_STEP_SUMMARY + echo "Check the annotations on the Files Changed tab for details." >> $GITHUB_STEP_SUMMARY + fi From 0546e197dd950d351436206522e7254812b87f53 Mon Sep 17 00:00:00 2001 From: vytisbulkevicius Date: Tue, 7 Apr 2026 13:18:33 +0300 Subject: [PATCH 03/13] Focus plugin check on critical wordpress.org issues, reduce noise --- .github/workflows/plugin-check.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml index fa9b5d1..3c0ddce 100644 --- a/.github/workflows/plugin-check.yml +++ b/.github/workflows/plugin-check.yml @@ -21,9 +21,21 @@ jobs: - uses: wordpress/plugin-check-action@v1 id: plugin-check with: - categories: plugin_repo,security,performance,general - ignore-warnings: false - ignore-errors: false + categories: plugin_repo,security,performance + exclude-directories: | + tests + bin + .github + ignore-codes: | + WordPress.WP.I18n.TextDomainMismatch + textdomain_mismatch + hidden_files + WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound + WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound + WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound + WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound + WordPress.PHP.DevelopmentFunctions.error_log_trigger_error + include-experimental: false - name: Plugin Check Summary if: always() From a82e51c8e052ba94b598d41783f0b004a5c2e640 Mon Sep 17 00:00:00 2001 From: vytisbulkevicius Date: Tue, 7 Apr 2026 13:33:47 +0300 Subject: [PATCH 04/13] Maximize wordpress.org coverage while keeping noise filtered --- .github/workflows/plugin-check.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml index 3c0ddce..2604cbb 100644 --- a/.github/workflows/plugin-check.yml +++ b/.github/workflows/plugin-check.yml @@ -21,7 +21,7 @@ jobs: - uses: wordpress/plugin-check-action@v1 id: plugin-check with: - categories: plugin_repo,security,performance + categories: plugin_repo,security,performance,general exclude-directories: | tests bin @@ -34,8 +34,10 @@ jobs: WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound + WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound WordPress.PHP.DevelopmentFunctions.error_log_trigger_error - include-experimental: false + WordPress.WP.EnqueuedResourceParameters.MissingVersion + include-experimental: true - name: Plugin Check Summary if: always() From 9028eb66a5bc8ecef9ef345bb39b21acd47c3562 Mon Sep 17 00:00:00 2001 From: vytisbulkevicius Date: Tue, 7 Apr 2026 14:00:11 +0300 Subject: [PATCH 05/13] Disable PR comment, keep results in action logs only --- .github/workflows/plugin-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml index 2604cbb..0838978 100644 --- a/.github/workflows/plugin-check.yml +++ b/.github/workflows/plugin-check.yml @@ -38,6 +38,7 @@ jobs: WordPress.PHP.DevelopmentFunctions.error_log_trigger_error WordPress.WP.EnqueuedResourceParameters.MissingVersion include-experimental: true + repo-token: '' - name: Plugin Check Summary if: always() From 40397ca8e1838d74dec7633ac3a22078fe02115b Mon Sep 17 00:00:00 2001 From: vytisbulkevicius Date: Tue, 7 Apr 2026 14:16:19 +0300 Subject: [PATCH 06/13] Pin plugin-check-action to v1.1.5 to avoid broken upstream dependency --- .github/workflows/plugin-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml index 0838978..15a8584 100644 --- a/.github/workflows/plugin-check.yml +++ b/.github/workflows/plugin-check.yml @@ -18,7 +18,7 @@ jobs: - name: Install Composer dependencies run: composer install --no-dev --optimize-autoloader - - uses: wordpress/plugin-check-action@v1 + - uses: wordpress/plugin-check-action@v1.1.5 id: plugin-check with: categories: plugin_repo,security,performance,general From 5ece5d20ff11badcd02e407df318ec9f5d18f328 Mon Sep 17 00:00:00 2001 From: vytisbulkevicius Date: Tue, 7 Apr 2026 14:27:16 +0300 Subject: [PATCH 07/13] Revert to plugin-check-action@v1, version pin not needed --- .github/workflows/plugin-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml index 15a8584..0838978 100644 --- a/.github/workflows/plugin-check.yml +++ b/.github/workflows/plugin-check.yml @@ -18,7 +18,7 @@ jobs: - name: Install Composer dependencies run: composer install --no-dev --optimize-autoloader - - uses: wordpress/plugin-check-action@v1.1.5 + - uses: wordpress/plugin-check-action@v1 id: plugin-check with: categories: plugin_repo,security,performance,general From 1470a7cdc0a855fa356ccfa563a23175feac4135 Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Tue, 14 Apr 2026 12:17:13 +0530 Subject: [PATCH 08/13] fix: restore svg menu icon size and styles --- includes/front.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/front.php b/includes/front.php index cb42e40..4dcb419 100644 --- a/includes/front.php +++ b/includes/front.php @@ -483,10 +483,10 @@ public static function get_svg_icon( $meta ) { } } if ( ! empty( $width ) ) { - $width = sprintf( ' width="%d"', $width ); + $width = sprintf( ' width="%d"', esc_attr( $width ) ); } if ( ! empty( $height ) ) { - $height = sprintf( ' height="%d"', $height ); + $height = sprintf( ' height="%d"', esc_attr( $height ) ); } $image_alt = get_post_meta( $meta['icon'], '_wp_attachment_image_alt', true ); $image_alt = $image_alt ? wp_strip_all_tags( $image_alt ) : ''; @@ -495,9 +495,9 @@ public static function get_svg_icon( $meta ) { esc_url( wp_get_attachment_url( $meta['icon'] ) ), esc_attr( $classes ), esc_attr( $image_alt ), - esc_attr( $width ), - esc_attr( $height ), - esc_attr( $style ) + $width, + $height, + $style ); } From 0de941c281a965b13916e3b3ab6d9c8aac5f70ca Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Fri, 17 Apr 2026 12:01:58 +0530 Subject: [PATCH 09/13] fix: vertical alignment in flex layouts --- includes/front.php | 35 ++++++++++++++++++++++++++++++++--- includes/meta.php | 8 ++++++++ includes/settings.php | 16 ---------------- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/includes/front.php b/includes/front.php index cb42e40..bce3e5f 100644 --- a/includes/front.php +++ b/includes/front.php @@ -339,6 +339,18 @@ public static function get_icon_style( $meta, $keys, $as_attribute = true ) { $rule = self::$default_style[ $key ]; + // Special handling for vertical-align because it affects the layout of flex containers. + if ( 'vertical_align' === $key ) { + $stored = isset( $meta[ $key ] ) ? $meta[ $key ] : $rule['value']; + + if ( $stored !== $rule['value'] ) { + $style_a[ $rule['property'] ] = $stored; + } + + $style_a['align-self'] = self::calculate_align_self( $stored ); + continue; + } + if ( ! isset( $meta[ $key ] ) || $meta[ $key ] === $rule['value'] ) { continue; } @@ -355,13 +367,13 @@ public static function get_icon_style( $meta, $keys, $as_attribute = true ) { return $style_s; } - foreach ( $style_a as $key => $value ) { - $style_s .= "{$key}:{$value};"; + foreach ( $style_a as $prop => $value ) { + $style_s .= "{$prop}:{$value};"; } $style_s = esc_attr( $style_s ); - if ( $as_attribute ) { + if ( $as_attribute ) { $style_s = sprintf( ' style="%s"', $style_s ); } @@ -513,4 +525,21 @@ public static function _add_menu_item_class( $classes, $item, $args ) { // phpcs $classes[] = 'menu-item'; return $classes; } + + /** + * Calculate align-self value. + * + * @param string $value vertical-align value. + * @return string + */ + private static function calculate_align_self( $value ) { + $align_self_map = array( + 'top' => 'flex-start', + 'middle' => 'center', + 'bottom' => 'flex-end', + 'baseline' => 'baseline', + ); + + return isset( $align_self_map[ $value ] ) ? $align_self_map[ $value ] : 'center'; + } } diff --git a/includes/meta.php b/includes/meta.php index fd8563d..51c8d0f 100644 --- a/includes/meta.php +++ b/includes/meta.php @@ -103,6 +103,14 @@ public static function get( $id, $defaults = array() ) { $value['position'] = $defaults['position']; } + // Backward-compatibility: values removed in favour of align-self support. + $supported_vertical_align = array( 'top', 'middle', 'bottom', 'baseline' ); + if ( isset( $value['vertical_align'] ) && + ! in_array( $value['vertical_align'], $supported_vertical_align, true ) + ) { + $value['vertical_align'] = 'middle'; + } + if ( isset( $value['size'] ) && ! isset( $value['font_size'] ) ) { $value['font_size'] = $value['size']; unset( $value['size'] ); diff --git a/includes/settings.php b/includes/settings.php index 666eb57..c7f88f4 100644 --- a/includes/settings.php +++ b/includes/settings.php @@ -535,18 +535,10 @@ public static function get_settings_fields( array $values = array() ) { 'label' => __( 'Vertical Align', 'menu-icons' ), 'default' => 'middle', 'choices' => array( - array( - 'value' => 'super', - 'label' => __( 'Super', 'menu-icons' ), - ), array( 'value' => 'top', 'label' => __( 'Top', 'menu-icons' ), ), - array( - 'value' => 'text-top', - 'label' => __( 'Text Top', 'menu-icons' ), - ), array( 'value' => 'middle', 'label' => __( 'Middle', 'menu-icons' ), @@ -555,18 +547,10 @@ public static function get_settings_fields( array $values = array() ) { 'value' => 'baseline', 'label' => __( 'Baseline', 'menu-icons' ), ), - array( - 'value' => 'text-bottom', - 'label' => __( 'Text Bottom', 'menu-icons' ), - ), array( 'value' => 'bottom', 'label' => __( 'Bottom', 'menu-icons' ), ), - array( - 'value' => 'sub', - 'label' => __( 'Sub', 'menu-icons' ), - ), ), ), 'font_size' => array( From f80a5e52e570e578fde1bd230ecce90c32a882ec Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Fri, 17 Apr 2026 12:20:58 +0530 Subject: [PATCH 10/13] fix: improve vertical alignment handling --- includes/front.php | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/includes/front.php b/includes/front.php index bce3e5f..5e1d89b 100644 --- a/includes/front.php +++ b/includes/front.php @@ -51,6 +51,19 @@ final class Menu_Icons_Front_End { */ protected static $hidden_label_class = 'visuallyhidden'; + /** + * Align-self map for vertical-align values. + * + * @access private + * @var array + */ + private static $align_self_map = array( + 'top' => 'flex-start', + 'middle' => 'center', + 'bottom' => 'flex-end', + 'baseline' => 'baseline', + ); + /** * Add hooks for front-end functionalities @@ -341,13 +354,13 @@ public static function get_icon_style( $meta, $keys, $as_attribute = true ) { // Special handling for vertical-align because it affects the layout of flex containers. if ( 'vertical_align' === $key ) { - $stored = isset( $meta[ $key ] ) ? $meta[ $key ] : $rule['value']; - - if ( $stored !== $rule['value'] ) { - $style_a[ $rule['property'] ] = $stored; + if ( ! isset( $meta[ $key ] ) || $meta[ $key ] === $rule['value'] ) { + continue; } - $style_a['align-self'] = self::calculate_align_self( $stored ); + $stored = $meta[ $key ]; + $style_a[ $rule['property'] ] = $stored; + $style_a['align-self'] = isset( self::$align_self_map[ $stored ] ) ? self::$align_self_map[ $stored ] : 'center'; continue; } @@ -525,21 +538,4 @@ public static function _add_menu_item_class( $classes, $item, $args ) { // phpcs $classes[] = 'menu-item'; return $classes; } - - /** - * Calculate align-self value. - * - * @param string $value vertical-align value. - * @return string - */ - private static function calculate_align_self( $value ) { - $align_self_map = array( - 'top' => 'flex-start', - 'middle' => 'center', - 'bottom' => 'flex-end', - 'baseline' => 'baseline', - ); - - return isset( $align_self_map[ $value ] ) ? $align_self_map[ $value ] : 'center'; - } } From e71cf211e36983e2f80da76804fbc5ba068a49da Mon Sep 17 00:00:00 2001 From: vytisbulkevicius Date: Thu, 23 Apr 2026 14:40:06 +0300 Subject: [PATCH 11/13] Update plugin check workflow with risk categorization and disable PR comment --- .github/workflows/plugin-check.yml | 81 ++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 4 deletions(-) diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml index 0838978..25298be 100644 --- a/.github/workflows/plugin-check.yml +++ b/.github/workflows/plugin-check.yml @@ -44,12 +44,85 @@ jobs: if: always() run: | RESULTS_FILE="${RUNNER_TEMP}/plugin-check-results.txt" + echo "## WordPress Plugin Check Results" >> $GITHUB_STEP_SUMMARY - if [ -s "$RESULTS_FILE" ]; then + echo "" >> $GITHUB_STEP_SUMMARY + + if [ ! -s "$RESULTS_FILE" ]; then + echo "No results file found or file is empty." >> $GITHUB_STEP_SUMMARY + echo "Check the action logs for details." >> $GITHUB_STEP_SUMMARY + exit 0 + fi + + # === HIGH RISK: Issues that can get your plugin closed or suspended === + echo "### 🚨 HIGH RISK — Can cause plugin closure or suspension" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + HIGH_RISK_PATTERNS=( + "Plugin Updater detected" + "Missing.*License.*Plugin Header" + "restricted term" + "trademarked_term" + "trademarks" + "Unescaped parameter.*\\$wpdb" + "Use placeholders and.*\\$wpdb->prepare" + "code_obfuscation" + "plugin_updater" + "no_unfiltered_uploads" + ) + + HIGH_RISK_REGEX=$(IFS='|'; echo "${HIGH_RISK_PATTERNS[*]}") + HIGH_RISK_FOUND=$(grep -iE "$HIGH_RISK_REGEX" "$RESULTS_FILE" || true) + + if [ -n "$HIGH_RISK_FOUND" ]; then echo '```' >> $GITHUB_STEP_SUMMARY - cat "$RESULTS_FILE" >> $GITHUB_STEP_SUMMARY + echo "$HIGH_RISK_FOUND" | sort -u >> $GITHUB_STEP_SUMMARY echo '```' >> $GITHUB_STEP_SUMMARY else - echo "No results file found or file is empty." >> $GITHUB_STEP_SUMMARY - echo "Check the annotations on the Files Changed tab for details." >> $GITHUB_STEP_SUMMARY + echo "✅ No high-risk issues found." >> $GITHUB_STEP_SUMMARY fi + + echo "" >> $GITHUB_STEP_SUMMARY + + # === MEDIUM RISK: Issues wordpress.org reviews flag === + echo "### ⚠️ MEDIUM RISK — Commonly flagged in wordpress.org reviews" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + MEDIUM_RISK_PATTERNS=( + "missing_direct_file_access_protection" + "trunk_stable_tag" + "mismatched_plugin_name" + "Missing.*\\$domain.*parameter" + "has been deprecated" + "wp_get_sites" + "curl_curl_" + "WordPress.WP.AlternativeFunctions" + "application_detected" + ) + + MEDIUM_RISK_REGEX=$(IFS='|'; echo "${MEDIUM_RISK_PATTERNS[*]}") + MEDIUM_RISK_FOUND=$(grep -iE "$MEDIUM_RISK_REGEX" "$RESULTS_FILE" || true) + + if [ -n "$MEDIUM_RISK_FOUND" ]; then + echo '```' >> $GITHUB_STEP_SUMMARY + echo "$MEDIUM_RISK_FOUND" | sort -u >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + else + echo "✅ No medium-risk issues found." >> $GITHUB_STEP_SUMMARY + fi + + echo "" >> $GITHUB_STEP_SUMMARY + + # === ALL OTHER ISSUES (collapsed) === + TOTAL=$(wc -l < "$RESULTS_FILE" | tr -d ' ') + HIGH_COUNT=$(echo "$HIGH_RISK_FOUND" | grep -c '.' || echo "0") + MEDIUM_COUNT=$(echo "$MEDIUM_RISK_FOUND" | grep -c '.' || echo "0") + OTHER_COUNT=$((TOTAL - HIGH_COUNT - MEDIUM_COUNT)) + + echo "
" >> $GITHUB_STEP_SUMMARY + echo "📋 Other issues ($OTHER_COUNT) — click to expand" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + grep -ivE "$HIGH_RISK_REGEX|$MEDIUM_RISK_REGEX" "$RESULTS_FILE" >> $GITHUB_STEP_SUMMARY || true + echo '```' >> $GITHUB_STEP_SUMMARY + echo "
" >> $GITHUB_STEP_SUMMARY From e1af1c424e899371da3452fbb343db2e802e692e Mon Sep 17 00:00:00 2001 From: vytisbulkevicius Date: Thu, 23 Apr 2026 14:48:03 +0300 Subject: [PATCH 12/13] Improve plugin check summary readability - parse JSON into clean messages --- .github/workflows/plugin-check.yml | 170 ++++++++++++++++++++--------- 1 file changed, 117 insertions(+), 53 deletions(-) diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml index 25298be..9ed0712 100644 --- a/.github/workflows/plugin-check.yml +++ b/.github/workflows/plugin-check.yml @@ -54,75 +54,139 @@ jobs: exit 0 fi - # === HIGH RISK: Issues that can get your plugin closed or suspended === - echo "### 🚨 HIGH RISK — Can cause plugin closure or suspension" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - - HIGH_RISK_PATTERNS=( - "Plugin Updater detected" - "Missing.*License.*Plugin Header" - "restricted term" - "trademarked_term" - "trademarks" - "Unescaped parameter.*\\$wpdb" - "Use placeholders and.*\\$wpdb->prepare" - "code_obfuscation" - "plugin_updater" - "no_unfiltered_uploads" + PARSED=$(python3 << 'PYEOF' + import json, sys, re + + high_risk_codes = [ + "plugin_updater", "code_obfuscation", "no_unfiltered_uploads", + "trademarked_term", "trademarks" + ] + high_risk_messages = [ + "Plugin Updater detected", "Missing.*License.*Plugin Header", + "restricted term", "Unescaped parameter.*\\$wpdb", + "Use placeholders and.*\\$wpdb->prepare" + ] + medium_risk_codes = [ + "missing_direct_file_access_protection", "trunk_stable_tag", + "mismatched_plugin_name", "application_detected" + ] + medium_risk_messages = [ + "Missing.*\\$domain.*parameter", "has been deprecated", + "wp_get_sites", "cURL functions is highly discouraged" + ] + + high, medium, other = [], [], [] + + try: + with open("${RUNNER_TEMP}/plugin-check-results.txt", "r") as f: + content = f.read().strip() + + all_issues = [] + try: + data = json.loads(content) + if isinstance(data, list): + all_issues = data + elif isinstance(data, dict): + for fp, issues in data.items(): + if isinstance(issues, list): + for issue in issues: + issue['_file'] = fp + all_issues.append(issue) + except json.JSONDecodeError: + for line in content.split('\n'): + line = line.strip() + if not line: continue + try: + parsed = json.loads(line) + if isinstance(parsed, list): all_issues.extend(parsed) + elif isinstance(parsed, dict): all_issues.append(parsed) + except json.JSONDecodeError: continue + + for issue in all_issues: + code = issue.get('code', '') + msg = issue.get('message', '') + itype = issue.get('type', 'ERROR') + line_num = issue.get('line', 0) + file_path = issue.get('_file', '') + + prefix = "❌" if itype == "ERROR" else "⚠️" + location = "" + if file_path: + location = f" ({file_path}" + if line_num and line_num > 0: location += f", line {line_num}" + location += ")" + elif line_num and line_num > 0: + location = f" (line {line_num})" + + readable = f"{prefix} {msg}{location}" + + is_high = code in high_risk_codes + if not is_high: + for p in high_risk_messages: + if re.search(p, msg, re.IGNORECASE): is_high = True; break + + is_medium = code in medium_risk_codes + if not is_medium and not is_high: + for p in medium_risk_messages: + if re.search(p, msg, re.IGNORECASE): is_medium = True; break + + if is_high: high.append(readable) + elif is_medium: medium.append(readable) + else: other.append(readable) + + def dedup(lst): + seen = set(); result = [] + for item in lst: + if item not in seen: seen.add(item); result.append(item) + return result + + high, medium, other = dedup(high), dedup(medium), dedup(other) + + print("---HIGH---") + for i in high: print(i) + print("---MEDIUM---") + for i in medium: print(i) + print("---OTHER---") + for i in other: print(i) + print("---COUNTS---") + print(f"{len(high)}|{len(medium)}|{len(other)}") + except Exception as e: + print(f"Parse error: {e}", file=sys.stderr) + print("---HIGH---\n---MEDIUM---\n---OTHER---\n---COUNTS---\n0|0|0") + PYEOF ) - HIGH_RISK_REGEX=$(IFS='|'; echo "${HIGH_RISK_PATTERNS[*]}") - HIGH_RISK_FOUND=$(grep -iE "$HIGH_RISK_REGEX" "$RESULTS_FILE" || true) + HIGH_SECTION=$(echo "$PARSED" | sed -n '/^---HIGH---$/,/^---MEDIUM---$/p' | sed '1d;$d') + MEDIUM_SECTION=$(echo "$PARSED" | sed -n '/^---MEDIUM---$/,/^---OTHER---$/p' | sed '1d;$d') + OTHER_SECTION=$(echo "$PARSED" | sed -n '/^---OTHER---$/,/^---COUNTS---$/p' | sed '1d;$d') + COUNTS=$(echo "$PARSED" | tail -1) + OTHER_COUNT=$(echo "$COUNTS" | cut -d'|' -f3) - if [ -n "$HIGH_RISK_FOUND" ]; then - echo '```' >> $GITHUB_STEP_SUMMARY - echo "$HIGH_RISK_FOUND" | sort -u >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY + echo "### 🚨 HIGH RISK — Can cause plugin closure or suspension" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + if [ -n "$HIGH_SECTION" ]; then + echo "$HIGH_SECTION" >> $GITHUB_STEP_SUMMARY else echo "✅ No high-risk issues found." >> $GITHUB_STEP_SUMMARY fi - echo "" >> $GITHUB_STEP_SUMMARY - # === MEDIUM RISK: Issues wordpress.org reviews flag === echo "### ⚠️ MEDIUM RISK — Commonly flagged in wordpress.org reviews" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - - MEDIUM_RISK_PATTERNS=( - "missing_direct_file_access_protection" - "trunk_stable_tag" - "mismatched_plugin_name" - "Missing.*\\$domain.*parameter" - "has been deprecated" - "wp_get_sites" - "curl_curl_" - "WordPress.WP.AlternativeFunctions" - "application_detected" - ) - - MEDIUM_RISK_REGEX=$(IFS='|'; echo "${MEDIUM_RISK_PATTERNS[*]}") - MEDIUM_RISK_FOUND=$(grep -iE "$MEDIUM_RISK_REGEX" "$RESULTS_FILE" || true) - - if [ -n "$MEDIUM_RISK_FOUND" ]; then - echo '```' >> $GITHUB_STEP_SUMMARY - echo "$MEDIUM_RISK_FOUND" | sort -u >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY + if [ -n "$MEDIUM_SECTION" ]; then + echo "$MEDIUM_SECTION" >> $GITHUB_STEP_SUMMARY else echo "✅ No medium-risk issues found." >> $GITHUB_STEP_SUMMARY fi - echo "" >> $GITHUB_STEP_SUMMARY - # === ALL OTHER ISSUES (collapsed) === - TOTAL=$(wc -l < "$RESULTS_FILE" | tr -d ' ') - HIGH_COUNT=$(echo "$HIGH_RISK_FOUND" | grep -c '.' || echo "0") - MEDIUM_COUNT=$(echo "$MEDIUM_RISK_FOUND" | grep -c '.' || echo "0") - OTHER_COUNT=$((TOTAL - HIGH_COUNT - MEDIUM_COUNT)) - echo "
" >> $GITHUB_STEP_SUMMARY echo "📋 Other issues ($OTHER_COUNT) — click to expand" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - echo '```' >> $GITHUB_STEP_SUMMARY - grep -ivE "$HIGH_RISK_REGEX|$MEDIUM_RISK_REGEX" "$RESULTS_FILE" >> $GITHUB_STEP_SUMMARY || true - echo '```' >> $GITHUB_STEP_SUMMARY + if [ -n "$OTHER_SECTION" ]; then + echo "$OTHER_SECTION" >> $GITHUB_STEP_SUMMARY + else + echo "No other issues." >> $GITHUB_STEP_SUMMARY + fi + echo "" >> $GITHUB_STEP_SUMMARY echo "
" >> $GITHUB_STEP_SUMMARY From b98e885dcad7d707833ccd392942a575a8463c55 Mon Sep 17 00:00:00 2001 From: vytisbulkevicius Date: Thu, 23 Apr 2026 14:54:22 +0300 Subject: [PATCH 13/13] Fix results parsing - pass file path via env var to Python --- .github/workflows/plugin-check.yml | 64 +++++++++++++++++++----------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml index 9ed0712..83a326f 100644 --- a/.github/workflows/plugin-check.yml +++ b/.github/workflows/plugin-check.yml @@ -42,9 +42,9 @@ jobs: - name: Plugin Check Summary if: always() + env: + RESULTS_FILE: ${{ runner.temp }}/plugin-check-results.txt run: | - RESULTS_FILE="${RUNNER_TEMP}/plugin-check-results.txt" - echo "## WordPress Plugin Check Results" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY @@ -54,31 +54,33 @@ jobs: exit 0 fi - PARSED=$(python3 << 'PYEOF' - import json, sys, re + PARSED=$(RESULTS_FILE="$RESULTS_FILE" python3 << 'PYEOF' + import json, os, re + + results_path = os.environ["RESULTS_FILE"] high_risk_codes = [ "plugin_updater", "code_obfuscation", "no_unfiltered_uploads", "trademarked_term", "trademarks" ] high_risk_messages = [ - "Plugin Updater detected", "Missing.*License.*Plugin Header", - "restricted term", "Unescaped parameter.*\\$wpdb", - "Use placeholders and.*\\$wpdb->prepare" + r"Plugin Updater detected", r"Missing.*License.*Plugin Header", + r"restricted term", r"Unescaped parameter.*\$wpdb", + r"Use placeholders and.*\$wpdb->prepare" ] medium_risk_codes = [ "missing_direct_file_access_protection", "trunk_stable_tag", "mismatched_plugin_name", "application_detected" ] medium_risk_messages = [ - "Missing.*\\$domain.*parameter", "has been deprecated", - "wp_get_sites", "cURL functions is highly discouraged" + r"Missing.*\$domain.*parameter", r"has been deprecated", + r"wp_get_sites", r"cURL functions is highly discouraged" ] high, medium, other = [], [], [] try: - with open("${RUNNER_TEMP}/plugin-check-results.txt", "r") as f: + with open(results_path, "r") as f: content = f.read().strip() all_issues = [] @@ -95,12 +97,16 @@ jobs: except json.JSONDecodeError: for line in content.split('\n'): line = line.strip() - if not line: continue + if not line: + continue try: parsed = json.loads(line) - if isinstance(parsed, list): all_issues.extend(parsed) - elif isinstance(parsed, dict): all_issues.append(parsed) - except json.JSONDecodeError: continue + if isinstance(parsed, list): + all_issues.extend(parsed) + elif isinstance(parsed, dict): + all_issues.append(parsed) + except json.JSONDecodeError: + continue for issue in all_issues: code = issue.get('code', '') @@ -113,7 +119,8 @@ jobs: location = "" if file_path: location = f" ({file_path}" - if line_num and line_num > 0: location += f", line {line_num}" + if line_num and line_num > 0: + location += f", line {line_num}" location += ")" elif line_num and line_num > 0: location = f" (line {line_num})" @@ -123,21 +130,31 @@ jobs: is_high = code in high_risk_codes if not is_high: for p in high_risk_messages: - if re.search(p, msg, re.IGNORECASE): is_high = True; break + if re.search(p, msg, re.IGNORECASE): + is_high = True + break is_medium = code in medium_risk_codes if not is_medium and not is_high: for p in medium_risk_messages: - if re.search(p, msg, re.IGNORECASE): is_medium = True; break + if re.search(p, msg, re.IGNORECASE): + is_medium = True + break - if is_high: high.append(readable) - elif is_medium: medium.append(readable) - else: other.append(readable) + if is_high: + high.append(readable) + elif is_medium: + medium.append(readable) + else: + other.append(readable) def dedup(lst): - seen = set(); result = [] + seen = set() + result = [] for item in lst: - if item not in seen: seen.add(item); result.append(item) + if item not in seen: + seen.add(item) + result.append(item) return result high, medium, other = dedup(high), dedup(medium), dedup(other) @@ -150,8 +167,9 @@ jobs: for i in other: print(i) print("---COUNTS---") print(f"{len(high)}|{len(medium)}|{len(other)}") + except Exception as e: - print(f"Parse error: {e}", file=sys.stderr) + print(f"Parse error: {e}", file=__import__('sys').stderr) print("---HIGH---\n---MEDIUM---\n---OTHER---\n---COUNTS---\n0|0|0") PYEOF )