github-advanced-security[bot] commented on code in PR #137:
URL: https://github.com/apache/airflow-steward/pull/137#discussion_r3226926549


##########
tools/skill-validator/src/skill_validator/__init__.py:
##########
@@ -506,18 +715,98 @@
     parser = argparse.ArgumentParser(
         description="Validate framework skill definitions.",
     )
-    parser.parse_args(argv)
+    parser.add_argument(
+        "--skip-categories",
+        default="",
+        help="Comma-separated list of violation categories to skip entirely.",
+    )
+    parser.add_argument(
+        "--strict",
+        action="store_true",
+        help="Promote SOFT categories (advisory) to hard failures.",
+    )
+    args = parser.parse_args(argv)
 
+    skip = {c.strip() for c in args.skip_categories.split(",") if c.strip()}
     violations = run_validation()
+    filtered = [v for v in violations if v.category not in skip]
 
-    if not violations:
+    if args.strict:
+        hard = filtered
+        soft: list[Violation] = []
+    else:
+        hard = [v for v in filtered if v.category not in SOFT_CATEGORIES]
+        soft = [v for v in filtered if v.category in SOFT_CATEGORIES]
+
+    if not filtered:
         print("skill-validator: OK (no violations)")
         return 0
 
-    print(f"skill-validator: {len(violations)} violation(s) found\n")
-    for v in violations:
-        print(v)
-    return 1
+    if soft:
+        _print_soft_warnings(soft)
+
+    if hard:
+        print(f"skill-validator: {len(hard)} violation(s) found\n")
+        for v in hard:
+            print(v)
+        return 1
+
+    return 0
+
+
+# ---------------------------------------------------------------------------
+# SOFT warning formatter
+# ---------------------------------------------------------------------------
+
+
+_SOFT_RULE_PREFIXES: tuple[str, ...] = (
+    "action-inventory",
+    "distinct-from",
+    "chain-handoff",
+    "parenthetical rationale",
+    "criteria-source",
+    "trigger phrase",
+)
+
+
+def _rule_name(message: str) -> str:
+    for prefix in _SOFT_RULE_PREFIXES:
+        if message.startswith(prefix):
+            return prefix
+    return "other"
+
+
+def _print_soft_warnings(soft: list[Violation]) -> None:
+    from collections import Counter, defaultdict
+
+    repo_root = find_repo_root()
+    by_file: dict[Path, list[Violation]] = defaultdict(list)
+    for v in soft:
+        by_file[v.path].append(v)
+
+    print(
+        f"skill-validator: {len(soft)} SOFT warning(s) across "
+        f"{len(by_file)} skill(s) — advisory, not blocking\n",
+        file=sys.stderr,
+    )
+
+    for path in sorted(by_file, key=lambda p: str(p)):

Review Comment:
   ## CodeQL / Unnecessary lambda
   
   This 'lambda' is just a simple wrapper around a callable object. Use that 
object directly.
   
   [Show more 
details](https://github.com/apache/airflow-steward/security/code-scanning/10)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to