2019-07-26 03:47:36 +02:00
|
|
|
set_global('zxcvbn', zrequire('zxcvbn', 'zxcvbn'));
|
2017-11-08 18:30:12 +01:00
|
|
|
zrequire('common');
|
2017-01-09 21:51:22 +01:00
|
|
|
|
2017-06-29 16:26:48 +02:00
|
|
|
set_global('i18n', global.stub_i18n);
|
|
|
|
|
2018-05-15 12:40:07 +02:00
|
|
|
run_test('basics', () => {
|
2019-11-02 00:06:25 +01:00
|
|
|
let accepted;
|
|
|
|
let password;
|
|
|
|
let warning;
|
2017-01-09 21:51:22 +01:00
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const bar = (function () {
|
|
|
|
const self = {};
|
2017-01-09 21:51:22 +01:00
|
|
|
|
|
|
|
self.width = function (width) {
|
|
|
|
self.w = width;
|
|
|
|
return self;
|
|
|
|
};
|
|
|
|
|
|
|
|
self.removeClass = function (arg) {
|
|
|
|
assert.equal(arg, 'bar-success bar-danger');
|
|
|
|
return self;
|
|
|
|
};
|
|
|
|
|
|
|
|
self.addClass = function (arg) {
|
|
|
|
self.added_class = arg;
|
|
|
|
return self;
|
|
|
|
};
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}());
|
|
|
|
|
passwords: Express the quality threshold as guesses required.
The original "quality score" was invented purely for populating
our password-strength progress bar, and isn't expressed in terms
that are particularly meaningful. For configuration and the core
accept/reject logic, it's better to use units that are readily
understood. Switch to those.
I considered using "bits of entropy", defined loosely as the log
of this number, but both the zxcvbn paper and the linked CACM
article (which I recommend!) are written in terms of the number
of guesses. And reading (most of) those two papers made me
less happy about referring to "entropy" in our terminology.
I already knew that notion was a little fuzzy if looked at
too closely, and I gained a better appreciation of how it's
contributed to confusion in discussing password policies and
to adoption of perverse policies that favor "Password1!" over
"derived unusual ravioli raft". So, "guesses" it is.
And although the log is handy for some analysis purposes
(certainly for a graph like those in the zxcvbn paper), it adds
a layer of abstraction, and I think makes it harder to think
clearly about attacks, especially in the online setting. So
just use the actual number, and if someone wants to set a
gigantic value, they will have the pleasure of seeing just
how many digits are involved.
(Thanks to @YJDave for a prototype that the code changes in this
commit are based on.)
2017-10-03 19:48:06 +02:00
|
|
|
function password_field(min_length, min_guesses) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const self = {};
|
2017-01-09 21:51:22 +01:00
|
|
|
|
|
|
|
self.data = function (field) {
|
|
|
|
if (field === 'minLength') {
|
|
|
|
return min_length;
|
passwords: Express the quality threshold as guesses required.
The original "quality score" was invented purely for populating
our password-strength progress bar, and isn't expressed in terms
that are particularly meaningful. For configuration and the core
accept/reject logic, it's better to use units that are readily
understood. Switch to those.
I considered using "bits of entropy", defined loosely as the log
of this number, but both the zxcvbn paper and the linked CACM
article (which I recommend!) are written in terms of the number
of guesses. And reading (most of) those two papers made me
less happy about referring to "entropy" in our terminology.
I already knew that notion was a little fuzzy if looked at
too closely, and I gained a better appreciation of how it's
contributed to confusion in discussing password policies and
to adoption of perverse policies that favor "Password1!" over
"derived unusual ravioli raft". So, "guesses" it is.
And although the log is handy for some analysis purposes
(certainly for a graph like those in the zxcvbn paper), it adds
a layer of abstraction, and I think makes it harder to think
clearly about attacks, especially in the online setting. So
just use the actual number, and if someone wants to set a
gigantic value, they will have the pleasure of seeing just
how many digits are involved.
(Thanks to @YJDave for a prototype that the code changes in this
commit are based on.)
2017-10-03 19:48:06 +02:00
|
|
|
} else if (field === 'minGuesses') {
|
|
|
|
return min_guesses;
|
2017-01-09 21:51:22 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
password = 'z!X4@S_&';
|
passwords: Express the quality threshold as guesses required.
The original "quality score" was invented purely for populating
our password-strength progress bar, and isn't expressed in terms
that are particularly meaningful. For configuration and the core
accept/reject logic, it's better to use units that are readily
understood. Switch to those.
I considered using "bits of entropy", defined loosely as the log
of this number, but both the zxcvbn paper and the linked CACM
article (which I recommend!) are written in terms of the number
of guesses. And reading (most of) those two papers made me
less happy about referring to "entropy" in our terminology.
I already knew that notion was a little fuzzy if looked at
too closely, and I gained a better appreciation of how it's
contributed to confusion in discussing password policies and
to adoption of perverse policies that favor "Password1!" over
"derived unusual ravioli raft". So, "guesses" it is.
And although the log is handy for some analysis purposes
(certainly for a graph like those in the zxcvbn paper), it adds
a layer of abstraction, and I think makes it harder to think
clearly about attacks, especially in the online setting. So
just use the actual number, and if someone wants to set a
gigantic value, they will have the pleasure of seeing just
how many digits are involved.
(Thanks to @YJDave for a prototype that the code changes in this
commit are based on.)
2017-10-03 19:48:06 +02:00
|
|
|
accepted = common.password_quality(password, bar, password_field(10, 80000));
|
2017-01-09 21:51:22 +01:00
|
|
|
assert(!accepted);
|
|
|
|
assert.equal(bar.w, '39.7%');
|
|
|
|
assert.equal(bar.added_class, 'bar-danger');
|
2017-06-29 16:26:48 +02:00
|
|
|
warning = common.password_warning(password, password_field(10));
|
|
|
|
assert.equal(warning, 'translated: Password should be at least 10 characters long');
|
2017-01-09 21:51:22 +01:00
|
|
|
|
|
|
|
password = 'foo';
|
passwords: Express the quality threshold as guesses required.
The original "quality score" was invented purely for populating
our password-strength progress bar, and isn't expressed in terms
that are particularly meaningful. For configuration and the core
accept/reject logic, it's better to use units that are readily
understood. Switch to those.
I considered using "bits of entropy", defined loosely as the log
of this number, but both the zxcvbn paper and the linked CACM
article (which I recommend!) are written in terms of the number
of guesses. And reading (most of) those two papers made me
less happy about referring to "entropy" in our terminology.
I already knew that notion was a little fuzzy if looked at
too closely, and I gained a better appreciation of how it's
contributed to confusion in discussing password policies and
to adoption of perverse policies that favor "Password1!" over
"derived unusual ravioli raft". So, "guesses" it is.
And although the log is handy for some analysis purposes
(certainly for a graph like those in the zxcvbn paper), it adds
a layer of abstraction, and I think makes it harder to think
clearly about attacks, especially in the online setting. So
just use the actual number, and if someone wants to set a
gigantic value, they will have the pleasure of seeing just
how many digits are involved.
(Thanks to @YJDave for a prototype that the code changes in this
commit are based on.)
2017-10-03 19:48:06 +02:00
|
|
|
accepted = common.password_quality(password, bar, password_field(2, 200));
|
2017-01-09 21:51:22 +01:00
|
|
|
assert(accepted);
|
|
|
|
assert.equal(bar.w, '10.390277164940581%');
|
|
|
|
assert.equal(bar.added_class, 'bar-success');
|
2017-06-29 16:26:48 +02:00
|
|
|
warning = common.password_warning(password, password_field(2));
|
|
|
|
assert.equal(warning, 'translated: Password is too weak');
|
2017-05-23 00:53:53 +02:00
|
|
|
|
|
|
|
password = 'aaaaaaaa';
|
passwords: Express the quality threshold as guesses required.
The original "quality score" was invented purely for populating
our password-strength progress bar, and isn't expressed in terms
that are particularly meaningful. For configuration and the core
accept/reject logic, it's better to use units that are readily
understood. Switch to those.
I considered using "bits of entropy", defined loosely as the log
of this number, but both the zxcvbn paper and the linked CACM
article (which I recommend!) are written in terms of the number
of guesses. And reading (most of) those two papers made me
less happy about referring to "entropy" in our terminology.
I already knew that notion was a little fuzzy if looked at
too closely, and I gained a better appreciation of how it's
contributed to confusion in discussing password policies and
to adoption of perverse policies that favor "Password1!" over
"derived unusual ravioli raft". So, "guesses" it is.
And although the log is handy for some analysis purposes
(certainly for a graph like those in the zxcvbn paper), it adds
a layer of abstraction, and I think makes it harder to think
clearly about attacks, especially in the online setting. So
just use the actual number, and if someone wants to set a
gigantic value, they will have the pleasure of seeing just
how many digits are involved.
(Thanks to @YJDave for a prototype that the code changes in this
commit are based on.)
2017-10-03 19:48:06 +02:00
|
|
|
accepted = common.password_quality(password, bar, password_field(6, 1e100));
|
2017-05-23 00:53:53 +02:00
|
|
|
assert(!accepted);
|
|
|
|
assert.equal(bar.added_class, 'bar-danger');
|
2017-06-29 16:26:48 +02:00
|
|
|
warning = common.password_warning(password, password_field(6));
|
|
|
|
assert.equal(warning, 'Repeats like "aaa" are easy to guess');
|
2017-05-23 00:53:53 +02:00
|
|
|
|
|
|
|
delete global.zxcvbn;
|
|
|
|
password = 'aaaaaaaa';
|
passwords: Express the quality threshold as guesses required.
The original "quality score" was invented purely for populating
our password-strength progress bar, and isn't expressed in terms
that are particularly meaningful. For configuration and the core
accept/reject logic, it's better to use units that are readily
understood. Switch to those.
I considered using "bits of entropy", defined loosely as the log
of this number, but both the zxcvbn paper and the linked CACM
article (which I recommend!) are written in terms of the number
of guesses. And reading (most of) those two papers made me
less happy about referring to "entropy" in our terminology.
I already knew that notion was a little fuzzy if looked at
too closely, and I gained a better appreciation of how it's
contributed to confusion in discussing password policies and
to adoption of perverse policies that favor "Password1!" over
"derived unusual ravioli raft". So, "guesses" it is.
And although the log is handy for some analysis purposes
(certainly for a graph like those in the zxcvbn paper), it adds
a layer of abstraction, and I think makes it harder to think
clearly about attacks, especially in the online setting. So
just use the actual number, and if someone wants to set a
gigantic value, they will have the pleasure of seeing just
how many digits are involved.
(Thanks to @YJDave for a prototype that the code changes in this
commit are based on.)
2017-10-03 19:48:06 +02:00
|
|
|
accepted = common.password_quality(password, bar, password_field(6, 1e100));
|
2017-05-23 00:53:53 +02:00
|
|
|
assert(accepted === undefined);
|
2017-06-29 16:26:48 +02:00
|
|
|
warning = common.password_warning(password, password_field(6));
|
|
|
|
assert(warning === undefined);
|
2018-05-15 12:40:07 +02:00
|
|
|
});
|