-
Notifications
You must be signed in to change notification settings - Fork 1
Fix infinite loop when parsing MagicMock objects #32
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
base: main
Are you sure you want to change the base?
Conversation
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v4...v6) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]>
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
recheck |
Debian Buster reached end-of-life and its repositories are no longer available at deb.debian.org. This updates the CI to use archive.debian.org for the Python 2.7 build which requires the Buster image.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #32 +/- ##
==========================================
+ Coverage 89.68% 89.82% +0.13%
==========================================
Files 6 6
Lines 863 865 +2
==========================================
+ Hits 774 777 +3
+ Misses 89 88 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ons/checkout-6 Bump actions/checkout from 4 to 6
Add dependabot[bot] to the allowlist so PRs that include dependabot commits don't fail the CLA check.
…sue-for-magicmock-objects
…-issue-for-magicmock-objects
Fix infinite loop when parsing MagicMock objects
Problem
When
llsd.parse()receives aMagicMockobject (or similar mock objects), it enters an infinite loop that consumes all available memory until the process is killed with OOM.This commonly occurs when tests incorrectly mock
requests.Responsewithout setting the.contentattribute - the defaultMagicMockis passed tollsd.parse()instead of bytes.Root Cause
In
LLSDBaseParser._reset(), the code checkedsomething.seekable()to determine if the input was a seekable stream. For aMagicMock:mock.seekable()returns anotherMagicMock(which is truthy)MagicMockobjects recursivelySolution
Modified
_reset()to validate input types properly:somethingis anio.IOBaseinstance (proper stream type)LLSDParseErrorfor invalid input typesChanges
llsd/base.py: Added proper input validation in_reset()methodtests/llsd_test.py: AddedInvalidInputTypestest class with tests forMagicMock,str,None, andintinputsTesting
All 96 tests pass.
Before this fix:
llsd.parse(MagicMock()) # Hangs forever, consumes all memory
After this fix:
llsd.parse(MagicMock())
Raises: LLSDParseError: Cannot parse LLSD from MagicMock. Expected bytes or a file-like object (io.IOBase subclass).