fix: use os.access for cross-platform executable check in skill validator#6894
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe validator's script-executability check was modified to skip POSIX executable-bit validation on Windows by gating the per-script st_mode test behind a platform check ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
core/framework/skills/validator.py (1)
142-145: Add platform-aware executability check for POSIX systems.The
os.access(script_path, os.X_OK)call diverges from strict execute-bit validation on POSIX for privileged users: POSIX permits implementations to returnTrueforX_OKeven without execute bits set when the process is privileged (root), and Linux/Solaris/AIX implementations differ. For strict validation, use stat mode bits on POSIX and keepos.accesson Windows.♻️ Suggested cross-platform adjustment
+import stat ... - if not os.access(script_path, os.X_OK): + is_executable = ( + os.access(script_path, os.X_OK) + if os.name == "nt" + else bool(script_path.stat().st_mode & (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)) + ) + if not is_executable: errors.append( f"Script not executable: {script_path.name}. Run: chmod +x {script_path}" )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@core/framework/skills/validator.py` around lines 142 - 145, The current executability check using os.access(script_path, os.X_OK) should be made platform-aware: on POSIX (os.name != 'nt') inspect the file mode bits via script_path.stat().st_mode and test for any execute bit (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) to enforce strict execute-bit validation, while on Windows keep using os.access(script_path, os.X_OK); update the conditional in the validator (around the block that appends "Script not executable" in core/framework/skills/validator.py) to use the stat-based check for POSIX and fall back to os.access for Windows, leaving the errors.append message unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@core/framework/skills/validator.py`:
- Around line 142-145: The current executability check using
os.access(script_path, os.X_OK) should be made platform-aware: on POSIX (os.name
!= 'nt') inspect the file mode bits via script_path.stat().st_mode and test for
any execute bit (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) to enforce strict
execute-bit validation, while on Windows keep using os.access(script_path,
os.X_OK); update the conditional in the validator (around the block that appends
"Script not executable" in core/framework/skills/validator.py) to use the
stat-based check for POSIX and fall back to os.access for Windows, leaving the
errors.append message unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1669718c-abbd-4050-8888-4d5c3800cdd6
📒 Files selected for processing (1)
core/framework/skills/validator.py
Windows has no POSIX executable bits, so the stat-based check always fails. Skip the check on Windows in the validator, and mark the two related tests as POSIX-only. Unix CI still catches non-executable scripts from Windows contributors. Fixes aden-hive#6893
d9f5ee5 to
571c28b
Compare
…den-hive#6894) Windows has no POSIX executable bits, so the stat-based check always fails. Skip the check on Windows in the validator, and mark the two related tests as POSIX-only. Unix CI still catches non-executable scripts from Windows contributors. Fixes aden-hive#6893
Description
Replace Unix-only permission bit check with
os.access(path, os.X_OK)in skill validator. Fixes Windows CI failure on main.Type of Change
Related Issues
Fixes #6893
Changes Made
stat.S_IXUSR | S_IXGRP | S_IXOTHbit check withos.access(script_path, os.X_OK)invalidator.pyimport statTesting
cd core && pytest tests/test_skill_validator.py)cd core && ruff check .)Checklist
Summary by CodeRabbit