Merge remote-tracking branch 'origin/GP-5207_ghidra1_BSimElasticBugs' into patch

This commit is contained in:
Ryan Kurtz
2024-12-19 11:15:11 -05:00
2 changed files with 13 additions and 6 deletions

View File

@@ -206,8 +206,14 @@ public class CreateBsimServerInfoDialog extends DialogComponentProvider {
nameField = new NotifyingTextField();
hostField = new NotifyingTextField();
portField =
new NotifyingTextField(Integer.toString(BSimServerInfo.DEFAULT_POSTGRES_PORT));
int defaultPort = -1;
if (type == BSimServerInfo.DBType.postgres) {
defaultPort = BSimServerInfo.DEFAULT_POSTGRES_PORT;
}
else if (type == BSimServerInfo.DBType.elastic) {
defaultPort = BSimServerInfo.DEFAULT_ELASTIC_PORT;
}
portField = new NotifyingTextField(Integer.toString(defaultPort));
JLabel nameLabel = new JLabel("DB Name:", SwingConstants.RIGHT);
JLabel hostLabel = new JLabel("Host:", SwingConstants.RIGHT);

View File

@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -1144,6 +1144,7 @@ public class ElasticDatabase implements FunctionDatabase {
String exeId, DescriptionManager manager, int maxDocuments) throws ElasticException {
long total;
long start = 0;
long count = 0;
do {
int limit = MAX_FUNCTION_WINDOW;
if (maxDocuments != 0 && maxDocuments - start < limit) {
@@ -1162,6 +1163,7 @@ public class ElasticDatabase implements FunctionDatabase {
doc = (JSONObject) element;
FunctionDescription funcDesc = convertDescriptionRow(doc, exeRecord, manager, null);
listFunctions.add(funcDesc);
++count;
}
if (hitsarray.size() == 0) {
break; // Shouldn't need this, but just in case
@@ -1169,7 +1171,7 @@ public class ElasticDatabase implements FunctionDatabase {
JSONArray sort = (JSONArray) doc.get("sort");
start = (Long) sort.get(0); // Sort value for last entry, for passing as search_after parameter
}
while (total > start);
while (total > count);
return (int) total;
}
@@ -1766,7 +1768,6 @@ public class ElasticDatabase implements FunctionDatabase {
buffer.append(
"{ \"script\": { \"inline\": \"if ((ctx._source.count -= params.count) <=0) { ctx.op = \\\"delete\\\" }\", ");
buffer.append("\"params\": { \"count\": ").append(entry.count).append("} } }\n");
maxVectors -= 1;
}
JSONObject resp = connection.executeBulk("/_bulk", buffer.toString());
JSONArray items = (JSONArray) resp.get("items");