Skip to content

feat(backend): implement binary download with dynamic sensor UUID inj…#124

Open
soorya38 wants to merge 3 commits into
honeynet:mainfrom
soorya38:main
Open

feat(backend): implement binary download with dynamic sensor UUID inj…#124
soorya38 wants to merge 3 commits into
honeynet:mainfrom
soorya38:main

Conversation

@soorya38
Copy link
Copy Markdown

@soorya38 soorya38 commented Jan 19, 2026

This PR introduces a new endpoint that serves sensor binaries with a unique UUID injected at download time. Each downloaded sensor binary is modified on the fly to embed a freshly generated UUID, ensuring every sensor instance has a distinct identity for tracking and management.


Related issue: #95

Changes

  • backend/utils.go

    • Added IndexReplace helper function to efficiently replace byte sequences within binary data.
  • backend/handlers.go

    • Implemented downloadBinaryHandler, which:

      • Locates the sensor binary based on os and arch parameters
        (expects path format: bin/sensor-{os}-{arch})
      • Generates a new random UUID per request
      • Replaces the placeholder UUID
        (00000000-0000-0000-0000-000000000000) inside the binary
      • Serves the modified binary with appropriate HTTP headers
  • backend/routes.go

    • Registered a new route:
      GET /download/:os/:arch
  • backend/server_test.go

    • Added TestDownloadBinaryHandler to validate:

      • Placeholder UUID is correctly replaced
      • Binary size remains unchanged after replacement
      • Correct response headers are set

Verification

  • Added unit test TestDownloadBinaryHandler that:

    • Mocks a binary file
    • Asserts correct UUID replacement
    • Ensures file integrity is preserved
  • Ran:

    go test -v ./backend/...
  • All tests passed

…ection

- Implemented [downloadBinaryHandler](cci:1://file:///Users/sooryaakilesh/test/open-source-contributions/ochi/backend/handlers.go:347:0-391:1) to serve sensor binaries.
- Added [IndexReplace](cci:1://file:///Users/sooryaakilesh/test/open-source-contributions/ochi/backend/utils.go:18:0-26:1) utility for efficient byte slice substitution.
- Injects a unique UUID into the binary by replacing the placeholder  on download.
- Registered  endpoint.
- Added unit tests to verify UUID replacement and content integrity. Related issue: honeynet#95
Comment thread backend/handlers.go Outdated
Comment thread backend/handlers.go Outdated
Comment thread backend/server_test.go Outdated
Comment thread backend/server_test.go Outdated
@soorya38 soorya38 requested a review from glaslos January 20, 2026 03:28
Signed-off-by: soorya38 <csasoorya@gmail.com>
@soorya38
Copy link
Copy Markdown
Author

@glaslos can you re-review ?

Comment thread backend/server_test.go Outdated
Comment thread backend/handlers.go Outdated
Comment thread backend/handlers.go Outdated
Comment thread backend/handlers.go
Signed-off-by: soorya38 <csasoorya@gmail.com>
@soorya38
Copy link
Copy Markdown
Author

@glaslos can you re-review ?

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.

2 participants