Skip to content

Commit 882e371

Browse files
committed
Modified rule - python-couchbase-empty-password-python
1 parent 3195f93 commit 882e371

File tree

4 files changed

+87
-83
lines changed

4 files changed

+87
-83
lines changed

package-lock.json

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
"author": "",
1313
"license": "ISC",
1414
"devDependencies": {
15-
"@ast-grep/cli": "^0.26.0"
15+
"@ast-grep/cli": "^0.28.1"
1616
}
17-
}
17+
}

rules/python/security/python-couchbase-empty-password-python.yml

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ utils:
2424
stopBy: neighbor
2525
kind: argument_list
2626
all:
27-
- has:
28-
stopBy: neighbor
29-
kind: string
30-
has:
31-
stopBy: neighbor
32-
kind: string_content
27+
- any:
28+
- has:
29+
stopBy: end
30+
kind: attribute
31+
has:
32+
stopBy: neighbor
33+
kind: identifier
34+
- has:
35+
stopBy: neighbor
36+
kind: string
3337
- has:
3438
stopBy: neighbor
3539
kind: string
@@ -38,35 +42,35 @@ utils:
3842
stopBy: neighbor
3943
kind: string_content
4044

41-
inside:
42-
stopBy: end
43-
kind: expression_statement
44-
follows:
45-
stopBy: end
46-
kind: import_from_statement
47-
all:
48-
- has:
49-
stopBy: end
50-
kind: dotted_name
51-
field: module_name
52-
all:
53-
- has:
54-
stopBy: end
55-
kind: identifier
56-
regex: couchbase_core
57-
- has:
45+
- inside:
46+
stopBy: end
47+
kind: module
48+
has:
49+
stopBy: end
50+
kind: import_from_statement
51+
all:
52+
- has:
53+
stopBy: end
54+
kind: dotted_name
55+
field: module_name
56+
all:
57+
- has:
58+
stopBy: end
59+
kind: identifier
60+
regex: couchbase_core
61+
- has:
62+
stopBy: end
63+
kind: identifier
64+
regex: cluster
65+
- has:
66+
stopBy: end
67+
kind: dotted_name
68+
field: name
69+
has:
5870
stopBy: end
5971
kind: identifier
60-
regex: cluster
61-
- has:
62-
stopBy: end
63-
kind: dotted_name
64-
field: name
65-
has:
66-
stopBy: end
67-
kind: identifier
68-
pattern: $R
69-
regex: PasswordAuthenticator
72+
pattern: $R
73+
regex: PasswordAuthenticator
7074
rule:
7175
all:
7276
- matches: match_passwordauthenticator

tests/__snapshots__/python-couchbase-empty-password-python-snapshot.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ snapshots:
1414
style: secondary
1515
start: 121
1616
end: 142
17-
- source: username
18-
style: secondary
19-
start: 144
20-
end: 152
2117
- source: '''username'''
2218
style: secondary
2319
start: 143
@@ -54,10 +50,14 @@ snapshots:
5450
style: secondary
5551
start: 64
5652
end: 120
57-
- source: PasswordAuthenticator('username', '')
58-
style: secondary
59-
start: 121
60-
end: 158
53+
- source: |
54+
import os
55+
from couchbase.cluster import Cluster, ClusterOptions
56+
from couchbase_core.cluster import PasswordAuthenticator
57+
PasswordAuthenticator('username', '')
58+
style: secondary
59+
start: 0
60+
end: 159
6161
? |
6262
import os
6363
from couchbase.cluster import Cluster, ClusterOptions
@@ -72,10 +72,6 @@ snapshots:
7272
style: secondary
7373
start: 179
7474
end: 200
75-
- source: username
76-
style: secondary
77-
start: 202
78-
end: 210
7975
- source: '''username'''
8076
style: secondary
8177
start: 201
@@ -112,7 +108,11 @@ snapshots:
112108
style: secondary
113109
start: 64
114110
end: 120
115-
- source: cluster = Cluster('couchbase://localhost', ClusterOptions(PasswordAuthenticator('username', '')))
116-
style: secondary
117-
start: 121
118-
end: 218
111+
- source: |
112+
import os
113+
from couchbase.cluster import Cluster, ClusterOptions
114+
from couchbase_core.cluster import PasswordAuthenticator
115+
cluster = Cluster('couchbase://localhost', ClusterOptions(PasswordAuthenticator('username', '')))
116+
style: secondary
117+
start: 0
118+
end: 219

0 commit comments

Comments
 (0)