diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..6235076 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,45 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added +- CONTRIBUTING.md with contribution guidelines +- CODE_OF_CONDUCT.md following Contributor Covenant +- SECURITY.md with security policy +- This CHANGELOG.md file + +## [0.5.0] - 2023 + +### Added +- I/O Mode: New `cdp.connection` module with WebSocket I/O support +- WebSocket management with async context managers +- JSON-RPC message framing +- Command multiplexing +- Event handling with async iterators +- Comprehensive error handling with typed exceptions + +### Changed +- Enhanced documentation with I/O mode examples +- Updated README with usage for both Sans-I/O and I/O modes + +## [0.4.x and earlier] + +### Features +- Sans-I/O mode with type wrappers for Chrome DevTools Protocol +- Auto-generated Python bindings from CDP specification +- Type hints for all CDP commands, events, and types +- Support for all CDP domains +- Documentation on ReadTheDocs +- Example scripts demonstrating CDP usage + +--- + +For a complete list of changes, see the [commit history](https://github.com/HyperionGray/python-chrome-devtools-protocol/commits/master). + +[Unreleased]: https://github.com/HyperionGray/python-chrome-devtools-protocol/compare/v0.5.0...HEAD +[0.5.0]: https://github.com/HyperionGray/python-chrome-devtools-protocol/releases/tag/v0.5.0 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..7969054 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at the project's +GitHub repository by opening an issue. All complaints will be reviewed and +investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..6ed89a1 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,108 @@ +# Contributing to PyCDP + +Thank you for your interest in contributing to Python Chrome DevTools Protocol (PyCDP)! This document provides guidelines for contributing to the project. + +## Code of Conduct + +By participating in this project, you agree to abide by our Code of Conduct (see [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)). + +## How to Contribute + +### Reporting Bugs + +If you find a bug, please open an issue on GitHub with: +- A clear description of the problem +- Steps to reproduce the issue +- Expected vs. actual behavior +- Your environment (OS, Python version, etc.) + +### Suggesting Enhancements + +Enhancement suggestions are welcome! Please open an issue describing: +- The enhancement you'd like to see +- Why it would be useful +- Any implementation ideas you have + +### Pull Requests + +1. **Fork the repository** and create your branch from `master` +2. **Install development dependencies**: + ```bash + pip install poetry + poetry install + ``` +3. **Make your changes** following the project's coding standards +4. **Run tests** to ensure nothing is broken: + ```bash + poetry run make + ``` +5. **Update documentation** if needed +6. **Commit your changes** with clear, descriptive commit messages +7. **Push to your fork** and submit a pull request + +## Development Setup + +### Prerequisites + +- Python 3.7 or higher +- Poetry for dependency management + +### Installation + +```bash +# Clone the repository +git clone https://github.com/HyperionGray/python-chrome-devtools-protocol.git +cd python-chrome-devtools-protocol + +# Install dependencies +poetry install +``` + +### Running Tests + +```bash +# Run all tests +poetry run make + +# Run specific test suites +poetry run pytest test/ +poetry run pytest generator/ + +# Run type checking +poetry run mypy cdp/ +poetry run mypy generator/ +``` + +### Code Generation + +This project generates Python code from the Chrome DevTools Protocol specification: + +```bash +poetry run python generator/generate.py +``` + +The generated code is checked into version control. If you modify the generator, run it and include the updated generated files in your PR. + +## Coding Standards + +- Follow [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guidelines +- Use type hints for all functions and methods +- Write docstrings for public APIs +- Ensure code passes `mypy` type checking +- Keep code coverage high + +## Project Structure + +- `cdp/` - Generated CDP protocol bindings +- `generator/` - Code generator for CDP bindings +- `test/` - Test suite +- `docs/` - Documentation source files +- `examples/` - Example usage scripts + +## Questions? + +If you have questions about contributing, feel free to open an issue or reach out to the maintainers. + +## License + +By contributing to PyCDP, you agree that your contributions will be licensed under the MIT License. diff --git a/LICENSE.md b/LICENSE.md new file mode 120000 index 0000000..7a694c9 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1 @@ +LICENSE \ No newline at end of file diff --git a/README.md b/README.md index 70504e3..7f0bd44 100644 --- a/README.md +++ b/README.md @@ -79,10 +79,6 @@ See the [examples directory](examples/) for more usage patterns. For users who prefer to manage their own I/O: -## Sans-I/O Mode (Original) - -For users who prefer to manage their own I/O: - ```python from cdp import page @@ -92,4 +88,41 @@ assert repr(frame_id) == "FrameId('my id')" For more information, see the [complete documentation](https://py-cdp.readthedocs.io). +## API Reference + +The library provides Python wrappers for all Chrome DevTools Protocol domains: + +- **Page**: Page control (navigation, screenshots, etc.) +- **DOM**: DOM inspection and manipulation +- **Network**: Network monitoring and interception +- **Runtime**: JavaScript execution and evaluation +- **Debugger**: JavaScript debugging +- **Performance**: Performance metrics and profiling +- **Security**: Security-related information +- And many more... + +For complete API documentation, visit [py-cdp.readthedocs.io](https://py-cdp.readthedocs.io). + +### Type System + +All CDP types, commands, and events are fully typed with Python type hints, providing: +- IDE autocomplete support +- Static type checking with mypy +- Clear API contracts +- Inline documentation + +## Contributing + +We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on: +- How to report bugs and request features +- Development setup and workflow +- Coding standards and testing requirements +- Pull request process + +For questions or discussions, feel free to open an issue on GitHub. + +## License + +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. + define hyperion gray diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..b3d11b0 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,77 @@ +# Security Policy + +## Supported Versions + +We release patches for security vulnerabilities for the following versions: + +| Version | Supported | +| ------- | ------------------ | +| 0.5.x | :white_check_mark: | +| < 0.5 | :x: | + +## Reporting a Vulnerability + +The PyCDP team takes security bugs seriously. We appreciate your efforts to responsibly disclose your findings. + +### How to Report + +To report a security vulnerability, please **do not** open a public GitHub issue. Instead: + +1. **Email**: Send details to the project maintainers via GitHub by opening a private security advisory at: + https://github.com/HyperionGray/python-chrome-devtools-protocol/security/advisories/new + +2. **Include the following information**: + - Description of the vulnerability + - Steps to reproduce the issue + - Potential impact + - Suggested fix (if you have one) + - Your contact information + +### What to Expect + +- **Acknowledgment**: We will acknowledge receipt of your vulnerability report within 48 hours +- **Communication**: We will keep you informed about the progress of fixing the vulnerability +- **Timeline**: We aim to release a fix within 30 days of receiving the report +- **Credit**: We will credit you for the discovery in the release notes (unless you prefer to remain anonymous) + +## Security Best Practices for Users + +When using PyCDP in your projects: + +1. **Keep Updated**: Always use the latest version to benefit from security patches +2. **Validate Input**: Sanitize and validate any data sent to the Chrome DevTools Protocol +3. **Network Security**: When connecting to Chrome instances, use secure connections where possible +4. **Least Privilege**: Run Chrome with minimal privileges necessary +5. **Review Dependencies**: Keep all dependencies up to date + +## Known Security Considerations + +### WebSocket Connections + +PyCDP's I/O mode uses WebSocket connections to communicate with Chrome instances. Be aware: + +- **Authentication**: Chrome DevTools Protocol endpoints typically don't have authentication. Ensure your Chrome instance is not exposed to untrusted networks. +- **Data Exposure**: CDP can execute arbitrary JavaScript and access all page data. Only connect to trusted Chrome instances. +- **Network Security**: Use `ws://localhost` for local development. In production, consider additional network security measures. + +### Code Execution + +The Chrome DevTools Protocol allows arbitrary JavaScript execution in the browser. When using PyCDP: + +- Never execute untrusted code through CDP commands +- Validate and sanitize any dynamic content before execution +- Be cautious when using CDP in multi-tenant environments + +## Disclosure Policy + +When we receive a security bug report, we will: + +1. Confirm the problem and determine affected versions +2. Audit code to find similar problems +3. Prepare fixes for all supported versions +4. Release patches as soon as possible +5. Credit the reporter in the release notes + +## Comments on This Policy + +If you have suggestions on how this process could be improved, please open an issue or pull request.