Skip to content

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

Sebastien Pouliot edited this page Mar 2, 2011 · 1 revision

SecureGetObjectDataOverridesRule

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

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.

Source code

You can browse the latest source code of this rule on github.com

Clone this wiki locally