chore: update Python3 bindings to work with upstream libinjection v4.0.0 API#7
Open
chore: update Python3 bindings to work with upstream libinjection v4.0.0 API#7
Conversation
Co-authored-by: fzipi <3012076+fzipi@users.noreply.github.com>
… compatibility Co-authored-by: fzipi <3012076+fzipi@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update the module to work with libinjection
Update Python3 bindings to work with upstream libinjection v4.0.0 API
Mar 11, 2026
fzipi
approved these changes
Mar 11, 2026
There was a problem hiding this comment.
Pull request overview
This PR updates the project’s Python 3 SWIG bindings and build tooling to work against upstream libinjection v4.0.0, and adds README build/usage instructions.
Changes:
- Adjusts packaging/build so the compiled extension is placed under the
libinjectionpackage and definesLIBINJECTION_VERSIONduring compilation. - Updates the SWIG interface for Python 3 string handling, exposes XSS APIs, and adds typemaps for correct length handling and fingerprint output.
- Updates Makefile/README build + test workflows (Python 3, SWIG 4.x, pytest).
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
setup.py |
Reads upstream version for LIBINJECTION_VERSION macro and renames the extension into the package namespace. |
libinjection/libinjection.i |
Python 3 C-API fixes, new includes, typemap updates, and exposes XSS-related APIs. |
libinjection/__init__.py |
Switches to explicit relative import for Python 3 package semantics. |
README.md |
Adds build instructions and usage examples (SQLi + XSS) and pytest guidance. |
Makefile |
Updates build/test commands for Python 3, SWIG 4.x, and pytest; updates upstream copy targets. |
.gitignore |
Ignores generated/copied artifacts like words.py and libinjection_error.h. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Collaborator
|
@copilot apply changes based on the comments in this thread |
…cture, and add API tests Co-authored-by: fzipi <3012076+fzipi@users.noreply.github.com>
Author
Applied all review feedback in commit
All 14 tests pass. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
libinjection/__init__.py- Python 2 implicit import to Python 3 explicit relative importlibinjection/libinjection.i:#include <string.h>to preamblePyUnicode_AsUTF8AndSize()- clear exception on NULLPy_BuildValue("s#", ...)toy#to avoid crash on non-UTF-8 bytes (e.g. 0xA0)arglistbeforePyObject_CallObject%apply (char *STRING, ...)with custom typemaps accepting bothstr(UTF-8) andbytes(passthrough)-o libinjection/libinjection_wrap.c -outdir libinjectionto SWIG commandsetup.py- dynamicLIBINJECTION_VERSIONdetection +encoding="utf-8"Makefile:libinjection_xss.h,libinjection_html5.h)-oand-outdiroutput flagspython3 -m pytest test_driver.py -v(nocd /tmp)pytest.py→example_sqli.pyto remove pytest module shadowingREADME.md- SWIG command with-o/-outdir, fix testing instructionstest_driver.py:upstream/tests/print_tokento not strip trailing spaces (needed for empty-value tokens)json2python.py- decode keyword bytes to str (latin-1) in lookup callbacktest_api.py- API tests for SQLi tuple return, XSS detection, stateful API, versionOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.