Skip to content

DART-262 Modify rule S2245: Add Dart language #4987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions rules/S2245/dart/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"securityStandards": {
"CWE": [
326,
330,
338,
1241
],
"OWASP": [
"A3"
],
"OWASP Mobile": [
"M5"
],
"OWASP Mobile Top 10 2024": [
"M10"
],
"MASVS": [
"MSTG-CRYPTO-6"
],
"OWASP Top 10 2021": [
"A2"
],
"ASVS 4.0": [
"6.2.4"
]
},
"quickfix": "unknown"
}
47 changes: 47 additions & 0 deletions rules/S2245/dart/rule.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
include::../description.adoc[]

include::../ask-yourself.adoc[]

include::../recommended.adoc[]

== Sensitive Code Example

[source,dart,diff-id=1,diff-type=noncompliant]
----
import 'dart:math';

final random = Random(); // Sensitive - Random() is not a secure random number generator
final randomByte = random.nextInt(256);
----

== Compliant Solution

[source,dart,diff-id=1,diff-type=compliant]
----
import 'dart:math';

final random = Random.secure();
final randomByte = random.nextInt(256);
----

include::../see.adoc[]

* OWASP - https://mas.owasp.org/checklists/MASVS-CRYPTO/[Mobile AppSec Verification Standard - Cryptography Requirements]
* OWASP - https://owasp.org/www-project-mobile-top-10/2016-risks/m5-insufficient-cryptography[Mobile Top 10 2016 Category M5 - Insufficient Cryptography]
* OWASP - https://owasp.org/www-project-mobile-top-10/2023-risks/m10-insufficient-cryptography[Mobile Top 10 2024 Category M10 - Insufficient Cryptography]

ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

include::../message.adoc[]

'''
== Comments And Links
(visible only on this page)

include::../comments-and-links.adoc[]

endif::env-github,rspecator-view[]