{"action":"created","comment":{"url":"https://api.github.com/repos/metarhia/common/pulls/comments/209027005","pull_request_review_id":144961032,"id":209027005,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwOTAyNzAwNQ==","diff_hunk":"@@ -0,0 +1,172 @@\n+'use strict';\n+\n+const MAX_PASS_LENGTH = 128;\n+const MIN_PASS_LENGTH = 10;\n+const MIN_PHRASE_LENGTH = 20;\n+\n+const MIN_LOGIN_LENGTH = 6;\n+const MAX_LOGIN_LENGTH = 255;\n+\n+const passwordTests = {\n+  MIN_LENGTH: [\n+    password => password.length < MIN_PASS_LENGTH,\n+    `The password must be longer than ${MIN_PASS_LENGTH} characters`\n+  ],\n+  MAX_LENGTH: [\n+    password => password.length > MAX_PASS_LENGTH,\n+    `The password must be less than ${MAX_PASS_LENGTH} characters`\n+  ],\n+  MIN_PHRASE_LENGTH: [\n+    password => password.length < MIN_PHRASE_LENGTH,\n+    `The passphrase must be longer than ${MIN_PHRASE_LENGTH} characters`\n+  ],\n+  REPEAT_CHARS: [\n+    password => /(.)\\1{2,}/.test(password),\n+    'The password can not contain a sequence of repeated chars'\n+  ],\n+  ONE_LOWERCASE_CHAR: [\n+    password => !/[a-z]/.test(password),\n+    'The password must contain lowercase char'\n+  ],\n+  ONE_UPPERERCASE_CHAR: [\n+    password => !/[A-Z]/.test(password),\n+    'The password must contain uppercase char'\n+  ],\n+  ONE_NUMBER: [\n+    password => !/[0-9]/.test(password),\n+    'The password must contain number'\n+  ],\n+  ONE_SPECIAL_CHAR: [\n+    password => !/[^A-Za-z0-9]/.test(password),\n+    'The password must contain special char'\n+  ]\n+};\n+\n+const loginTests = {\n+  MIN_LENGTH: [\n+    login => login.length < MIN_LOGIN_LENGTH,\n+    `The login must be longer than ${MIN_LOGIN_LENGTH} characters`\n+  ],\n+  MAX_LENGTH: [\n+    login => login.length > MAX_LOGIN_LENGTH,\n+    `The login must be less than ${MAX_LOGIN_LENGTH} characters`\n+  ]\n+};\n+\n+const loginPasswordTests = {\n+  LOGIN_INCLUDES_PASSWORD: [\n+    (login, password) => login.includes(password),\n+    'The login can not contain a password'\n+  ],\n+  PASSWORD_INCLUDES_LOGIN: [\n+    (login, password) => password.includes(login),\n+    'The password can not contain a login'\n+  ]\n+};\n+\n+class AuthenticationStrength {\n+  constructor(\n+    hints, // Array, [{ required: Array, optional: Array }, ...]\n+    bestPercent // Number, percent of best test group\n+  ) {\n+    this.hints = hints;\n+    this.bestPercent = bestPercent;\n+  }\n+  get valid() {\n+    return !!this.bestPercent;\n+  }\n+  get strength() {\n+    if (this.bestPercent < 25) {\n+      return 'Very weak';\n+    } else if (this.bestPercent < 40) {\n+      return 'Weak';\n+    } else if (this.bestPercent < 60) {\n+      return 'Good';\n+    } else if (this.bestPercent < 80) {\n+      return 'Strong';\n+    } else {\n+      return 'Very strong';\n+    }\n+  }\n+}\n+\n+const makeTest = (\n+  // Function that checks the arguments on a test suite\n+  tests, // Array, array of password/login tests\n+  testGroups, // Array, [ [[requiredTest, ...], [optionalTest, ...]], ...]","path":"lib/authentication.js","position":96,"original_position":96,"commit_id":"e13b9ec05181ab82971349cef1bbe6f75c0fd03f","original_commit_id":"e13b9ec05181ab82971349cef1bbe6f75c0fd03f","user":{"login":"lundibundi","id":9109612,"node_id":"MDQ6VXNlcjkxMDk2MTI=","avatar_url":"https://avatars0.githubusercontent.com/u/9109612?v=4","gravatar_id":"","url":"https://api.github.com/users/lundibundi","html_url":"https://github.com/lundibundi","followers_url":"https://api.github.com/users/lundibundi/followers","following_url":"https://api.github.com/users/lundibundi/following{/other_user}","gists_url":"https://api.github.com/users/lundibundi/gists{/gist_id}","starred_url":"https://api.github.com/users/lundibundi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lundibundi/subscriptions","organizations_url":"https://api.github.com/users/lundibundi/orgs","repos_url":"https://api.github.com/users/lundibundi/repos","events_url":"https://api.github.com/users/lundibundi/events{/privacy}","received_events_url":"https://api.github.com/users/lundibundi/received_events","type":"User","site_admin":false},"body":"I don't understand why is it possible to have multiple groups of required and optional tests? Isn't it one array of required tests and one of optional? Then it's possible to just use\r\n```\r\n{\r\n  required: [],\r\n  optional: [],\r\n}\r\n```","created_at":"2018-08-09T18:06:47Z","updated_at":"2018-08-09T18:06:47Z","html_url":"https://github.com/metarhia/common/pull/154#discussion_r209027005","pull_request_url":"https://api.github.com/repos/metarhia/common/pulls/154","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/metarhia/common/pulls/comments/209027005"},"html":{"href":"https://github.com/metarhia/common/pull/154#discussion_r209027005"},"pull_request":{"href":"https://api.github.com/repos/metarhia/common/pulls/154"}}},"pull_request":{"url":"https://api.github.com/repos/metarhia/common/pulls/154","id":206471284,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA2NDcxMjg0","html_url":"https://github.com/metarhia/common/pull/154","diff_url":"https://github.com/metarhia/common/pull/154.diff","patch_url":"https://github.com/metarhia/common/pull/154.patch","issue_url":"https://api.github.com/repos/metarhia/common/issues/154","number":154,"state":"open","locked":false,"title":"Add owasp authentication library","user":{"login":"bugagashenkj","id":31734731,"node_id":"MDQ6VXNlcjMxNzM0NzMx","avatar_url":"https://avatars2.githubusercontent.com/u/31734731?v=4","gravatar_id":"","url":"https://api.github.com/users/bugagashenkj","html_url":"https://github.com/bugagashenkj","followers_url":"https://api.github.com/users/bugagashenkj/followers","following_url":"https://api.github.com/users/bugagashenkj/following{/other_user}","gists_url":"https://api.github.com/users/bugagashenkj/gists{/gist_id}","starred_url":"https://api.github.com/users/bugagashenkj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bugagashenkj/subscriptions","organizations_url":"https://api.github.com/users/bugagashenkj/orgs","repos_url":"https://api.github.com/users/bugagashenkj/repos","events_url":"https://api.github.com/users/bugagashenkj/events{/privacy}","received_events_url":"https://api.github.com/users/bugagashenkj/received_events","type":"User","site_admin":false},"body":"Close #148 ","created_at":"2018-08-06T17:50:21Z","updated_at":"2018-08-09T18:06:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"05679fbca11113cc6cfcdd25680877bbccd98f41","assignee":null,"assignees":[],"requested_reviewers":[{"login":"belochub","id":3501391,"node_id":"MDQ6VXNlcjM1MDEzOTE=","avatar_url":"https://avatars1.githubusercontent.com/u/3501391?v=4","gravatar_id":"","url":"https://api.github.com/users/belochub","html_url":"https://github.com/belochub","followers_url":"https://api.github.com/users/belochub/followers","following_url":"https://api.github.com/users/belochub/following{/other_user}","gists_url":"https://api.github.com/users/belochub/gists{/gist_id}","starred_url":"https://api.github.com/users/belochub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/belochub/subscriptions","organizations_url":"https://api.github.com/users/belochub/orgs","repos_url":"https://api.github.com/users/belochub/repos","events_url":"https://api.github.com/users/belochub/events{/privacy}","received_events_url":"https://api.github.com/users/belochub/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/metarhia/common/pulls/154/commits","review_comments_url":"https://api.github.com/repos/metarhia/common/pulls/154/comments","review_comment_url":"https://api.github.com/repos/metarhia/common/pulls/comments{/number}","comments_url":"https://api.github.com/repos/metarhia/common/issues/154/comments","statuses_url":"https://api.github.com/repos/metarhia/common/statuses/e13b9ec05181ab82971349cef1bbe6f75c0fd03f","head":{"label":"metarhia:authentication","ref":"authentication","sha":"e13b9ec05181ab82971349cef1bbe6f75c0fd03f","user":{"login":"metarhia","id":18060695,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4MDYwNjk1","avatar_url":"https://avatars2.githubusercontent.com/u/18060695?v=4","gravatar_id":"","url":"https://api.github.com/users/metarhia","html_url":"https://github.com/metarhia","followers_url":"https://api.github.com/users/metarhia/followers","following_url":"https://api.github.com/users/metarhia/following{/other_user}","gists_url":"https://api.github.com/users/metarhia/gists{/gist_id}","starred_url":"https://api.github.com/users/metarhia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metarhia/subscriptions","organizations_url":"https://api.github.com/users/metarhia/orgs","repos_url":"https://api.github.com/users/metarhia/repos","events_url":"https://api.github.com/users/metarhia/events{/privacy}","received_events_url":"https://api.github.com/users/metarhia/received_events","type":"Organization","site_admin":false},"repo":{"id":83913120,"node_id":"MDEwOlJlcG9zaXRvcnk4MzkxMzEyMA==","name":"common","full_name":"metarhia/common","owner":{"login":"metarhia","id":18060695,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4MDYwNjk1","avatar_url":"https://avatars2.githubusercontent.com/u/18060695?v=4","gravatar_id":"","url":"https://api.github.com/users/metarhia","html_url":"https://github.com/metarhia","followers_url":"https://api.github.com/users/metarhia/followers","following_url":"https://api.github.com/users/metarhia/following{/other_user}","gists_url":"https://api.github.com/users/metarhia/gists{/gist_id}","starred_url":"https://api.github.com/users/metarhia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metarhia/subscriptions","organizations_url":"https://api.github.com/users/metarhia/orgs","repos_url":"https://api.github.com/users/metarhia/repos","events_url":"https://api.github.com/users/metarhia/events{/privacy}","received_events_url":"https://api.github.com/users/metarhia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/metarhia/common","description":"Metarhia Common Library","fork":false,"url":"https://api.github.com/repos/metarhia/common","forks_url":"https://api.github.com/repos/metarhia/common/forks","keys_url":"https://api.github.com/repos/metarhia/common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/metarhia/common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/metarhia/common/teams","hooks_url":"https://api.github.com/repos/metarhia/common/hooks","issue_events_url":"https://api.github.com/repos/metarhia/common/issues/events{/number}","events_url":"https://api.github.com/repos/metarhia/common/events","assignees_url":"https://api.github.com/repos/metarhia/common/assignees{/user}","branches_url":"https://api.github.com/repos/metarhia/common/branches{/branch}","tags_url":"https://api.github.com/repos/metarhia/common/tags","blobs_url":"https://api.github.com/repos/metarhia/common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/metarhia/common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/metarhia/common/git/refs{/sha}","trees_url":"https://api.github.com/repos/metarhia/common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/metarhia/common/statuses/{sha}","languages_url":"https://api.github.com/repos/metarhia/common/languages","stargazers_url":"https://api.github.com/repos/metarhia/common/stargazers","contributors_url":"https://api.github.com/repos/metarhia/common/contributors","subscribers_url":"https://api.github.com/repos/metarhia/common/subscribers","subscription_url":"https://api.github.com/repos/metarhia/common/subscription","commits_url":"https://api.github.com/repos/metarhia/common/commits{/sha}","git_commits_url":"https://api.github.com/repos/metarhia/common/git/commits{/sha}","comments_url":"https://api.github.com/repos/metarhia/common/comments{/number}","issue_comment_url":"https://api.github.com/repos/metarhia/common/issues/comments{/number}","contents_url":"https://api.github.com/repos/metarhia/common/contents/{+path}","compare_url":"https://api.github.com/repos/metarhia/common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/metarhia/common/merges","archive_url":"https://api.github.com/repos/metarhia/common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/metarhia/common/downloads","issues_url":"https://api.github.com/repos/metarhia/common/issues{/number}","pulls_url":"https://api.github.com/repos/metarhia/common/pulls{/number}","milestones_url":"https://api.github.com/repos/metarhia/common/milestones{/number}","notifications_url":"https://api.github.com/repos/metarhia/common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/metarhia/common/labels{/name}","releases_url":"https://api.github.com/repos/metarhia/common/releases{/id}","deployments_url":"https://api.github.com/repos/metarhia/common/deployments","created_at":"2017-03-04T17:54:15Z","updated_at":"2018-08-07T13:30:11Z","pushed_at":"2018-08-09T13:38:39Z","git_url":"git://github.com/metarhia/common.git","ssh_url":"git@github.com:metarhia/common.git","clone_url":"https://github.com/metarhia/common.git","svn_url":"https://github.com/metarhia/common","homepage":null,"size":373,"stargazers_count":25,"watchers_count":25,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"archived":false,"open_issues_count":23,"license":null,"forks":6,"open_issues":23,"watchers":25,"default_branch":"master"}},"base":{"label":"metarhia:master","ref":"master","sha":"3e2fcffa2dd9a6668e7023d798a7a322dff62a80","user":{"login":"metarhia","id":18060695,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4MDYwNjk1","avatar_url":"https://avatars2.githubusercontent.com/u/18060695?v=4","gravatar_id":"","url":"https://api.github.com/users/metarhia","html_url":"https://github.com/metarhia","followers_url":"https://api.github.com/users/metarhia/followers","following_url":"https://api.github.com/users/metarhia/following{/other_user}","gists_url":"https://api.github.com/users/metarhia/gists{/gist_id}","starred_url":"https://api.github.com/users/metarhia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metarhia/subscriptions","organizations_url":"https://api.github.com/users/metarhia/orgs","repos_url":"https://api.github.com/users/metarhia/repos","events_url":"https://api.github.com/users/metarhia/events{/privacy}","received_events_url":"https://api.github.com/users/metarhia/received_events","type":"Organization","site_admin":false},"repo":{"id":83913120,"node_id":"MDEwOlJlcG9zaXRvcnk4MzkxMzEyMA==","name":"common","full_name":"metarhia/common","owner":{"login":"metarhia","id":18060695,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4MDYwNjk1","avatar_url":"https://avatars2.githubusercontent.com/u/18060695?v=4","gravatar_id":"","url":"https://api.github.com/users/metarhia","html_url":"https://github.com/metarhia","followers_url":"https://api.github.com/users/metarhia/followers","following_url":"https://api.github.com/users/metarhia/following{/other_user}","gists_url":"https://api.github.com/users/metarhia/gists{/gist_id}","starred_url":"https://api.github.com/users/metarhia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metarhia/subscriptions","organizations_url":"https://api.github.com/users/metarhia/orgs","repos_url":"https://api.github.com/users/metarhia/repos","events_url":"https://api.github.com/users/metarhia/events{/privacy}","received_events_url":"https://api.github.com/users/metarhia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/metarhia/common","description":"Metarhia Common Library","fork":false,"url":"https://api.github.com/repos/metarhia/common","forks_url":"https://api.github.com/repos/metarhia/common/forks","keys_url":"https://api.github.com/repos/metarhia/common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/metarhia/common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/metarhia/common/teams","hooks_url":"https://api.github.com/repos/metarhia/common/hooks","issue_events_url":"https://api.github.com/repos/metarhia/common/issues/events{/number}","events_url":"https://api.github.com/repos/metarhia/common/events","assignees_url":"https://api.github.com/repos/metarhia/common/assignees{/user}","branches_url":"https://api.github.com/repos/metarhia/common/branches{/branch}","tags_url":"https://api.github.com/repos/metarhia/common/tags","blobs_url":"https://api.github.com/repos/metarhia/common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/metarhia/common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/metarhia/common/git/refs{/sha}","trees_url":"https://api.github.com/repos/metarhia/common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/metarhia/common/statuses/{sha}","languages_url":"https://api.github.com/repos/metarhia/common/languages","stargazers_url":"https://api.github.com/repos/metarhia/common/stargazers","contributors_url":"https://api.github.com/repos/metarhia/common/contributors","subscribers_url":"https://api.github.com/repos/metarhia/common/subscribers","subscription_url":"https://api.github.com/repos/metarhia/common/subscription","commits_url":"https://api.github.com/repos/metarhia/common/commits{/sha}","git_commits_url":"https://api.github.com/repos/metarhia/common/git/commits{/sha}","comments_url":"https://api.github.com/repos/metarhia/common/comments{/number}","issue_comment_url":"https://api.github.com/repos/metarhia/common/issues/comments{/number}","contents_url":"https://api.github.com/repos/metarhia/common/contents/{+path}","compare_url":"https://api.github.com/repos/metarhia/common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/metarhia/common/merges","archive_url":"https://api.github.com/repos/metarhia/common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/metarhia/common/downloads","issues_url":"https://api.github.com/repos/metarhia/common/issues{/number}","pulls_url":"https://api.github.com/repos/metarhia/common/pulls{/number}","milestones_url":"https://api.github.com/repos/metarhia/common/milestones{/number}","notifications_url":"https://api.github.com/repos/metarhia/common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/metarhia/common/labels{/name}","releases_url":"https://api.github.com/repos/metarhia/common/releases{/id}","deployments_url":"https://api.github.com/repos/metarhia/common/deployments","created_at":"2017-03-04T17:54:15Z","updated_at":"2018-08-07T13:30:11Z","pushed_at":"2018-08-09T13:38:39Z","git_url":"git://github.com/metarhia/common.git","ssh_url":"git@github.com:metarhia/common.git","clone_url":"https://github.com/metarhia/common.git","svn_url":"https://github.com/metarhia/common","homepage":null,"size":373,"stargazers_count":25,"watchers_count":25,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"archived":false,"open_issues_count":23,"license":null,"forks":6,"open_issues":23,"watchers":25,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/metarhia/common/pulls/154"},"html":{"href":"https://github.com/metarhia/common/pull/154"},"issue":{"href":"https://api.github.com/repos/metarhia/common/issues/154"},"comments":{"href":"https://api.github.com/repos/metarhia/common/issues/154/comments"},"review_comments":{"href":"https://api.github.com/repos/metarhia/common/pulls/154/comments"},"review_comment":{"href":"https://api.github.com/repos/metarhia/common/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/metarhia/common/pulls/154/commits"},"statuses":{"href":"https://api.github.com/repos/metarhia/common/statuses/e13b9ec05181ab82971349cef1bbe6f75c0fd03f"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"lundibundi"}}