{"action":"created","comment":{"url":"https://api.github.com/repos/apache/tomcat80/pulls/comments/61557490","id":61557490,"diff_hunk":"@@ -123,6 +128,98 @@ public void setJarScanFilter(JarScanFilter jarScanFilter) {\n     }\n \n     /**\n+     * Tests is the file is a zip file\n+     *\n+     * @param file\n+     * @return\n+     * @throws IOException\n+     */\n+    private static boolean isZipFile(File file) throws IOException {\n+        if (file.isDirectory()) {\n+            return false;\n+        }\n+        if (!file.canRead()) {\n+            throw new IOException(\"Cannot read file \" + file.getAbsolutePath());\n+        }\n+        if (file.length() < 4) {\n+            return false;\n+        }\n+        try (DataInputStream in = new DataInputStream(new FileInputStream(file))) {\n+            return in.readInt() == 0x504b0304;\n+        }\n+    }\n+\n+    /**\n+     * Returns the URLS of all jars managed directly or indirectly (given\n+     * \"Class-Path\" manifest relationships) by the class loader\n+     *\n+     * @param cl\n+     * @return\n+     */\n+    public static URL[] getURLs(URLClassLoader cl) {\n+        HashSet<URL> visited = new HashSet<>();\n+        URL[] urLs = cl.getURLs();\n+        if (urLs != null) {\n+            for (URL urL : urLs) {\n+                try {\n+                    visitJar(visited, urL);\n+                } catch (IOException iOException) {\n+                    throw new RuntimeException(iOException);\n+                }\n+            }\n+        }\n+        URL[] ret = new URL[visited.size()];\n+        int i = 0;\n+        for (URL url : visited) {\n+            ret[i++] = url;\n+        }\n+        return ret;\n+    }\n+\n+    /**\n+     * Performs a DFS traversal over the graph of jars given the \"Class-Path\"\n+     * reference\n+     *\n+     * @param visited\n+     * @param jar\n+     * @throws IOException\n+     */\n+    public static void visitJar(Set<URL> visited, URL jar) throws IOException {\n+        File file = new File(jar.getFile());\n+        if (!file.exists()) {\n+            return;\n+        }\n+        visited.add(jar);\n+\n+        if (!isZipFile(file)) {\n+            return;\n+        }\n+","path":"java/org/apache/tomcat/util/scan/StandardJarScanner.java","position":90,"original_position":90,"commit_id":"987d3279f6e4cbc9e505a718e4e37c0336e3e640","original_commit_id":"987d3279f6e4cbc9e505a718e4e37c0336e3e640","user":{"login":"markt-asf","id":4690029,"avatar_url":"https://avatars.githubusercontent.com/u/4690029?v=3","gravatar_id":"","url":"https://api.github.com/users/markt-asf","html_url":"https://github.com/markt-asf","followers_url":"https://api.github.com/users/markt-asf/followers","following_url":"https://api.github.com/users/markt-asf/following{/other_user}","gists_url":"https://api.github.com/users/markt-asf/gists{/gist_id}","starred_url":"https://api.github.com/users/markt-asf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markt-asf/subscriptions","organizations_url":"https://api.github.com/users/markt-asf/orgs","repos_url":"https://api.github.com/users/markt-asf/repos","events_url":"https://api.github.com/users/markt-asf/events{/privacy}","received_events_url":"https://api.github.com/users/markt-asf/received_events","type":"User","site_admin":false},"body":"While it isn't as clean, it is probably going to be more efficient to check the manifest at the same time as the scan rather than opening the JAR once to check the manifest and a second time to scan it.","created_at":"2016-04-29T10:12:33Z","updated_at":"2016-04-29T10:12:33Z","html_url":"https://github.com/apache/tomcat80/pull/5#discussion_r61557490","pull_request_url":"https://api.github.com/repos/apache/tomcat80/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/apache/tomcat80/pulls/comments/61557490"},"html":{"href":"https://github.com/apache/tomcat80/pull/5#discussion_r61557490"},"pull_request":{"href":"https://api.github.com/repos/apache/tomcat80/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/apache/tomcat80/pulls/5","id":63969986,"html_url":"https://github.com/apache/tomcat80/pull/5","diff_url":"https://github.com/apache/tomcat80/pull/5.diff","patch_url":"https://github.com/apache/tomcat80/pull/5.patch","issue_url":"https://api.github.com/repos/apache/tomcat80/issues/5","number":5,"state":"open","locked":false,"title":"Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=59226","user":{"login":"idelvall","id":5653455,"avatar_url":"https://avatars.githubusercontent.com/u/5653455?v=3","gravatar_id":"","url":"https://api.github.com/users/idelvall","html_url":"https://github.com/idelvall","followers_url":"https://api.github.com/users/idelvall/followers","following_url":"https://api.github.com/users/idelvall/following{/other_user}","gists_url":"https://api.github.com/users/idelvall/gists{/gist_id}","starred_url":"https://api.github.com/users/idelvall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idelvall/subscriptions","organizations_url":"https://api.github.com/users/idelvall/orgs","repos_url":"https://api.github.com/users/idelvall/repos","events_url":"https://api.github.com/users/idelvall/events{/privacy}","received_events_url":"https://api.github.com/users/idelvall/received_events","type":"User","site_admin":false},"body":"StandardJarScanner ignores jars in manifest Class-path header.\r\n\r\nhttps://bz.apache.org/bugzilla/show_bug.cgi?id=59226\r\n\r\nhttp://stackoverflow.com/questions/35922072/scanning-manifest-classpath-jars-in-embeeded-tomcat/36185408#36185408","created_at":"2016-03-23T23:37:46Z","updated_at":"2016-04-29T10:12:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"db565b093f06f25044b0ec34a261742f7d5d179a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/tomcat80/pulls/5/commits","review_comments_url":"https://api.github.com/repos/apache/tomcat80/pulls/5/comments","review_comment_url":"https://api.github.com/repos/apache/tomcat80/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/tomcat80/issues/5/comments","statuses_url":"https://api.github.com/repos/apache/tomcat80/statuses/987d3279f6e4cbc9e505a718e4e37c0336e3e640","head":{"label":"idelvall:trunk","ref":"trunk","sha":"987d3279f6e4cbc9e505a718e4e37c0336e3e640","user":{"login":"idelvall","id":5653455,"avatar_url":"https://avatars.githubusercontent.com/u/5653455?v=3","gravatar_id":"","url":"https://api.github.com/users/idelvall","html_url":"https://github.com/idelvall","followers_url":"https://api.github.com/users/idelvall/followers","following_url":"https://api.github.com/users/idelvall/following{/other_user}","gists_url":"https://api.github.com/users/idelvall/gists{/gist_id}","starred_url":"https://api.github.com/users/idelvall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idelvall/subscriptions","organizations_url":"https://api.github.com/users/idelvall/orgs","repos_url":"https://api.github.com/users/idelvall/repos","events_url":"https://api.github.com/users/idelvall/events{/privacy}","received_events_url":"https://api.github.com/users/idelvall/received_events","type":"User","site_admin":false},"repo":{"id":54556513,"name":"tomcat80","full_name":"idelvall/tomcat80","owner":{"login":"idelvall","id":5653455,"avatar_url":"https://avatars.githubusercontent.com/u/5653455?v=3","gravatar_id":"","url":"https://api.github.com/users/idelvall","html_url":"https://github.com/idelvall","followers_url":"https://api.github.com/users/idelvall/followers","following_url":"https://api.github.com/users/idelvall/following{/other_user}","gists_url":"https://api.github.com/users/idelvall/gists{/gist_id}","starred_url":"https://api.github.com/users/idelvall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idelvall/subscriptions","organizations_url":"https://api.github.com/users/idelvall/orgs","repos_url":"https://api.github.com/users/idelvall/repos","events_url":"https://api.github.com/users/idelvall/events{/privacy}","received_events_url":"https://api.github.com/users/idelvall/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/idelvall/tomcat80","description":"Mirror of Apache Tomcat 8.0.x","fork":true,"url":"https://api.github.com/repos/idelvall/tomcat80","forks_url":"https://api.github.com/repos/idelvall/tomcat80/forks","keys_url":"https://api.github.com/repos/idelvall/tomcat80/keys{/key_id}","collaborators_url":"https://api.github.com/repos/idelvall/tomcat80/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/idelvall/tomcat80/teams","hooks_url":"https://api.github.com/repos/idelvall/tomcat80/hooks","issue_events_url":"https://api.github.com/repos/idelvall/tomcat80/issues/events{/number}","events_url":"https://api.github.com/repos/idelvall/tomcat80/events","assignees_url":"https://api.github.com/repos/idelvall/tomcat80/assignees{/user}","branches_url":"https://api.github.com/repos/idelvall/tomcat80/branches{/branch}","tags_url":"https://api.github.com/repos/idelvall/tomcat80/tags","blobs_url":"https://api.github.com/repos/idelvall/tomcat80/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/idelvall/tomcat80/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/idelvall/tomcat80/git/refs{/sha}","trees_url":"https://api.github.com/repos/idelvall/tomcat80/git/trees{/sha}","statuses_url":"https://api.github.com/repos/idelvall/tomcat80/statuses/{sha}","languages_url":"https://api.github.com/repos/idelvall/tomcat80/languages","stargazers_url":"https://api.github.com/repos/idelvall/tomcat80/stargazers","contributors_url":"https://api.github.com/repos/idelvall/tomcat80/contributors","subscribers_url":"https://api.github.com/repos/idelvall/tomcat80/subscribers","subscription_url":"https://api.github.com/repos/idelvall/tomcat80/subscription","commits_url":"https://api.github.com/repos/idelvall/tomcat80/commits{/sha}","git_commits_url":"https://api.github.com/repos/idelvall/tomcat80/git/commits{/sha}","comments_url":"https://api.github.com/repos/idelvall/tomcat80/comments{/number}","issue_comment_url":"https://api.github.com/repos/idelvall/tomcat80/issues/comments{/number}","contents_url":"https://api.github.com/repos/idelvall/tomcat80/contents/{+path}","compare_url":"https://api.github.com/repos/idelvall/tomcat80/compare/{base}...{head}","merges_url":"https://api.github.com/repos/idelvall/tomcat80/merges","archive_url":"https://api.github.com/repos/idelvall/tomcat80/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/idelvall/tomcat80/downloads","issues_url":"https://api.github.com/repos/idelvall/tomcat80/issues{/number}","pulls_url":"https://api.github.com/repos/idelvall/tomcat80/pulls{/number}","milestones_url":"https://api.github.com/repos/idelvall/tomcat80/milestones{/number}","notifications_url":"https://api.github.com/repos/idelvall/tomcat80/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/idelvall/tomcat80/labels{/name}","releases_url":"https://api.github.com/repos/idelvall/tomcat80/releases{/id}","deployments_url":"https://api.github.com/repos/idelvall/tomcat80/deployments","created_at":"2016-03-23T12:03:22Z","updated_at":"2016-03-23T12:03:32Z","pushed_at":"2016-04-29T08:42:16Z","git_url":"git://github.com/idelvall/tomcat80.git","ssh_url":"git@github.com:idelvall/tomcat80.git","clone_url":"https://github.com/idelvall/tomcat80.git","svn_url":"https://github.com/idelvall/tomcat80","homepage":"","size":36248,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"apache:trunk","ref":"trunk","sha":"cabd9523a2adaa5ab810d539d75243e828b2f7ed","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":26389457,"name":"tomcat80","full_name":"apache/tomcat80","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/tomcat80","description":"Mirror of Apache Tomcat 8.0.x","fork":false,"url":"https://api.github.com/repos/apache/tomcat80","forks_url":"https://api.github.com/repos/apache/tomcat80/forks","keys_url":"https://api.github.com/repos/apache/tomcat80/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/tomcat80/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/tomcat80/teams","hooks_url":"https://api.github.com/repos/apache/tomcat80/hooks","issue_events_url":"https://api.github.com/repos/apache/tomcat80/issues/events{/number}","events_url":"https://api.github.com/repos/apache/tomcat80/events","assignees_url":"https://api.github.com/repos/apache/tomcat80/assignees{/user}","branches_url":"https://api.github.com/repos/apache/tomcat80/branches{/branch}","tags_url":"https://api.github.com/repos/apache/tomcat80/tags","blobs_url":"https://api.github.com/repos/apache/tomcat80/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/tomcat80/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/tomcat80/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/tomcat80/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/tomcat80/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/tomcat80/languages","stargazers_url":"https://api.github.com/repos/apache/tomcat80/stargazers","contributors_url":"https://api.github.com/repos/apache/tomcat80/contributors","subscribers_url":"https://api.github.com/repos/apache/tomcat80/subscribers","subscription_url":"https://api.github.com/repos/apache/tomcat80/subscription","commits_url":"https://api.github.com/repos/apache/tomcat80/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/tomcat80/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/tomcat80/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/tomcat80/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/tomcat80/contents/{+path}","compare_url":"https://api.github.com/repos/apache/tomcat80/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/tomcat80/merges","archive_url":"https://api.github.com/repos/apache/tomcat80/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/tomcat80/downloads","issues_url":"https://api.github.com/repos/apache/tomcat80/issues{/number}","pulls_url":"https://api.github.com/repos/apache/tomcat80/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/tomcat80/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/tomcat80/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/tomcat80/labels{/name}","releases_url":"https://api.github.com/repos/apache/tomcat80/releases{/id}","deployments_url":"https://api.github.com/repos/apache/tomcat80/deployments","created_at":"2014-11-09T08:00:07Z","updated_at":"2016-04-15T11:09:36Z","pushed_at":"2016-04-29T08:42:17Z","git_url":"git://github.com/apache/tomcat80.git","ssh_url":"git@github.com:apache/tomcat80.git","clone_url":"https://github.com/apache/tomcat80.git","svn_url":"https://github.com/apache/tomcat80","homepage":"","size":42228,"stargazers_count":42,"watchers_count":42,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":54,"mirror_url":"git://git.apache.org/tomcat80.git","open_issues_count":4,"forks":54,"open_issues":4,"watchers":42,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/tomcat80/pulls/5"},"html":{"href":"https://github.com/apache/tomcat80/pull/5"},"issue":{"href":"https://api.github.com/repos/apache/tomcat80/issues/5"},"comments":{"href":"https://api.github.com/repos/apache/tomcat80/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/tomcat80/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/tomcat80/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/tomcat80/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/apache/tomcat80/statuses/987d3279f6e4cbc9e505a718e4e37c0336e3e640"}}}}