4242
4343 - name : Plugin Check Summary
4444 if : always()
45+ env :
46+ RESULTS_FILE : ${{ runner.temp }}/plugin-check-results.txt
4547 run : |
46- RESULTS_FILE="${RUNNER_TEMP}/plugin-check-results.txt"
47-
4848 echo "## WordPress Plugin Check Results" >> $GITHUB_STEP_SUMMARY
4949 echo "" >> $GITHUB_STEP_SUMMARY
5050
@@ -54,31 +54,33 @@ jobs:
5454 exit 0
5555 fi
5656
57- PARSED=$(python3 << 'PYEOF'
58- import json, sys, re
57+ PARSED=$(RESULTS_FILE="$RESULTS_FILE" python3 << 'PYEOF'
58+ import json, os, re
59+
60+ results_path = os.environ["RESULTS_FILE"]
5961
6062 high_risk_codes = [
6163 "plugin_updater", "code_obfuscation", "no_unfiltered_uploads",
6264 "trademarked_term", "trademarks"
6365 ]
6466 high_risk_messages = [
65- "Plugin Updater detected", "Missing.*License.*Plugin Header",
66- "restricted term", "Unescaped parameter.*\ \$wpdb",
67- "Use placeholders and.*\ \$wpdb->prepare"
67+ r "Plugin Updater detected", r "Missing.*License.*Plugin Header",
68+ r "restricted term", r "Unescaped parameter.*\$wpdb",
69+ r "Use placeholders and.*\$wpdb->prepare"
6870 ]
6971 medium_risk_codes = [
7072 "missing_direct_file_access_protection", "trunk_stable_tag",
7173 "mismatched_plugin_name", "application_detected"
7274 ]
7375 medium_risk_messages = [
74- "Missing.*\\ $domain.*parameter", "has been deprecated",
75- "wp_get_sites", "cURL functions is highly discouraged"
76+ r "Missing.*\$domain.*parameter", r "has been deprecated",
77+ r "wp_get_sites", r "cURL functions is highly discouraged"
7678 ]
7779
7880 high, medium, other = [], [], []
7981
8082 try:
81- with open("${RUNNER_TEMP}/plugin-check-results.txt" , "r") as f:
83+ with open(results_path , "r") as f:
8284 content = f.read().strip()
8385
8486 all_issues = []
@@ -95,12 +97,16 @@ jobs:
9597 except json.JSONDecodeError:
9698 for line in content.split('\n'):
9799 line = line.strip()
98- if not line: continue
100+ if not line:
101+ continue
99102 try:
100103 parsed = json.loads(line)
101- if isinstance(parsed, list): all_issues.extend(parsed)
102- elif isinstance(parsed, dict): all_issues.append(parsed)
103- except json.JSONDecodeError: continue
104+ if isinstance(parsed, list):
105+ all_issues.extend(parsed)
106+ elif isinstance(parsed, dict):
107+ all_issues.append(parsed)
108+ except json.JSONDecodeError:
109+ continue
104110
105111 for issue in all_issues:
106112 code = issue.get('code', '')
@@ -113,7 +119,8 @@ jobs:
113119 location = ""
114120 if file_path:
115121 location = f" ({file_path}"
116- if line_num and line_num > 0: location += f", line {line_num}"
122+ if line_num and line_num > 0:
123+ location += f", line {line_num}"
117124 location += ")"
118125 elif line_num and line_num > 0:
119126 location = f" (line {line_num})"
@@ -123,21 +130,31 @@ jobs:
123130 is_high = code in high_risk_codes
124131 if not is_high:
125132 for p in high_risk_messages:
126- if re.search(p, msg, re.IGNORECASE): is_high = True; break
133+ if re.search(p, msg, re.IGNORECASE):
134+ is_high = True
135+ break
127136
128137 is_medium = code in medium_risk_codes
129138 if not is_medium and not is_high:
130139 for p in medium_risk_messages:
131- if re.search(p, msg, re.IGNORECASE): is_medium = True; break
140+ if re.search(p, msg, re.IGNORECASE):
141+ is_medium = True
142+ break
132143
133- if is_high: high.append(readable)
134- elif is_medium: medium.append(readable)
135- else: other.append(readable)
144+ if is_high:
145+ high.append(readable)
146+ elif is_medium:
147+ medium.append(readable)
148+ else:
149+ other.append(readable)
136150
137151 def dedup(lst):
138- seen = set(); result = []
152+ seen = set()
153+ result = []
139154 for item in lst:
140- if item not in seen: seen.add(item); result.append(item)
155+ if item not in seen:
156+ seen.add(item)
157+ result.append(item)
141158 return result
142159
143160 high, medium, other = dedup(high), dedup(medium), dedup(other)
@@ -150,8 +167,9 @@ jobs:
150167 for i in other: print(i)
151168 print("---COUNTS---")
152169 print(f"{len(high)}|{len(medium)}|{len(other)}")
170+
153171 except Exception as e:
154- print(f"Parse error: {e}", file=sys.stderr)
172+ print(f"Parse error: {e}", file=__import__(' sys') .stderr)
155173 print("---HIGH---\n---MEDIUM---\n---OTHER---\n---COUNTS---\n0|0|0")
156174 PYEOF
157175 )
0 commit comments