Skills/Python: harden script edge cases and add regression tests (#24277)

* Skill creator: skip self-including .skill output

* Skill creator tests: cover output-dir-inside-skill case

* Skill validator: parse frontmatter robustly across newlines

* Skill validator tests: add CRLF and malformed frontmatter coverage

* Model usage: require positive --days value

* Model usage tests: cover --days validation and filtering

* Nano banana: close input image handles after loading

* Skill validator: keep type hints compatible with older python

* Changelog: credit @vincentkoc for Python skills hardening
This commit is contained in:
Vincent Koc
2026-02-23 02:34:23 -05:00
committed by GitHub
parent 36400df086
commit c8a62e1cea
8 changed files with 137 additions and 11 deletions

View File

@@ -135,6 +135,20 @@ class TestPackageSkillSecurity(TestCase):
names = set(archive.namelist())
self.assertIn("nested-skill/lib/helpers/util.py", names)
def test_skips_output_archive_when_output_dir_is_skill_dir(self):
skill_dir = self.create_skill("self-output-skill")
result = package_skill(str(skill_dir), str(skill_dir))
self.assertIsNotNone(result)
skill_file = skill_dir / "self-output-skill.skill"
self.assertTrue(skill_file.exists())
with zipfile.ZipFile(skill_file, "r") as archive:
names = set(archive.namelist())
self.assertIn("self-output-skill/SKILL.md", names)
self.assertIn("self-output-skill/script.py", names)
self.assertNotIn("self-output-skill/self-output-skill.skill", names)
if __name__ == "__main__":
main()