Skip to content

Commit

Permalink
[risk=no] [PD-14784] Genetic Variant Search Changes and DOS applicati…
Browse files Browse the repository at this point in the history
…on hang up fix (#1462)

* survey queries for location data

* survey queries for location data

* survey queries for location data

* survey queries for location data

* survey queries for location data

* trying to fix DOS breakage on <

---------

Co-authored-by: Srushti Gangireddy <[email protected]>
  • Loading branch information
SrushtiGangireddy and Srushti Gangireddy authored Sep 19, 2024
1 parent 77f9e76 commit be94630
Show file tree
Hide file tree
Showing 13 changed files with 214 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public static String modifyMultipleMatchKeyword(String query, SearchType searchT
public Slice<DbConcept> searchConcepts(String query, StandardConceptFilter standardConceptFilter, List<Long> conceptIds, List<String> vocabularyIds, String domainId, int limit, int minCount, int page,
TestFilter testFilter, OrderFilter orderFilter) {


Specification<DbConcept> conceptSpecification =
(root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> predicates = new ArrayList<>();
Expand All @@ -151,6 +152,7 @@ public Slice<DbConcept> searchConcepts(String query, StandardConceptFilter stand
Pattern regex = Pattern.compile("[$&+,:;=\\\\?@#|/'<>.^*()%!-]");
if (keyword != null && regex.matcher(keyword).find() && keyword.length() == 1) {
keyword = "\"" + keyword + "\"";
keyword = escapeSpecialCharacters(keyword);
}

Expression<Double> matchExp = null;
Expand Down Expand Up @@ -261,10 +263,17 @@ public List<Concept> getSourceConcepts(Long conceptId, Integer count) {
.collect(Collectors.toList());
}

// Escaping function to safely handle special characters
private String escapeSpecialCharacters(String input) {
return input.replaceAll("<", "\\<") // Escape less-than
.replaceAll(">", "\\>"); // Escape greater-than
}

public List<Long> getDrugIngredientsByBrand(String query) {
Pattern regex = Pattern.compile("[$&+,:;=\\\\?@#|/'<>.^*()%!-]");
if (query != null && regex.matcher(query).find() && query.length() == 1) {
query = "\"" + query + "\"";
query = escapeSpecialCharacters(query);
}
return conceptDao.findDrugIngredientsByBrand(query);
}
Expand Down
12 changes: 6 additions & 6 deletions public-api/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Uncomment the following to turn on full SQL debugging
#logging.level.org.hibernate.SQL=DEBUG
#logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
spring.jpa.properties.hibernate.show_sql=true
#spring.jpa.properties.hibernate.show_sql=true
#spring.jpa.properties.hibernate.format_sql=true
#spring.jpa.properties.hibernate.type=trace

Expand Down Expand Up @@ -31,11 +31,11 @@ spring.liquibase.enabled=false
management.endpoints.enabled-by-default=false
spring.jackson.serialization.write-dates-as-timestamps=false

logging.level.org.springframework.security=DEBUG
#logging.level.org.springframework.security=DEBUG

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration

spring.log.debug=true
logging.level.root=DEBUG
logging.level.org.springframework.web=DEBUG
logging.level.org.springframework.web.filter.CommonsRequestLoggingFilter=DEBUG
#spring.log.debug=true
#logging.level.root=DEBUG
#logging.level.org.springframework.web=DEBUG
#logging.level.org.springframework.web.filter.CommonsRequestLoggingFilter=DEBUG
34 changes: 30 additions & 4 deletions public-ui/src/app/app-routing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ export const AppRoutingComponent: React.FunctionComponent = () => {
path="/variants"
component={() =>
GenomicViewComponent({
selectionId: 2,
routeData: {
title: "SNV/Indel Variants",
breadcrumb: { value: "SNV/Indel Variants" },
title: "Variants",
breadcrumb: { value: "Variants" },
},
})
}
Expand All @@ -118,9 +119,34 @@ export const AppRoutingComponent: React.FunctionComponent = () => {
path="/variants/:search"
component={() =>
GenomicViewComponent({
selectionId: 2,
routeData: {
title: "SNVIndel Variants",
breadcrumb: { value: "SNV/Indel Variants" },
title: "Variants",
breadcrumb: { value: "Variants" },
},
})
}
/>
<AppRoute
path="/structural-variants"
component={() =>
GenomicViewComponent({
selectionId: 4,
routeData: {
title: "Variants",
breadcrumb: { value: "Variants" },
},
})
}
/>
<AppRoute
path="/structural-variants/:search"
component={() =>
GenomicViewComponent({
selectionId: 4,
routeData: {
title: "Variants",
breadcrumb: { value: "Variants" },
},
})
}
Expand Down
30 changes: 26 additions & 4 deletions public-ui/src/app/data-browser/databrowser-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ const routes: Routes = [
component: AppRouting,
canActivate: [IsSafeGuard],
data: {
title: "SNV/Indel Variants",
title: "Variants",
breadcrumb: {
value: "SNV/Indel Variants",
value: "Variants",
},
},
},
Expand All @@ -97,9 +97,31 @@ const routes: Routes = [
component: AppRouting,
canActivate: [IsSafeGuard],
data: {
title: "SNV/Indel Variants",
title: "Variants",
breadcrumb: {
value: "SNV/Indel Variants",
value: "Variants",
},
},
},
{
path: "structural-variants",
component: AppRouting,
canActivate: [IsSafeGuard],
data: {
title: "Variants",
breadcrumb: {
value: "Variants",
},
},
},
{
path: "structural-variants/:search",
component: AppRouting,
canActivate: [IsSafeGuard],
data: {
title: "Variants",
breadcrumb: {
value: "Variants",
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ export const EhrViewReactComponent = withRouteData(
}

fetchConcepts(searchRequest: any, append: boolean) {
console.log('Fetching ????');
dataBrowserApi()
.searchConcepts(searchRequest)
.then((results) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class GenomicSearchComponent extends React.Component<Props, State> {
super(props);
this.scrollDiv = React.createRef();
this.state = {
searchTerm: null,
searchTerm: this.props.searchTerm || "",
filterMetadata: this.props.filterMetadata,
sortMetadata: this.props.sortMetadata,
submittedFilterMetadata: this.props.submittedFilterMetadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class VariantSearchComponent extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
searchWord: "",
searchWord: this.props.searchTerm || "",
filterShow: false,
filteredMetadata: undefined,
filteredMetaMap: undefined,
Expand Down Expand Up @@ -204,6 +204,8 @@ export class VariantSearchComponent extends React.Component<Props, State> {
const variantListSizeDisplay = variantListSize
? variantListSize.toLocaleString()
: 0;
console.log(searchWord);
console.log(searchWord.length);
return (
<React.Fragment>
<style>{css}</style>
Expand Down
Loading

0 comments on commit be94630

Please sign in to comment.