Skip to content

Commit

Permalink
fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Aug 21, 2023
1 parent 0ff974e commit 2b3cd1b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class SampleFileStatusChecker implements StatusChecker {
@Override
public boolean isComplete(TransferProcess transferProcess, List<ProvisionedResource> resources) {
var destination = transferProcess.getDataRequest().getDataDestination();
var path = destination.getProperty("path");
var path = destination.getStringProperty("path");
return Optional.ofNullable(path)
.map(this::checkPath)
.orElse(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,12 @@ public boolean canHandle(DataFlowRequest request) {
return "file".equalsIgnoreCase(request.getDestinationDataAddress().getType());
}

@Override
public @NotNull Result<Boolean> validate(DataFlowRequest request) {
return Result.success(true);
}

@Override
public DataSink createSink(DataFlowRequest request) {
var destination = request.getDestinationDataAddress();

// verify destination path
var path = destination.getProperty("path");
var path = destination.getStringProperty("path");
// As this is a controlled test input below is to avoid path-injection warning by CodeQL
var destinationFile = new File(path.replaceAll("\\.", ".").replaceAll("/", "/"));

Expand All @@ -62,4 +57,9 @@ public DataSink createSink(DataFlowRequest request) {
.monitor(monitor)
.build();
}

@Override
public @NotNull Result<Void> validateRequest(DataFlowRequest request) {
return Result.success();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@ public boolean canHandle(DataFlowRequest dataRequest) {
}

@Override
public @NotNull Result<Boolean> validate(DataFlowRequest request) {
public DataSource createSource(DataFlowRequest request) {
var source = getFile(request);
if (!source.exists()) {
return Result.failure("Source file " + source.getName() + " does not exist!");
}

return Result.success(true);
return new FileTransferDataSource(source);
}

@Override
public DataSource createSource(DataFlowRequest request) {
public @NotNull Result<Void> validateRequest(DataFlowRequest request) {
var source = getFile(request);
return new FileTransferDataSource(source);
if (!source.exists()) {
return Result.failure("Source file " + source.getName() + " does not exist!");
}

return Result.success();
}

@NotNull
private File getFile(DataFlowRequest request) {
var dataAddress = request.getSourceDataAddress();
// verify source path
var sourceFileName = dataAddress.getProperty("filename");
var path = dataAddress.getProperty("path");
var sourceFileName = dataAddress.getStringProperty("filename");
var path = dataAddress.getStringProperty("path");
// As this is a controlled test input below is to avoid path-injection warning by CodeQL
sourceFileName = sourceFileName.replaceAll("\\.", ".").replaceAll("/", "/");
path = path.replaceAll("\\.", ".").replaceAll("/", "/");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public MarkerFileCreator(Monitor monitor) {
*/
@Override
public void preCompleted(final TransferProcess process) {
Path path = Path.of(process.getDataRequest().getDataDestination().getProperty("path"));
Path path = Path.of(process.getDataRequest().getDataDestination().getStringProperty("path"));
if (!Files.isDirectory(path)) {
path = path.getParent();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void initialize(ServiceExtensionContext context) {
private static class FileStatusChecker implements StatusChecker {
@Override
public boolean isComplete(TransferProcess transferProcess, List<ProvisionedResource> resources) {
var path = transferProcess.getDataDestination().getProperty("path");
var path = transferProcess.getDataDestination().getStringProperty("path");
return path != null && new File(path).exists();
}
}
Expand Down

0 comments on commit 2b3cd1b

Please sign in to comment.