Skip to content

Commit cb79ed3

Browse files
author
Sakshis
committed
modification in express-session-hardcoded-secret-javascript
1 parent a64e2a0 commit cb79ed3

File tree

2 files changed

+19
-192
lines changed

2 files changed

+19
-192
lines changed

rules/javascript/security/express-session-hardcoded-secret-javascript.yml

Lines changed: 19 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -41,73 +41,14 @@ utils:
4141
stopBy: end
4242
kind: string_fragment
4343

44-
- any:
45-
- follows:
46-
stopBy: end
47-
kind: import_statement
48-
all:
49-
- has:
50-
stopBy: end
51-
kind: import_clause
52-
has:
53-
stopBy: neighbor
54-
kind: identifier
55-
pattern: $T
56-
- has:
57-
stopBy: neighbor
58-
kind: string
59-
has:
60-
stopBy: neighbor
61-
kind: string_fragment
62-
regex: '^express-session$'
63-
64-
- follows:
65-
stopBy: end
66-
kind: expression_statement
67-
has:
68-
stopBy: end
69-
kind: assignment_expression
70-
has:
71-
stopBy: end
72-
kind: call_expression
73-
all:
74-
- has:
75-
stopBy: neighbor
76-
kind: identifier
77-
regex: '^require$'
78-
- has:
79-
stopBy: end
80-
kind: arguments
81-
has:
82-
stopBy: neighbor
83-
kind: string
84-
has:
85-
stopBy: neighbor
86-
kind: string_fragment
87-
regex: '^express-session$'
88-
89-
- follows:
90-
stopBy: end
91-
kind: import_statement
92-
all:
93-
- has:
94-
stopBy: neighbor
95-
kind: import_clause
96-
has:
97-
stopBy: neighbor
98-
kind: namespace_import
99-
has:
100-
stopBy: neighbor
101-
kind: identifier
102-
pattern: $T
103-
- has:
104-
stopBy: neighbor
105-
kind: string
106-
has:
107-
stopBy: neighbor
108-
kind: string_fragment
109-
regex: '^express-session$'
110-
44+
- follows:
45+
stopBy: end
46+
kind: import_statement
47+
any:
48+
- pattern: import session from 'express'
49+
- pattern: import session from 'express-session'
50+
- pattern: import {session} from 'express-session'
51+
- pattern: import * as session from 'express-session'
11152
MATCH_SECRET_with_Instance:
11253
kind: pair
11354
all:
@@ -144,75 +85,21 @@ utils:
14485
any:
14586
- kind: lexical_declaration
14687
- kind: expression_statement
147-
any:
148-
- follows:
149-
stopBy: end
150-
kind: import_statement
151-
all:
152-
- has:
153-
stopBy: end
154-
kind: import_clause
155-
has:
156-
stopBy: neighbor
157-
kind: identifier
158-
pattern: $T
159-
- has:
160-
stopBy: neighbor
161-
kind: string
162-
has:
163-
stopBy: neighbor
164-
kind: string_fragment
165-
regex: '^express-session$'
166-
- follows:
167-
stopBy: end
168-
kind: expression_statement
169-
has:
170-
stopBy: end
171-
kind: assignment_expression
172-
has:
173-
stopBy: end
174-
kind: call_expression
175-
all:
176-
- has:
177-
stopBy: neighbor
178-
kind: identifier
179-
regex: '^require$'
180-
- has:
181-
stopBy: end
182-
kind: arguments
183-
has:
184-
stopBy: neighbor
185-
kind: string
186-
has:
187-
stopBy: neighbor
188-
kind: string_fragment
189-
regex: '^express-session$'
190-
- follows:
191-
stopBy: end
192-
kind: import_statement
193-
all:
194-
- has:
195-
stopBy: neighbor
196-
kind: import_clause
197-
has:
198-
stopBy: neighbor
199-
kind: namespace_import
200-
has:
201-
stopBy: neighbor
202-
kind: identifier
203-
pattern: $T
204-
- has:
205-
stopBy: neighbor
206-
kind: string
207-
has:
208-
stopBy: neighbor
209-
kind: string_fragment
210-
regex: '^express-session$'
88+
follows:
89+
stopBy: end
90+
kind: import_statement
91+
any:
92+
- pattern: import session from 'express'
93+
- pattern: import session from 'express-session'
94+
- pattern: import {session} from 'express-session'
95+
- pattern: import * as session from 'express-session'
96+
21197
rule:
21298
kind: pair
21399
any:
214100
- matches: MATCH_SECRET
215101
- matches: MATCH_SECRET_with_Instance
102+
216103
constraints:
217104
S:
218-
regex: '^secret$'
105+
regex: '^secret$'

tests/__snapshots__/express-session-hardcoded-secret-javascript-snapshot.yml

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,6 @@ snapshots:
5050
style: secondary
5151
start: 55
5252
end: 129
53-
- source: session
54-
style: secondary
55-
start: 12
56-
end: 19
57-
- source: '* as session'
58-
style: secondary
59-
start: 7
60-
end: 19
61-
- source: '* as session'
62-
style: secondary
63-
start: 7
64-
end: 19
65-
- source: express-session
66-
style: secondary
67-
start: 26
68-
end: 41
69-
- source: '''express-session'''
70-
style: secondary
71-
start: 25
72-
end: 42
7353
- source: import * as session from 'express-session'
7454
style: secondary
7555
start: 0
@@ -129,26 +109,6 @@ snapshots:
129109
style: secondary
130110
start: 47
131111
end: 113
132-
- source: session
133-
style: secondary
134-
start: 12
135-
end: 19
136-
- source: '* as session'
137-
style: secondary
138-
start: 7
139-
end: 19
140-
- source: '* as session'
141-
style: secondary
142-
start: 7
143-
end: 19
144-
- source: express-session
145-
style: secondary
146-
start: 26
147-
end: 41
148-
- source: '''express-session'''
149-
style: secondary
150-
start: 25
151-
end: 42
152112
- source: import * as session from 'express-session'
153113
style: secondary
154114
start: 0
@@ -208,26 +168,6 @@ snapshots:
208168
style: secondary
209169
start: 47
210170
end: 116
211-
- source: session
212-
style: secondary
213-
start: 12
214-
end: 19
215-
- source: '* as session'
216-
style: secondary
217-
start: 7
218-
end: 19
219-
- source: '* as session'
220-
style: secondary
221-
start: 7
222-
end: 19
223-
- source: express-session
224-
style: secondary
225-
start: 26
226-
end: 41
227-
- source: '''express-session'''
228-
style: secondary
229-
start: 25
230-
end: 42
231171
- source: import * as session from 'express-session'
232172
style: secondary
233173
start: 0

0 commit comments

Comments
 (0)