Skip to content

Gendarme.Rules.Security.Cas.SecureGetObjectDataOverridesRule(2.10)

Sebastien Pouliot edited this page Feb 9, 2011 · 3 revisions

SecureGetObjectDataOverridesRule

Assembly: Gendarme.Rules.Security.Cas
Version: 2.10

Description

This rule fires if a type implements System.Runtime.Serialization.ISerializable but the GetObjectData method is not protected with a Demand or LinkDemand for SerializationFormatter.

Examples

Bad example:

public class Bad : ISerializable {
    public override void GetObjectData (SerializationInfo info, StreamingContext context)
    {
    }
}

Good example:

public class Good : ISerializable {
    [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)]
    public override void GetObjectData (SerializationInfo info, StreamingContext context)
    {
    }
}

Notes

  • Before Gendarme 2.2 this rule was part of Gendarme.Rules.Security.
Clone this wiki locally