Skip to content

Commit

Permalink
Fixed static code analysis issues
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaSBrown committed Apr 9, 2024
1 parent 8592941 commit e8bf07e
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 36 deletions.
6 changes: 3 additions & 3 deletions compose/cleanup_globus_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ export DATAFED_GLOBUS_CRED_FILE_PATH="$DATAFED_HOST_CRED_FILE_PATH"

if [ -f "$DATAFED_HOST_CRED_FILE_PATH" ]
then
export GCS_CLI_CLIENT_ID=$(cat "${DATAFED_HOST_CRED_FILE_PATH}" | jq -r .client)
export GCS_CLI_CLIENT_SECRET=$(cat "${DATAFED_HOST_CRED_FILE_PATH}" | jq -r .secret)
export GCS_CLI_CLIENT_ID=$(jq -r .client < "${DATAFED_HOST_CRED_FILE_PATH}")
export GCS_CLI_CLIENT_SECRET=$(jq -r .secret < "${DATAFED_HOST_CRED_FILE_PATH}")
fi

if [ -f "$DATAFED_GLOBUS_DEPLOYMENT_KEY_PATH" ]
then
export GCS_CLI_ENDPOINT_ID=$(cat "${DATAFED_GLOBUS_DEPLOYMENT_KEY_PATH}" | jq -r .client_id)
export GCS_CLI_ENDPOINT_ID=$(jq -r .client_id < "${DATAFED_GLOBUS_DEPLOYMENT_KEY_PATH}")
fi

sudo globus-connect-server node cleanup
Expand Down
4 changes: 2 additions & 2 deletions compose/generate_globus_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ then
mkdir -p "$local_DATAFED_GLOBUS_KEY_DIR"
fi

. ${PROJECT_ROOT}/compose/.env
. "${PROJECT_ROOT}/compose/.env"

DATAFED_GLOBUS_DEPLOYMENT_KEY_PATH="$DATAFED_HOST_DEPLOYMENT_KEY_PATH" \
DATAFED_GLOBUS_CRED_FILE_PATH="$DATAFED_HOST_CRED_FILE_PATH" \
DATAFED_GLOBUS_CONTROL_PORT="$DATAFED_GLOBUS_CONTROL_PORT" \
DATAFED_GLOBUS_SUBSCRIPTION="$DATAFED_GLOBUS_SUBSCRIPTION" \
DATAFED_GCS_ROOT_NAME="$DATAFED_GCS_ROOT_NAME" \
python3 ${PROJECT_ROOT}/scripts/globus/initialize_globus_endpoint.py
python3 "${PROJECT_ROOT}/scripts/globus/initialize_globus_endpoint.py"
2 changes: 1 addition & 1 deletion repository/docker/entrypoint_authz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ do
msg='.'
sleep 5

