mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 10:03:43 -05:00
Sanitise s3 info and fix for s3
This commit is contained in:
parent
9936fbe3c9
commit
52e5d2921f
5 changed files with 56 additions and 14 deletions
|
@ -29,7 +29,9 @@ public class Config implements JSONSource {
|
||||||
config.apiBaseURL,
|
config.apiBaseURL,
|
||||||
config.postbackURL,
|
config.postbackURL,
|
||||||
config.serviceName,
|
config.serviceName,
|
||||||
Oauth2.asSanitised(config.oauth2)
|
Oauth2.asSanitised(config.oauth2),
|
||||||
|
SwapStoreConfig.sanitisedCopy(config.swapStore),
|
||||||
|
config.swapJob
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,14 +58,18 @@ public class Config implements JSONSource {
|
||||||
fromJSON(new Gson().fromJson(reader, JsonElement.class));
|
fromJSON(new Gson().fromJson(reader, JsonElement.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Config(int port,
|
public Config(
|
||||||
String rootGitDirectory,
|
int port,
|
||||||
String username,
|
String rootGitDirectory,
|
||||||
String password,
|
String username,
|
||||||
String apiBaseURL,
|
String password,
|
||||||
String postbackURL,
|
String apiBaseURL,
|
||||||
String serviceName,
|
String postbackURL,
|
||||||
Oauth2 oauth2) {
|
String serviceName,
|
||||||
|
Oauth2 oauth2,
|
||||||
|
SwapStoreConfig swapStore,
|
||||||
|
SwapJobConfig swapJob
|
||||||
|
) {
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.rootGitDirectory = rootGitDirectory;
|
this.rootGitDirectory = rootGitDirectory;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
|
@ -72,6 +78,8 @@ public class Config implements JSONSource {
|
||||||
this.postbackURL = postbackURL;
|
this.postbackURL = postbackURL;
|
||||||
this.serviceName = serviceName;
|
this.serviceName = serviceName;
|
||||||
this.oauth2 = oauth2;
|
this.oauth2 = oauth2;
|
||||||
|
this.swapStore = swapStore;
|
||||||
|
this.swapJob = swapJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -153,6 +153,7 @@ public class SwapJobImpl implements SwapJob {
|
||||||
projName,
|
projName,
|
||||||
swapStore.openDownloadStream(projName)
|
swapStore.openDownloadStream(projName)
|
||||||
);
|
);
|
||||||
|
swapStore.remove(projName);
|
||||||
dbStore.setLastAccessedTime(
|
dbStore.setLastAccessedTime(
|
||||||
projName,
|
projName,
|
||||||
Timestamp.valueOf(LocalDateTime.now())
|
Timestamp.valueOf(LocalDateTime.now())
|
||||||
|
|
|
@ -60,4 +60,17 @@ public class SwapStoreConfig {
|
||||||
return s3BucketName;
|
return s3BucketName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SwapStoreConfig sanitisedCopy() {
|
||||||
|
return new SwapStoreConfig(
|
||||||
|
type,
|
||||||
|
awsAccessKey == null ? null : "<awsAccessKey>",
|
||||||
|
awsSecret == null ? null : "<awsSecret>",
|
||||||
|
s3BucketName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SwapStoreConfig sanitisedCopy(SwapStoreConfig swapStore) {
|
||||||
|
return swapStore == null ? null : swapStore.sanitisedCopy();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,14 +62,20 @@ public class WLRepositoryResolver
|
||||||
/* Such as FailedConnectionException */
|
/* Such as FailedConnectionException */
|
||||||
throw e;
|
throw e;
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
Log.warn("Runtime exception when trying to open repo", e);
|
Log.warn(
|
||||||
|
"Runtime exception when trying to open repo: " + projName,
|
||||||
|
e
|
||||||
|
);
|
||||||
throw new ServiceMayNotContinueException(e);
|
throw new ServiceMayNotContinueException(e);
|
||||||
} catch (ForbiddenException e) {
|
} catch (ForbiddenException e) {
|
||||||
throw new ServiceNotAuthorizedException();
|
throw new ServiceNotAuthorizedException();
|
||||||
} catch (GitUserException e) {
|
} catch (GitUserException e) {
|
||||||
throw new ServiceMayNotContinueException(e.getMessage(), e);
|
throw new ServiceMayNotContinueException(e.getMessage(), e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.warn("IOException when trying to open repo", e);
|
Log.warn(
|
||||||
|
"IOException when trying to open repo: " + projName,
|
||||||
|
e
|
||||||
|
);
|
||||||
throw new ServiceMayNotContinueException("Internal server error.");
|
throw new ServiceMayNotContinueException("Internal server error.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import uk.ac.ic.wlgitbridge.snapshot.servermock.util.FileUtil;
|
||||||
import uk.ac.ic.wlgitbridge.util.Util;
|
import uk.ac.ic.wlgitbridge.util.Util;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -629,8 +630,18 @@ public class WLGitBridgeIntegrationTest {
|
||||||
int exitCode = gitProcess.waitFor();
|
int exitCode = gitProcess.waitFor();
|
||||||
if (exitCode != 0) {
|
if (exitCode != 0) {
|
||||||
System.err.println("git clone failed. Dumping stderr and stdout.");
|
System.err.println("git clone failed. Dumping stderr and stdout.");
|
||||||
System.err.println(IOUtils.toString(gitProcess.getErrorStream()));
|
System.err.println(
|
||||||
System.err.println(IOUtils.toString(gitProcess.getInputStream()));
|
IOUtils.toString(
|
||||||
|
gitProcess.getErrorStream(),
|
||||||
|
StandardCharsets.UTF_8
|
||||||
|
)
|
||||||
|
);
|
||||||
|
System.err.println(
|
||||||
|
IOUtils.toString(
|
||||||
|
gitProcess.getInputStream(),
|
||||||
|
StandardCharsets.UTF_8
|
||||||
|
)
|
||||||
|
);
|
||||||
fail("git clone failed");
|
fail("git clone failed");
|
||||||
}
|
}
|
||||||
File repositoryDir = new File(dir, repositoryName);
|
File repositoryDir = new File(dir, repositoryName);
|
||||||
|
@ -680,7 +691,10 @@ public class WLGitBridgeIntegrationTest {
|
||||||
if (swapCfg != null) {
|
if (swapCfg != null) {
|
||||||
cfgStr += ",\n" +
|
cfgStr += ",\n" +
|
||||||
" \"swapStore\": {\n" +
|
" \"swapStore\": {\n" +
|
||||||
" \"type\": \"memory\"\n" +
|
" \"type\": \"memory\",\n" +
|
||||||
|
" \"awsAccessKey\": null,\n" +
|
||||||
|
" \"awsSecret\": null,\n" +
|
||||||
|
" \"s3BucketName\": \"com.overleaf.testbucket\"\n" +
|
||||||
" },\n" +
|
" },\n" +
|
||||||
" \"swapJob\": {\n" +
|
" \"swapJob\": {\n" +
|
||||||
" \"minProjects\": " +
|
" \"minProjects\": " +
|
||||||
|
|
Loading…
Reference in a new issue