You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (preg_match('/^max-age=(\d+)(;.*)?$/', $transportSecurityValidity, $m)) {
120
+
$transportSecurityValidity = (int)$m[1];
121
+
if ($transportSecurityValidity < $minimumSeconds) {
122
+
$msg .= $this->l10n->t('- The `Strict-Transport-Security` HTTP header is not set to at least `%d` seconds (current value: `%d`). For enhanced security, it is recommended to enable HSTS.', [$minimumSeconds, $transportSecurityValidity])."\n";
123
+
}
124
+
} elseif (!empty($transportSecurityValidity)) {
125
+
$msg .= $this->l10n->t('- The `Strict-Transport-Security` HTTP header is malformed: `%s`. For enhanced security, it is recommended to enable HSTS.', [$transportSecurityValidity])."\n";
126
+
} else {
127
+
$msg .= $this->l10n->t('- The `Strict-Transport-Security` HTTP header is not set (should be at least `%d` seconds). For enhanced security, it is recommended to enable HSTS.', [$minimumSeconds])."\n";
128
+
}
129
+
116
130
if (!empty($msg)) {
117
-
return SetupResult::warning($this->l10n->t('Some headers are not set correctly on your instance')."\n".$msg, descriptionParameters:$msgParameters);
131
+
return SetupResult::warning(
132
+
$this->l10n->t('Some headers are not set correctly on your instance')."\n".$msg,
@@ -161,6 +164,9 @@ public function dataFailure(): array {
161
164
'referrer-origin' => [['Referrer-Policy' => 'origin'], "- The `Referrer-Policy` HTTP header is not set to `no-referrer`, `no-referrer-when-downgrade`, `strict-origin`, `strict-origin-when-cross-origin` or `same-origin`. This can leak referer information. See the {w3c-recommendation}.\n"],
162
165
'referrer-origin-when-cross-origin' => [['Referrer-Policy' => 'origin-when-cross-origin'], "- The `Referrer-Policy` HTTP header is not set to `no-referrer`, `no-referrer-when-downgrade`, `strict-origin`, `strict-origin-when-cross-origin` or `same-origin`. This can leak referer information. See the {w3c-recommendation}.\n"],
163
166
'referrer-unsafe-url' => [['Referrer-Policy' => 'unsafe-url'], "- The `Referrer-Policy` HTTP header is not set to `no-referrer`, `no-referrer-when-downgrade`, `strict-origin`, `strict-origin-when-cross-origin` or `same-origin`. This can leak referer information. See the {w3c-recommendation}.\n"],
167
+
'hsts-missing' => [['Strict-Transport-Security' => ''], "- The `Strict-Transport-Security` HTTP header is not set (should be at least `15552000` seconds). For enhanced security, it is recommended to enable HSTS.\n"],
168
+
'hsts-too-low' => [['Strict-Transport-Security' => 'max-age=15551999'], "- The `Strict-Transport-Security` HTTP header is not set to at least `15552000` seconds (current value: `15551999`). For enhanced security, it is recommended to enable HSTS.\n"],
169
+
'hsts-malformed' => [['Strict-Transport-Security' => 'iAmABogusHeader342'], "- The `Strict-Transport-Security` HTTP header is malformed: `iAmABogusHeader342`. For enhanced security, it is recommended to enable HSTS.\n"],
msg: 'Error occurred while checking server setup',
358
-
type: OC.SetupChecks.MESSAGE_TYPE_ERROR
359
-
}]);
360
-
done();
361
-
});
362
-
});
363
-
364
-
it('should return a SSL warning if SSL used without Strict-Transport-Security-Header',function(done){
365
-
protocolStub.returns('https');
366
-
varasync=OC.SetupChecks.checkGeneric();
367
-
368
-
suite.server.requests[0].respond(200,
369
-
{
370
-
'X-XSS-Protection': '1; mode=block',
371
-
'X-Content-Type-Options': 'nosniff',
372
-
'X-Robots-Tag': 'noindex, nofollow',
373
-
'X-Frame-Options': 'SAMEORIGIN',
374
-
'X-Permitted-Cross-Domain-Policies': 'none',
375
-
'Referrer-Policy': 'no-referrer',
376
-
}
377
-
);
378
-
379
-
async.done(function(data,s,x){
380
-
expect(data).toEqual([{
381
-
msg: 'The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.example.org/admin-security">security tips ↗</a>.',
382
-
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
383
-
}]);
384
-
done();
385
-
});
386
-
});
387
-
388
-
it('should return a SSL warning if SSL used with to small Strict-Transport-Security-Header',function(done){
389
-
protocolStub.returns('https');
390
-
varasync=OC.SetupChecks.checkGeneric();
391
-
392
-
suite.server.requests[0].respond(200,
393
-
{
394
-
'Strict-Transport-Security': 'max-age=15551999',
395
-
'X-XSS-Protection': '1; mode=block',
396
-
'X-Content-Type-Options': 'nosniff',
397
-
'X-Robots-Tag': 'noindex, nofollow',
398
-
'X-Frame-Options': 'SAMEORIGIN',
399
-
'X-Permitted-Cross-Domain-Policies': 'none',
400
-
'Referrer-Policy': 'no-referrer',
401
-
}
402
-
);
403
-
404
-
async.done(function(data,s,x){
405
-
expect(data).toEqual([{
406
-
msg: 'The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.example.org/admin-security">security tips ↗</a>.',
407
-
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
408
-
}]);
409
-
done();
410
-
});
411
-
});
412
-
413
-
it('should return a SSL warning if SSL used with to a bogus Strict-Transport-Security-Header',function(done){
msg: 'The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the <a target="_blank" rel="noreferrer noopener" class="external" href="https://docs.example.org/admin-security">security tips ↗</a>.',
432
-
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
433
-
}]);
434
-
done();
435
-
});
436
-
});
437
-
438
-
it('should return no SSL warning if SSL used with to exact the minimum Strict-Transport-Security-Header',function(done){
439
-
protocolStub.returns('https');
440
-
varasync=OC.SetupChecks.checkGeneric();
441
-
442
-
suite.server.requests[0].respond(200,{
443
-
'Strict-Transport-Security': 'max-age=15768000',
444
-
'X-XSS-Protection': '1; mode=block',
445
-
'X-Content-Type-Options': 'nosniff',
446
-
'X-Robots-Tag': 'noindex, nofollow',
447
-
'X-Frame-Options': 'SAMEORIGIN',
448
-
'X-Permitted-Cross-Domain-Policies': 'none',
449
-
'Referrer-Policy': 'no-referrer',
450
-
});
451
-
452
-
async.done(function(data,s,x){
453
-
expect(data).toEqual([]);
454
-
done();
455
-
});
456
-
});
457
-
458
-
it('should return no SSL warning if SSL used with to more than the minimum Strict-Transport-Security-Header',function(done){
459
-
protocolStub.returns('https');
460
-
varasync=OC.SetupChecks.checkGeneric();
461
-
462
-
suite.server.requests[0].respond(200,{
463
-
'Strict-Transport-Security': 'max-age=99999999',
464
-
'X-XSS-Protection': '1; mode=block',
465
-
'X-Content-Type-Options': 'nosniff',
466
-
'X-Robots-Tag': 'noindex, nofollow',
467
-
'X-Frame-Options': 'SAMEORIGIN',
468
-
'X-Permitted-Cross-Domain-Policies': 'none',
469
-
'Referrer-Policy': 'no-referrer',
470
-
});
471
-
472
-
async.done(function(data,s,x){
473
-
expect(data).toEqual([]);
474
-
done();
475
-
});
476
-
});
477
-
478
-
it('should return no SSL warning if SSL used with to more than the minimum Strict-Transport-Security-Header and includeSubDomains parameter',function(done){
it('should return no SSL warning if SSL used with to more than the minimum Strict-Transport-Security-Header and includeSubDomains and preload parameter',function(done){
0 commit comments