HTTP_CODE=$(${DATAFED_DEPENDENCIES_INSTALL_PATH}/bin/curl -s -o /dev/null -w "%{http_code}\n" -I "https://${DATAFED_GCS_URL}/api/info")
HTTP_CODE=$("${DATAFED_DEPENDENCIES_INSTALL_PATH}/bin/curl" -s -o /dev/null -w "%{http_code}\n" -I "https://${DATAFED_GCS_URL}/api/info")
if [ "$HTTP_CODE" == "200" ]
then
break
Expand Down
4 changes: 2 additions & 2 deletions repository/docker/entrypoint_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ PROJECT_ROOT=$(realpath "${SOURCE}/../..")
# This is only part of the solution the other part is running chown
if [ -n "$UID" ]; then
echo "Switching datafed user to UID: ${UID}"
usermod -u $UID datafed
chown -R datafed:root ${PROJECT_ROOT}
usermod -u "$UID" datafed
chown -R datafed:root "${PROJECT_ROOT}"
chown -R datafed:root /opt/datafed/repo/
chown -R datafed:root /mnt/datafed
fi
Expand Down
6 changes: 3 additions & 3 deletions repository/gridftp/globus5/authz/source/libauthz.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ bool setConfigVal(const char *a_label, char *a_dest, char *a_src,

if (len > a_max_len) {
AUTHZ_LOG_ERROR(
"DataFed - '%s' value too long in authz config file (max %lu).\n",
"DataFed - '%s' value too long in authz config file (max %zu).\n",
a_label, a_max_len);
return true;
}
Expand Down Expand Up @@ -483,6 +483,8 @@ globus_result_t gsi_authz_authorize_async(va_list ap) {

AUTHZ_LOG_DEBUG("libauthz.c GLOBUS_GRIDFTP_GUEST_IDENTITY_IDS: %s\n",
callout_ids1);
AUTHZ_LOG_DEBUG("libauthz.c GLOBUS_GRIDFTP_MAPPED_USERNAME: %s\n",
callout_username_mapped1);
AUTHZ_LOG_DEBUG("libauthz.c GLOBUS_GRIDFTP_MAPPED_IDENTITY_ID: %s\n",
callout_id_mapped1);
AUTHZ_LOG_INFO("Allowed collection path: %s, action: %s, object is %s\n",
Expand Down Expand Up @@ -572,8 +574,6 @@ globus_result_t gsi_authz_authorize_async(va_list ap) {
}

char *callout_ids = getenv("GLOBUS_GRIDFTP_GUEST_IDENTITY_IDS");
char *callout_username_mapped =
getenv("GLOBUS_GRIDFTP_MAPPED_USERNAME");
char *callout_id_mapped =
getenv("GLOBUS_GRIDFTP_MAPPED_IDENTITY_ID");

Expand Down
2 changes: 1 addition & 1 deletion scripts/dependency_install_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,14 @@ install_libcurl() {
mkdir -p "${PROJECT_ROOT}/external/libcurl"
tar -xf "curl-${DATAFED_LIBCURL}.tar.gz" -C "${PROJECT_ROOT}/external/libcurl"
cd "${PROJECT_ROOT}/external/libcurl/curl-${DATAFED_LIBCURL}"
PKG_CONFIG_PATH="${DATAFED_DEPENDENCIES_INSTALL_PATH}/lib/pkgconfig" \

# Making third party features and dependencies explicit
# OpenSSL is needed for HTTPS encryption
# File - allows caching requires libc
# GNUTLS - HTTPS support session management certificate verification etc
# NOTE: NSS - Network Security Services for HTTP support is deprecated
# NOTE: metalink - is no longer supported and not a valid argument
PKG_CONFIG_PATH="${DATAFED_DEPENDENCIES_INSTALL_PATH}/lib/pkgconfig" \
./configure --with-ssl="${DATAFED_DEPENDENCIES_INSTALL_PATH}" --with-gnutls --with-zlib \
--enable-file --disable-shared \
--disable-ldap --disable-ldaps --disable-rtsp --disable-dict \
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_authz_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ else
local_DATAFED_GCS_COLLECTION_ROOT_PATH=$(printenv DATAFED_GCS_COLLECTION_ROOT_PATH)
fi

if [ -z $DATAFED_GLOBUS_REPO_USER ]
if [ -z "${DATAFED_GLOBUS_REPO_USER}" ]
then
local_DATAFED_AUTHZ_USER="$DATAFED_GLOBUS_REPO_USER"
else
Expand Down
2 changes: 0 additions & 2 deletions scripts/globus/create_guest_collection.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import globus_sdk
from globus_sdk import AccessTokenAuthorizer
import utils
import os
import sys


# The Globus project the GCS endpoint will be created in
Expand Down
2 changes: 1 addition & 1 deletion scripts/globus/globus_cleanup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import globus_sdk
from globus_sdk import AuthClient, GroupsClient
from globus_sdk import AuthClient, GroupsClient
from globus_sdk.scopes import GroupsScopes
import subprocess
import sys
Expand Down
2 changes: 1 addition & 1 deletion scripts/globus/initialize_globus_endpoint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import globus_sdk
import utils
from globus_sdk import AuthClient, GroupsClient
from globus_sdk import AuthClient, GroupsClient
from globus_sdk.scopes import GroupsScopes

import os
Expand Down
24 changes: 7 additions & 17 deletions scripts/globus/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import globus_sdk
import subprocess
from globus_sdk import AuthClient, AccessTokenAuthorizer
import json
import os
import sys
Expand Down Expand Up @@ -145,7 +143,7 @@ def validFile(file_name):
def getCredentialFromFile(cred_file_name, cred_id):
# Check to see if the local secret is the same id and not just the same
# name
cred_exists_locally, cred_empty = validFile(cred_file_name)
_, cred_empty = validFile(cred_file_name)
if cred_empty is False:
with open(cred_file_name, "r") as f:
loaded_data = json.load(f)
Expand All @@ -157,7 +155,7 @@ def getCredentialFromFile(cred_file_name, cred_id):
def getClientIdFromCredFile(cred_file_name):
# Check to see if the local secret is the same id and not just the same
# name
cred_exists_locally, cred_empty = validFile(cred_file_name)
_, cred_empty = validFile(cred_file_name)
if cred_empty is False:
with open(cred_file_name, "r") as f:
loaded_data = json.load(f)
Expand All @@ -168,7 +166,7 @@ def getClientIdFromCredFile(cred_file_name):
def getEndpointIdFromFile(deployment_key_file_path):
# Check to see if the local secret is the same id and not just the same
# name
exists_locally, empty = validFile(deployment_key_file_path)
_, empty = validFile(deployment_key_file_path)
if empty is False:
with open(deployment_key_file_path, "r") as f:
loaded_data = json.load(f)
Expand Down Expand Up @@ -230,12 +228,6 @@ def createClient(auth_client, client_name, project_id, cred_name, cred_file):

cred_id = getCredentialID(auth_client, client_id, cred_name)

cred_exists_on_cloud = False
if cred_id:
cred_exists_on_cloud = True

cred_exists_locally, cred_empty = validFile(cred_file)

client_secret = getClientSecret(
auth_client, client_id, cred_name, cred_id, cred_file
)
Expand Down Expand Up @@ -285,11 +277,10 @@ def isGCSDeploymentKeyValid(auth_client, project_id, endpoint_name, gcs_id):
else:
# Found a globus_connect_server but did not find local deployment
# key
if deployment_key_empty:
print(
"Found globus_connect_server already registered but did"
" not find deployment key locally."
)
print(
"Found globus_connect_server already registered but did"
" not find deployment key locally."
)
return False


Expand All @@ -314,7 +305,6 @@ def createGCSEndpoint(
userinfo,
):

identity_id = userinfo["sub"]
email = userinfo["email"]
username = userinfo["preferred_username"]
organization = userinfo["identity_provider_display_name"]
Expand Down
4 changes: 2 additions & 2 deletions web/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ if [ -n "$UID" ]; then
usermod -u "$UID" datafed
fi

chown -R datafed:root ${DATAFED_INSTALL_PATH}/web
chown -R datafed:root ${BUILD_DIR}
chown -R datafed:root "${DATAFED_INSTALL_PATH}/web"
chown -R datafed:root "${BUILD_DIR}"

SCRIPT=$(realpath "$0")
SOURCE=$(dirname "$SCRIPT")
Expand Down

0 comments on commit e8bf07e

Please sign in to comment.