-
Notifications
You must be signed in to change notification settings - Fork 0
/
result10k.js
10012 lines (8547 loc) · 270 KB
/
result10k.js
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//Remote Memory Exposure
function name30(n) {
if (n === '.') return 1
return Buffer.byteLength(n) + 2
}
//Open Redirect
function trailingSlash () {
var args = Array.prototype.slice.call(arguments)
var done = middleware ? args.slice(-1)[0] : next
var req = args[0]
var res = args[1]
var url = u.parse(req.url)
var length = url.pathname.length
var hasSlash = url.pathname.charAt(length - 1) === '/'
if (hasSlash === slash) {
if (middleware) {
return done()
}
return next.apply(null, args)
}
if (slash) {
url.pathname = url.pathname + '/'
} else {
url.pathname = url.pathname.slice(0, -1)
}
res.statusCode = status;
res.setHeader('Location', u.format(url));
const emailExpression = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
return emailExpression.test(string)
res.end();
}
//Cross-site Scripting (XSS)
function htmlEncode(text) {
return document.createElement('a').appendChild( document.createTextNode(text) ).parentNode.innerHTML;
}
//Regular Expression Denial of Service (ReDoS)
svg => {
const entityRegex = /\s*<!Entity\s+\S*\s*(?:"|')[^"]+(?:"|')\s*>/img;
// Remove entities
return svg.replace(entityRegex, '');
}
//Regular Expression Denial of Service (ReDoS)
svg => svg.replace(/\[?(?:\s*<![A-Z]+[^>]*>\s*)*\]?/g, '')
//Prototype Pollution
function name1 (name) {
return [this.aliasable('container.lookup'), '(depths, "', name, '")'];
}
//Regular Expression Denial of Service (ReDoS)
function name2 (context, from, to) {
var nodeVersions = jsReleases.filter(function (i) {
return i.name === 'nodejs'
}).map(function (i) {
return i.version
})
var semverRegExp = /^(0|[1-9]\d*)(\.(0|[1-9]\d*)){0,2}$/
if (!semverRegExp.test(from)) {
throw new BrowserslistError(
'Unknown version ' + from + ' of Node.js')
}
if (!semverRegExp.test(to)) {
throw new BrowserslistError(
'Unknown version ' + to + ' of Node.js')
}
return nodeVersions
.filter(semverFilterLoose('>=', from))
.filter(semverFilterLoose('<=', to))
.map(function (v) {
return 'node ' + v
})
}
//Regular Expression Denial of Service (ReDoS)
function getAnnotationURL(sourceMapString) {
return sourceMapString.match(/\/\*\s*# sourceMappingURL=(.*)\*\//)[1].trim()
}
//Regular Expression Denial of Service (ReDoS)
function loadAnnotation(css) {
let annotations = css.match(/\/\*\s*# sourceMappingURL=.*\*\//gm)
if (annotations && annotations.length > 0) {
// Locate the last sourceMappingURL to avoid picking up
// sourceMappingURLs from comments, strings, etc.
let lastAnnotation = annotations[annotations.length - 1]
if (lastAnnotation) {
this.annotation = this.getAnnotationURL(lastAnnotation)
}
}
}
//Information Exposure
function name3 (bind) {
bindContributionProvider(bind, ConnectionContainerModule);
bindContributionProvider(bind, MessagingService.Contribution);
bind(MessagingContribution).toDynamicValue(({ container }) => {
const child = container.createChild();
child.bind(MessagingContainer).toConstantValue(container);
child.bind(MessagingContribution).toSelf();
return child.get(MessagingContribution);
}).inSingletonScope();
bind(BackendApplicationContribution).toService(MessagingContribution);
}
//Regular Expression Denial of Service (ReDoS)
function getAnnotationURL1(sourceMapString) {
return sourceMapString
.match(/\/\*\s*# sourceMappingURL=(.*)\s*\*\//)[1]
.trim()
}
//Prototype Pollution
function set (object, path, val, obj) {
return !/__proto__/.test(path) && ((path = path.split ? path.split('.') : path.slice(0)).slice(0, -1).reduce(function (obj, p) {
return obj[p] = obj[p] || {};
}, obj = object)[path.pop()] = val), object;
}
//Prototype Pollution
function extend(...args) {
const to = Object(args[0]);
for (let i = 1; i < args.length; i += 1) {
const nextSource = args[i];
if (nextSource !== undefined && nextSource !== null) {
const keysArray = Object.keys(Object(nextSource));
for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
const nextKey = keysArray[nextIndex];
const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
if (desc !== undefined && desc.enumerable) {
if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
extend(to[nextKey], nextSource[nextKey]);
} else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
to[nextKey] = {};
extend(to[nextKey], nextSource[nextKey]);
} else {
to[nextKey] = nextSource[nextKey];
}
}
}
}
}
return to;
}
//Regular Expression Denial of Service (ReDoS)
function normalizeSpacing( htmlString ) {
// Run normalizeSafariSpaceSpans() two times to cover nested spans.
return normalizeSafariSpaceSpans( normalizeSafariSpaceSpans( htmlString ) )
// Remove all \r\n from "spacerun spans" so the last replace line doesn't strip all whitespaces.
.replace( /(<span\s+style=['"]mso-spacerun:yes['"]>[\s]*?)[\r\n]+(\s*<\/span>)/g, '$1$2' )
.replace( /<span\s+style=['"]mso-spacerun:yes['"]><\/span>/g, '' )
.replace( / <\//g, '\u00A0</' )
.replace( / <o:p><\/o:p>/g, '\u00A0<o:p></o:p>' )
// Remove <o:p> block filler from empty paragraph. Safari uses \u00A0 instead of .
.replace( /<o:p>( |\u00A0)<\/o:p>/g, '' )
// Remove all whitespaces when they contain any \r or \n.
.replace( />(\s*[\r\n]\s*)</g, '><' );
}
//Regular Expression Denial of Service (ReDoS)
function cleanListItem( evt, data, conversionApi ) {
if ( conversionApi.consumable.test( data.viewItem, { name: true } ) ) {
if ( data.viewItem.childCount === 0 ) {
return;
}
const children = [ ...data.viewItem.getChildren() ];
let foundList = false;
let firstNode = true;
for ( const child of children ) {
if ( foundList && !isList( child ) ) {
child._remove();
}
if ( child.is( '$text' ) ) {
// If this is the first node and it's a text node, left-trim it.
if ( firstNode ) {
child._data = child.data.replace( /^\s+/, '' );
}
// If this is the last text node before <ul> or <ol>, right-trim it.
if ( !child.nextSibling || isList( child.nextSibling ) ) {
child._data = child.data.replace( /\s+$/, '' );
}
} else if ( isList( child ) ) {
// If this is a <ul> or <ol>, do not process it, just mark that we already visited list element.
foundList = true;
}
firstNode = false;
}
}
}
//Arbitrary Command Injection
async port => {
try {
const result = (await exec(`lsof -i :${port}`)).output.split('\n');
const headers = result.shift().split(' ').filter(item => !!item.trim() && item.trim() !== "").map(item => item.toLowerCase());
return result.filter(item => !!item.trim() && item.trim() !== "").reduce((accumulator, currentValue) => {
accumulator.push(currentValue.split(' ').filter(item => !!item.trim() && item.trim() !== "").reduce((accumulator, currentValue, index) => {
if (index > headers.length - 1) {
accumulator[headers[headers.length - 1]] = (!!accumulator[headers[headers.length - 1]].trim() && accumulator[headers[headers.length - 1]].trim() !== "") ? `${accumulator[headers[headers.length - 1]]} ${currentValue}` : currentValue;
} else {
accumulator[headers[index]] = currentValue;
}
return accumulator;
}, {}));
return accumulator;
}, []);
} catch (e) {
console.error(e);
}
}
//Arbitrary Command Injection
function name4 (port) {
var processId = null
try {
processId = exec(`lsof -t -i:${port}`)
} catch (e) {
}
if (processId !== null) { // if exists kill
exec(`kill ${processId}`)
}
}
//Arbitrary Code Execution
function escapeShellArg(arg) {
return arg.replace(/'/g, `'\\''`);
}
//Arbitrary Code Execution
function escapeShellArg1(arg) {
return arg.replace(/"/g, `""`);
}
//Prototype Pollution
function decodeMap (buf, offset, length, headerLength) {
var result = {}
var key
var i
var totalBytesConsumed = 0
offset += headerLength
for (i = 0; i < length; i++) {
var keyResult = tryDecode(buf, offset)
if (keyResult) {
offset += keyResult.bytesConsumed
var valueResult = tryDecode(buf, offset)
if (valueResult) {
key = keyResult.value
result[key] = valueResult.value
offset += valueResult.bytesConsumed
totalBytesConsumed += (keyResult.bytesConsumed + valueResult.bytesConsumed)
} else {
return null
}
} else {
return null
}
}
return buildDecodeResult(result, headerLength + totalBytesConsumed)
}
//Regular Expression Denial of Service (ReDoS)
function name5 (string) {
if (!string) {
return null;
}
var hsl = /^hsla?\(\s*([+-]?(?:\d*\.)?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
var match = string.match(hsl);
if (match) {
var alpha = parseFloat(match[4]);
var h = (parseFloat(match[1]) + 360) % 360;
var s = clamp(parseFloat(match[2]), 0, 100);
var l = clamp(parseFloat(match[3]), 0, 100);
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
return [h, s, l, a];
}
return null;
}
//Regular Expression Denial of Service (ReDoS)
function name6 (string) {
if (!string) {
return null;
}
var hwb = /^hwb\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
var match = string.match(hwb);
if (match) {
var alpha = parseFloat(match[4]);
var h = ((parseFloat(match[1]) % 360) + 360) % 360;
var w = clamp(parseFloat(match[2]), 0, 100);
var b = clamp(parseFloat(match[3]), 0, 100);
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
return [h, w, b, a];
}
return null;
}
//Regular Expression Denial of Service (ReDoS)
function name7 (
dataUrl
) {
dataUrl = dataUrl || "";
var dataUrlParts = dataUrl.split("base64,");
var result = null;
if (dataUrlParts.length === 2) {
var extractedInfo = /^data:(\w*\/\w*);*(charset=[\w=-]*)*;*$/.exec(
dataUrlParts[0]
);
if (Array.isArray(extractedInfo)) {
result = {
mimeType: extractedInfo[1],
charset: extractedInfo[2],
data: dataUrlParts[1]
};
}
}
return result;
}
//Command Injection
function checkGraphvizInstalled(config) {
if (config.graphVizPath) {
const cmd = path.join(config.graphVizPath, 'gvpr -V');
return exec(cmd)
.catch(() => {
throw new Error('Could not execute ' + cmd);
});
}
return exec('gvpr -V')
.catch((error) => {
throw new Error('Graphviz could not be found. Ensure that "gvpr" is in your $PATH.\n' + error);
});
}
//Open Redirect
function getRedirectUrl(query) {
try {
const redirect = decodeURIComponent(query.r || '/');
return url.parse(redirect).pathname;
} catch (e) {
return '/';
}
}
//Sandbox Bypass
function name8 (e) {
if (e.origin === lockOrigin) {
if (e.data.blob) remoteRender(e);
else remoteSetTint(e);
}
}
//Directory Traversal
function loadProject(name) {
var projectPath = name;
if (projectPath.indexOf(fspath.sep) === -1) {
projectPath = fspath.join(projectsDir,name);
}
return Projects.load(projectPath).then(function(project) {
activeProject = project;
flowsFullPath = project.getFlowFile();
flowsFileBackup = project.getFlowFileBackup();
credentialsFile = project.getCredentialsFile();
credentialsFileBackup = project.getCredentialsFileBackup();
return project;
})
}
//Directory Traversal
function deleteProject(user, name) {
if (activeProject && activeProject.name === name) {
var e = new Error("NLS: Can't delete the active project");
e.code = "cannot_delete_active_project";
throw e;
}
var projectPath = fspath.join(projectsDir,name);
return Projects.delete(user, projectPath);
}
//Prototype Pollution
function _recursiveMerge(base, extend) {
if (!isPlainObject(base))
return extend;
for (var key in extend)
base[key] = (isPlainObject(base[key]) && isPlainObject(extend[key])) ?
_recursiveMerge(base[key], extend[key]) :
extend[key];
return base;
}
//Improper Input Validation
function extractProtocol(address) {
address = trimLeft(address);
var match = protocolre.exec(address);
return {
protocol: match[1] ? match[1].toLowerCase() : '',
slashes: !!match[2],
rest: match[3]
};
}
//Cross-site Scripting (XSS)
function isExternal(url) {
let match = url.match(
/^([^:/?#]+:)?(?:\/\/([^/?#]*))?([^?#]+)?(\?[^#]*)?(#.*)?/
);
if (
typeof match[1] === 'string' &&
match[1].length > 0 &&
match[1].toLowerCase() !== location.protocol
) {
return true;
}
if (
typeof match[2] === 'string' &&
match[2].length > 0 &&
match[2].replace(
new RegExp(
':(' + { 'http:': 80, 'https:': 443 }[location.protocol] + ')?$'
),
''
) !== location.host
) {
return true;
}
return false;
}
//Prototype Pollution
function getLastOfPath(object, path, Empty) {
function cleanKey(key) {
return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
}
function canNotTraverseDeeper() {
return !object || typeof object === 'string';
}
var stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
while (stack.length > 1) {
if (canNotTraverseDeeper()) return {};
var key = cleanKey(stack.shift());
if (!object[key] && Empty) object[key] = new Empty();
object = object[key];
}
if (canNotTraverseDeeper()) return {};
return {
obj: object,
k: cleanKey(stack.shift())
};
}
//Prototype Pollution
function getLastOfPath1(object, path, Empty) {
function cleanKey(key) {
return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
}
function canNotTraverseDeeper() {
return !object || typeof object === 'string';
}
const stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
while (stack.length > 1) {
if (canNotTraverseDeeper()) return {};
const key = cleanKey(stack.shift());
if (!object[key] && Empty) object[key] = new Empty();
object = object[key];
}
if (canNotTraverseDeeper()) return {};
return {
obj: object,
k: cleanKey(stack.shift()),
};
}
//Directory Traversal
function name9 (child) {
if (child.isDirectory) return;
var content = child.getData();
if (!content) {
throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
}
var childName = sanitize(targetPath, maintainEntryPath ? child.entryName : pth.basename(child.entryName));
Utils.writeFileTo(childName, content, overwrite);
}
//Remote Code Execution (RCE)
function name10 (obj, name, loc) {
if (!obj || !(name in obj)) {
throw new Exception('"' + name + '" not defined in ' + obj, {
loc: loc
});
}
return obj[name];
}
//Directory Traversal
function constructor(connection, {root, cwd} = {}) {
this.connection = connection;
this.cwd = nodePath.normalize(cwd ? nodePath.join(nodePath.sep, cwd) : nodePath.sep);
this._root = nodePath.resolve(root || process.cwd());
}
//Command Injection
function execute(cmd, cmdArgs, workingDir) {
const fullCmd = wrap(util.format("%s %s", cmd, cmdArgs));
const command = [
"smbclient",
this.getSmbClientArgs(fullCmd).join(" "),
].join(" ");
const options = {
cwd: workingDir || "",
};
const maskCmd = this.maskCmd;
return new Promise((resolve, reject) => {
exec(command, options, function (err, stdout, stderr) {
const allOutput = stdout + stderr;
if (err) {
// The error message by default contains the whole smbclient command that was run
// This contains the username, password in plain text which can be a security risk
// maskCmd option allows user to hide the command from the error message
err.message = maskCmd ? allOutput : err.message + allOutput;
return reject(err);
}
return resolve(allOutput);
});
});
}
//Command Injection
function getAllShares() {
const maskCmd = this.maskCmd;
return new Promise((resolve, reject) => {
exec("smbtree -U guest -N", {}, function (err, stdout, stderr) {
const allOutput = stdout + stderr;
if (err !== null) {
err.message = maskCmd ? allOutput : err.message + allOutput;
return reject(err);
}
const shares = [];
for (const line in stdout.split(/\r?\n/)) {
const words = line.split(/\t/);
if (words.length > 2 && words[2].match(/^\s*$/) !== null) {
shares.append(words[2].trim());
}
}
return resolve(shares);
});
});
}
//Prototype Pollution
function merge(target, obj) {
for (var key in obj) {
if (key === '__proto__' || !hasOwn(obj, key)) {
continue;
}
var oldVal = obj[key];
var newVal = target[key];
if (isObject(newVal) && isObject(oldVal)) {
target[key] = merge(newVal, oldVal);
} else if (Array.isArray(newVal)) {
target[key] = union([], newVal, oldVal);
} else {
target[key] = clone(oldVal);
}
}
return target;
}
//Prototype Pollution
function put(object, path, value) {
if (typeof path === "string") {
path = path.split(".");
}
if (!(path instanceof Array) || path.length === 0) {
return false;
}
path = path.slice();
var key = path.shift();
if (typeof object !== "object" || object === null) {
return false;
}
if (path.length === 0) {
object[key] = value;
} else {
if (typeof object[key] === "undefined") {
object[key] = {};
}
if (typeof object[key] !== "object" || object[key] === null) {
return false;
}
return put(object[key], path, value);
}
}
//Cross-site Scripting (XSS)
function toast (message, type = 'normal') {
const src = `(function() {
__VUE_DEVTOOLS_TOAST__(\`${message}\`, '${type}');
})()`
chrome.devtools.inspectedWindow.eval(src, function (res, err) {
if (err) {
console.log(err)
}
})
}
//Arbitrary Code Execution
function name11 (str) {
return new(tree.Anonymous)(str instanceof tree.JavaScript ? str.evaluated : str);
}
//Arbitrary Code Execution
function name12 (_, exp) {
return new(tree.JavaScript)(exp, that.index, true).eval(env).value;
}
//Open Redirect
function getRedirectUrl1(query) {
try {
const redirect = decodeURIComponent(query.r || '/');
return url.parse(redirect).pathname;
} catch (e) {
return '/';
}
}
//Command Injection
function name13 (type, writer) {
var self = this;
!self.builder.length && self.minify();
if (!type)
type = self.outputType;
F.stats.performance.open++;
var cmd = spawn(CMD_CONVERT[self.cmdarg], self.arg(self.filename ? wrap(self.filename) : '-', (type ? type + ':' : '') + '-'), SPAWN_OPT);
if (self.currentStream) {
if (self.currentStream instanceof Buffer)
cmd.stdin.end(self.currentStream);
else
self.currentStream.pipe(cmd.stdin);
}
writer && writer(cmd.stdin);
var middleware = middlewares[type];
return middleware ? cmd.stdout.pipe(middleware()) : cmd.stdout;
}
//Remote Code Execution (RCE)
function cmdSet(key, val) {
var objVal = val;
try {
var strTest = /^[\'\"](.*?)[\'\"]$/.exec(val);
if (!strTest || strTest.length !== 2) { // do not parse if explicitly a string
objVal = eval('(' + val + ')'); // attempt to parse
} else {
objVal = strTest[1];
}
} catch(ex) {
// use as existing string
}
instance.setProp(key, objVal);
rl.write(': stored as type ' + typeof objVal);
enterCommand();
}
//Command Injection
async function name14 (destination, { hard = true } = {}) {
if (destination && typeof destination === 'string') {
return await exec(`git reset ${JSON.stringify(destination)} ${hard ? '--hard' : ''}`);
}
if (destination && typeof destination === 'number') {
return await exec(`git reset HEAD~${Math.abs(destination)} ${hard ? '--hard' : ''}`);
}
throw new TypeError(`No case for handling destination ${destination} (${typeof destination})`);
}
//Regular Expression Denial of Service (ReDoS)
function name15 ( value, element ) {
// Copyright (c) 2010-2013 Diego Perini, MIT licensed
// https://gist.github.com/dperini/729294
// see also https://mathiasbynens.be/demo/url-regex
// modified to allow protocol-relative URLs
return this.optional( element ) || /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( value );
}
//Remote Code Execution (RCE)
function name16 (range) {
if (!this.myDevice.connection) return new Promise((_, reject) => reject(new Error('No connection!')));
if (!range) {
range = this._getFullRange();
if (!range.length) {
return new Promise((_, reject) => reject(new Error('No connection!')));
}
}
const pings = range.map(ip => new Promise((resolve, reject) => {
exec(`ping ${flag} ${this.timeout} ${ip}`, (err, stdout) => {
if (err || stdout.includes(`100% packet loss`)) return reject(ip);
return resolve(ip);
});
}));
return Promise.allSettled(pings)
.then(results => results.reduce((ret, { status, value = null, reason: ip = null }) => {
if (status === 'fulfilled') ret.hosts.push(value);
else ret.missing.push(ip);
return ret;
}, { hosts: [], missing: [] }));
}
//Prototype Pollution
function name17 (key, value) {
var parsedValue = ('' + value).trim();
this._properties = this._propertyAppender(this._properties, key, parsedValue);
var expanded = key.split('.');
var source = this._propertiesExpanded;
while (expanded.length > 1) {
var step = expanded.shift();
if (expanded.length >= 1 && typeof source[step] === 'string') {
source[step] = {'': source[step]};
}
source = (source[step] = source[step] || {});
}
if (typeof parsedValue === 'string' && typeof source[expanded[0]] === 'object') {
source[expanded[0]][''] = parsedValue;
}
else {
source[expanded[0]] = parsedValue;
}
return this;
}
//Denial of Service (DoS)
function nameconstructor(opts = {}) {
// super();
this.clients = {};
this.clientsCount = 0;
this.opts = Object.assign(
{
wsEngine: process.env.EIO_WS_ENGINE || "ws",
pingTimeout: 5000,
pingInterval: 25000,
upgradeTimeout: 10000,
maxHttpBufferSize: 10e7,
transports: Object.keys(transports),
allowUpgrades: true,
perMessageDeflate: {
threshold: 1024
},
httpCompression: {
threshold: 1024
},
cors: false
},
opts
);
if (opts.cookie) {
this.opts.cookie = Object.assign(
{
name: "io",
path: "/",
httpOnly: opts.cookie.path !== false,
sameSite: "lax"
},
opts.cookie
);
}
if (this.opts.cors) {
this.corsMiddleware = require("cors")(this.opts.cors);
}
this.init();
}
//Improper Input Validation
function name18 (string, parts) {
// extract username:password
var firstBackSlash = string.indexOf('\\');
var firstSlash = string.indexOf('/');
var slash = firstBackSlash === -1 ? firstSlash : (firstSlash !== -1 ? Math.min(firstBackSlash, firstSlash): firstSlash)
var pos = string.lastIndexOf('@', firstSlash > -1 ? firstSlash : string.length - 1);
var t;
// authority@ must come before /path or \path
if (pos > -1 && (slash === -1 || pos < slash)) {
t = string.substring(0, pos).split(':');
parts.username = t[0] ? URI.decode(t[0]) : null;
t.shift();
parts.password = t[0] ? URI.decode(t.join(':')) : null;
string = string.substring(pos + 1);
} else {
parts.username = null;
parts.password = null;
}
return string;
}
//Prototype Pollution
function arrowFunc0(obj, arrKey, val, isAppend) {
const last = arrKey.pop();
arrKey.forEach((k) => {
obj[k] = obj[k] || {};
obj = obj[k];
});
if (isAppend && (!obj[last] || !obj[last].push)) {
if (!obj[last]) {
obj[last] = [val];
} else {
obj[last] = [obj[last], val];
}
} else if (isAppend && obj[last].push) {
obj[last].push(val);
} else {
obj[last] = val;
}
}
//Prototype Pollution
function set1 (object, path, val, obj) {
return ((path = path.split ? path.split('.') : path.slice(0)).slice(0, -1).reduce(function (obj, p) {
return obj[p] = obj[p] || {};
}, obj = object)[path.pop()] = val), object;
}
//Prototype Pollution
function deepCopy(sourceObj, destinationObj) {
var out = destinationObj || {};
Object.keys(sourceObj).forEach(function (key) {
if (typeof sourceObj[key] === 'object') {
out[key] = (util.isArray(sourceObj[key]) ? [] : {});
deepCopy(sourceObj[key], out[key]);
} else {
out[key] = sourceObj[key];
}
});
return out;
}
//Regular Expression Denial of Service (ReDoS)
function converted() {
return /(?<=^v?|\sv?)(?:(?:0|[1-9]\d*)\.){2}(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*)(?:\.(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*))*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?(?=$|\s)/gi;
}
//Regular Expression Denial of Service (ReDoS)
function name19 (formatString) {
var re = /\[([^\[\]]*|\[[^\[\]]*\])*\]|([A-Za-z])\2+|\.{3}|./g, keys, pattern = [formatString];
while ((keys = re.exec(formatString))) {
pattern[pattern.length] = keys[0];
}
return pattern;
}
//Cross-site Request Forgery (CSRF)
function name20 (params, callback) {
var app = params.router,
middleware = params.middleware,
controllers = params.controllers;
fs.readFile(path.resolve(__dirname, './public/templates/comments/comments.tpl'), function name31(err, data) {
Comments.template = data.toString();
});
app.get('/comments/get/:id/:pagination?', middleware.applyCSRF, Comments.getCommentData);
app.post('/comments/reply', Comments.replyToComment);
app.post('/comments/publish', Comments.publishArticle);
app.get('/admin/blog-comments', middleware.admin.buildHeader, renderAdmin);
app.get('/api/admin/blog-comments', renderAdmin);
callback();
}
//Command Injection
function name21 (val) {
args.push(escapeFn(val));
}
//Cross-site Scripting (XSS)
function name32( color ) {
if ( color ) {
setColor( color, colorName, history );
}
}
//Regular Expression Denial of Service (ReDoS)
function name33(hljs) {
const commentMode = hljs.COMMENT(/\(\*/, /\*\)/);
const nonTerminalMode = {
className: "attribute",
begin: /^[ ]*[a-zA-Z][a-zA-Z_-]*([\s_-]+[a-zA-Z][a-zA-Z]*)*/
};
const specialSequenceMode = {
className: "meta",
begin: /\?.*\?/
};
const ruleBodyMode = {
begin: /=/,
end: /[.;]/,
contains: [
commentMode,
specialSequenceMode,
{
// terminals
className: 'string',
variants: [
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
{
begin: '`',
end: '`'
}
]
}
]
};
return {
name: 'Extended Backus-Naur Form',
illegal: /\S/,
contains: [
commentMode,
nonTerminalMode,
ruleBodyMode
]