Skip to content

Commit 29ec62d

Browse files
author
Sakshis
committed
node-sequelize-hardcoded-secret-argument-typescript
1 parent 8cef5e1 commit 29ec62d

3 files changed

+158
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
id: node-sequelize-hardcoded-secret-argument-typescript
2+
language: typescript
3+
severity: warning
4+
message: >-
5+
A secret is hard-coded in the application. Secrets stored in source
6+
code, such as credentials, identifiers, and other types of sensitive data,
7+
can be leaked and used by internal or external malicious actors. Use
8+
environment variables to securely provide credentials and other secrets or
9+
retrieve them from a secure vault or Hardware Security Module (HSM).
10+
note: >-
11+
[CWE-287] Improper Authentication.
12+
[REFERENCES]
13+
- https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
14+
utils:
15+
MATCH_BLANK_PASSWORD:
16+
kind: string
17+
pattern: $Q
18+
inside:
19+
stopBy: end
20+
kind: lexical_declaration
21+
all:
22+
- has:
23+
stopBy: end
24+
kind: new_expression
25+
all:
26+
- has:
27+
stopBy: end
28+
kind: identifier
29+
pattern: $E
30+
- has:
31+
stopBy: end
32+
kind: arguments
33+
nthChild: 2
34+
has:
35+
stopBy: end
36+
kind: string
37+
nthChild: 3
38+
pattern: $Q
39+
has:
40+
stopBy: end
41+
kind: string_fragment
42+
- any:
43+
- follows:
44+
stopBy: end
45+
kind: lexical_declaration
46+
has:
47+
stopBy: end
48+
kind: variable_declarator
49+
has:
50+
stopBy: end
51+
kind: identifier
52+
pattern: $E
53+
- follows:
54+
stopBy: end
55+
kind: import_statement
56+
has:
57+
stopBy: end
58+
kind: import_clause
59+
has:
60+
stopBy: end
61+
kind: identifier
62+
pattern: $E
63+
- follows:
64+
stopBy: end
65+
kind: import_statement
66+
has:
67+
stopBy: end
68+
kind: import_clause
69+
has:
70+
stopBy: end
71+
kind: identifier
72+
pattern: $E
73+
rule:
74+
kind: string
75+
matches: MATCH_BLANK_PASSWORD
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
id: node-sequelize-hardcoded-secret-argument-typescript
2+
snapshots:
3+
? |
4+
const Sequelize = require('sequelize');
5+
const sequelize = new Sequelize('database', 'username', 'password', {
6+
host: 'localhost',
7+
port: '5433',
8+
dialect: 'postgres'
9+
})
10+
: labels:
11+
- source: '''password'''
12+
style: primary
13+
start: 96
14+
end: 106
15+
- source: Sequelize
16+
style: secondary
17+
start: 62
18+
end: 71
19+
- source: password
20+
style: secondary
21+
start: 97
22+
end: 105
23+
- source: '''password'''
24+
style: secondary
25+
start: 96
26+
end: 106
27+
- source: |-
28+
('database', 'username', 'password', {
29+
host: 'localhost',
30+
port: '5433',
31+
dialect: 'postgres'
32+
})
33+
style: secondary
34+
start: 71
35+
end: 165
36+
- source: |-
37+
new Sequelize('database', 'username', 'password', {
38+
host: 'localhost',
39+
port: '5433',
40+
dialect: 'postgres'
41+
})
42+
style: secondary
43+
start: 58
44+
end: 165
45+
- source: Sequelize
46+
style: secondary
47+
start: 6
48+
end: 15
49+
- source: Sequelize = require('sequelize')
50+
style: secondary
51+
start: 6
52+
end: 38
53+
- source: const Sequelize = require('sequelize');
54+
style: secondary
55+
start: 0
56+
end: 39
57+
- source: |-
58+
const sequelize = new Sequelize('database', 'username', 'password', {
59+
host: 'localhost',
60+
port: '5433',
61+
dialect: 'postgres'
62+
})
63+
style: secondary
64+
start: 40
65+
end: 165
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
id: node-sequelize-hardcoded-secret-argument-typescript
2+
valid:
3+
- |
4+
const Sequelize = require('sequelize');
5+
const sequelize = new Sequelize({
6+
database: 'pinche',
7+
username: 'root',
8+
password: '123456789',
9+
dialect: 'mysql'
10+
})
11+
invalid:
12+
- |
13+
const Sequelize = require('sequelize');
14+
const sequelize = new Sequelize('database', 'username', 'password', {
15+
host: 'localhost',
16+
port: '5433',
17+
dialect: 'postgres'
18+
})

0 commit comments

Comments
 (0)