synapse-hub 2.2.1 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -132,13 +132,28 @@ def resolve_target_repo(cli_target=None, cli_repo=None):
132
132
  def gate_0_author_integrity(repo_root, mode="AUTO"):
133
133
  print("\n[GATE 0] Running Author Attribution & Anti-Tamper Integrity Guard...")
134
134
  try:
135
- from author_integrity import verify_author_attribution, get_canonical_watermark, DEFAULT_REPO_ROOT
135
+ from author_integrity import (
136
+ verify_author_attribution,
137
+ get_canonical_watermark,
138
+ verify_author_fingerprint,
139
+ DEFAULT_REPO_ROOT,
140
+ )
136
141
  except ImportError:
137
142
  import sys
138
143
  sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
139
- from author_integrity import verify_author_attribution, get_canonical_watermark, DEFAULT_REPO_ROOT
144
+ from author_integrity import (
145
+ verify_author_attribution,
146
+ get_canonical_watermark,
147
+ verify_author_fingerprint,
148
+ DEFAULT_REPO_ROOT,
149
+ )
150
+
151
+ # 1. Cryptographic SHA-256 fingerprint verification
152
+ if not verify_author_fingerprint():
153
+ print("[FAIL] Cryptographic author fingerprint mismatch! Original creator ('Thế Vị @TeeVee998') has been tampered with.")
154
+ return False
140
155
 
141
- # In HUB mode, verify the Hub repository itself.
156
+ # 2. In HUB mode, verify the Hub repository itself.
142
157
  # In TARGET mode, verify the Hub tools root to guarantee engine integrity.
143
158
  check_root = repo_root if mode == "HUB" else DEFAULT_REPO_ROOT
144
159
  valid, violations = verify_author_attribution(check_root)
@@ -148,7 +163,7 @@ def gate_0_author_integrity(repo_root, mode="AUTO"):
148
163
  print(f" • {v}")
149
164
  print(" Under MIT License, original author attribution to 'Thế Vị (@TeeVee998)' must be preserved.")
150
165
  return False
151
- print(f"[PASS] Author Attribution & Copyright Notice verified intact: {get_canonical_watermark()}")
166
+ print(f"[PASS] Author Attribution & Cryptographic Provenance verified intact: {get_canonical_watermark()}")
152
167
  return True
153
168
 
154
169
 
@@ -222,43 +237,42 @@ def gate_2_path_portability(repo_root, mode="AUTO"):
222
237
 
223
238
 
224
239
  def gate_3_clean_pom(repo_root, mode="AUTO"):
225
- print("\n[GATE 3] Checking Clean POM & Flat Architecture in Scripts/......")
226
- scripts_dir = os.path.join(repo_root, "Scripts")
227
-
228
- has_groovy = False
229
- if os.path.isdir(scripts_dir):
230
- groovy_files = [f for f in glob.glob(os.path.join(scripts_dir, "**", "*.groovy"), recursive=True)]
231
- has_groovy = len(groovy_files) > 0
232
-
233
- if not has_groovy:
234
- if mode == "HUB":
235
- print("[SKIP] Hub Mode: Repository contains QA Hub assets; no target Groovy scripts in Scripts/ to verify.")
236
- return True
237
- else:
238
- print("[SKIP] No Groovy test scripts present in Scripts/ directory.")
239
- return True
240
+ print("\n[GATE 3] Checking Clean POM & Flat Architecture in Test Scripts...")
241
+ effective_mode = detect_repo_mode(repo_root) if mode == "AUTO" else mode
242
+ if effective_mode == "HUB":
243
+ print("[PASS] Hub Mode: Repository contains QA Hub assets; Clean POM applies to target test suites.")
244
+ return True
245
+
246
+ test_dirs = ["Scripts", "tests", "test", "e2e", "specs", "cypress"]
247
+ test_files = []
248
+ for td in test_dirs:
249
+ d = os.path.join(repo_root, td)
250
+ if os.path.isdir(d):
251
+ for ext in ("*.groovy", "*.ts", "*.js", "*.py", "*.java"):
252
+ test_files.extend(glob.glob(os.path.join(d, "**", ext), recursive=True))
253
+
254
+ if not test_files:
255
+ print("[SKIP] No test scripts present in candidate directories (Scripts/, tests/, e2e/).")
256
+ return True
240
257
 
241
258
  violations = []
