{"action":"created","comment":{"url":"https://api.github.com/repos/zaproxy/zaproxy/pulls/comments/213345213","pull_request_review_id":150161172,"id":213345213,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMzM0NTIxMw==","diff_hunk":"@@ -320,47 +326,63 @@ public WebSession authenticate(SessionManagementMethod sessionManagementMethod,\n \t\t}\n \t\t\n \t\t/**\n-\t\t * Modifies the input {@code requestMessage} by replacing fresh anti-CSRF token value in the request body.  \n-\t\t * It first checks if the input {@code requestMessage} has an anti-CSRF token.\n-\t\t * If yes, then it makes a {@code GET} request to the login page in order to renew the anti-CSRF token.\n-\t\t * Then it modifies the input {@code requestMessage} with the regenerated anti-CSRF token value.\n-\t\t * If the first {@code POST} login request does not have anti-CSRF token\n+\t\t * <strong>Modifies</strong> the input {@code requestMessage} by replacing \n+\t\t * old ACSRF token value with the fresh one in the request body.  \n+\t\t * It first checks if the input {@code loginMsgWithFreshAcsrfToken} has any anti-CSRF token.\n+\t\t * If yes, then it modifies the input {@code requestMessage} with the fresh anti-CSRF token value.\n+\t\t * If the {@code loginMsgWithFreshAcsrfToken} does not have any ACSRF token \n \t\t * then the input {@code requestMessage} is left as it is.\n \t\t * \n-\t\t * @param requestMessage the login request message with correct credential\n-\t\t * @param user the user of the context\n+\t\t * @param requestMessage the login ({@code POST})request message with correct credentials\n+\t\t * @param loginMsgWithFreshAcsrfToken the {@code HttpMessage} of the login page(/form) with fresh cookie and ACSRF token. \n \t\t * @throws IOException if problem occurs when sending login request to get login page.\n \t\t */\n-\t\tprivate void replaceAntiCsrfTokenValueIfRequired(HttpMessage requestMessage, User user) throws IOException {\n+\t\tprivate void replaceAntiCsrfTokenValueIfRequired(HttpMessage requestMessage, HttpMessage loginMsgWithFreshAcsrfToken) throws IOException {\n \t\t\tif(extAntiCsrf == null) {\n \t\t\t\textAntiCsrf = Control.getSingleton().getExtensionLoader().getExtension(ExtensionAntiCSRF.class);\n \t\t\t}\n-\t\t\tList<AntiCsrfToken> antiCsrfTokensOfFirstLoginMsg = null;\n+\t\t\tList<AntiCsrfToken> freshAcsrfTokens = null;\n   \t\t\tif(extAntiCsrf != null) {\n-\t\t\t\tantiCsrfTokensOfFirstLoginMsg = extAntiCsrf.getTokens(requestMessage);\n-\t\t\t}\n-\t\t\tAntiCsrfToken antiCsrfTokenOfFirstLoginMsg = null;\n-\t\t\tif(antiCsrfTokensOfFirstLoginMsg != null && antiCsrfTokensOfFirstLoginMsg.size() > 0) {\n-\t\t\t\tantiCsrfTokenOfFirstLoginMsg = antiCsrfTokensOfFirstLoginMsg.get(0);\n+\t\t\t\tfreshAcsrfTokens = extAntiCsrf.getTokensFromResponse(loginMsgWithFreshAcsrfToken);\n+\t\t\t} else {\n+\t\t\t\tLOGGER.warn(\"ExtensionAntiCSRF is not available, skipping ACSRF replacing task\");\n+\t\t\t\treturn;\n \t\t\t}\n-\t\t\t\n-\t\t\tif (antiCsrfTokenOfFirstLoginMsg != null) {\n-\t\t\t\tHttpMessage loginMsgToRegenerateAntiCsrfToken = antiCsrfTokenOfFirstLoginMsg.getMsg().cloneAll();\n-\t\t\t\tloginMsgToRegenerateAntiCsrfToken.setRequestingUser(user);\n-\t\t\t\t\n-\t\t\t\t// Clear any session identifiers\n-\t\t\t\tloginMsgToRegenerateAntiCsrfToken.getRequestHeader().setHeader(HttpRequestHeader.COOKIE, null);\n+\t\t\tif(freshAcsrfTokens != null && freshAcsrfTokens.size() > 0) {","path":"src/org/zaproxy/zap/authentication/PostBasedAuthenticationMethodType.java","position":69,"original_position":69,"commit_id":"a40113500612f8fab703a71195ea92628dc3ee8a","original_commit_id":"a40113500612f8fab703a71195ea92628dc3ee8a","user":{"login":"thc202","id":4639210,"node_id":"MDQ6VXNlcjQ2MzkyMTA=","avatar_url":"https://avatars0.githubusercontent.com/u/4639210?v=4","gravatar_id":"","url":"https://api.github.com/users/thc202","html_url":"https://github.com/thc202","followers_url":"https://api.github.com/users/thc202/followers","following_url":"https://api.github.com/users/thc202/following{/other_user}","gists_url":"https://api.github.com/users/thc202/gists{/gist_id}","starred_url":"https://api.github.com/users/thc202/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thc202/subscriptions","organizations_url":"https://api.github.com/users/thc202/orgs","repos_url":"https://api.github.com/users/thc202/repos","events_url":"https://api.github.com/users/thc202/events{/privacy}","received_events_url":"https://api.github.com/users/thc202/received_events","type":"User","site_admin":false},"body":"We could invert the condition and return sooner (like done in the previous if), to reduce nesting.","created_at":"2018-08-28T14:47:34Z","updated_at":"2018-08-28T14:50:13Z","html_url":"https://github.com/zaproxy/zaproxy/pull/4696#discussion_r213345213","pull_request_url":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4696","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/zaproxy/zaproxy/pulls/comments/213345213"},"html":{"href":"https://github.com/zaproxy/zaproxy/pull/4696#discussion_r213345213"},"pull_request":{"href":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4696"}}},"pull_request":{"url":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4696","id":190920204,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkwOTIwMjA0","html_url":"https://github.com/zaproxy/zaproxy/pull/4696","diff_url":"https://github.com/zaproxy/zaproxy/pull/4696.diff","patch_url":"https://github.com/zaproxy/zaproxy/pull/4696.patch","issue_url":"https://api.github.com/repos/zaproxy/zaproxy/issues/4696","number":4696,"state":"open","locked":false,"title":"Replace fresh ACSRF token value without directly relying on the old ACSRF token value","user":{"login":"KajanM","id":17596394,"node_id":"MDQ6VXNlcjE3NTk2Mzk0","avatar_url":"https://avatars1.githubusercontent.com/u/17596394?v=4","gravatar_id":"","url":"https://api.github.com/users/KajanM","html_url":"https://github.com/KajanM","followers_url":"https://api.github.com/users/KajanM/followers","following_url":"https://api.github.com/users/KajanM/following{/other_user}","gists_url":"https://api.github.com/users/KajanM/gists{/gist_id}","starred_url":"https://api.github.com/users/KajanM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KajanM/subscriptions","organizations_url":"https://api.github.com/users/KajanM/orgs","repos_url":"https://api.github.com/users/KajanM/repos","events_url":"https://api.github.com/users/KajanM/events{/privacy}","received_events_url":"https://api.github.com/users/KajanM/received_events","type":"User","site_admin":false},"body":"fix for #1370 ","created_at":"2018-05-28T12:38:10Z","updated_at":"2018-08-28T14:50:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d181de3f2d0183dad97160c59cbf6d8b0f5a56f0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":220536002,"node_id":"MDU6TGFiZWwyMjA1MzYwMDI=","url":"https://api.github.com/repos/zaproxy/zaproxy/labels/Type-Task","name":"Type-Task","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4696/commits","review_comments_url":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4696/comments","review_comment_url":"https://api.github.com/repos/zaproxy/zaproxy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zaproxy/zaproxy/issues/4696/comments","statuses_url":"https://api.github.com/repos/zaproxy/zaproxy/statuses/a40113500612f8fab703a71195ea92628dc3ee8a","head":{"label":"KajanM:renew-cookie-before-each-login","ref":"renew-cookie-before-each-login","sha":"a40113500612f8fab703a71195ea92628dc3ee8a","user":{"login":"KajanM","id":17596394,"node_id":"MDQ6VXNlcjE3NTk2Mzk0","avatar_url":"https://avatars1.githubusercontent.com/u/17596394?v=4","gravatar_id":"","url":"https://api.github.com/users/KajanM","html_url":"https://github.com/KajanM","followers_url":"https://api.github.com/users/KajanM/followers","following_url":"https://api.github.com/users/KajanM/following{/other_user}","gists_url":"https://api.github.com/users/KajanM/gists{/gist_id}","starred_url":"https://api.github.com/users/KajanM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KajanM/subscriptions","organizations_url":"https://api.github.com/users/KajanM/orgs","repos_url":"https://api.github.com/users/KajanM/repos","events_url":"https://api.github.com/users/KajanM/events{/privacy}","received_events_url":"https://api.github.com/users/KajanM/received_events","type":"User","site_admin":false},"repo":{"id":122687100,"node_id":"MDEwOlJlcG9zaXRvcnkxMjI2ODcxMDA=","name":"zaproxy","full_name":"KajanM/zaproxy","owner":{"login":"KajanM","id":17596394,"node_id":"MDQ6VXNlcjE3NTk2Mzk0","avatar_url":"https://avatars1.githubusercontent.com/u/17596394?v=4","gravatar_id":"","url":"https://api.github.com/users/KajanM","html_url":"https://github.com/KajanM","followers_url":"https://api.github.com/users/KajanM/followers","following_url":"https://api.github.com/users/KajanM/following{/other_user}","gists_url":"https://api.github.com/users/KajanM/gists{/gist_id}","starred_url":"https://api.github.com/users/KajanM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KajanM/subscriptions","organizations_url":"https://api.github.com/users/KajanM/orgs","repos_url":"https://api.github.com/users/KajanM/repos","events_url":"https://api.github.com/users/KajanM/events{/privacy}","received_events_url":"https://api.github.com/users/KajanM/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/KajanM/zaproxy","description":"The OWASP ZAP core project","fork":true,"url":"https://api.github.com/repos/KajanM/zaproxy","forks_url":"https://api.github.com/repos/KajanM/zaproxy/forks","keys_url":"https://api.github.com/repos/KajanM/zaproxy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KajanM/zaproxy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KajanM/zaproxy/teams","hooks_url":"https://api.github.com/repos/KajanM/zaproxy/hooks","issue_events_url":"https://api.github.com/repos/KajanM/zaproxy/issues/events{/number}","events_url":"https://api.github.com/repos/KajanM/zaproxy/events","assignees_url":"https://api.github.com/repos/KajanM/zaproxy/assignees{/user}","branches_url":"https://api.github.com/repos/KajanM/zaproxy/branches{/branch}","tags_url":"https://api.github.com/repos/KajanM/zaproxy/tags","blobs_url":"https://api.github.com/repos/KajanM/zaproxy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KajanM/zaproxy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KajanM/zaproxy/git/refs{/sha}","trees_url":"https://api.github.com/repos/KajanM/zaproxy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KajanM/zaproxy/statuses/{sha}","languages_url":"https://api.github.com/repos/KajanM/zaproxy/languages","stargazers_url":"https://api.github.com/repos/KajanM/zaproxy/stargazers","contributors_url":"https://api.github.com/repos/KajanM/zaproxy/contributors","subscribers_url":"https://api.github.com/repos/KajanM/zaproxy/subscribers","subscription_url":"https://api.github.com/repos/KajanM/zaproxy/subscription","commits_url":"https://api.github.com/repos/KajanM/zaproxy/commits{/sha}","git_commits_url":"https://api.github.com/repos/KajanM/zaproxy/git/commits{/sha}","comments_url":"https://api.github.com/repos/KajanM/zaproxy/comments{/number}","issue_comment_url":"https://api.github.com/repos/KajanM/zaproxy/issues/comments{/number}","contents_url":"https://api.github.com/repos/KajanM/zaproxy/contents/{+path}","compare_url":"https://api.github.com/repos/KajanM/zaproxy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KajanM/zaproxy/merges","archive_url":"https://api.github.com/repos/KajanM/zaproxy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KajanM/zaproxy/downloads","issues_url":"https://api.github.com/repos/KajanM/zaproxy/issues{/number}","pulls_url":"https://api.github.com/repos/KajanM/zaproxy/pulls{/number}","milestones_url":"https://api.github.com/repos/KajanM/zaproxy/milestones{/number}","notifications_url":"https://api.github.com/repos/KajanM/zaproxy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KajanM/zaproxy/labels{/name}","releases_url":"https://api.github.com/repos/KajanM/zaproxy/releases{/id}","deployments_url":"https://api.github.com/repos/KajanM/zaproxy/deployments","created_at":"2018-02-24T00:30:38Z","updated_at":"2018-06-27T05:35:43Z","pushed_at":"2018-08-21T19:31:52Z","git_url":"git://github.com/KajanM/zaproxy.git","ssh_url":"git@github.com:KajanM/zaproxy.git","clone_url":"https://github.com/KajanM/zaproxy.git","svn_url":"https://github.com/KajanM/zaproxy","homepage":null,"size":177060,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"zaproxy:develop","ref":"develop","sha":"e707687a5af95fc96a65d036b5fea31194f1845f","user":{"login":"zaproxy","id":6716868,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY3MTY4Njg=","avatar_url":"https://avatars2.githubusercontent.com/u/6716868?v=4","gravatar_id":"","url":"https://api.github.com/users/zaproxy","html_url":"https://github.com/zaproxy","followers_url":"https://api.github.com/users/zaproxy/followers","following_url":"https://api.github.com/users/zaproxy/following{/other_user}","gists_url":"https://api.github.com/users/zaproxy/gists{/gist_id}","starred_url":"https://api.github.com/users/zaproxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaproxy/subscriptions","organizations_url":"https://api.github.com/users/zaproxy/orgs","repos_url":"https://api.github.com/users/zaproxy/repos","events_url":"https://api.github.com/users/zaproxy/events{/privacy}","received_events_url":"https://api.github.com/users/zaproxy/received_events","type":"Organization","site_admin":false},"repo":{"id":36817565,"node_id":"MDEwOlJlcG9zaXRvcnkzNjgxNzU2NQ==","name":"zaproxy","full_name":"zaproxy/zaproxy","owner":{"login":"zaproxy","id":6716868,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY3MTY4Njg=","avatar_url":"https://avatars2.githubusercontent.com/u/6716868?v=4","gravatar_id":"","url":"https://api.github.com/users/zaproxy","html_url":"https://github.com/zaproxy","followers_url":"https://api.github.com/users/zaproxy/followers","following_url":"https://api.github.com/users/zaproxy/following{/other_user}","gists_url":"https://api.github.com/users/zaproxy/gists{/gist_id}","starred_url":"https://api.github.com/users/zaproxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaproxy/subscriptions","organizations_url":"https://api.github.com/users/zaproxy/orgs","repos_url":"https://api.github.com/users/zaproxy/repos","events_url":"https://api.github.com/users/zaproxy/events{/privacy}","received_events_url":"https://api.github.com/users/zaproxy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zaproxy/zaproxy","description":"The OWASP ZAP core project","fork":false,"url":"https://api.github.com/repos/zaproxy/zaproxy","forks_url":"https://api.github.com/repos/zaproxy/zaproxy/forks","keys_url":"https://api.github.com/repos/zaproxy/zaproxy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zaproxy/zaproxy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zaproxy/zaproxy/teams","hooks_url":"https://api.github.com/repos/zaproxy/zaproxy/hooks","issue_events_url":"https://api.github.com/repos/zaproxy/zaproxy/issues/events{/number}","events_url":"https://api.github.com/repos/zaproxy/zaproxy/events","assignees_url":"https://api.github.com/repos/zaproxy/zaproxy/assignees{/user}","branches_url":"https://api.github.com/repos/zaproxy/zaproxy/branches{/branch}","tags_url":"https://api.github.com/repos/zaproxy/zaproxy/tags","blobs_url":"https://api.github.com/repos/zaproxy/zaproxy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zaproxy/zaproxy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zaproxy/zaproxy/git/refs{/sha}","trees_url":"https://api.github.com/repos/zaproxy/zaproxy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zaproxy/zaproxy/statuses/{sha}","languages_url":"https://api.github.com/repos/zaproxy/zaproxy/languages","stargazers_url":"https://api.github.com/repos/zaproxy/zaproxy/stargazers","contributors_url":"https://api.github.com/repos/zaproxy/zaproxy/contributors","subscribers_url":"https://api.github.com/repos/zaproxy/zaproxy/subscribers","subscription_url":"https://api.github.com/repos/zaproxy/zaproxy/subscription","commits_url":"https://api.github.com/repos/zaproxy/zaproxy/commits{/sha}","git_commits_url":"https://api.github.com/repos/zaproxy/zaproxy/git/commits{/sha}","comments_url":"https://api.github.com/repos/zaproxy/zaproxy/comments{/number}","issue_comment_url":"https://api.github.com/repos/zaproxy/zaproxy/issues/comments{/number}","contents_url":"https://api.github.com/repos/zaproxy/zaproxy/contents/{+path}","compare_url":"https://api.github.com/repos/zaproxy/zaproxy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zaproxy/zaproxy/merges","archive_url":"https://api.github.com/repos/zaproxy/zaproxy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zaproxy/zaproxy/downloads","issues_url":"https://api.github.com/repos/zaproxy/zaproxy/issues{/number}","pulls_url":"https://api.github.com/repos/zaproxy/zaproxy/pulls{/number}","milestones_url":"https://api.github.com/repos/zaproxy/zaproxy/milestones{/number}","notifications_url":"https://api.github.com/repos/zaproxy/zaproxy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zaproxy/zaproxy/labels{/name}","releases_url":"https://api.github.com/repos/zaproxy/zaproxy/releases{/id}","deployments_url":"https://api.github.com/repos/zaproxy/zaproxy/deployments","created_at":"2015-06-03T16:55:01Z","updated_at":"2018-08-28T14:44:09Z","pushed_at":"2018-08-28T09:12:14Z","git_url":"git://github.com/zaproxy/zaproxy.git","ssh_url":"git@github.com:zaproxy/zaproxy.git","clone_url":"https://github.com/zaproxy/zaproxy.git","svn_url":"https://github.com/zaproxy/zaproxy","homepage":null,"size":177131,"stargazers_count":4375,"watchers_count":4375,"language":"Java","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":819,"mirror_url":null,"archived":false,"open_issues_count":631,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":819,"open_issues":631,"watchers":4375,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4696"},"html":{"href":"https://github.com/zaproxy/zaproxy/pull/4696"},"issue":{"href":"https://api.github.com/repos/zaproxy/zaproxy/issues/4696"},"comments":{"href":"https://api.github.com/repos/zaproxy/zaproxy/issues/4696/comments"},"review_comments":{"href":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4696/comments"},"review_comment":{"href":"https://api.github.com/repos/zaproxy/zaproxy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zaproxy/zaproxy/pulls/4696/commits"},"statuses":{"href":"https://api.github.com/repos/zaproxy/zaproxy/statuses/a40113500612f8fab703a71195ea92628dc3ee8a"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"thc202"}}