Skip to content

Commit

Permalink
Fix for NR-286896, where incorrect route calculated when empty route …
Browse files Browse the repository at this point in the history
…detected
  • Loading branch information
IshikaDawda committed Jul 25, 2024
1 parent 7960d89 commit d1a2e22
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,17 +317,21 @@ public void registerOperation(AbstractOperation operation) {
processStackTrace(operation);
// boolean blockNeeded = checkIfBlockingNeeded(operation.getApiID());
// securityMetaData.getMetaData().setApiBlocked(blockNeeded);
HttpRequest request = securityMetaData.getRequest();
// if (StringUtils.isEmpty(request.getRoute())){

// fallback mechanism for route detection
Framework frameWork = Framework.UNKNOWN;
if(!securityMetaData.getFuzzRequestIdentifier().getK2Request() && StringUtils.isNotBlank(securityMetaData.getMetaData().getFramework())) {
if(StringUtils.isNotBlank(securityMetaData.getMetaData().getFramework())) {
frameWork = Framework.valueOf(securityMetaData.getMetaData().getFramework());
}
HttpRequest request = securityMetaData.getRequest();
if (!securityMetaData.getFuzzRequestIdentifier().getK2Request() && StringUtils.isEmpty(request.getRoute())){
request.setRoute(getEndpointRoute(StringUtils.substringBefore(request.getUrl(), "?"), frameWork), true);
String route = getEndpointRoute(StringUtils.substringBefore(request.getUrl(), "?"), frameWork);
if( route != null){
request.setRoute(route);
}
logger.log(LogLevel.FINEST,"Route detection using Application Endpoint", this.getClass().getName());
}
// }

if (needToGenerateEvent(operation.getApiID())) {
DispatcherPool.getInstance().dispatchEvent(operation, securityMetaData);
if (!firstEventProcessed.get()) {
Expand Down Expand Up @@ -379,7 +383,7 @@ private String getEndpointRoute(String uri) {
}
}
}
return StringUtils.EMPTY;
return null;
}

private int jumpRoute(List<RouteSegment> value, int i1, List<String> uriSegments, int i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public String getRoute() {
}

public void setRoute(String route){
this.route = StringUtils.removeEnd(StringUtils.prependIfMissing(route, StringUtils.SEPARATOR), StringUtils.SEPARATOR);
this.route = StringUtils.prependIfMissing(StringUtils.removeEnd(route, StringUtils.SEPARATOR), StringUtils.SEPARATOR);
}

public void setRoute(String segment, boolean isAlreadyServlet) {
Expand Down

0 comments on commit d1a2e22

Please sign in to comment.