Skip to content

Commit aaad501

Browse files
committed
apply a filter to select only cSploit releases from MSF repo
1 parent d06a4ac commit aaad501

1 file changed

Lines changed: 30 additions & 8 deletions

File tree

cSploit/src/org/csploit/android/net/GitHubParser.java

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
package org.csploit.android.net;
2222

23-
import org.csploit.android.core.Logger;
23+
import org.csploit.android.core.*;
24+
import org.csploit.android.core.System;
2425
import org.json.JSONArray;
2526
import org.json.JSONException;
2627
import org.json.JSONObject;
@@ -46,12 +47,23 @@ public class GitHubParser {
4647
private JSONObject mLastCommit = null;
4748
private JSONObject mLastRelease = null;
4849

50+
private String mTagFilter = null;
51+
4952
private static GitHubParser msfRepo = new GitHubParser("cSploit", "android.MSF");
5053
private static GitHubParser cSploitRepo = new GitHubParser("cSploit", "android");
5154
private static GitHubParser coreRepo = new GitHubParser("cSploit", "android.native");
5255
private static GitHubParser rubyRepo = new GitHubParser("cSploit", "android.native.ruby");
5356

5457
public static GitHubParser getMsfRepo() {
58+
String customUsername = System.getSettings().getString("MSF_GITHUB_USERNAME", "cSploit");
59+
String customProject = System.getSettings().getString("MSF_GITHUB_PROJECT", "android.MSF");
60+
61+
if(!customUsername.equals(msfRepo.username) || !customProject.equals(msfRepo.project)) {
62+
msfRepo = new GitHubParser(customUsername, customProject);
63+
}
64+
65+
msfRepo.mTagFilter = "csploit";
66+
5567
return msfRepo;
5668
}
5769

@@ -89,13 +101,21 @@ private void fetchReleases() throws IOException, JSONException {
89101
for(int i=0;i<releases.length();i++) {
90102
release = releases.getJSONObject(i);
91103

92-
if(!release.getBoolean("draft") && !release.getBoolean("prerelease")) {
93-
if(!found) {
94-
mLastRelease = release;
95-
found = true;
96-
}
97-
mReleases.put(release);
104+
if(release.getBoolean("draft") || release.getBoolean("prerelease"))
105+
continue;
106+
107+
if(mTagFilter != null) {
108+
String tag = release.getString("tag_name");
109+
110+
if(!tag.matches(mTagFilter))
111+
continue;
98112
}
113+
114+
if(!found) {
115+
mLastRelease = release;
116+
found = true;
117+
}
118+
mReleases.put(release);
99119
}
100120
}
101121

@@ -151,7 +171,9 @@ public synchronized String getLastReleaseVersion() throws JSONException, IOExcep
151171
if(mLastRelease==null)
152172
return null;
153173

154-
return mLastRelease.getString("tag_name").substring(1);
174+
String name = mLastRelease.getString("tag_name");
175+
176+
return name.startsWith("v") ? name.substring(1) : name;
155177
}
156178

157179
public synchronized String getLastReleaseAssetUrl() throws JSONException, IOException {

0 commit comments

Comments
 (0)