Skip to content

Commit c005848

Browse files
committed
Merge branch 'develop' into cwl-283_rv355_grpc_proto
Signed-off-by: Lacewell, Chaunte W <[email protected]>
2 parents ad43d71 + 460b557 commit c005848

File tree

11 files changed

+405
-61
lines changed

11 files changed

+405
-61
lines changed

.github/coverage/cpp.develop.coverage_report.txt

Lines changed: 12 additions & 12 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
71.332
1+
68.113

.github/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ colorlog==6.9.0
55
coverage==7.8.0
66
cryptography==44.0.2
77
Flask==3.1.1
8-
gcovr==8.3
8+
gcovr==8.4
99
imutils==0.5.4
1010
itsdangerous==2.2.0
1111
Jinja2==3.1.6
@@ -14,7 +14,7 @@ MarkupSafe==3.0.2
1414
numpy==1.26.4
1515
opencv-python-headless==4.11.0.86
1616
pillow==11.1.0
17-
protobuf==4.24.2
17+
protobuf==4.25.8
1818
pycparser==2.22
1919
Pygments==2.19.1
2020
pyzmq==26.4.0

.github/scripts/Dockerfile.checkin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ RUN if [ "${BUILD_COVERAGE}" = "ON" ]; then \
307307
apt-get install -y --no-install-suggests --no-install-recommends gdb ; \
308308
apt-get clean ; \
309309
rm -rf /var/lib/apt/lists/* ; \
310-
python3 -m pip install --no-cache-dir "gcovr>=7.0" ; \
310+
python3 -m pip install --no-cache-dir "gcovr==8.4" ; \
311311
curl -L -o /vdms/minio https://dl.min.io/server/minio/release/linux-amd64/minio ; \
312312
chmod +x /vdms/minio ; \
313313
mkdir -p /vdms/minio_files/minio-bucket ; \

.github/scripts/setup_vdms.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ LIBEDIT_VERSION="20230828-3.1"
198198
NUMPY_MIN_VERSION="1.26.0"
199199
OPENCV_VERSION="4.9.0"
200200
PEG_VERSION="0.1.19"
201-
PROTOBUF_VERSION="24.2"
201+
PROTOBUF_VERSION="25.8"
202202
TILEDB_VERSION="2.14.1"
203203
VALIJSON_VERSION="v0.6"
204204
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: "CodeQL Analysis"
2+
3+
on:
4+
push:
5+
branches: [ "develop" ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
analyze-python:
10+
name: Analyze Python
11+
runs-on: ubuntu-latest
12+
13+
permissions:
14+
actions: read
15+
contents: read
16+
security-events: write
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Initialize CodeQL (Python)
23+
uses: github/codeql-action/init@v3
24+
with:
25+
languages: python
26+
27+
- name: Autobuild Python
28+
uses: github/codeql-action/autobuild@v3
29+
30+
- name: Perform CodeQL Analysis (Python)
31+
uses: github/codeql-action/analyze@v3
32+
33+
analyze-cpp:
34+
name: Analyze CPP
35+
runs-on: ubuntu-latest
36+
37+
# Run everything inside your Docker image
38+
container:
39+
image: intellabs/vdms:latest
40+
41+
permissions:
42+
actions: read
43+
contents: read
44+
security-events: write
45+
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
language: [ 'cpp' ] # VDMS is C++ based
50+
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
with:
55+
submodules: recursive
56+
57+
58+
- name: Install latest CMake
59+
run: |
60+
apt-get update
61+
apt-get remove --purge -y cmake cmake-data || true
62+
apt-get install -y wget tar xz-utils build-essential
63+
64+
CMAKE_VERSION=3.30.4
65+
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz
66+
tar -xzf cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz
67+
mv cmake-${CMAKE_VERSION}-linux-x86_64 /opt/cmake
68+
ln -sf /opt/cmake/bin/* /usr/local/bin/
69+
cmake --version
70+
71+
- name: Initialize CodeQL
72+
uses: github/codeql-action/init@v3
73+
with:
74+
languages: cpp
75+
queries: security-extended,security-and-quality
76+
build-mode: manual
77+
78+
- name: Configure CMake (disable linking)
79+
run: |
80+
sed -i "s|#include <stdio.h>|#include <stdio.h>\n#include <stdexcept>|" src/pmgd/test/neighbortest.cc
81+
sed -i "s|#include <stdio.h>|#include <stdio.h>\n#include <stdexcept>|" src/pmgd/tools/mkgraph.cc
82+
sed -i "s|java-11-openjdk|java-17-openjdk|g" src/pmgd/java/CMakeLists.txt
83+
cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
84+
-DCMAKE_C_LINK_EXECUTABLE="/bin/true" \
85+
-DCMAKE_CXX_LINK_EXECUTABLE="/bin/true"
86+
87+
- name: Build (compile only, no linking)
88+
run: cmake --build build -j$(nproc)
89+
90+
- name: Perform CodeQL Analysis
91+
uses: github/codeql-action/analyze@v3
92+
with:
93+
category: '/language:cpp'
94+
output: ./codeql-results
95+
96+
- name: Upload SARIF File
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name : codeql-results
100+
path: ./codeql-results/**/*.sarif
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Intel Security Scan
2+
3+
permissions: read-all
4+
5+
on:
6+
workflow_dispatch: {}
7+
schedule:
8+
- cron: "5 4 * * sun" # 4:05 AM Sunday
9+
10+
jobs:
11+
Call-Workflow:
12+
uses: intel/.github/.github/workflows/intel_scan.yaml@main
13+
permissions:
14+
contents: read
15+
packages: read
16+
actions: read
17+
security-events: write

