Implement CoreCLR security properties on reflection info types.
public virtual bool IsSecurityCritical {
get {
- throw new NotImplementedException ();
+ throw new NotSupportedException ();
}
}
public virtual bool IsSecuritySafeCritical {
get {
- throw new NotImplementedException ();
+ throw new NotSupportedException ();
}
}
public virtual bool IsSecurityTransparent {
get {
- throw new NotImplementedException ();
+ throw new NotSupportedException ();
}
}
public virtual bool IsSecurityCritical {
get {
- throw new NotImplementedException ();
+ throw new NotSupportedException ();
}
}
public virtual bool IsSecuritySafeCritical {
get {
- throw new NotImplementedException ();
+ throw new NotSupportedException ();
}
}
public virtual bool IsSecurityTransparent {
get {
- throw new NotImplementedException ();
+ throw new NotSupportedException ();
}
}
if (DeclaringType.ContainsGenericParameters)
throw new InvalidOperationException ("Late bound operations cannot be performed on fields with types for which Type.ContainsGenericParameters is true.");
}
+
+ //seclevel { transparent = 0, safe-critical = 1, critical = 2}
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ public extern int get_core_clr_security_level ();
+
+ public override bool IsSecurityTransparent {
+ get { return get_core_clr_security_level () == 0; }
+ }
+
+ public override bool IsSecurityCritical {
+ get { return get_core_clr_security_level () > 0; }
+ }
+
+ public override bool IsSecuritySafeCritical {
+ get { return get_core_clr_security_level () == 1; }
+ }
}
}
public override IList<CustomAttributeData> GetCustomAttributesData () {
return CustomAttributeData.GetCustomAttributes (this);
}
+
+ //seclevel { transparent = 0, safe-critical = 1, critical = 2}
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ public extern int get_core_clr_security_level ();
+
+ public override bool IsSecurityTransparent {
+ get { return get_core_clr_security_level () == 0; }
+ }
+
+ public override bool IsSecurityCritical {
+ get { return get_core_clr_security_level () > 0; }
+ }
+
+ public override bool IsSecuritySafeCritical {
+ get { return get_core_clr_security_level () == 1; }
+ }
}
ICALL(MFIELD_3, "GetValueInternal", ves_icall_MonoField_GetValueInternal)
ICALL(MFIELD_6, "ResolveType", ves_icall_MonoField_ResolveType)
ICALL(MFIELD_4, "SetValueInternal", ves_icall_MonoField_SetValueInternal)
+ICALL(MFIELD_7, "get_core_clr_security_level", ves_icall_MonoField_get_core_clr_security_level)
ICALL_TYPE(MGENCM, "System.Reflection.MonoGenericCMethod", MGENCM_1)
ICALL(MGENCM_1, "get_ReflectedType", ves_icall_MonoGenericMethod_get_ReflectedType)
ICALL(MMETH_6, "get_IsGenericMethod", ves_icall_MonoMethod_get_IsGenericMethod)
ICALL(MMETH_7, "get_IsGenericMethodDefinition", ves_icall_MonoMethod_get_IsGenericMethodDefinition)
ICALL(MMETH_8, "get_base_method", ves_icall_MonoMethod_get_base_method)
+ICALL(MMETH_10, "get_core_clr_security_level", ves_icall_MonoMethod_get_core_clr_security_level)
ICALL(MMETH_9, "get_name", ves_icall_MonoMethod_get_name)
ICALL_TYPE(MMETHI, "System.Reflection.MonoMethodInfo", MMETHI_4)
return mono_security_core_clr_class_level (klass);
}
+ICALL_EXPORT int
+ves_icall_MonoField_get_core_clr_security_level (MonoReflectionField *this)
+{
+ MonoClassField *field = this->field;
+ return mono_security_core_clr_field_level (field, TRUE);
+}
+
+ICALL_EXPORT int
+ves_icall_MonoMethod_get_core_clr_security_level (MonoReflectionMethod *this)
+{
+ MonoMethod *method = this->method;
+ return mono_security_core_clr_method_level (method, TRUE);
+}
+
static void
fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *aname, MonoAssemblyName *name, const char *absolute, gboolean by_default_version, gboolean default_publickey, gboolean default_token)
{
return mono_security_core_clr_class_level_no_platform_check (class);
}
+/*
+ * mono_security_core_clr_field_level:
+ *
+ * Return the MonoSecurityCoreCLRLevel for the specified field.
+ * If with_class_level is TRUE then the type (class) will also be
+ * checked, otherwise this will only report the information about
+ * the field itself.
+ */
+MonoSecurityCoreCLRLevel
+mono_security_core_clr_field_level (MonoClassField *field, gboolean with_class_level)
+{
+ MonoCustomAttrInfo *cinfo;
+ MonoSecurityCoreCLRLevel level = MONO_SECURITY_CORE_CLR_TRANSPARENT;
+
+ /* if get_reflection_caller returns NULL then we assume the caller has NO privilege */
+ if (!field)
+ return level;
+
+ /* non-platform code is always Transparent - whatever the attributes says */
+ if (!mono_security_core_clr_test && !mono_security_core_clr_is_platform_image (field->parent->image))
+ return level;
+
+ cinfo = mono_custom_attrs_from_field (field->parent, field);
+ if (cinfo) {
+ level = mono_security_core_clr_level_from_cinfo (cinfo, field->parent->image);
+ mono_custom_attrs_free (cinfo);
+ }
+
+ if (with_class_level && level == MONO_SECURITY_CORE_CLR_TRANSPARENT)
+ level = mono_security_core_clr_class_level (field->parent);
+
+ return level;
+}
+
/*
* mono_security_core_clr_method_level:
*
return MONO_SECURITY_CORE_CLR_TRANSPARENT;
}
+MonoSecurityCoreCLRLevel
+mono_security_core_clr_field_level (MonoClassField *field, gboolean with_class_level)
+{
+ return MONO_SECURITY_CORE_CLR_TRANSPARENT;
+}
+
MonoSecurityCoreCLRLevel
mono_security_core_clr_method_level (MonoMethod *method, gboolean with_class_level)
{
extern MonoException* mono_security_core_clr_is_call_allowed (MonoMethod *caller, MonoMethod *callee);
extern MonoSecurityCoreCLRLevel mono_security_core_clr_class_level (MonoClass *klass);
+extern MonoSecurityCoreCLRLevel mono_security_core_clr_field_level (MonoClassField *field, gboolean with_class_level);
extern MonoSecurityCoreCLRLevel mono_security_core_clr_method_level (MonoMethod *method, gboolean with_class_level);
extern gboolean mono_security_core_clr_is_platform_image (MonoImage *image);