-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create rule S6639: Memory allocations should not be vulnerable to Den…
…ial of Service attacks (#3153)
- Loading branch information
1 parent
c40e726
commit 7dd1082
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
include::../common/description.adoc[] | ||
|
||
== Why is this an issue? | ||
|
||
include::../common/rationale.adoc[] | ||
|
||
=== What is the potential impact? | ||
|
||
include::../common/impact.adoc[] | ||
|
||
== How to fix it | ||
|
||
=== Code examples | ||
|
||
==== Noncompliant code example | ||
|
||
[source,csharp,diff-id=1,diff-type=noncompliant] | ||
---- | ||
def example(): | ||
limit = int(request.args.get('limit')) | ||
data = '#' * limit # Noncompliant | ||
---- | ||
|
||
==== Compliant solution | ||
|
||
[source,csharp,diff-id=1,diff-type=compliant] | ||
---- | ||
def example(): | ||
limit = int(request.args.get('limit')) | ||
restricted_limit = min(10, limit) | ||
data = '#' * restricted_limit | ||
---- | ||
|
||
=== How does this work? | ||
|
||
include::../common/fix/upper-limit.adoc[] | ||
|
||
Here, the example compliant code uses the `min` function to enforce a | ||
reasonable upper bound to the allocation size. In that case, no more than 10 | ||
bytes can be allocated at a time. | ||
|
||
include::../common/fix/environment-hardening.adoc[] | ||
|
||
== Resources | ||
=== Documentation | ||
|
||
include::../common/resources/documentation.adoc[] | ||
|
||
=== Standards | ||
|
||
include::../common/resources/standards.adoc[] | ||
|
||
|
||
ifdef::env-github,rspecator-view[] | ||
|
||
''' | ||
== Implementation Specification | ||
(visible only on this page) | ||
|
||
include::../common/message.adoc[] | ||
|
||
''' |