src/PMGDQuery.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,8 @@ void PMGDQuery::QueryNode(int ref, const std::string &tag,
676676
const Json::Value &constraints,
677677
const Json::Value &results, bool unique,
678678
bool intermediate_query) {
679+
_readonly = false;
680+
679681
PMGDCmd *cmdquery = new PMGDCmd();
680682
cmdquery->set_cmd_id(PMGDCmd::QueryNode);
681683
cmdquery->set_cmd_grp_id(_current_group_id);
@@ -713,6 +715,8 @@ void PMGDQuery::QueryEdge(int ref, int src_ref, int dest_ref,
713715
const std::string &tag,
714716
const Json::Value &constraints,
715717
const Json::Value &results, bool unique) {
718+
_readonly = false;
719+
716720
PMGDCmd *cmdquery = new PMGDCmd();
717721
cmdquery->set_cmd_id(PMGDCmd::QueryEdge);
718722
cmdquery->set_cmd_grp_id(_current_group_id);

src/QueryHandlerNeo4j.cc

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -186,63 +186,75 @@ void QueryHandlerNeo4j::process_query(protobufs::queryMessage &proto_query,
186186
Json::Value json_responses;
187187
Json::Value cmd_result;
188188

189+
std::vector<std::string> images_log;
190+
189191
Json::Value root;
190192
int blob_count = 0;
191193
bool error = false;
192194

193-
rc = parse_commands(proto_query, root);
194-
// begin neo4j transaction
195-
tx = neoconn_pool->open_tx(conn, 10000, "w");
196-
for (int j = 0; j < root.size(); j++) {
197-
Json::Value neo4j_resp;
198-
std::string cypher;
195+
try {
196+
rc = parse_commands(proto_query, root);
197+
// begin neo4j transaction
198+
tx = neoconn_pool->open_tx(conn, 10000, "w");
199+
for (int j = 0; j < root.size(); j++) {
200+
Json::Value neo4j_resp;
201+
std::string cypher;
199202

200-
Json::Value &query = root[j];
201-
std::string cmd = query.getMemberNames()[0];
203+
Json::Value &query = root[j];
204+
std::string cmd = query.getMemberNames()[0];
202205

203206

204-
if (_rs_cmds.count(cmd) == 0) {
205-
std::cout<<"Command: " << cmd << "Does not exist!" << std::endl;
206-
}
207+
if (_rs_cmds.count(cmd) == 0) {
208+
std::cout<<"Command: " << cmd << "Does not exist!" << std::endl;
209+
}
207210

208-
Neo4jCommand *rscmd = _rs_cmds[cmd];
209-
cypher = query[cmd]["cypher"].asString();
211+
Neo4jCommand *rscmd = _rs_cmds[cmd];
212+
cypher = query[cmd]["cypher"].asString();
210213

211-
const std::string &blob =
212-
rscmd->need_blob(query) ? proto_query.blobs(blob_count++) : "";
214+
const std::string &blob =
215+
rscmd->need_blob(query) ? proto_query.blobs(blob_count++) : "";
213216

214-
rc = rscmd->data_processing(cypher, query, blob, 0, cmd_result);
215-
if (rc != 0) {
216-
error = true;
217-
proto_res.set_json(fastWriter.write(cmd_result));
218-
break;
219-
}
220-
res_stream = neoconn_pool->run_in_tx((char *)cypher.c_str(), tx);
221-
neo4j_resp = neoconn_pool->results_to_json(res_stream);
222-
query["cp_result"] = cmd_result;
223-
Json::Value resp_retval = rscmd->construct_responses(neo4j_resp, query, proto_res, blob);
224-
//THIS IS VERY CLUNKY and confusing, NEEDS TO BE REFACTORED
225-
if (neo4j_resp.isMember("metadata_res") && (cmd == "NeoAdd" || cmd == "NeoFind")) {
226-
resp_retval["metadata_res"] = neo4j_resp["metadata_res"];
227-
}
228-
json_responses.append(resp_retval);
217+
rc = rscmd->data_processing(cypher, query, blob, 0, cmd_result);
218+
if (rc != 0) {
219+
error = true;
220+
proto_res.set_json(fastWriter.write(cmd_result));
221+
break;
222+
}
223+
if (cmd_result.isMember("image_added")) {
224+
images_log.push_back(cmd_result["image_added"].asString());
225+
}
226+
res_stream = neoconn_pool->run_in_tx((char *)cypher.c_str(), tx);
227+
neo4j_resp = neoconn_pool->results_to_json(res_stream);
228+
query["cp_result"] = cmd_result;
229+
Json::Value resp_retval = rscmd->construct_responses(neo4j_resp, query, proto_res, blob);
230+
//THIS IS VERY CLUNKY and confusing, NEEDS TO BE REFACTORED
231+
if (neo4j_resp.isMember("metadata_res") && (cmd == "NeoAdd" || cmd == "NeoFind")) {
232+
resp_retval["metadata_res"] = neo4j_resp["metadata_res"];
233+
}
234+
json_responses.append(resp_retval);
229235

230236

231-
}
232-
proto_res.set_json(fastWriter.write(json_responses));
233-
// commit neo4j transaction, needs to be updated in future to account for
234-
// errors on response construction
235-
if (error == false) {
236-
rc = neoconn_pool->commit_tx(tx);
237-
238-
if(rc != 0){
239-
printf("Warning! Transaction Error: %d\n", rc);
240-
exit(1);
237+
}
238+
proto_res.set_json(fastWriter.write(json_responses));
239+
// commit neo4j transaction, needs to be updated in future to account for
240+
// errors on response construction
241+
if (error == false) {
242+
rc = neoconn_pool->commit_tx(tx);
243+
244+
if(rc != 0){
245+
printf("Warning! Transaction Error: %d\n", rc);
246+
exit(1);
247+
}
248+
241249
}
242250

251+
neoconn_pool->put_conn(conn);
252+
} catch(...) {
253+
VCL::RemoteConnection *connection = get_existing_connection();
254+
for (const std::string image : images_log) {
255+
connection->Remove_Object(image);
256+
}
243257
}
244-
245-
neoconn_pool->put_conn(conn);
246258
}
247259

248260
int QueryHandlerNeo4j::parse_commands(

src/QueryHandlerPMGD.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include "pmgd.h"
4848
#include "util.h"
4949
#include "PmgdFilter.h"
50+
#include "OpsIOCoordinator.h"
5051

5152
#include "APISchema.h"
5253
#include <jsoncpp/json/writer.h>
@@ -276,6 +277,16 @@ void QueryHandlerPMGD::process_query(
276277
Json::Value response;
277278
response.append(exception_error);
278279
proto_res.set_json(fastWriter.write(response));
280+
281+
if (VDMSConfig::instance()->get_aws_flag()) {
282+
VCL::RemoteConnection *connection = get_existing_connection();
283+
for (const std::string image : images_log) {
284+
connection->Remove_Object(image);
285+
}
286+
for (const std::string video : videos_log) {
287+
connection->Remove_Object(video);
288+
}
289+
}
279290
};
280291

281292
try {

0 commit comments

Comments
 (0)