rspec/rules/S4211/csharp/rule.adoc

68 lines
1.7 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
Transparency attributes, ``++SecurityCriticalAttribute++`` and ``++SecuritySafeCriticalAttribute++`` are used to identify code that performs security-critical operations. The second one indicates that it is safe to call this code from transparent, while the first one does not. Since the transparency attributes of code elements with larger scope take precedence over transparency attributes of code elements that are contained in the first element a class, for instance, with a ``++SecurityCriticalAttribute++`` can not contain a method with a ``++SecuritySafeCriticalAttribute++``.
This rule raises an issue when a member is marked with a ``++System.Security++`` security attribute that has a different transparency than the security attribute of a container of the member.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,csharp]
2021-04-28 16:49:39 +02:00
----
using System;
using System.Security;
namespace MyLibrary
{
[SecurityCritical]
public class Foo
{
[SecuritySafeCritical] // Noncompliant
public void Bar()
{
}
}
}
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,csharp]
2021-04-28 16:49:39 +02:00
----
using System;
using System.Security;
namespace MyLibrary
{
[SecurityCritical]
public class Foo
{
public void Bar()
{
}
}
}
----
== Resources
2021-04-28 16:49:39 +02:00
* https://owasp.org/Top10/A05_2021-Security_Misconfiguration/[OWASP Top 10 2021 Category A5] - Security Misconfiguration
* https://owasp.org/www-project-top-ten/2017/A6_2017-Security_Misconfiguration[OWASP Top 10 2017 Category A6] - Security Misconfiguration
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
include::highlighting.adoc[]
endif::env-github,rspecator-view[]