{"action":"created","comment":{"url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/pulls/comments/40539524","id":40539524,"diff_hunk":"@@ -0,0 +1,115 @@\n+package ie.teamchile.smartapp.util;\n+\n+import android.content.Context;\n+import android.content.pm.ApplicationInfo;\n+import android.content.pm.PackageManager;\n+import android.content.pm.Signature;\n+import android.os.Build;\n+\n+import java.io.BufferedReader;\n+import java.io.File;\n+import java.io.InputStreamReader;\n+import java.security.MessageDigest;\n+import java.security.NoSuchAlgorithmException;\n+\n+/**\n+ * Created by user on 9/12/15.\n+ */\n+public class EnvironmentChecker {\n+    private static String cert = \"\";\n+\n+    public static boolean isCertInvalid(Context context) {\n+        String fingerprintMD5 = \"\";\n+        Signature[] sigs = new Signature[0];\n+        try {\n+            sigs = context.getPackageManager().getPackageInfo(context.getPackageName(),\n+                    PackageManager.GET_SIGNATURES).signatures;\n+\n+            for (Signature sig : sigs) {\n+                byte[] hexBytes = sig.toByteArray();\n+                MessageDigest digest = MessageDigest.getInstance(\"MD5\");\n+\n+                byte[] md5digest = new byte[0];\n+\n+                if (digest != null) {\n+                    md5digest = digest.digest(hexBytes);\n+                    StringBuilder sb = new StringBuilder();\n+                    for (int i = 0; i < md5digest.length; ++i) {\n+                        sb.append((Integer.toHexString((md5digest[i] & 0xFF) | 0x100)).substring(1, 3));\n+                    }\n+                    fingerprintMD5 = sb.toString();\n+                }\n+            }\n+\n+        } catch (PackageManager.NameNotFoundException e) {\n+            e.printStackTrace();\n+        } catch (NoSuchAlgorithmException e) {\n+            e.printStackTrace();\n+        }\n+        return !fingerprintMD5.equals(cert);\n+    }\n+\n+    public static boolean isDeviceRooted() {\n+        return (checkRootMethod1() || checkRootMethod2() || checkRootMethod3());\n+    }\n+\n+    private static boolean checkRootMethod1() {\n+        String buildTags = android.os.Build.TAGS;\n+        return buildTags != null && buildTags.contains(\"test-keys\");\n+    }\n+\n+    private static boolean checkRootMethod2() {\n+        String[] paths = {\"/system/app/Superuser.apk\", \"/sbin/su\", \"/system/bin/su\",\n+                \"/system/xbin/su\", \"/data/local/xbin/su\", \"/data/local/bin/su\",","path":"app/src/main/java/ie/teamchile/smartapp/util/EnvironmentChecker.java","position":63,"original_position":63,"commit_id":"418ac2e82c0dd6104dc39eb971fbbd9ea57043a8","original_commit_id":"418ac2e82c0dd6104dc39eb971fbbd9ea57043a8","user":{"login":"sciritai","id":1171007,"avatar_url":"https://avatars.githubusercontent.com/u/1171007?v=3","gravatar_id":"","url":"https://api.github.com/users/sciritai","html_url":"https://github.com/sciritai","followers_url":"https://api.github.com/users/sciritai/followers","following_url":"https://api.github.com/users/sciritai/following{/other_user}","gists_url":"https://api.github.com/users/sciritai/gists{/gist_id}","starred_url":"https://api.github.com/users/sciritai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sciritai/subscriptions","organizations_url":"https://api.github.com/users/sciritai/orgs","repos_url":"https://api.github.com/users/sciritai/repos","events_url":"https://api.github.com/users/sciritai/events{/privacy}","received_events_url":"https://api.github.com/users/sciritai/received_events","type":"User","site_admin":false},"body":"I presume these are typical paths that get installed when a device is rooted?","created_at":"2015-09-28T10:53:13Z","updated_at":"2015-09-28T10:53:13Z","html_url":"https://github.com/TheProductWorks/SMART-android-app/pull/16#discussion_r40539524","pull_request_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/pulls/16","_links":{"self":{"href":"https://api.github.com/repos/TheProductWorks/SMART-android-app/pulls/comments/40539524"},"html":{"href":"https://github.com/TheProductWorks/SMART-android-app/pull/16#discussion_r40539524"},"pull_request":{"href":"https://api.github.com/repos/TheProductWorks/SMART-android-app/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/pulls/16","id":44874163,"html_url":"https://github.com/TheProductWorks/SMART-android-app/pull/16","diff_url":"https://github.com/TheProductWorks/SMART-android-app/pull/16.diff","patch_url":"https://github.com/TheProductWorks/SMART-android-app/pull/16.patch","issue_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/issues/16","number":16,"state":"open","locked":false,"title":"Secure engineering","user":{"login":"otormaigh","id":10416394,"avatar_url":"https://avatars.githubusercontent.com/u/10416394?v=3","gravatar_id":"","url":"https://api.github.com/users/otormaigh","html_url":"https://github.com/otormaigh","followers_url":"https://api.github.com/users/otormaigh/followers","following_url":"https://api.github.com/users/otormaigh/following{/other_user}","gists_url":"https://api.github.com/users/otormaigh/gists{/gist_id}","starred_url":"https://api.github.com/users/otormaigh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/otormaigh/subscriptions","organizations_url":"https://api.github.com/users/otormaigh/orgs","repos_url":"https://api.github.com/users/otormaigh/repos","events_url":"https://api.github.com/users/otormaigh/events{/privacy}","received_events_url":"https://api.github.com/users/otormaigh/received_events","type":"User","site_admin":false},"body":"This pull request is in reponse to Issue #9 \r\n\r\nSome of the new implmented features are currently disabled because they would hinder development.\r\n\r\nAdditions:\r\n* Adds ability for app to check if it is running on an emulator.\r\n* Adds ability for app to check if the MD5 sum of the certificate it was signed with matches with the relevant credentials.\r\n* Adds ability for app to check if it is running in debuggable mode.","created_at":"2015-09-13T14:56:25Z","updated_at":"2015-09-28T10:53:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0e79559f0b49c22fe02d5a2891a5db00dfa69782","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/pulls/16/commits","review_comments_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/pulls/16/comments","review_comment_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/issues/16/comments","statuses_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/statuses/418ac2e82c0dd6104dc39eb971fbbd9ea57043a8","head":{"label":"otormaigh:secureEngineering","ref":"secureEngineering","sha":"418ac2e82c0dd6104dc39eb971fbbd9ea57043a8","user":{"login":"otormaigh","id":10416394,"avatar_url":"https://avatars.githubusercontent.com/u/10416394?v=3","gravatar_id":"","url":"https://api.github.com/users/otormaigh","html_url":"https://github.com/otormaigh","followers_url":"https://api.github.com/users/otormaigh/followers","following_url":"https://api.github.com/users/otormaigh/following{/other_user}","gists_url":"https://api.github.com/users/otormaigh/gists{/gist_id}","starred_url":"https://api.github.com/users/otormaigh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/otormaigh/subscriptions","organizations_url":"https://api.github.com/users/otormaigh/orgs","repos_url":"https://api.github.com/users/otormaigh/repos","events_url":"https://api.github.com/users/otormaigh/events{/privacy}","received_events_url":"https://api.github.com/users/otormaigh/received_events","type":"User","site_admin":false},"repo":{"id":28860345,"name":"SMART","full_name":"otormaigh/SMART","owner":{"login":"otormaigh","id":10416394,"avatar_url":"https://avatars.githubusercontent.com/u/10416394?v=3","gravatar_id":"","url":"https://api.github.com/users/otormaigh","html_url":"https://github.com/otormaigh","followers_url":"https://api.github.com/users/otormaigh/followers","following_url":"https://api.github.com/users/otormaigh/following{/other_user}","gists_url":"https://api.github.com/users/otormaigh/gists{/gist_id}","starred_url":"https://api.github.com/users/otormaigh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/otormaigh/subscriptions","organizations_url":"https://api.github.com/users/otormaigh/orgs","repos_url":"https://api.github.com/users/otormaigh/repos","events_url":"https://api.github.com/users/otormaigh/events{/privacy}","received_events_url":"https://api.github.com/users/otormaigh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/otormaigh/SMART","description":"","fork":false,"url":"https://api.github.com/repos/otormaigh/SMART","forks_url":"https://api.github.com/repos/otormaigh/SMART/forks","keys_url":"https://api.github.com/repos/otormaigh/SMART/keys{/key_id}","collaborators_url":"https://api.github.com/repos/otormaigh/SMART/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/otormaigh/SMART/teams","hooks_url":"https://api.github.com/repos/otormaigh/SMART/hooks","issue_events_url":"https://api.github.com/repos/otormaigh/SMART/issues/events{/number}","events_url":"https://api.github.com/repos/otormaigh/SMART/events","assignees_url":"https://api.github.com/repos/otormaigh/SMART/assignees{/user}","branches_url":"https://api.github.com/repos/otormaigh/SMART/branches{/branch}","tags_url":"https://api.github.com/repos/otormaigh/SMART/tags","blobs_url":"https://api.github.com/repos/otormaigh/SMART/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/otormaigh/SMART/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/otormaigh/SMART/git/refs{/sha}","trees_url":"https://api.github.com/repos/otormaigh/SMART/git/trees{/sha}","statuses_url":"https://api.github.com/repos/otormaigh/SMART/statuses/{sha}","languages_url":"https://api.github.com/repos/otormaigh/SMART/languages","stargazers_url":"https://api.github.com/repos/otormaigh/SMART/stargazers","contributors_url":"https://api.github.com/repos/otormaigh/SMART/contributors","subscribers_url":"https://api.github.com/repos/otormaigh/SMART/subscribers","subscription_url":"https://api.github.com/repos/otormaigh/SMART/subscription","commits_url":"https://api.github.com/repos/otormaigh/SMART/commits{/sha}","git_commits_url":"https://api.github.com/repos/otormaigh/SMART/git/commits{/sha}","comments_url":"https://api.github.com/repos/otormaigh/SMART/comments{/number}","issue_comment_url":"https://api.github.com/repos/otormaigh/SMART/issues/comments{/number}","contents_url":"https://api.github.com/repos/otormaigh/SMART/contents/{+path}","compare_url":"https://api.github.com/repos/otormaigh/SMART/compare/{base}...{head}","merges_url":"https://api.github.com/repos/otormaigh/SMART/merges","archive_url":"https://api.github.com/repos/otormaigh/SMART/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/otormaigh/SMART/downloads","issues_url":"https://api.github.com/repos/otormaigh/SMART/issues{/number}","pulls_url":"https://api.github.com/repos/otormaigh/SMART/pulls{/number}","milestones_url":"https://api.github.com/repos/otormaigh/SMART/milestones{/number}","notifications_url":"https://api.github.com/repos/otormaigh/SMART/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/otormaigh/SMART/labels{/name}","releases_url":"https://api.github.com/repos/otormaigh/SMART/releases{/id}","created_at":"2015-01-06T11:31:04Z","updated_at":"2015-07-18T12:09:43Z","pushed_at":"2015-09-26T12:26:37Z","git_url":"git://github.com/otormaigh/SMART.git","ssh_url":"git@github.com:otormaigh/SMART.git","clone_url":"https://github.com/otormaigh/SMART.git","svn_url":"https://github.com/otormaigh/SMART","homepage":null,"size":12961,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":0,"forks":3,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"TheProductWorks:master","ref":"master","sha":"676e2af330a79145037ff7a990c6e610702c3b20","user":{"login":"TheProductWorks","id":8091747,"avatar_url":"https://avatars.githubusercontent.com/u/8091747?v=3","gravatar_id":"","url":"https://api.github.com/users/TheProductWorks","html_url":"https://github.com/TheProductWorks","followers_url":"https://api.github.com/users/TheProductWorks/followers","following_url":"https://api.github.com/users/TheProductWorks/following{/other_user}","gists_url":"https://api.github.com/users/TheProductWorks/gists{/gist_id}","starred_url":"https://api.github.com/users/TheProductWorks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheProductWorks/subscriptions","organizations_url":"https://api.github.com/users/TheProductWorks/orgs","repos_url":"https://api.github.com/users/TheProductWorks/repos","events_url":"https://api.github.com/users/TheProductWorks/events{/privacy}","received_events_url":"https://api.github.com/users/TheProductWorks/received_events","type":"Organization","site_admin":false},"repo":{"id":41514169,"name":"SMART-android-app","full_name":"TheProductWorks/SMART-android-app","owner":{"login":"TheProductWorks","id":8091747,"avatar_url":"https://avatars.githubusercontent.com/u/8091747?v=3","gravatar_id":"","url":"https://api.github.com/users/TheProductWorks","html_url":"https://github.com/TheProductWorks","followers_url":"https://api.github.com/users/TheProductWorks/followers","following_url":"https://api.github.com/users/TheProductWorks/following{/other_user}","gists_url":"https://api.github.com/users/TheProductWorks/gists{/gist_id}","starred_url":"https://api.github.com/users/TheProductWorks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheProductWorks/subscriptions","organizations_url":"https://api.github.com/users/TheProductWorks/orgs","repos_url":"https://api.github.com/users/TheProductWorks/repos","events_url":"https://api.github.com/users/TheProductWorks/events{/privacy}","received_events_url":"https://api.github.com/users/TheProductWorks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TheProductWorks/SMART-android-app","description":"Android version of the SMART Care Tool for the Community Midwifery team in The National Maternity Hospital, Holles Street.","fork":true,"url":"https://api.github.com/repos/TheProductWorks/SMART-android-app","forks_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/forks","keys_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/teams","hooks_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/hooks","issue_events_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/issues/events{/number}","events_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/events","assignees_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/assignees{/user}","branches_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/branches{/branch}","tags_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/tags","blobs_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/git/refs{/sha}","trees_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/statuses/{sha}","languages_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/languages","stargazers_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/stargazers","contributors_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/contributors","subscribers_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/subscribers","subscription_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/subscription","commits_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/commits{/sha}","git_commits_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/git/commits{/sha}","comments_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/comments{/number}","issue_comment_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/issues/comments{/number}","contents_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/contents/{+path}","compare_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/merges","archive_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/downloads","issues_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/issues{/number}","pulls_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/pulls{/number}","milestones_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/milestones{/number}","notifications_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/labels{/name}","releases_url":"https://api.github.com/repos/TheProductWorks/SMART-android-app/releases{/id}","created_at":"2015-08-27T22:18:14Z","updated_at":"2015-08-27T22:37:51Z","pushed_at":"2015-09-13T14:56:25Z","git_url":"git://github.com/TheProductWorks/SMART-android-app.git","ssh_url":"git@github.com:TheProductWorks/SMART-android-app.git","clone_url":"https://github.com/TheProductWorks/SMART-android-app.git","svn_url":"https://github.com/TheProductWorks/SMART-android-app","homepage":"","size":11767,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":12,"forks":0,"open_issues":12,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TheProductWorks/SMART-android-app/pulls/16"},"html":{"href":"https://github.com/TheProductWorks/SMART-android-app/pull/16"},"issue":{"href":"https://api.github.com/repos/TheProductWorks/SMART-android-app/issues/16"},"comments":{"href":"https://api.github.com/repos/TheProductWorks/SMART-android-app/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/TheProductWorks/SMART-android-app/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/TheProductWorks/SMART-android-app/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TheProductWorks/SMART-android-app/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/TheProductWorks/SMART-android-app/statuses/418ac2e82c0dd6104dc39eb971fbbd9ea57043a8"}}}}