Skip to content

Add built-in methods to bytes type#2341

Open
nullmonk wants to merge 1 commit into
mainfrom
add-bytes-methods-15367603936580828145
Open

Add built-in methods to bytes type#2341
nullmonk wants to merge 1 commit into
mainfrom
add-bytes-methods-15367603936580828145

Conversation

@nullmonk

Copy link
Copy Markdown
Collaborator

Implemented a full set of Python-like built-in methods for the bytes type in eldritch-core. This includes:

  • split, rsplit, splitlines
  • strip, lstrip, rstrip
  • startswith, endswith
  • removeprefix, removesuffix
  • find, index, rfind, rindex
  • count, replace, join, partition, rpartition

All methods were implemented in implants/lib/eldritch/eldritch-core/src/interpreter/methods/bytes.rs and registered in mod.rs. A new test file implants/lib/eldritch/eldritch-core/tests/bytes_methods.rs was added to verify the functionality and ensure no regressions or panics on edge cases.


PR created automatically by Jules for task 15367603936580828145 started by @nullmonk

- Added split, splitlines, rsplit, strip, lstrip, rstrip,
  startswith, endswith, removeprefix, removesuffix,
  find, index, rfind, rindex, count, replace, join,
  partition, and rpartition to bytes type.
- Added comprehensive tests in tests/bytes_methods.rs.
- Ensured methods handle edge cases safely (empty pattern,
  pattern longer than source).

Co-authored-by: nullmonk <15130760+nullmonk@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
3198 3198 0 0 0 0 1ms

Previous Results

Build 🏗️ Result 🧪 Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Other ❓ Flaky 🍂 Duration ⏱️
#2308 3198 3198 0 0 0 0 1m 12s

Insights

Average Tests per Run Total Flaky Tests Total Failed Slowest Test (p95)
3198 0 0 6m 48s

Test Changes

0 test added, 0 removed

Slowest Tests

Test 📝 Results 📊 Duration (avg) ⏱️ Duration (p95) ⏱️
eldritch-libfile: std::list_recent_impl::tests::test_list_recent_default_args 3 4m 45s 6m 48s
eldritch-libfile: std::list_recent_impl::tests::test_list_recent_default_args 3 4m 45s 6m 48s
eldritch-libfile: std::list_recent_impl::tests::test_list_recent_default_args 3 4m 45s 6m 48s
TestPortalDowngrade 1 6.0s 6.0s
TestDockerExecutor_Build_ContextCancellation 1 5.6s 5.6s
eldritch-libsys: std::dll_inject_impl::tests::test_dll_inject_simple 1 5.2s 5.2s
TestInteractiveShell 1 5.0s 5.0s
TestOtherStreamOutput 1 5.0s 5.0s
TestPTYOutputOrdering 1 3.3s 3.3s
TestPTYOutputDelivery 1 3.2s 3.2s

🎉 No failed tests in this run. | 🍂 No flaky tests in this run.

Github Test Reporter by CTRF 💚

@KCarretto KCarretto left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do these methods need to be reimplemented for bytes? Most of them seem to rely on the bytes data being strings or the parameters being strings or some sort of casting. Can't we just str(mybytes).split("\n") in that case for example? If we absolutely must implement this for bytes, we should create an abstraction so that we don't need to maintain the code in two separate places.

@hulto

hulto commented May 1, 2026

Copy link
Copy Markdown
Collaborator

I think we should add bytes native ways to do these. I ran into this during NCCDC and had to do this weird workaround since I wanted to split on a byte not a string or char.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants