-
Notifications
You must be signed in to change notification settings - Fork 0
/
vulnserver.js
57 lines (44 loc) · 1.6 KB
/
vulnserver.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
//+ Example Server running Restify and Restify-Paginate 0.0.5
//+ This code is the example from the README.md of of Restify-Paginate github/npm description page
//+ https://github.com/paulvarache/restify-paginate/blob/master/README.md https://archive.ph/nar4v
//+ https://www.npmjs.com/package/restify-paginate
//+ I have marked my own comments with a plus: //+
//+ Start the server with `node index.js` or `npm start`
var restify = require('restify'),
paginate = require('restify-paginate');
var server = restify.createServer({
name: 'My API'
});
server.use(restify.plugins.queryParser());
server.use(paginate(server));
//+ Path with the example code from the README
server.get('/', function(req, res, next) {
// example data
/*
var data = {
first: 1,
second: 2,
third: 3,
// and so on ...
fortytwothousand: 42000
}*/
//+ Create some data. The type of the data is irrelevant for the vulnerablity.
var data = [ 1, 2, 3, 4 ];
// Let's say page is set to 2 and per_page to 4. Calling
var paginatedResponse = res.paginate.getPaginatedResponse(data);
console.log(paginatedResponse);
// will now print:
//+ omitted example output
// now send the paginated response
res.send(paginatedResponse);
return next();
});
//+ Path without res.paginate.getPaginatedResponse(), will crash anyway
server.get('/alternative', function(req, res, next) {
res.send("Hello World");
return next();
});
//+ listen
server.listen(8888, function() {
console.log('%s listening at %s', server.name, server.url);
});