winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.77k stars 189 forks source link

sim permission model is broken when using sim.IResource mechanism #6548

Open ekeren opened 1 month ago

ekeren commented 1 month ago

I tried this:

The sim permission model is broken for classes using sim.IResource, it only gives permission for the call method

bring cloud;

let c = new cloud.Counter();
class ExampleOfPermissions {
  extern "./some.js" 
  pub static inflight inc(c: cloud.Counter);
}

new cloud.Function(inflight () => {
  c.peek(); // this will give permission to the call functions (which will allow also the inc functionality)
  ExampleOfPermissions.inc(c);
});
exports.inc = async (c) => {
  await c.inc(1);
}

This happened:

It worked

I expected this:

To tell me that I didn't grant inc permissions to the resource

Is there a workaround?

No response

Anything else?

No response

Wing Version

0.74.8

Node.js Version

No response

Platform(s)

No response

Community Notes