Skip to content

Commit

Permalink
chore(http-json): block certain URLs (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmetzke authored Dec 12, 2022
1 parent 0280b31 commit 861c89c
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import io.camunda.connector.http.model.ErrorResponse;
import io.camunda.connector.http.model.HttpJsonRequest;
import io.camunda.connector.http.model.HttpJsonResult;
import io.camunda.connector.impl.ConnectorInputException;
import io.camunda.connector.impl.config.ConnectorConfigurationUtil;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -55,6 +56,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.validation.ValidationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -232,6 +234,10 @@ public void writeTo(OutputStream outputStream) throws IOException {

protected HttpRequest createRequest(final HttpJsonRequest request, String bearerToken)
throws IOException {
// TODO: add more holistic solution
if (request.getUrl().contains("computeMetadata")) {
throw new ConnectorInputException(new ValidationException("The provided URL is not allowed"));
}
final String method = request.getMethod().toUpperCase();
final GenericUrl genericUrl = new GenericUrl(request.getUrl());
final HttpContent content = createContent(request);
Expand Down

0 comments on commit 861c89c

Please sign in to comment.