roster-server 2.4.10 → 2.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roster-server",
3
- "version": "2.4.10",
3
+ "version": "2.4.11",
4
4
  "description": "👾 RosterServer - A domain host router to host multiple HTTPS.",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -36,6 +36,7 @@
36
36
  "@greenlock/manager": "^3.1.0",
37
37
  "@root/acme": "^3.1.0",
38
38
  "@root/csr": "^0.8.1",
39
+ "@root/encoding": "^1.0.1",
39
40
  "@root/keypairs": "^0.10.0",
40
41
  "@root/mkdirp": "^1.0.0",
41
42
  "@root/request": "^1.6.1",
@@ -2,7 +2,7 @@
2
2
 
3
3
  const PHP_PATH = /(?:^|\/)[^/]*\.php(?:$|\/)/i;
4
4
  const SCANNER_PATH = /(?:^|\/)(?:\.git|\.hg|\.svn|\.ssh|\.aws|cgi-bin|server-status|vendor\/phpunit|wp-admin|wp-content|wp-includes|wp-json)(?:\/|$)/i;
5
- const SCANNER_FILE = /(?:^|\/)(?:\.env(?:\.[^/]*)?|\.htaccess|composer\.(?:json|lock)|web\.config)(?:\/|$)/i;
5
+ const SCANNER_FILE = /(?:^|\/)(?:\.env(?:\.[^/]*)?|\.htaccess|composer\.(?:json|lock)|security\.txt|web\.config)(?:\/|$)/i;
6
6
 
7
7
  function requirePositiveInteger(options, name) {
8
8
  const value = options[name];
@@ -8,6 +8,7 @@ const http = require('http');
8
8
  const os = require('os');
9
9
  const Roster = require('../index.js');
10
10
  const { createScannerBlocker } = require('../plugins/scanner-blocker.js');
11
+ const HttpsMiddleware = require('../vendor/greenlock-express/https-middleware.js');
11
12
  const {
12
13
  wildcardRoot,
13
14
  hostMatchesWildcard,
@@ -40,6 +41,37 @@ function httpGet(host, port, pathname = '/') {
40
41
  });
41
42
  }
42
43
 
44
+ describe('vendored HTTPS hostname middleware', () => {
45
+ function invoke(host) {
46
+ let appCalled = false;
47
+ let body;
48
+ const req = { headers: { host }, socket: {} };
49
+ const res = {
50
+ end(value) {
51
+ body = value;
52
+ }
53
+ };
54
+ HttpsMiddleware.create({}, () => {
55
+ appCalled = true;
56
+ })(req, res);
57
+ return { appCalled, body, req, res };
58
+ }
59
+
60
+ it('accepts a valid Host header with a numeric port', () => {
61
+ const result = invoke('example.com:8880');
62
+ assert.strictEqual(result.appCalled, true);
63
+ assert.strictEqual(result.res.statusCode, undefined);
64
+ assert.strictEqual(result.req.headers.host, 'example.com');
65
+ });
66
+
67
+ it('rejects a Host header with a non-numeric port', () => {
68
+ const result = invoke('example.com:invalid');
69
+ assert.strictEqual(result.appCalled, false);
70
+ assert.strictEqual(result.res.statusCode, 400);
71
+ assert.match(result.body, /Malformed HTTP Header/);
72
+ });
73
+ });
74
+
43
75
  describe('wildcardRoot', () => {
44
76
  it('returns root domain for *.example.com', () => {
45
77
  assert.strictEqual(wildcardRoot('*.example.com'), 'example.com');
@@ -61,9 +61,11 @@ describe('scanner-blocker plugin', () => {
61
61
  const urls = [
62
62
  '/install.php',
63
63
  '/user-new\\.php',
64
+ '/wp-login.php',
64
65
  '/wp-json',
65
66
  '/.git/config',
66
- '/%252eenv'
67
+ '/%252eenv',
68
+ '/security.txt'
67
69
  ];
68
70
 
69
71
  for (const [index, url] of urls.entries()) {
@@ -20,6 +20,7 @@ SanitizeHost.create = function(gl, app) {
20
20
  var hostname = HttpMiddleware.getHostname(req);
21
21
  // Replace the hostname, and get the safe version
22
22
  var safehost = HttpMiddleware.sanitizeHostname(req);
23
+ var normalizedHostname = hostname.toLowerCase().replace(/:\d+$/, "");
23
24
 
24
25
  // if no hostname, move along
25
26
  if (!hostname) {
@@ -28,7 +29,7 @@ SanitizeHost.create = function(gl, app) {
28
29
  }
29
30
 
30
31
  // if there were unallowed characters, complain
31
- if (safehost.length !== hostname.length) {
32
+ if (safehost !== normalizedHostname) {
32
33
  res.statusCode = 400;
33
34
  res.end("Malformed HTTP Header: 'Host: " + hostname + "'");
34
35
  return;