mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2026-04-23 22:30:28 +00:00
ACS-10505 modifying libreoffice workdir and user's registryconfig file to block external links
This commit is contained in:
@@ -29,6 +29,7 @@ package org.alfresco.transform.base;
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.SERVICE_UNAVAILABLE;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE;
|
||||
|
||||
@@ -117,6 +118,9 @@ public class TransformController
|
||||
@Value("${container.behind-ingres}")
|
||||
private boolean behindIngres;
|
||||
|
||||
@Value("${transform.endpoint.test.enable}")
|
||||
private boolean enableTestEndpoint;
|
||||
|
||||
TransformEngine transformEngine;
|
||||
private final AtomicReference<ProbeTransform> probeTransform = new AtomicReference<>();
|
||||
|
||||
@@ -314,6 +318,12 @@ public class TransformController
|
||||
@RequestParam(value = TARGET_MIMETYPE, required = false) String targetMimetype,
|
||||
@RequestParam Map<String, String> origRequestParameters)
|
||||
{
|
||||
|
||||
if (!enableTestEndpoint)
|
||||
{
|
||||
throw new TransformException(SERVICE_UNAVAILABLE, "Test endpoint is disabled");
|
||||
}
|
||||
|
||||
// Remaps request parameters from test.html and hands them off to the normal transform endpoint.
|
||||
// There are name<i> and value<i> parameters which allow dynamic names and values to be used.
|
||||
Map<String, String> requestParameters = new HashMap<>();
|
||||
|
||||
@@ -36,6 +36,9 @@ logging:
|
||||
filestore-url: ${FILE_STORE_URL:http://localhost:8099/alfresco/api/-default-/private/sfs/versions/1/file}
|
||||
|
||||
transform:
|
||||
endpoint:
|
||||
test:
|
||||
enable: true
|
||||
core:
|
||||
version: @project.version@
|
||||
engine:
|
||||
|
||||
@@ -54,7 +54,7 @@ public class LibreOfficeProfileManager
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(LibreOfficeProfileManager.class);
|
||||
private static final String PROBE_RESOURCE = "/probe.doc";
|
||||
private static final String PATCH_RESOURCE = "/disable-external-link-patch.txt";
|
||||
private static final String PATCH_RESOURCE = "/libreoffice_registry_patch.json";
|
||||
private static final String REGISTRY_FILE = "registrymodifications.xcu";
|
||||
private static final String USER_PROFILE_DIR = "user";
|
||||
|
||||
@@ -152,16 +152,6 @@ public class LibreOfficeProfileManager
|
||||
FileUtils.writeStringToFile(registry, registryContent, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
// private String readPatchFromResource() throws Exception
|
||||
// {
|
||||
// InputStream inputStream = getClass().getResourceAsStream(PATCH_RESOURCE);
|
||||
// if (inputStream == null)
|
||||
// {
|
||||
// throw new IllegalStateException("disable-external-link-patch.txt resource not found!");
|
||||
// }
|
||||
// return IOUtils.toString(inputStream, StandardCharsets.UTF_8).trim();
|
||||
// }
|
||||
|
||||
private File findLibreOfficeUserProfile(File dir)
|
||||
{
|
||||
File userDir = findDirectChild(dir, USER_PROFILE_DIR);
|
||||
@@ -209,7 +199,7 @@ public class LibreOfficeProfileManager
|
||||
|
||||
private List<PatchItem> readPatchItemsFromJson() throws Exception
|
||||
{
|
||||
InputStream inputStream = getClass().getResourceAsStream("/libreoffice_registry_patch.json");
|
||||
InputStream inputStream = getClass().getResourceAsStream(PATCH_RESOURCE);
|
||||
if (inputStream == null)
|
||||
{
|
||||
throw new IllegalStateException("libreoffice_registry_patch.json not found!");
|
||||
|
||||
@@ -168,16 +168,6 @@ public class JodConverterSharedInstance implements JodConverter
|
||||
throw new RuntimeException(
|
||||
"OpenOffice template profile directory " + templateProfileDir + " does not exist.");
|
||||
}
|
||||
|
||||
// //making sure 'user' subdir exists
|
||||
// Optional<File> userFile = Arrays.stream(requireNonNull(tmp.listFiles()))
|
||||
// .filter(File::isDirectory)
|
||||
// .filter(f->f.getName().equals("user"))
|
||||
// .findAny();
|
||||
// if(userFile.isEmpty()) {
|
||||
// File userDir = new File(tmp, "user");
|
||||
// }
|
||||
|
||||
this.templateProfileDir = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user