Transfer actual code with Protobuffers

25 views
Skip to first unread message

Alex TS

unread,
May 30, 2017, 2:18:30 PM5/30/17
to Protocol Buffers
Hey everyone,
I'm quite new to Protocol Buffers and don't really have a background on the theme, so pardon me if this sounds absurd or if this is not the right forum.

With that out of the way, if I'd like to transfer say, a method, from the server to execute on the client. Is that possible at all using the `bytes` type or something similar?

The issue being that in an ideal world I'd like to run a method on the server with the arguments provided by the client and get it back resolved for injection.

As a silly example, something like this, in JS:

ServiceX
const privateMethod = (x) => x * x
const publicMethod = (elementId, y) => document.getElementById(elementId).innerHTML(privateMethod(y))


ClientY
server.publicMethod("root", 3)


Is it possible to transfer the `publicMethod` itself from the server for a later execution triggered by the client and having the side effects also on the client? My idea here being basically to be able to create an application in one service in an isolated way and inject it on another service that doesn't have to know any details of its implementation details.

Thanks for your help!

Marc Gravell

unread,
May 30, 2017, 2:34:10 PM5/30/17
to Alex TS, Protocol Buffers
That's not something that protobuf targets. If you have a syntax that allows you to convey an expression as a string or similar, then by all means do that - but protobuf will just see it as an opaque string. Note that there are usually a range of concerns when transferring executable code (of any kind) - less of a concern for server-to-client, but not removed. Think "XSS", for a trivial example.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscribe@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Ashraful Rajon

unread,
May 31, 2017, 1:55:46 AM5/31/17
to Protocol Buffers

Alex TS

unread,
May 31, 2017, 2:14:20 AM5/31/17
to Protocol Buffers, alexandr...@gmail.com
Thanks for the quick reply, Marc.

Yeah, I thought of the issues regarding security but was thinking of experimenting with it since it was really a server-to-client only use-case.

I'll think about what to do next then.


On Tuesday, May 30, 2017 at 8:34:10 PM UTC+2, Marc Gravell wrote:
That's not something that protobuf targets. If you have a syntax that allows you to convey an expression as a string or similar, then by all means do that - but protobuf will just see it as an opaque string. Note that there are usually a range of concerns when transferring executable code (of any kind) - less of a concern for server-to-client, but not removed. Think "XSS", for a trivial example.
On 30 May 2017 7:18 p.m., "Alex TS" <alexandr...@gmail.com> wrote:
Hey everyone,
I'm quite new to Protocol Buffers and don't really have a background on the theme, so pardon me if this sounds absurd or if this is not the right forum.

With that out of the way, if I'd like to transfer say, a method, from the server to execute on the client. Is that possible at all using the `bytes` type or something similar?

The issue being that in an ideal world I'd like to run a method on the server with the arguments provided by the client and get it back resolved for injection.

As a silly example, something like this, in JS:

ServiceX
const privateMethod = (x) => x * x
const publicMethod = (elementId, y) => document.getElementById(elementId).innerHTML(privateMethod(y))


ClientY
server.publicMethod("root", 3)


Is it possible to transfer the `publicMethod` itself from the server for a later execution triggered by the client and having the side effects also on the client? My idea here being basically to be able to create an application in one service in an isolated way and inject it on another service that doesn't have to know any details of its implementation details.

Thanks for your help!

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages