Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,4 @@ public void updateShouldRemoveImpFromUpdateBidRequestWhenAllBiddersFiltered() {
assertThat(result.getImp()).isEmpty();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,4 @@ public void getShouldThrowExceptionWhenBucketNotFound() {
assertThat(ar.cause().getMessage()).contains("Bucket not found");
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public LiveIntentOmniChannelIdentityProcessedAuctionRequestHook(LiveIntentOmniCh
double logSamplingRate) {

this.config = Objects.requireNonNull(config);
HttpUtil.validateUrlSyntax(config.getIdentityResolutionEndpoint());
HttpUtil.validateUrl(config.getIdentityResolutionEndpoint());
this.mapper = Objects.requireNonNull(mapper);
this.httpClient = Objects.requireNonNull(httpClient);
this.logSamplingRate = logSamplingRate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,4 @@ private ExtBidPrebid parseExtBidPrebid(Bid bid) {
return null;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,4 @@ public void shouldProduceReturnTrueWhenConfigIsEnabledAndBidRequestHasApp() {
private static Config givenConfig(boolean enabled) {
return Config.of(true, AppVideoHtmlConfig.of(enabled, null));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ PbRichmediaFilterModule pbRichmediaFilterModule(
new BidResponsesMraidFilter(),
new ModuleConfigResolver(mapper, globalProperties))));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,4 @@ public MraidFilterResult filterByPattern(String mraidScriptPattern,

return MraidFilterResult.of(filteredResponses, analyticsResults);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,4 @@ private static BidderBid givenBid(String impId, String adm) {
private static BidderError givenError(String... rejectedImps) {
return BidderError.of("Invalid bid", BidderError.Type.invalid_bid, Set.of(rejectedImps));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,4 @@ public void resolveShouldReturnGlobalConfigWhenAccountConfigMissingProperties()
// then
assertThat(actualProperties).isEqualTo(GLOBAL_PROPERTIES);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -280,5 +280,4 @@ private static AnalyticsResult givenAnalyticsResult(String bidder, String... rej
Bid.builder().id("bid-" + impId).impid(impId).build()).build()).toList(),
RESPONSE_REJECTED_INVALID_CREATIVE);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ public void shouldHaveValidInitialConfigs() {
// given and when and then
assertThat(PbRichmediaFilterModule.CODE).isEqualTo("pb-richmedia-filter");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,4 @@ private static SchemaFunctionArguments<BidRequest, RequestRuleContext> givenFunc
null,
RequestRuleContext.of(AuctionContext.builder().build(), Granularity.Request.instance(), "datacenter"));
}

}
19 changes: 0 additions & 19 deletions extra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
<commons.collections.version>4.4</commons.collections.version>
<commons.compress.version>1.27.1</commons.compress.version>
<commons-math3.version>3.6.1</commons-math3.version>
<commons-validator.version>1.10.0</commons-validator.version>
<scram.version>2.1</scram.version>
<httpclient.version>4.5.14</httpclient.version>
<ipaddress.version>5.5.1</ipaddress.version>
<oshi.version>6.8.0</oshi.version>
<json-schema-validator.version>1.5.6</json-schema-validator.version>
Expand Down Expand Up @@ -137,23 +135,6 @@
<artifactId>commons-math3</artifactId>
<version>${commons-math3.version}</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>${commons-validator.version}</version>
</dependency>
<!-- TODO: refactor code to replace URIBuilder with something else so that this dep can be removed -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.seancfoley</groupId>
<artifactId>ipaddress</artifactId>
Expand Down
12 changes: 4 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
<groupId>io.vertx</groupId>
<artifactId>vertx-auth-common</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-uri-template</artifactId>
</dependency>
<dependency>
<groupId>com.ongres.scram</groupId>
<artifactId>client</artifactId>
Expand Down Expand Up @@ -110,14 +114,6 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
</dependency>
<dependency>
<groupId>com.github.seancfoley</groupId>
<artifactId>ipaddress</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.iab.openrtb.response.SeatBid;
import io.vertx.core.Future;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.http.client.utils.URIBuilder;
import org.prebid.server.analytics.AnalyticsReporter;
import org.prebid.server.analytics.model.AuctionEvent;
import org.prebid.server.analytics.model.NotificationEvent;
Expand All @@ -27,9 +26,9 @@
import org.prebid.server.log.LoggerFactory;
import org.prebid.server.proto.openrtb.ext.request.ExtRequest;
import org.prebid.server.proto.openrtb.ext.request.ExtRequestPrebid;
import org.prebid.server.util.Uri;
import org.prebid.server.vertx.httpclient.HttpClient;

import java.net.URISyntaxException;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
Expand All @@ -43,6 +42,7 @@ public class LiveIntentAnalyticsReporter implements AnalyticsReporter {

private final HttpClient httpClient;
private final LiveIntentAnalyticsProperties properties;
private final Uri analyticsEndpoint;
private final JacksonMapper jacksonMapper;

public LiveIntentAnalyticsReporter(
Expand All @@ -52,6 +52,7 @@ public LiveIntentAnalyticsReporter(

this.httpClient = Objects.requireNonNull(httpClient);
this.properties = Objects.requireNonNull(properties);
this.analyticsEndpoint = Uri.of(properties.getAnalyticsEndpoint());
this.jacksonMapper = Objects.requireNonNull(jacksonMapper);
}

Expand Down Expand Up @@ -96,12 +97,9 @@ private Future<Void> processAuctionEvent(AuctionContext auctionContext) {

try {
return httpClient.post(
new URIBuilder(properties.getAnalyticsEndpoint())
.setPath("/analytic-events/pbsj-bids")
.build()
.toString(),
jacksonMapper.encodeToString(pbsjBids),
properties.getTimeoutMs())
analyticsEndpoint.replaceMacro("path", "/analytic-events/pbsj-bids").expand(),
jacksonMapper.encodeToString(pbsjBids),
properties.getTimeoutMs())
.mapEmpty();
} catch (Exception e) {
logger.error("Error processing event: {}", e.getMessage());
Expand Down Expand Up @@ -169,18 +167,12 @@ private Optional<PbsjBid> buildPbsjBid(
}

private Future<Void> processNotificationEvent(NotificationEvent notificationEvent) {
try {
final String url = new URIBuilder(properties.getAnalyticsEndpoint())
.setPath("/analytic-events/pbsj-winning-bid")
.setParameter("b", notificationEvent.getBidder())
.setParameter("bidId", notificationEvent.getBidId())
.build()
.toString();
return httpClient.get(url, properties.getTimeoutMs()).mapEmpty();
} catch (URISyntaxException e) {
logger.error("Error composing url for notification event: {}", e.getMessage());
return Future.failedFuture(e);
}
final String url = analyticsEndpoint
.replaceMacro("path", "/analytic-events/pbsj-winning-bid")
.addQueryParam("b", notificationEvent.getBidder())
.addQueryParam("bidId", notificationEvent.getBidId())
.expand();
return httpClient.get(url, properties.getTimeoutMs()).mapEmpty();
}

@Override
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/prebid/server/auction/DsaEnforcer.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,4 @@ private ExtBidDsa getDsaResponse(JsonNode dsaExt) {
return null;
}
}

}
10 changes: 8 additions & 2 deletions src/main/java/org/prebid/server/auction/IpAddressHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@
import inet.ipaddr.IPAddressString;
import inet.ipaddr.IPAddressStringParameters;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.conn.util.InetAddressUtils;
import org.prebid.server.auction.model.IpAddress;
import org.prebid.server.log.Logger;
import org.prebid.server.log.LoggerFactory;

import java.util.List;
import java.util.regex.Pattern;

public class IpAddressHelper {

private static final Logger logger = LoggerFactory.getLogger(IpAddressHelper.class);

private static final Pattern IP_V4_PATTERN = Pattern.compile("""
^\
(?:[1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.\
(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){2}\
(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$
""".strip());
private static final IPAddressStringParameters IP_ADDRESS_VALIDATION_OPTIONS =
IPAddressString.DEFAULT_VALIDATION_OPTIONS.toBuilder()
.allowSingleSegment(false)
Expand Down Expand Up @@ -73,7 +79,7 @@ public IpAddress toIpAddress(String ip) {
}

public String maskIpv4(String ip) {
if (StringUtils.isBlank(ip) || !InetAddressUtils.isIPv4Address(ip)) {
if (StringUtils.isBlank(ip) || !IP_V4_PATTERN.matcher(ip).matches()) {
return ip;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ public class ImpRejection implements Rejection {
public static ImpRejection of(String impId, BidRejectionReason reason) {
return ImpRejection.of(null, impId, reason);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ public static BidAdjustmentType of(String name) {
return UNKNOWN;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ public static BidAdjustmentsRules of(BidAdjustments bidAdjustments) {

return BidAdjustmentsRules.of(MapUtils.unmodifiableMap(rules));
}

}
1 change: 0 additions & 1 deletion src/main/java/org/prebid/server/bidder/GenericBidder.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,4 @@ private static List<BidderBid> bidsFromResponse(BidRequest bidRequest, BidRespon
.map(bid -> BidderBid.of(bid, BidderUtil.getBidType(bid, impMap), bidResponse.getCur()))
.toList();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import io.vertx.core.http.HttpMethod;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.utils.URIBuilder;
import org.prebid.server.bidder.Bidder;
import org.prebid.server.bidder.adgeneration.model.AdgenerationResponse;
import org.prebid.server.bidder.model.BidderBid;
Expand All @@ -31,8 +30,8 @@
import org.prebid.server.proto.openrtb.ext.response.BidType;
import org.prebid.server.util.HttpUtil;
import org.prebid.server.util.ObjectUtil;
import org.prebid.server.util.Uri;

import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand All @@ -51,11 +50,11 @@ public class AdgenerationBidder implements Bidder<Void> {
new TypeReference<>() {
};

private final String endpointUrl;
private final Uri endpoint;
private final JacksonMapper mapper;

public AdgenerationBidder(String endpointUrl, JacksonMapper mapper) {
this.endpointUrl = HttpUtil.validateUrl(Objects.requireNonNull(endpointUrl));
this.endpoint = Uri.of(endpointUrl);
this.mapper = Objects.requireNonNull(mapper);
}

Expand Down Expand Up @@ -96,47 +95,41 @@ private ExtImpAdgeneration parseAndValidateImpExt(Imp imp) {
}

private String getUri(String adSize, String id, String currency, BidRequest bidRequest) {
final URIBuilder uriBuilder;
try {
uriBuilder = new URIBuilder(endpointUrl);
} catch (URISyntaxException e) {
throw new PreBidException("Invalid url: %s, error: %s".formatted(endpointUrl, e.getMessage()));
}

uriBuilder
.addParameter("posall", "SSPLOC")
.addParameter("id", id)
.addParameter("hb", "true")
.addParameter("t", "json3")
.addParameter("currency", currency)
.addParameter("sdkname", "prebidserver")
.addParameter("adapterver", VERSION);

addParameterIfNotEmpty(uriBuilder, "sizes", adSize);
addParameterIfNotEmpty(uriBuilder, "tp", ObjectUtil.getIfNotNull(bidRequest.getSite(), Site::getPage));
addParameterIfNotEmpty(uriBuilder, "appbundle", ObjectUtil.getIfNotNull(bidRequest.getApp(), App::getBundle));
addParameterIfNotEmpty(uriBuilder, "appname", ObjectUtil.getIfNotNull(bidRequest.getApp(), App::getName));
final Uri.ParameterizedUri parameterizedUri = endpoint
.addQueryParam("posall", "SSPLOC")
.addQueryParam("id", id)
.addQueryParam("hb", "true")
.addQueryParam("t", "json3")
.addQueryParam("currency", currency)
.addQueryParam("sdkname", "prebidserver")
.addQueryParam("adapterver", VERSION);

addParameterIfNotEmpty(parameterizedUri, "sizes", adSize);
addParameterIfNotEmpty(parameterizedUri, "tp", ObjectUtil.getIfNotNull(bidRequest.getSite(), Site::getPage));
addParameterIfNotEmpty(
parameterizedUri, "appbundle", ObjectUtil.getIfNotNull(bidRequest.getApp(), App::getBundle));
addParameterIfNotEmpty(parameterizedUri, "appname", ObjectUtil.getIfNotNull(bidRequest.getApp(), App::getName));
addParameterIfNotEmpty(
uriBuilder, "transactionid", ObjectUtil.getIfNotNull(bidRequest.getSource(), Source::getTid));
parameterizedUri, "transactionid", ObjectUtil.getIfNotNull(bidRequest.getSource(), Source::getTid));

final Device device = bidRequest.getDevice();
final String deviceOs = device != null ? device.getOs() : null;
if ("android".equals(deviceOs)) {
uriBuilder.addParameter("sdktype", "1");
addParameterIfNotEmpty(uriBuilder, "advertising_id", device.getIfa());
parameterizedUri.addQueryParam("sdktype", "1");
addParameterIfNotEmpty(parameterizedUri, "advertising_id", device.getIfa());
} else if ("ios".equals(deviceOs)) {
uriBuilder.addParameter("sdktype", "2");
addParameterIfNotEmpty(uriBuilder, "idfa", device.getIfa());
parameterizedUri.addQueryParam("sdktype", "2");
addParameterIfNotEmpty(parameterizedUri, "idfa", device.getIfa());
} else {
uriBuilder.addParameter("sdktype", "0");
parameterizedUri.addQueryParam("sdktype", "0");
}

return uriBuilder.toString();
return parameterizedUri.expand();
}

private static void addParameterIfNotEmpty(URIBuilder uriBuilder, String parameter, String value) {
private static void addParameterIfNotEmpty(Uri.ParameterizedUri parameterizedUri, String parameter, String value) {
if (StringUtils.isNotEmpty(value)) {
uriBuilder.addParameter(parameter, value);
parameterizedUri.addQueryParam(parameter, value);
}
}

Expand Down
Loading
Loading