Upgrade API Documentation to be Python 3 Compatible
Proposed change
This PR updates the API document API.md to transition all Python examples from Python 2 to Python 3.10+. The current documentation contains deprecated syntax including print ..., the u' string prefix, and missing byte decoding, which leads to errors in Python 3.
Proposed changes are as follows:
- Byte-to-String Handling: Updated all
r.contentexamples to include.decode('utf-8')to prevent TypeError in Python 3. - SSL/TLS Configuration: Added explicit
verify=Falseto all example requests to prevent the errorcertificate verify failed: self-signed certificatesince by default Python 3 enforces certificate verification and the API uses a self-signed certificate. - Syntax Change: Changed
print ...toprint(...)and removed Python 2 specific unicode prefixu'.
Type of change
- [ ] New core framework functionality
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] Code refactoring without any functionality changes
- [ ] New or existing module/payload change
- [x] Documentation/localization improvement
- [ ] Test coverage improvement
- [ ] Dependency upgrade
- [ ] Other improvement (best practice, cleanup, optimization, etc)
Checklist
- [x] I've followed the contributing guidelines
- [ ] I've run
make pre-commit, it didn't generate any changes - [ ] I've run
make test, all tests passed locally
No actionable comments were generated in the recent review. ๐
โน๏ธ Recent review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
๐ฅ Commits
Reviewing files that changed from the base of the PR and between 7e8d1dc0b73cd8cee9fcc5eb4caf47d2cc3d73ed and ec34e3f6958163ec804a11627c1ae1e2af3bac19.
๐ Files selected for processing (1)
docs/API.md
Summary by CodeRabbit
- Documentation
- Updated API docs: examples now show disabling SSL verification for local self-signed certificates (with a clear warning not to use this against external/production hosts) and demonstrate decoded/JSON response handling in example requests and outputs.
Walkthrough
Adds a note about disabling SSL warnings for local Nettacker API with self-signed certificates and updates HTTP examples to use verify=False and to parse responses with r.json() or r.text instead of raw r.content.
Changes
| Cohort / File(s) | Summary |
|---|---|
API Documentation Examples docs/API.md |
Added a note explaining disable_warnings(InsecureRequestWarning) and that verify=False is for local/self-signed certs only. Updated HTTP examples to include verify=False. Replaced r.content-based outputs with r.json() or r.text across examples (new scan, session flows, results retrieval, hosts listing, HTML/JSON outputs). Status code checks and overall flows preserved. |
Estimated code review effort
๐ฏ 3 (Moderate) | โฑ๏ธ ~20 minutes
๐ฅ Pre-merge checks | โ 3
โ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | โ Passed | The title accurately reflects the main change: updating API documentation for Python 3 compatibility, which aligns with the described changes to syntax, byte handling, and SSL verification. |
| Description check | โ Passed | The description is directly related to the changeset, providing clear details about Python 2 to Python 3 migration including byte decoding, SSL verification, and syntax updates. |
| Docstring Coverage | โ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
โ๏ธ Tip: You can configure your own custom pre-merge checks in the settings.
โจ Finishing Touches
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
@arkid15r and @securestep9 - can you review? Thanks.