mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:18 +00:00
Match non-lowercase with S105 again (#3258)
This commit is contained in:
parent
c65585e14a
commit
cd6413ca09
3 changed files with 110 additions and 84 deletions
|
@ -19,6 +19,8 @@ token = "s3cr3t"
|
||||||
secrete = "s3cr3t"
|
secrete = "s3cr3t"
|
||||||
safe = password = "s3cr3t"
|
safe = password = "s3cr3t"
|
||||||
password = safe = "s3cr3t"
|
password = safe = "s3cr3t"
|
||||||
|
PASSWORD = "s3cr3t"
|
||||||
|
PassWord = "s3cr3t"
|
||||||
|
|
||||||
d["password"] = "s3cr3t"
|
d["password"] = "s3cr3t"
|
||||||
d["pass"] = "s3cr3t"
|
d["pass"] = "s3cr3t"
|
||||||
|
@ -68,6 +70,8 @@ passed_msg = "You have passed!"
|
||||||
compassion = "Please don't match!"
|
compassion = "Please don't match!"
|
||||||
impassable = "You shall not pass!"
|
impassable = "You shall not pass!"
|
||||||
passwords = ""
|
passwords = ""
|
||||||
|
PASSWORDS = ""
|
||||||
passphrases = ""
|
passphrases = ""
|
||||||
|
PassPhrases = ""
|
||||||
tokens = ""
|
tokens = ""
|
||||||
secrets = ""
|
secrets = ""
|
||||||
|
|
|
@ -4,8 +4,9 @@ use rustpython_parser::ast::{Constant, Expr, ExprKind};
|
||||||
|
|
||||||
use crate::checkers::ast::Checker;
|
use crate::checkers::ast::Checker;
|
||||||
|
|
||||||
static PASSWORD_CANDIDATE_REGEX: Lazy<Regex> =
|
static PASSWORD_CANDIDATE_REGEX: Lazy<Regex> = Lazy::new(|| {
|
||||||
Lazy::new(|| Regex::new(r"(^|_)(pas+wo?r?d|pass(phrase)?|pwd|token|secrete?)($|_)").unwrap());
|
Regex::new(r"(^|_)(?i)(pas+wo?r?d|pass(phrase)?|pwd|token|secrete?)($|_)").unwrap()
|
||||||
|
});
|
||||||
|
|
||||||
pub fn string_literal(expr: &Expr) -> Option<&str> {
|
pub fn string_literal(expr: &Expr) -> Option<&str> {
|
||||||
match &expr.node {
|
match &expr.node {
|
||||||
|
@ -17,7 +18,6 @@ pub fn string_literal(expr: &Expr) -> Option<&str> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Maybe use regex for this?
|
|
||||||
pub fn matches_password_name(string: &str) -> bool {
|
pub fn matches_password_name(string: &str) -> bool {
|
||||||
PASSWORD_CANDIDATE_REGEX.is_match(string)
|
PASSWORD_CANDIDATE_REGEX.is_match(string)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
source: src/rules/flake8_bandit/mod.rs
|
source: crates/ruff/src/rules/flake8_bandit/mod.rs
|
||||||
expression: diagnostics
|
expression: diagnostics
|
||||||
---
|
---
|
||||||
- kind:
|
- kind:
|
||||||
|
@ -105,46 +105,46 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 23
|
row: 22
|
||||||
column: 16
|
|
||||||
end_location:
|
|
||||||
row: 23
|
|
||||||
column: 24
|
|
||||||
fix: ~
|
|
||||||
parent: ~
|
|
||||||
- kind:
|
|
||||||
HardcodedPasswordString:
|
|
||||||
string: s3cr3t
|
|
||||||
location:
|
|
||||||
row: 24
|
|
||||||
column: 12
|
|
||||||
end_location:
|
|
||||||
row: 24
|
|
||||||
column: 20
|
|
||||||
fix: ~
|
|
||||||
parent: ~
|
|
||||||
- kind:
|
|
||||||
HardcodedPasswordString:
|
|
||||||
string: s3cr3t
|
|
||||||
location:
|
|
||||||
row: 25
|
|
||||||
column: 14
|
|
||||||
end_location:
|
|
||||||
row: 25
|
|
||||||
column: 22
|
|
||||||
fix: ~
|
|
||||||
parent: ~
|
|
||||||
- kind:
|
|
||||||
HardcodedPasswordString:
|
|
||||||
string: s3cr3t
|
|
||||||
location:
|
|
||||||
row: 26
|
|
||||||
column: 11
|
column: 11
|
||||||
end_location:
|
end_location:
|
||||||
row: 26
|
row: 22
|
||||||
column: 19
|
column: 19
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
HardcodedPasswordString:
|
||||||
|
string: s3cr3t
|
||||||
|
location:
|
||||||
|
row: 23
|
||||||
|
column: 11
|
||||||
|
end_location:
|
||||||
|
row: 23
|
||||||
|
column: 19
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
HardcodedPasswordString:
|
||||||
|
string: s3cr3t
|
||||||
|
location:
|
||||||
|
row: 25
|
||||||
|
column: 16
|
||||||
|
end_location:
|
||||||
|
row: 25
|
||||||
|
column: 24
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
HardcodedPasswordString:
|
||||||
|
string: s3cr3t
|
||||||
|
location:
|
||||||
|
row: 26
|
||||||
|
column: 12
|
||||||
|
end_location:
|
||||||
|
row: 26
|
||||||
|
column: 20
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
- kind:
|
- kind:
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
|
@ -161,9 +161,31 @@ expression: diagnostics
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 28
|
row: 28
|
||||||
column: 13
|
column: 11
|
||||||
end_location:
|
end_location:
|
||||||
row: 28
|
row: 28
|
||||||
|
column: 19
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
HardcodedPasswordString:
|
||||||
|
string: s3cr3t
|
||||||
|
location:
|
||||||
|
row: 29
|
||||||
|
column: 14
|
||||||
|
end_location:
|
||||||
|
row: 29
|
||||||
|
column: 22
|
||||||
|
fix: ~
|
||||||
|
parent: ~
|
||||||
|
- kind:
|
||||||
|
HardcodedPasswordString:
|
||||||
|
string: s3cr3t
|
||||||
|
location:
|
||||||
|
row: 30
|
||||||
|
column: 13
|
||||||
|
end_location:
|
||||||
|
row: 30
|
||||||
column: 21
|
column: 21
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -171,10 +193,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 29
|
row: 31
|
||||||
column: 15
|
column: 15
|
||||||
end_location:
|
end_location:
|
||||||
row: 29
|
row: 31
|
||||||
column: 23
|
column: 23
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -182,10 +204,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 30
|
row: 32
|
||||||
column: 23
|
column: 23
|
||||||
end_location:
|
end_location:
|
||||||
row: 30
|
row: 32
|
||||||
column: 31
|
column: 31
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -193,10 +215,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 31
|
row: 33
|
||||||
column: 23
|
column: 23
|
||||||
end_location:
|
end_location:
|
||||||
row: 31
|
row: 33
|
||||||
column: 31
|
column: 31
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -204,10 +226,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 35
|
row: 37
|
||||||
column: 15
|
column: 15
|
||||||
end_location:
|
end_location:
|
||||||
row: 35
|
row: 37
|
||||||
column: 23
|
column: 23
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -215,10 +237,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 39
|
row: 41
|
||||||
column: 19
|
column: 19
|
||||||
end_location:
|
end_location:
|
||||||
row: 39
|
row: 41
|
||||||
column: 27
|
column: 27
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -226,10 +248,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 40
|
row: 42
|
||||||
column: 16
|
column: 16
|
||||||
end_location:
|
end_location:
|
||||||
row: 40
|
row: 42
|
||||||
column: 24
|
column: 24
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -237,10 +259,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 41
|
row: 43
|
||||||
column: 17
|
column: 17
|
||||||
end_location:
|
end_location:
|
||||||
row: 41
|
row: 43
|
||||||
column: 25
|
column: 25
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -248,10 +270,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 42
|
row: 44
|
||||||
column: 14
|
column: 14
|
||||||
end_location:
|
end_location:
|
||||||
row: 42
|
row: 44
|
||||||
column: 22
|
column: 22
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -259,10 +281,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 43
|
row: 45
|
||||||
column: 17
|
column: 17
|
||||||
end_location:
|
end_location:
|
||||||
row: 43
|
row: 45
|
||||||
column: 25
|
column: 25
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -270,10 +292,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 44
|
row: 46
|
||||||
column: 16
|
column: 16
|
||||||
end_location:
|
end_location:
|
||||||
row: 44
|
row: 46
|
||||||
column: 24
|
column: 24
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -281,10 +303,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 45
|
row: 47
|
||||||
column: 18
|
column: 18
|
||||||
end_location:
|
end_location:
|
||||||
row: 45
|
row: 47
|
||||||
column: 26
|
column: 26
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -292,10 +314,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 47
|
row: 49
|
||||||
column: 12
|
column: 12
|
||||||
end_location:
|
end_location:
|
||||||
row: 47
|
row: 49
|
||||||
column: 20
|
column: 20
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -303,10 +325,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 48
|
row: 50
|
||||||
column: 9
|
column: 9
|
||||||
end_location:
|
end_location:
|
||||||
row: 48
|
row: 50
|
||||||
column: 17
|
column: 17
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -314,10 +336,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 49
|
row: 51
|
||||||
column: 10
|
column: 10
|
||||||
end_location:
|
end_location:
|
||||||
row: 49
|
row: 51
|
||||||
column: 18
|
column: 18
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -325,10 +347,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 50
|
row: 52
|
||||||
column: 7
|
column: 7
|
||||||
end_location:
|
end_location:
|
||||||
row: 50
|
row: 52
|
||||||
column: 15
|
column: 15
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -336,10 +358,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 51
|
row: 53
|
||||||
column: 10
|
column: 10
|
||||||
end_location:
|
end_location:
|
||||||
row: 51
|
row: 53
|
||||||
column: 18
|
column: 18
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -347,10 +369,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 52
|
row: 54
|
||||||
column: 9
|
column: 9
|
||||||
end_location:
|
end_location:
|
||||||
row: 52
|
row: 54
|
||||||
column: 17
|
column: 17
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -358,10 +380,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 53
|
row: 55
|
||||||
column: 11
|
column: 11
|
||||||
end_location:
|
end_location:
|
||||||
row: 53
|
row: 55
|
||||||
column: 19
|
column: 19
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -369,10 +391,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: s3cr3t
|
string: s3cr3t
|
||||||
location:
|
location:
|
||||||
row: 54
|
row: 56
|
||||||
column: 20
|
column: 20
|
||||||
end_location:
|
end_location:
|
||||||
row: 54
|
row: 56
|
||||||
column: 28
|
column: 28
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -380,10 +402,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: "1\n2"
|
string: "1\n2"
|
||||||
location:
|
location:
|
||||||
row: 56
|
row: 58
|
||||||
column: 12
|
column: 12
|
||||||
end_location:
|
end_location:
|
||||||
row: 56
|
row: 58
|
||||||
column: 18
|
column: 18
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -391,10 +413,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: "3\t4"
|
string: "3\t4"
|
||||||
location:
|
location:
|
||||||
row: 59
|
row: 61
|
||||||
column: 12
|
column: 12
|
||||||
end_location:
|
end_location:
|
||||||
row: 59
|
row: 61
|
||||||
column: 18
|
column: 18
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
@ -402,10 +424,10 @@ expression: diagnostics
|
||||||
HardcodedPasswordString:
|
HardcodedPasswordString:
|
||||||
string: "5\r6"
|
string: "5\r6"
|
||||||
location:
|
location:
|
||||||
row: 62
|
row: 64
|
||||||
column: 12
|
column: 12
|
||||||
end_location:
|
end_location:
|
||||||
row: 62
|
row: 64
|
||||||
column: 18
|
column: 18
|
||||||
fix: ~
|
fix: ~
|
||||||
parent: ~
|
parent: ~
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue