Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

Commented Issue: Restricted access to non-public accessors of public properties is not enforced [71]

0
0
Hi, I'm having an issue with exposed host object which has a property with public getter and private setter.
For example, I can put a script like "SomeObject.Name = ...". Is there a way to prevent this?

```
public class SomeObject
{
private string _name;
public string Name
{
get { return this._name; }
private set { this._name = value; }
}
}
```

And also, If I try to expose an object instance as interface, I still be able to access to the object's members.
For example,
```
public class SomeObject : IInterface
{
private string _name;
public string Name
{
get { return this.Name; }
private set { this._name = value; }
}

public string ToSomeString()
{
return this._name;
}
}

public interface IInterface
{
string ToSomeString();
}
```
```
IInterface obj = new SomeObject();
Engine.AddHostObject("O", obj);
```

I can put script like O.Name = “A”.

Thank you
Comments: Hi again, ​ >I was thinking that I can introduce a proxy pattern to expose an interface. It also can limit the access of non-public properties. ​ Yes, that's certainly an option, but we'll fix the non-public getter/setter issue anyway :) ​ >Microsoft.ClearScript.Util.AssemblyHelpers is trying to load every assembly at the first launching if "AssemblyTable.bin" doesn't exist. ​ Yes, but it should only do that if you're loading or exposing one or more assemblies by name. There are several ways to do that in ClearScript, but you can always avoid it by specifying preloaded assemblies instead. In fact, that's our recommendation for web applications. Thanks again, and good luck!

Viewing all articles
Browse latest Browse all 2297