forked from ShiftLeftSecurity/shiftleft-ts-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
db-init.ts
196 lines (190 loc) · 5.55 KB
/
db-init.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
import { MongoDBClient } from './src/DB/MongoDBClient';
const timeoutRef = setTimeout(console.log, 20000);
function initDB() {
new MongoDBClient().connect(async function(err, client) {
if (err) {
console.error(err);
process.exit(1);
}
const db = client.db('tarpit', { returnNonCachedInstance: true });
await createUsers(db);
clearTimeout(timeoutRef);
console.log('Database initialized');
console.log(await db.stats());
await client.close();
});
}
setTimeout(initDB, 10000);
async function createUsers(db) {
/* JSON Generated from https://next.json-generator.com
[
{
'repeat(10)': {
_id: '{{objectId()}}',
age: '{{integer(20, 40)}}',
firstName: '{{firstName()}}',
lastName: '{{surname()}}',
company: '{{company().toUpperCase()}}',
email(tags) {
return `${this.firstName}.${this.lastName}@${this.company}${tags.domainZone()}`.toLowerCase();
},
phone: '+1 {{phone()}}',
address: '{{integer(100, 999)}} {{street()}}, {{city()}}, {{state()}}',
zipCode: '{{integer(100, 10000)}}',
creditCard: '{{guid()}}',
username() {
return `${this.lastName}_${this.firstName}`;
},
password: '{{lorem(1, "words")}}'
}
}
]
*/
try {
await db.collection('users').drop();
} catch (ex) {
console.error(ex);
}
return await db.collection('users').insertMany([
{
_id: '5da7676ce86f5ea81ff1a6b9',
age: 27,
firstName: 'Alexis',
lastName: 'Hopper',
company: 'OBLIQ',
email: '[email protected]',
phone: '+1 (925) 494-3355',
address: '356 Essex Street, Defiance, Washington',
zipCode: 6847,
creditCard: '8067e0fa-6257-4c3b-ad65-3be58407aec9',
username: 'Hopper_Alexis',
password: 'velit'
},
{
_id: '5da7676ca2d1bd0af6c2d1ea',
age: 24,
firstName: 'Austin',
lastName: 'Bean',
company: 'PANZENT',
email: '[email protected]',
phone: '+1 (976) 478-3057',
address: '829 Regent Place, Slovan, Wisconsin',
zipCode: 4308,
creditCard: '53f17923-8570-47aa-8dfb-cf0a06960c24',
username: 'Bean_Austin',
password: 'velit'
},
{
_id: '5da7676cf60eb4346135eba2',
age: 38,
firstName: 'Stefanie',
lastName: 'Mcconnell',
company: 'GEEKY',
email: '[email protected]',
phone: '+1 (812) 410-2261',
address: '703 Bryant Street, Blende, New Mexico',
zipCode: 3923,
creditCard: '2fe32288-1170-4473-90a0-bc9dda35808d',
username: 'Mcconnell_Stefanie',
password: 'adipisicing'
},
{
_id: '5da7676c9e2211a2d5666fb4',
age: 20,
firstName: 'Joyner',
lastName: 'Taylor',
company: 'NEBULEAN',
email: '[email protected]',
phone: '+1 (870) 587-3097',
address: '223 Ross Street, Irwin, Kansas',
zipCode: 6212,
creditCard: '11f4cf91-8bfa-4b7d-bf0e-c62a1a7a4cdc',
username: 'Taylor_Joyner',
password: 'reprehenderit'
},
{
_id: '5da7676c9a90e183896faaad',
age: 22,
firstName: 'Sawyer',
lastName: 'Singleton',
company: 'SCENTY',
email: '[email protected]',
phone: '+1 (976) 458-2882',
address: '197 McKibbin Street, Golconda, Arkansas',
zipCode: 6751,
creditCard: '2ed79a48-ba3e-4765-9e38-4485a5ef477d',
username: 'Singleton_Sawyer',
password: 'ut'
},
{
_id: '5da7676cb7a174cbfab07a2f',
age: 37,
firstName: 'Potts',
lastName: 'Mccullough',
company: 'FURNAFIX',
email: '[email protected]',
phone: '+1 (806) 527-3795',
address: '980 Amity Street, Tecolotito, Vermont',
zipCode: 9137,
creditCard: 'e0051644-143c-4b9f-a880-3de60663261d',
username: 'Mccullough_Potts',
password: 'veniam'
},
{
_id: '5da7676ca1c04e3c74a0eff2',
age: 38,
firstName: 'English',
lastName: 'Daniels',
company: 'SUPPORTAL',
email: '[email protected]',
phone: '+1 (890) 514-2523',
address: '842 Herkimer Place, Lithium, Montana',
zipCode: 7104,
creditCard: 'b35e26be-d1c9-4a88-9bb0-61cbb33acdea',
username: 'Daniels_English',
password: 'minim'
},
{
_id: '5da7676c60b6aa83b1f1f164',
age: 35,
firstName: 'Allison',
lastName: 'Mullen',
company: 'ONTALITY',
email: '[email protected]',
phone: '+1 (842) 422-2577',
address: '431 Rockwell Place, Roderfield, Maryland',
zipCode: 9920,
creditCard: '4296a5ff-40e3-4557-964e-6cf9920d07e6',
username: 'Mullen_Allison',
password: 'veniam'
},
{
_id: '5da7676c4ff7bf4248309e3b',
age: 27,
firstName: 'Hansen',
lastName: 'Farmer',
company: 'METROZ',
email: '[email protected]',
phone: '+1 (934) 447-3223',
address: '866 Mill Street, Stockdale, Alaska',
zipCode: 5357,
creditCard: '7ef425ef-b7e7-447a-b7fa-8982ac09000a',
username: 'Farmer_Hansen',
password: 'dolore'
},
{
_id: '5da7676c8197615bddd87f5d',
age: 38,
firstName: 'Monica',
lastName: 'Stein',
company: 'KAGE',
email: '[email protected]',
phone: '+1 (911) 560-2495',
address: '989 Radde Place, Alleghenyville, Maine',
zipCode: 5691,
creditCard: '2ef14544-ab4c-4814-8968-9242f1e26a83',
username: 'Stein_Monica',
password: 'ipsum'
}
]);
}