242
- for root, dirs, files in os.walk(scripts_dir):
243
- for f in files:
244
- if f.endswith(".groovy"):
245
- full_path = os.path.join(root, f)
246
- rel_path = os.path.relpath(full_path, repo_root)
247
- try:
248
- with open(full_path, "r", encoding="utf-8", errors="ignore") as fp:
249
- for line_no, line in enumerate(fp, 1):
250
- stripped = line.strip()
251
- if stripped.startswith("//") or stripped.startswith("/*"):
252
- continue
253
- if "findTestObject" in line:
254
- violations.append((rel_path, line_no, "Raw findTestObject"))
255
- if "//" in line and ("//table" in line or "//input" in line or "//button" in line):
256
- violations.append((rel_path, line_no, "Raw XPath"))
257
- except Exception:
258
- pass
259
+ for full_path in sorted(set(test_files)):
260
+ rel_path = os.path.relpath(full_path, repo_root)
261
+ try:
262
+ with open(full_path, "r", encoding="utf-8", errors="ignore") as fp:
263
+ for line_no, line in enumerate(fp, 1):
264
+ stripped = line.strip()
265
+ if stripped.startswith("//") or stripped.startswith("/*") or stripped.startswith("#"):
266
+ continue
267
+ if "findTestObject" in line:
268
+ violations.append((rel_path, line_no, "Raw findTestObject"))
269
+ if "//" in line and ("//table" in line or "//input" in line or "//button" in line):
270
+ violations.append((rel_path, line_no, "Raw XPath"))
271
+ except Exception:
272
+ pass
259
273
 
260
274
  if violations:
261
- print(f"[FAIL] {len(violations)} Clean POM violations in Scripts/:")
275
+ print(f"[FAIL] {len(violations)} Clean POM violations in test scripts:")
262
276
  for rel_path, line_no, reason in violations:
263
277
  print(f" - {rel_path}:{line_no} ({reason})")
264
278
  return False
@@ -389,26 +403,35 @@ def gate_6_credential_security(repo_root, mode="AUTO"):
389
403
 
390
404
  def gate_7_infer_linter(repo_root, mode="AUTO"):
391
405
  print("\n[GATE 7] Running Meta Infer-Style Static Defect & Fake-Pass Sentinel...")
392
- scripts_dir = os.path.join(repo_root, "Scripts")
393
- has_groovy = False
394
- if os.path.isdir(scripts_dir):
395
- groovy_files = [f for f in glob.glob(os.path.join(scripts_dir, "**", "*.groovy"), recursive=True)]
396
- has_groovy = len(groovy_files) > 0
397
-
398
- if not has_groovy:
399
- if mode == "HUB":
400
- print("[SKIP] Hub Mode: No Groovy test scripts in Scripts/ to scan (Static Defect Sentinel active for target projects).")
401
- return True
402
- else:
403
- print("[SKIP] No Groovy test scripts present in Scripts/ directory.")
404
- return True
406
+ effective_mode = detect_repo_mode(repo_root) if mode == "AUTO" else mode
407
+ if effective_mode == "HUB":
408
+ print("[PASS] Hub Mode: Static Defect Sentinel active for target projects.")
409
+ return True
410
+
411
+ test_dirs = ["Scripts", "tests", "test", "e2e", "specs", "cypress"]
412
+ has_tests = False
413
+ target_scan_dir = None
414
+ for td in test_dirs:
415
+ d = os.path.join(repo_root, td)
416
+ if os.path.isdir(d):
417
+ for ext in ("*.groovy", "*.ts", "*.js", "*.py", "*.java"):
418
+ if glob.glob(os.path.join(d, "**", ext), recursive=True):
419
+ has_tests = True
420
+ target_scan_dir = d
421
+ break
422
+ if has_tests:
423
+ break
424
+
425
+ if not has_tests:
426
+ print("[SKIP] No test scripts (Groovy/TS/JS/Py) present in candidate test directories.")
427
+ return True
405
428
 
406
429
  infer_script = os.path.join(SCRIPT_DIR, "infer_linter.py")
407
430
  if not os.path.exists(infer_script):
408
431
  infer_script = os.path.join(repo_root, "tools", "infer_linter.py")
409
432
 
410
433
  if os.path.exists(infer_script):
411
- res = subprocess.run([sys.executable, infer_script, "--dir", scripts_dir], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
434
+ res = subprocess.run([sys.executable, infer_script, "--dir", target_scan_dir], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
412
435
  if res.returncode != 0:
413
436
  print("[FAIL] Static Defect Sentinel detected critical issues in test scripts:")
414
437
  print(res.stdout)