mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-21 09:01:56 -07:00
Avoid leaking access token to log by filter it out
This commit is contained in:
parent
7ccb47d206
commit
546791d938
3 changed files with 18 additions and 5 deletions
|
|
@ -47,7 +47,7 @@ public class InstallModActivity extends LoggableActivity
|
|||
appendToLog("");
|
||||
}
|
||||
});
|
||||
JREUtils.redirectAndPrintJRELog(this);
|
||||
JREUtils.redirectAndPrintJRELog(this, null);
|
||||
|
||||
final File modFile = (File) getIntent().getExtras().getSerializable("modFile");
|
||||
final String javaArgs = getIntent().getExtras().getString("javaArgs");
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ public class JREUtils
|
|||
}
|
||||
}
|
||||
|
||||
public static void redirectAndPrintJRELog(final LoggableActivity act) {
|
||||
private static boolean checkAccessTokenLeak = true;
|
||||
public static void redirectAndPrintJRELog(final LoggableActivity act, final String accessToken) {
|
||||
JREUtils.redirectLogcat();
|
||||
Log.v("jrelog","Log starts here");
|
||||
Thread t = new Thread(new Runnable(){
|
||||
|
|
@ -59,12 +60,24 @@ public class JREUtils
|
|||
while ((line = reader.readLine()) != null) {
|
||||
act.appendlnToLog(line);
|
||||
}
|
||||
reader.close();
|
||||
*/
|
||||
|
||||
byte[] buf = new byte[512];
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = p.getInputStream().read(buf)) != -1) {
|
||||
act.appendToLog(new String(buf, 0, len));
|
||||
String currStr = new String(buf, 0, len);
|
||||
|
||||
// Avoid leaking access token to log by replace it.
|
||||
// Also, Minecraft will just print it once.
|
||||
if (checkAccessTokenLeak) {
|
||||
checkAccessTokenLeak = false;
|
||||
if (accessToken != null && accessToken.length() > 5 && currStr.contains(accessToken)) {
|
||||
currStr.replace(accessToken, "ACCESS_TOKEN_HIDDEN");
|
||||
}
|
||||
}
|
||||
|
||||
act.appendToLog(currStr);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e("jrelog-logcat", "IOException on logging thread");
|
||||
|
|
|
|||
|
|
@ -952,7 +952,7 @@ public class MainActivity extends LoggableActivity implements OnTouchListener, O
|
|||
// checkJavaArgsIsLaunchable();
|
||||
appendlnToLog("Info: Custom Java arguments: \"" + LauncherPreferences.PREF_CUSTOM_JAVA_ARGS + "\"");
|
||||
|
||||
JREUtils.redirectAndPrintJRELog(this);
|
||||
JREUtils.redirectAndPrintJRELog(this, mProfile.getAccessToken());
|
||||
Tools.launchMinecraft(this, mProfile, mVersionInfo);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue