Skip to content

Commit

Permalink
Limit rule to not apply to rust (#353)
Browse files Browse the repository at this point in the history
* Limit rule to not apply to rust

Fix #352

* Add rust rules for insecure random
  • Loading branch information
gfs authored Jan 10, 2022
1 parent 3314822 commit ff2f8fb
Showing 1 changed file with 72 additions and 12 deletions.
84 changes: 72 additions & 12 deletions rules/default/security/cryptography/random.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
"tags": [
"Cryptography.PRNG.Weak"
],
"language": [
"c",
"cpp",
"csharp",
"python",
"php",
"java",
"javascript",
"typescript"
],
"severity": "important",
"rule_info": "DS148264.md",
"patterns": [
{
"pattern": "DUAL_EC_DRBG",
"type": "string",
"scopes": [
"code"
]
},
{
"pattern": "pseudoRandomBytes",
"type": "string",
Expand Down Expand Up @@ -67,32 +70,89 @@
]
},
{
"pattern": "(32969|18273)",
"pattern": "System.Random",
"type": "string",
"scopes": [
"code"
]
},
{
"pattern": "\\bRandom\\(",
"type": "regex-word",
"scopes": [
"code"
]
},
{
"pattern": "System.Random",
"pattern": "arc4random",
"type": "string",
"scopes": [
"code"
]
}
]
},
{
"name": "Do not use weak/non-cryptographic random number generators",
"id": "DS148264",
"description": "Use cryptographic random numbers generators for anything even close to a security function.",
"recommendation": "Use the Rust Rand crate.",
"tags": [
"Cryptography.PRNG.Weak"
],
"language": [
"rust"
],
"severity": "important",
"rule_info": "DS148264.md",
"patterns": [
{
"pattern": "seed_from_u64",
"type": "string",
"scopes": [
"code"
]
},
{
"pattern": "\\bRandom\\(",
"type": "regex-word",
"pattern": "fastrand",
"type": "string",
"scopes": [
"code"
]
},
{
"pattern": "arc4random",
"pattern": "oorandom",
"type": "string",
"scopes": [
"code"
]
}
]
},
{
"name": "Do not use weak/non-cryptographic random number generators",
"id": "DS148264",
"description": "Use cryptographic random numbers generators for anything even close to a security function.",
"recommendation": "Replacements depend on language.",
"tags": [
"Cryptography.PRNG.Weak"
],
"severity": "important",
"rule_info": "DS148264.md",
"patterns": [
{
"pattern": "DUAL_EC_DRBG",
"type": "string",
"scopes": [
"code"
]
},
{
"pattern": "(32969|18273)",
"type": "regex-word",
"scopes": [
"code"
]
}
]
},
Expand Down

0 comments on commit ff2f8fb

Please sign in to comment.