-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Copilot/learn upgrade save test run develop repeat #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
5hy7xz92nd-oss
wants to merge
2
commits into
bikini:main
Choose a base branch
from
5hy7xz92nd-oss:copilot/learn-upgrade-save-test-run-develop-repeat
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file added
BIN
+14 KB
curl-smtp-expn-recipient-crlf-injection/__pycache__/run_demo.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+9.34 KB
discourse-scoped-api-key-preauth-bypass/__pycache__/poc.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+9.24 KB
ffmpeg-rasc-dlta-calc-poc/poc/__pycache__/rasc_dlta_os_helper.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+6.48 KB
firefox-152.0.5-backup-nss-rce-poc/__pycache__/build_backup.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+8.53 KB
libssh2-publickey-list-calc-poc/__pycache__/replay-calc-poc.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+9.48 KB
libssh2-publickey-list-calc-poc/poc/__pycache__/live_publickey_server.cpython-312.pyc
Binary file not shown.
Binary file added
BIN
+16.9 KB
nghttp2-nghttpx-upgrade-queue-poison-poc/__pycache__/poc.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import unittest | ||
| from pathlib import Path | ||
|
|
||
| import validate_pocs | ||
|
|
||
|
|
||
| class ValidatePocsTest(unittest.TestCase): | ||
| def setUp(self) -> None: | ||
| self.repo_root = Path(__file__).resolve().parents[1] | ||
|
|
||
| def test_discovery_finds_expected_targets(self) -> None: | ||
| python_targets = validate_pocs.discover_python_targets(self.repo_root) | ||
| package_targets = validate_pocs.discover_package_targets(self.repo_root) | ||
|
|
||
| self.assertTrue(any(path.name == "run_demo.py" for path in python_targets)) | ||
| self.assertTrue(any(path.name == "package.json" for path in package_targets)) | ||
| self.assertGreater(len(python_targets), 20) | ||
| self.assertGreater(len(package_targets), 0) | ||
|
|
||
| def test_validation_succeeds(self) -> None: | ||
| result = validate_pocs.validate_repo(self.repo_root) | ||
| self.assertEqual(result["errors"], []) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| #!/usr/bin/env python3 | ||
| """Validate the repository's PoC entrypoints and manifests.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import argparse | ||
| import json | ||
| import py_compile | ||
| import sys | ||
| from pathlib import Path | ||
| from typing import List, Dict, Tuple | ||
|
5hy7xz92nd-oss marked this conversation as resolved.
|
||
|
|
||
|
|
||
| EXCLUDED_DIRS = {".git", "__pycache__"} | ||
|
|
||
|
|
||
| def discover_python_targets(root: Path) -> List[Path]: | ||
| return sorted( | ||
| path | ||
| for path in root.rglob("*.py") | ||
| if not any(part in EXCLUDED_DIRS for part in path.parts) | ||
| ) | ||
|
|
||
|
|
||
| def discover_package_targets(root: Path) -> List[Path]: | ||
| return sorted( | ||
| path | ||
| for path in root.rglob("package.json") | ||
| if not any(part in EXCLUDED_DIRS for part in path.parts) | ||
| ) | ||
|
|
||
|
|
||
| def validate_repo(root: Path) -> Dict[str, object]: | ||
| python_targets = discover_python_targets(root) | ||
| package_targets = discover_package_targets(root) | ||
| errors: List[str] = [] | ||
|
|
||
| for path in python_targets: | ||
| try: | ||
| py_compile.compile(str(path), doraise=True) | ||
| except py_compile.PyCompileError as exc: # pragma: no cover - exercised in tests when broken code exists | ||
| errors.append(f"{path.relative_to(root)}: {exc}") | ||
|
|
||
| for path in package_targets: | ||
| try: | ||
| data = json.loads(path.read_text(encoding="utf-8")) | ||
| except json.JSONDecodeError as exc: | ||
| errors.append(f"{path.relative_to(root)}: invalid JSON ({exc})") | ||
| continue | ||
|
|
||
| scripts = data.get("scripts") | ||
| if isinstance(scripts, dict) and "poc" in scripts: | ||
| if not isinstance(scripts["poc"], str) or not scripts["poc"].strip(): | ||
| errors.append(f"{path.relative_to(root)}: scripts.poc must be a non-empty string") | ||
|
|
||
| return { | ||
| "root": str(root), | ||
| "python_files": len(python_targets), | ||
| "package_json_files": len(package_targets), | ||
| "errors": errors, | ||
| } | ||
|
|
||
|
|
||
| def main(argv: List[str] | None = None) -> int: | ||
| parser = argparse.ArgumentParser(description=__doc__) | ||
| parser.add_argument("--root", type=Path, default=Path(__file__).resolve().parent) | ||
| args = parser.parse_args(argv) | ||
|
|
||
| result = validate_repo(args.root.resolve()) | ||
| for error in result["errors"]: | ||
| print(error, file=sys.stderr) | ||
|
|
||
| print( | ||
| f"validated {result['python_files']} Python files and {result['package_json_files']} package manifests" | ||
| ) | ||
| if result["errors"]: | ||
| print("validation failed", file=sys.stderr) | ||
| return 1 | ||
| print("validation succeeded") | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| raise SystemExit(main()) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.