07.11.2014 Views

Enterprise Library Test Guide - Willy .Net

Enterprise Library Test Guide - Willy .Net

Enterprise Library Test Guide - Willy .Net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Test</strong>ing for Security Best Practices 145<br />

Check<br />

Yes<br />

Yes<br />

Yes<br />

Yes<br />

Description<br />

Implement declarative checks for virtual internal methods.<br />

Derived classes can override virtual internal methods. This can change the behavior of<br />

the application block. (Public types do not have internal virtual members so they do not<br />

need these checks.)<br />

Fields should be private. When necessary, expose field values with read-write or readonly<br />

public properties. The following example shows how to use the read-only property<br />

to prevent an attacker from changing the tokens that make up a database connection<br />

string.<br />

public abstract class Database : IInstrumentationEventProvider<br />

{<br />

private static readonly string VALID_USER_ID_TOKENS =<br />

Resources.UserName;<br />

private static readonly string VALID_PASSWORD_TOKENS =<br />

Resources.Password;<br />

(Code access security checks do not apply to fields.)<br />

Use read-only properties where possible.<br />

Review how the application block uses event handlers.<br />

Cryptography Checklist<br />

Table 34 lists the cryptography recommendations.<br />

Table 34: Cryptography Checklist<br />

Check<br />

Yes<br />

Description<br />

Use the .NET Framework-provided cryptography providers instead of custom providers.<br />

The Cryptography Application Block wraps standard .NET providers. Customers can<br />

choose to use a custom provider but this is not a recommended practice.<br />

continued

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!