{"action":"created","comment":{"url":"https://api.github.com/repos/zaproxy/community-scripts/pulls/comments/193780213","pull_request_review_id":126822525,"id":193780213,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5Mzc4MDIxMw==","diff_hunk":"@@ -0,0 +1,45 @@\n+/*\n+ * Inject Javascript code into a webpage.\n+ *\n+ *   - Code will be added inside <script></script> tags in the Response body's\n+ *   <head></head> before sending it to the client.\n+ *   - Code to be added is read from the file which path is `FILE` (this need to\n+ *   be an absolute path, /tmp/test.js in our case).\n+ */\n+\n+FILE = '/tmp/test.js'\n+SCRIPT = '\\t<script>' + loadScriptFromFile(FILE) + '</script>\\n';\n+\n+function loadScriptFromFile(file) {\n+    Files = Java.type('java.nio.file.Files');\n+    Paths = Java.type('java.nio.file.Paths');\n+    String = Java.type('java.lang.String');\n+\n+    filePath = Paths.get(file);\n+    return new String(Files.readAllBytes(filePath), 'UTF-8');\n+}\n+\n+function sendingRequest(msg, initiator, helper) {}\n+\n+function responseReceived(msg, initiator, helper) {\n+    body = msg.getResponseBody();\n+    bodyAsStr = body.toString();\n+    header = msg.getResponseHeader();\n+\n+    xRequestedWith = msg.getRequestHeader().getHeader('X-Requested-With');\n+    contentType = header.getHeader('Content-Type');\n+\n+    contentTypeRegex = new RegExp(/text\\/html;/g);\n+\n+    if (!contentTypeRegex.test(contentType)\n+        || xRequestedWith == 'XMLHttpRequest') {\n+        return true;\n+    }\n+\n+    index = body.toString().indexOf('<head>') + '<head>\\n'.length();\n+\n+    newBody = bodyAsStr.slice(0, index) + SCRIPT + bodyAsStr.slice(index);\n+    header.setContentLength(newBody.length() + 1);","path":"httpsender/inject_js_in_html_page.js","position":null,"original_position":42,"commit_id":"bde9c368ac652c11c9c8d6db9788d937d5a8712d","original_commit_id":"115f715333df8f8606cd9ba2d85e4e10ba28374b","user":{"login":"Pamplemousse","id":2647236,"node_id":"MDQ6VXNlcjI2NDcyMzY=","avatar_url":"https://avatars3.githubusercontent.com/u/2647236?v=4","gravatar_id":"","url":"https://api.github.com/users/Pamplemousse","html_url":"https://github.com/Pamplemousse","followers_url":"https://api.github.com/users/Pamplemousse/followers","following_url":"https://api.github.com/users/Pamplemousse/following{/other_user}","gists_url":"https://api.github.com/users/Pamplemousse/gists{/gist_id}","starred_url":"https://api.github.com/users/Pamplemousse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pamplemousse/subscriptions","organizations_url":"https://api.github.com/users/Pamplemousse/orgs","repos_url":"https://api.github.com/users/Pamplemousse/repos","events_url":"https://api.github.com/users/Pamplemousse/events{/privacy}","received_events_url":"https://api.github.com/users/Pamplemousse/received_events","type":"User","site_admin":false},"body":"Done.","created_at":"2018-06-07T15:02:05Z","updated_at":"2018-06-07T15:04:57Z","html_url":"https://github.com/zaproxy/community-scripts/pull/106#discussion_r193780213","pull_request_url":"https://api.github.com/repos/zaproxy/community-scripts/pulls/106","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/zaproxy/community-scripts/pulls/comments/193780213"},"html":{"href":"https://github.com/zaproxy/community-scripts/pull/106#discussion_r193780213"},"pull_request":{"href":"https://api.github.com/repos/zaproxy/community-scripts/pulls/106"}},"in_reply_to_id":193760816},"pull_request":{"url":"https://api.github.com/repos/zaproxy/community-scripts/pulls/106","id":193296786,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkzMjk2Nzg2","html_url":"https://github.com/zaproxy/community-scripts/pull/106","diff_url":"https://github.com/zaproxy/community-scripts/pull/106.diff","patch_url":"https://github.com/zaproxy/community-scripts/pull/106.patch","issue_url":"https://api.github.com/repos/zaproxy/community-scripts/issues/106","number":106,"state":"open","locked":false,"title":"HttpSender script to inject JS into an HTML page","user":{"login":"Pamplemousse","id":2647236,"node_id":"MDQ6VXNlcjI2NDcyMzY=","avatar_url":"https://avatars3.githubusercontent.com/u/2647236?v=4","gravatar_id":"","url":"https://api.github.com/users/Pamplemousse","html_url":"https://github.com/Pamplemousse","followers_url":"https://api.github.com/users/Pamplemousse/followers","following_url":"https://api.github.com/users/Pamplemousse/following{/other_user}","gists_url":"https://api.github.com/users/Pamplemousse/gists{/gist_id}","starred_url":"https://api.github.com/users/Pamplemousse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pamplemousse/subscriptions","organizations_url":"https://api.github.com/users/Pamplemousse/orgs","repos_url":"https://api.github.com/users/Pamplemousse/repos","events_url":"https://api.github.com/users/Pamplemousse/events{/privacy}","received_events_url":"https://api.github.com/users/Pamplemousse/received_events","type":"User","site_admin":false},"body":"Inject inlined Javascript into the \\<head\\> tag of a targeted HTML page.","created_at":"2018-06-07T11:59:52Z","updated_at":"2018-06-07T15:04:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a1b9bbc189d99954d4af74c1486718ea0bfb5ecb","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/zaproxy/community-scripts/pulls/106/commits","review_comments_url":"https://api.github.com/repos/zaproxy/community-scripts/pulls/106/comments","review_comment_url":"https://api.github.com/repos/zaproxy/community-scripts/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zaproxy/community-scripts/issues/106/comments","statuses_url":"https://api.github.com/repos/zaproxy/community-scripts/statuses/bde9c368ac652c11c9c8d6db9788d937d5a8712d","head":{"label":"Pamplemousse:master","ref":"master","sha":"bde9c368ac652c11c9c8d6db9788d937d5a8712d","user":{"login":"Pamplemousse","id":2647236,"node_id":"MDQ6VXNlcjI2NDcyMzY=","avatar_url":"https://avatars3.githubusercontent.com/u/2647236?v=4","gravatar_id":"","url":"https://api.github.com/users/Pamplemousse","html_url":"https://github.com/Pamplemousse","followers_url":"https://api.github.com/users/Pamplemousse/followers","following_url":"https://api.github.com/users/Pamplemousse/following{/other_user}","gists_url":"https://api.github.com/users/Pamplemousse/gists{/gist_id}","starred_url":"https://api.github.com/users/Pamplemousse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pamplemousse/subscriptions","organizations_url":"https://api.github.com/users/Pamplemousse/orgs","repos_url":"https://api.github.com/users/Pamplemousse/repos","events_url":"https://api.github.com/users/Pamplemousse/events{/privacy}","received_events_url":"https://api.github.com/users/Pamplemousse/received_events","type":"User","site_admin":false},"repo":{"id":136470071,"node_id":"MDEwOlJlcG9zaXRvcnkxMzY0NzAwNzE=","name":"community-scripts","full_name":"Pamplemousse/community-scripts","owner":{"login":"Pamplemousse","id":2647236,"node_id":"MDQ6VXNlcjI2NDcyMzY=","avatar_url":"https://avatars3.githubusercontent.com/u/2647236?v=4","gravatar_id":"","url":"https://api.github.com/users/Pamplemousse","html_url":"https://github.com/Pamplemousse","followers_url":"https://api.github.com/users/Pamplemousse/followers","following_url":"https://api.github.com/users/Pamplemousse/following{/other_user}","gists_url":"https://api.github.com/users/Pamplemousse/gists{/gist_id}","starred_url":"https://api.github.com/users/Pamplemousse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pamplemousse/subscriptions","organizations_url":"https://api.github.com/users/Pamplemousse/orgs","repos_url":"https://api.github.com/users/Pamplemousse/repos","events_url":"https://api.github.com/users/Pamplemousse/events{/privacy}","received_events_url":"https://api.github.com/users/Pamplemousse/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Pamplemousse/community-scripts","description":"A collection of ZAP scripts provided by the community - pull requests very welcome!","fork":true,"url":"https://api.github.com/repos/Pamplemousse/community-scripts","forks_url":"https://api.github.com/repos/Pamplemousse/community-scripts/forks","keys_url":"https://api.github.com/repos/Pamplemousse/community-scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Pamplemousse/community-scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Pamplemousse/community-scripts/teams","hooks_url":"https://api.github.com/repos/Pamplemousse/community-scripts/hooks","issue_events_url":"https://api.github.com/repos/Pamplemousse/community-scripts/issues/events{/number}","events_url":"https://api.github.com/repos/Pamplemousse/community-scripts/events","assignees_url":"https://api.github.com/repos/Pamplemousse/community-scripts/assignees{/user}","branches_url":"https://api.github.com/repos/Pamplemousse/community-scripts/branches{/branch}","tags_url":"https://api.github.com/repos/Pamplemousse/community-scripts/tags","blobs_url":"https://api.github.com/repos/Pamplemousse/community-scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Pamplemousse/community-scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Pamplemousse/community-scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/Pamplemousse/community-scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Pamplemousse/community-scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/Pamplemousse/community-scripts/languages","stargazers_url":"https://api.github.com/repos/Pamplemousse/community-scripts/stargazers","contributors_url":"https://api.github.com/repos/Pamplemousse/community-scripts/contributors","subscribers_url":"https://api.github.com/repos/Pamplemousse/community-scripts/subscribers","subscription_url":"https://api.github.com/repos/Pamplemousse/community-scripts/subscription","commits_url":"https://api.github.com/repos/Pamplemousse/community-scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/Pamplemousse/community-scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/Pamplemousse/community-scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/Pamplemousse/community-scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/Pamplemousse/community-scripts/contents/{+path}","compare_url":"https://api.github.com/repos/Pamplemousse/community-scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Pamplemousse/community-scripts/merges","archive_url":"https://api.github.com/repos/Pamplemousse/community-scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Pamplemousse/community-scripts/downloads","issues_url":"https://api.github.com/repos/Pamplemousse/community-scripts/issues{/number}","pulls_url":"https://api.github.com/repos/Pamplemousse/community-scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/Pamplemousse/community-scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/Pamplemousse/community-scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Pamplemousse/community-scripts/labels{/name}","releases_url":"https://api.github.com/repos/Pamplemousse/community-scripts/releases{/id}","deployments_url":"https://api.github.com/repos/Pamplemousse/community-scripts/deployments","created_at":"2018-06-07T11:52:29Z","updated_at":"2018-06-07T14:48:58Z","pushed_at":"2018-06-07T14:48:56Z","git_url":"git://github.com/Pamplemousse/community-scripts.git","ssh_url":"git@github.com:Pamplemousse/community-scripts.git","clone_url":"https://github.com/Pamplemousse/community-scripts.git","svn_url":"https://github.com/Pamplemousse/community-scripts","homepage":null,"size":290,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"zaproxy:master","ref":"master","sha":"1b252bdf39e456988202f1afa8b4f0946a211b20","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":28714269,"node_id":"MDEwOlJlcG9zaXRvcnkyODcxNDI2OQ==","name":"community-scripts","full_name":"zaproxy/community-scripts","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/community-scripts","description":"A collection of ZAP scripts provided by the community - pull requests very welcome!","fork":false,"url":"https://api.github.com/repos/zaproxy/community-scripts","forks_url":"https://api.github.com/repos/zaproxy/community-scripts/forks","keys_url":"https://api.github.com/repos/zaproxy/community-scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zaproxy/community-scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zaproxy/community-scripts/teams","hooks_url":"https://api.github.com/repos/zaproxy/community-scripts/hooks","issue_events_url":"https://api.github.com/repos/zaproxy/community-scripts/issues/events{/number}","events_url":"https://api.github.com/repos/zaproxy/community-scripts/events","assignees_url":"https://api.github.com/repos/zaproxy/community-scripts/assignees{/user}","branches_url":"https://api.github.com/repos/zaproxy/community-scripts/branches{/branch}","tags_url":"https://api.github.com/repos/zaproxy/community-scripts/tags","blobs_url":"https://api.github.com/repos/zaproxy/community-scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zaproxy/community-scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zaproxy/community-scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/zaproxy/community-scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zaproxy/community-scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/zaproxy/community-scripts/languages","stargazers_url":"https://api.github.com/repos/zaproxy/community-scripts/stargazers","contributors_url":"https://api.github.com/repos/zaproxy/community-scripts/contributors","subscribers_url":"https://api.github.com/repos/zaproxy/community-scripts/subscribers","subscription_url":"https://api.github.com/repos/zaproxy/community-scripts/subscription","commits_url":"https://api.github.com/repos/zaproxy/community-scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/zaproxy/community-scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/zaproxy/community-scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/zaproxy/community-scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/zaproxy/community-scripts/contents/{+path}","compare_url":"https://api.github.com/repos/zaproxy/community-scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zaproxy/community-scripts/merges","archive_url":"https://api.github.com/repos/zaproxy/community-scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zaproxy/community-scripts/downloads","issues_url":"https://api.github.com/repos/zaproxy/community-scripts/issues{/number}","pulls_url":"https://api.github.com/repos/zaproxy/community-scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/zaproxy/community-scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/zaproxy/community-scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zaproxy/community-scripts/labels{/name}","releases_url":"https://api.github.com/repos/zaproxy/community-scripts/releases{/id}","deployments_url":"https://api.github.com/repos/zaproxy/community-scripts/deployments","created_at":"2015-01-02T13:39:26Z","updated_at":"2018-05-29T13:41:06Z","pushed_at":"2018-06-07T14:48:58Z","git_url":"git://github.com/zaproxy/community-scripts.git","ssh_url":"git@github.com:zaproxy/community-scripts.git","clone_url":"https://github.com/zaproxy/community-scripts.git","svn_url":"https://github.com/zaproxy/community-scripts","homepage":null,"size":287,"stargazers_count":291,"watchers_count":291,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":86,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":86,"open_issues":3,"watchers":291,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zaproxy/community-scripts/pulls/106"},"html":{"href":"https://github.com/zaproxy/community-scripts/pull/106"},"issue":{"href":"https://api.github.com/repos/zaproxy/community-scripts/issues/106"},"comments":{"href":"https://api.github.com/repos/zaproxy/community-scripts/issues/106/comments"},"review_comments":{"href":"https://api.github.com/repos/zaproxy/community-scripts/pulls/106/comments"},"review_comment":{"href":"https://api.github.com/repos/zaproxy/community-scripts/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zaproxy/community-scripts/pulls/106/commits"},"statuses":{"href":"https://api.github.com/repos/zaproxy/community-scripts/statuses/bde9c368ac652c11c9c8d6db9788d937d5a8712d"}},"author_association":"NONE"}}
{"actor":{"display_login":"Pamplemousse"}}