Skip to content

fix: add plugin tests#188

Merged
deacon-mp merged 1 commit intomasterfrom
fix/add-plugin-tests
Mar 18, 2026
Merged

fix: add plugin tests#188
deacon-mp merged 1 commit intomasterfrom
fix/add-plugin-tests

Conversation

@deacon-mp
Copy link
Copy Markdown
Contributor

Add functional and security regression tests

@deacon-mp deacon-mp merged commit 18e24a5 into master Mar 18, 2026
2 checks passed
@deacon-mp deacon-mp deleted the fix/add-plugin-tests branch March 18, 2026 03:04
@deacon-mp deacon-mp requested a review from Copilot March 18, 2026 03:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new functional + security regression test suite for the training plugin to catch syntax issues, validate ability YAML content, and detect insecure patterns in Python sources.

Changes:

  • Add AST-based syntax validation for hook.py and all plugin .py files
  • Add abilities YAML discovery/parsing + basic schema checks
  • Add security pattern scans for verify=False, shell=True, and missing requests timeouts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +68 to +73
"""data/abilities/ directory should exist."""
assert os.path.isdir(os.path.join(PLUGIN_DIR, "data", "abilities"))

def test_abilities_yaml_files_exist(self):
"""There should be at least one YAML ability file."""
assert len(self._yaml_files()) > 0, "No .yml files found in data/abilities/"
Comment on lines +75 to +84
def test_abilities_yaml_parseable(self):
"""Each abilities YAML file should be parseable."""
import yaml
for yf in self._yaml_files():
with open(yf, "r") as fh:
try:
docs = list(yaml.safe_load_all(fh))
except yaml.YAMLError as exc:
rel = os.path.relpath(yf, PLUGIN_DIR)
pytest.fail(f"YAML parse error in {rel}: {exc}")
Tests cover:
- hook.py syntax validation via ast.parse
- Abilities YAML validation (if present)
- Requirements.txt dependency checks (if present)
Comment on lines +169 to +191
pattern = re.compile(r"requests\.(get|post|put|delete|patch|head)\(")
for fpath in self._py_files():
with open(fpath, "r") as fh:
source = fh.read()
for match in pattern.finditer(source):
start = match.start()
depth = 0
end = start
for i in range(start, min(start + 500, len(source))):
if source[i] == "(":
depth += 1
elif source[i] == ")":
depth -= 1
if depth == 0:
end = i
break
call_text = source[start:end]
if "timeout" not in call_text:
line_num = source[:start].count("\n") + 1
rel = os.path.relpath(fpath, PLUGIN_DIR)
pytest.fail(
f"requests call without timeout at {rel}:{line_num}"
)
Comment on lines +25 to +26
with open(hook_path, "r") as fh:
source = fh.read()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants