owasp-password-strength-test
Advanced tools
Comparing version 1.2.2 to 1.3.0
{ | ||
"name": "owasp-password-strength-test", | ||
"main": "owasp-password-strength-test.js", | ||
"version": "1.2.2", | ||
"homepage": "https://github.com/viaforensics/owasp-password-strength-test", | ||
"version": "1.3.0", | ||
"homepage": "https://github.com/nowsecure/owasp-password-strength-test", | ||
"authors": [ | ||
@@ -7,0 +7,0 @@ "Chris Lane <chris@chris-allen-lane.com>" |
@@ -41,2 +41,3 @@ /* globals define */ | ||
required: [ | ||
// enforce a minimum length | ||
@@ -62,2 +63,3 @@ function(password) { | ||
}, | ||
], | ||
@@ -99,6 +101,7 @@ | ||
function(password) { | ||
if (!/[^A-Za-z0-9 ]/.test(password)) { | ||
if (!/[^A-Za-z0-9]/.test(password)) { | ||
return 'The password must contain at least one special character.'; | ||
} | ||
}, | ||
], | ||
@@ -115,2 +118,4 @@ }; | ||
passedTests : [], | ||
requiredTestErrors : [], | ||
optionalTestErrors : [], | ||
isPassphrase : false, | ||
@@ -128,2 +133,3 @@ strong : true, | ||
result.errors.push(err); | ||
result.requiredTestErrors.push(err); | ||
result.failedTests.push(i); | ||
@@ -152,2 +158,3 @@ } else { | ||
result.errors.push(err); | ||
result.optionalTestErrors.push(err); | ||
result.failedTests.push(j); | ||
@@ -154,0 +161,0 @@ } else { |
{ | ||
"name": "owasp-password-strength-test", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"description": "A password-strength tester based upon the OWASP guidelines for enforcing strong passwords.", | ||
@@ -5,0 +5,0 @@ "main": "owasp-password-strength-test.js", |
@@ -8,3 +8,3 @@ OWASP Password Strength Test | ||
`owasp-password-strength-test` is not an OWASP project - it is simply based off | ||
`owasp-password-strength-test` is not an OWASP project - it is merely based off | ||
of OWASP research. | ||
@@ -84,2 +84,4 @@ | ||
failedTests : [], | ||
requiredTestErrors : [], | ||
optionalTestErrors : [], | ||
passedTests : [ 0, 1, 2, 3, 4, 5, 6 ], | ||
@@ -105,2 +107,10 @@ isPassphrase : false, | ||
passedTests : [ 1, 2, 3 ], | ||
requiredTestErrors : [ | ||
'The password must be at least 10 characters long.', | ||
], | ||
optionalTestErrors : [ | ||
'The password must contain at least one uppercase letter.', | ||
'The password must contain at least one number.', | ||
'The password must contain at least one special character.' | ||
], | ||
isPassphrase : false, | ||
@@ -123,2 +133,8 @@ strong : false, | ||
- `requiredTestErrors` is an array containing the error messages of required | ||
tests that have failed. | ||
- `optionalTestErrors` is an array containing the error messages of optional | ||
tests that have failed. | ||
- `isPassphrase` is a `boolean` indicating whether or not the password was | ||
@@ -125,0 +141,0 @@ considered to be a passphrase. |
28
test.js
@@ -12,2 +12,3 @@ var should = require('should'); | ||
result.errors.should.have.length(1); | ||
result.requiredTestErrors.should.have.length(1); | ||
result.failedTests.should.containEql(0); | ||
@@ -25,2 +26,3 @@ }); | ||
result.errors.should.have.length(1); | ||
result.requiredTestErrors.should.have.length(1); | ||
result.failedTests.should.containEql(1); | ||
@@ -33,5 +35,5 @@ }); | ||
result.errors.should.have.length(1); | ||
result.requiredTestErrors.should.have.length(1); | ||
result.failedTests.should.containEql(2); | ||
}); | ||
}); | ||
@@ -45,2 +47,4 @@ | ||
result.errors.should.be.empty; | ||
result.requiredTestErrors.should.be.empty; | ||
result.optionalTestErrors.should.be.empty; | ||
result.failedTests.should.be.empty; | ||
@@ -54,2 +58,3 @@ result.passedTests.should.eql([0, 1, 2, 3, 4, 5, 6]); | ||
result.errors.should.have.length(1); | ||
result.optionalTestErrors.should.have.length(1); | ||
result.failedTests.should.containEql(3); | ||
@@ -62,2 +67,3 @@ }); | ||
result.errors.should.have.length(1); | ||
result.optionalTestErrors.should.have.length(1); | ||
result.failedTests.should.containEql(4); | ||
@@ -70,2 +76,3 @@ }); | ||
result.errors.should.have.length(1); | ||
result.optionalTestErrors.should.have.length(1); | ||
result.failedTests.should.containEql(5); | ||
@@ -78,5 +85,24 @@ }); | ||
result.errors.should.have.length(1); | ||
result.optionalTestErrors.should.have.length(1); | ||
result.failedTests.should.containEql(6); | ||
}); | ||
it('the appropriate characters should be recognized as special', function() { | ||
// see: https://www.owasp.org/index.php/Password_special_characters | ||
var specials = ' !"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'.split(''); | ||
// test each special character | ||
specials.forEach(function(special) { | ||
var password = ['L0veSex', special, 'SecretGod'].join(''); | ||
var result = owasp.test(password); | ||
result.strong.should.be.true; | ||
result.errors.should.be.empty; | ||
result.requiredTestErrors.should.be.empty; | ||
result.optionalTestErrors.should.be.empty; | ||
result.failedTests.should.be.empty; | ||
result.passedTests.should.eql([0, 1, 2, 3, 4, 5, 6]); | ||
}); | ||
}); | ||
}); | ||
@@ -83,0 +109,0 @@ }); |
20115
296
241