Codacy compliant

This commit is contained in:
Samuel Huang
2024-10-01 00:15:33 +10:00
parent 3ae14cfa24
commit c1f71bf1bb
18 changed files with 73 additions and 129 deletions

View File

@@ -1,60 +0,0 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow checks out code, performs a Codacy security scan
# and integrates the results with the
# GitHub Advanced Security code scanning feature. For more information on
# the Codacy security scan action usage and parameters, see
# https://github.com/codacy/codacy-analysis-cli-action.
# For more information on Codacy Analysis CLI in general, see
# https://github.com/codacy/codacy-analysis-cli.
name: Codacy Security Scan
on:
push:
branches: [ "master", "dev" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
schedule:
- cron: '45 16 * * 5'
permissions:
contents: read
jobs:
codacy-security-scan:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
name: Codacy Security Scan
runs-on: ubuntu-latest
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout code
uses: actions/checkout@v3
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@d840f886c4bd4edc059706d09c6a1586111c540b
with:
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
# You can also omit the token and run the tools that support default configurations
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
verbose: true
output: results.sarif
format: sarif
# Adjust severity of non-security issues
gh-code-scanning-compat: true
# Force 0 exit code to allow SARIF file generation
# This will handover control about PR rejection to the GitHub side
max-allowed-issues: 2147483647
# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif

4
run.sh
View File

@@ -136,7 +136,7 @@ while true ; do
done
# Invoking all hook-URLs
if [ -n "${HOOKURL}" ]; then
if [ "${#HOOKURL[@]}" -gt 0 ]; then
for URL in "${HOOKURL[@]}"
do
echo "curl -sSL $URL"
@@ -185,7 +185,7 @@ if [ -n "${STSVR}" ]; then
done
fi
if [ -n "${NGSVR}" ]; then
if [ "${#NGSVR[@]}" -gt 0 ]; then
for svropt in "${NGSVR[@]}"
do
NGOPT="${NGOPT} --ng-server ${svropt},$xopt"

View File

@@ -7,10 +7,10 @@ usage() {
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
IFS=',' read -a options <<< "$1"
IFS=',' read -ra options <<< "$1"
for option in "${options[@]}"
do
IFS='=' read -a kv <<< "$option"
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
d|domain)
domain="${kv[1]}"
@@ -65,7 +65,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles
# User settings
for user in "${xuser[@]}"
do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}")
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi
@@ -99,5 +99,5 @@ do
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound
echo "$inbound"
exit 0

View File

@@ -7,10 +7,10 @@ usage() {
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
IFS=',' read -a options <<< "$1"
IFS=',' read -ra options <<< "$1"
for option in "${options[@]}"
do
IFS='=' read -a kv <<< "$option"
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
d|dest)
dest="${kv[1]}"
@@ -64,7 +64,7 @@ fi
if [ -z "${prvkey}" ]; then
>&2 echo -e "Warning: PrivateKey undefined, Generated new...\n"
kv=($(/usr/local/bin/xray x25519|cut -d ' ' -f3|tr ' '))
read -ra kv <<< "$(/usr/local/bin/xray x25519|cut -d ' ' -f3|tr '\r\n' ' ')"
prvkey="${kv[0]}"
pubkey="${kv[1]}"
>&2 echo -e "PublicKey: $pubkey\n"
@@ -88,7 +88,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles
# User settings
for user in "${xuser[@]}"
do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}")
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi
@@ -136,5 +136,5 @@ do
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound
echo "$inbound"
exit 0

View File

@@ -7,10 +7,10 @@ usage() {
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
IFS=',' read -a options <<< "$1"
IFS=',' read -ra options <<< "$1"
for option in "${options[@]}"
do
IFS='=' read -a kv <<< "$option"
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -81,7 +81,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles
# User settings
for user in "${xuser[@]}"
do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}")
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi
@@ -117,5 +117,5 @@ do
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound
echo "$inbound"
exit 0

View File

@@ -7,10 +7,10 @@ usage() {
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
IFS=',' read -a options <<< "$1"
IFS=',' read -ra options <<< "$1"
for option in "${options[@]}"
do
IFS='=' read -a kv <<< "$option"
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
d|domain)
domain="${kv[1]}"
@@ -65,7 +65,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles
# User settings
for user in "${xuser[@]}"
do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}")
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi

View File

@@ -7,10 +7,10 @@ usage() {
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
IFS=',' read -a options <<< "$1"
IFS=',' read -ra options <<< "$1"
for option in "${options[@]}"
do
IFS='=' read -a kv <<< "$option"
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -81,7 +81,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles
# User settings
for user in "${xuser[@]}"
do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}")
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi

View File

@@ -7,10 +7,10 @@ usage() {
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
IFS=',' read -a options <<< "$1"
IFS=',' read -ra options <<< "$1"
for option in "${options[@]}"
do
IFS='=' read -a kv <<< "$option"
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
d|dest)
dest="${kv[1]}"
@@ -61,7 +61,7 @@ fi
if [ -z "${prvkey}" ]; then
>&2 echo -e "Warning: PrivateKey undefined, Generated new...\n"
kv=($(/usr/local/bin/xray x25519|cut -d ' ' -f3|tr ' '))
read -ra kv <<< "$(/usr/local/bin/xray x25519|cut -d ' ' -f3|tr '\r\n' ' ')"
prvkey="${kv[0]}"
pubkey="${kv[1]}"
>&2 echo -e "PublicKey: $pubkey\n"
@@ -80,7 +80,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles
# User settings
for user in "${xuser[@]}"
do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}")
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi
@@ -128,5 +128,5 @@ do
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound
echo "$inbound"
exit 0

View File

@@ -7,10 +7,10 @@ usage() {
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
IFS=',' read -a options <<< "$1"
IFS=',' read -ra options <<< "$1"
for option in "${options[@]}"
do
IFS='=' read -a kv <<< "$option"
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -73,7 +73,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles
# User settings
for user in "${xuser[@]}"
do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}")
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi
@@ -109,5 +109,5 @@ do
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound
echo "$inbound"
exit 0

View File

@@ -7,10 +7,10 @@ usage() {
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
IFS=',' read -a options <<< "$1"
IFS=',' read -ra options <<< "$1"
for option in "${options[@]}"
do
IFS='=' read -a kv <<< "$option"
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
d|domain)
domain="${kv[1]}"
@@ -65,7 +65,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles
# User settings
for user in "${xuser[@]}"
do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}")
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi
@@ -99,5 +99,5 @@ do
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound
echo "$inbound"
exit 0

View File

@@ -7,10 +7,10 @@ usage() {
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
IFS=',' read -a options <<< "$1"
IFS=',' read -ra options <<< "$1"
for option in "${options[@]}"
do
IFS='=' read -a kv <<< "$option"
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -81,7 +81,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vles
# User settings
for user in "${xuser[@]}"
do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}")
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi
@@ -117,5 +117,5 @@ do
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound
echo "$inbound"
exit 0

View File

@@ -7,10 +7,10 @@ usage() {
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
IFS=',' read -a options <<< "$1"
IFS=',' read -ra options <<< "$1"
for option in "${options[@]}"
do
IFS='=' read -a kv <<< "$option"
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -73,7 +73,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vmes
# User settings
for user in "${xuser[@]}"
do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}")
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi
@@ -109,5 +109,5 @@ do
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound
echo "$inbound"
exit 0

View File

@@ -7,10 +7,10 @@ usage() {
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
IFS=',' read -a options <<< "$1"
IFS=',' read -ra options <<< "$1"
for option in "${options[@]}"
do
IFS='=' read -a kv <<< "$option"
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
d|domain)
domain="${kv[1]}"
@@ -65,7 +65,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vmes
# User settings
for user in "${xuser[@]}"
do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}")
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi
@@ -102,5 +102,5 @@ do
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound
echo "$inbound"
exit 0

View File

@@ -7,10 +7,10 @@ usage() {
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
IFS=',' read -a options <<< "$1"
IFS=',' read -ra options <<< "$1"
for option in "${options[@]}"
do
IFS='=' read -a kv <<< "$option"
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -81,7 +81,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"vmes
# User settings
for user in "${xuser[@]}"
do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}")
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi
@@ -120,5 +120,5 @@ do
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound
echo "$inbound"
exit 0

View File

@@ -69,10 +69,10 @@ sed -i '/\#STREAM_TAG/d' $NGCONF
# Generate Nginx Stream server configuration.
if [ -n "${STSVR}" ]; then
options=($(echo $STSVR |tr ',' ' '))
IFS=',' read -ra options <<< "$STSVR"
for option in "${options[@]}"
do
kv=($(echo $option |tr '=' ' '))
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
p|port)
STPORT="${kv[1]}"
@@ -82,6 +82,7 @@ options=($(echo $STSVR |tr ',' ' '))
;;
esac
done
unset IFS
if [ -z "${STPORT}" ]; then STPORT=443; fi
if ! [ "${STPORT}" -eq "${STPORT}" ] 2>/dev/null; then >&2 echo "Stream port number must be numeric"; exit 1; fi
@@ -90,10 +91,10 @@ options=($(echo $STSVR |tr ',' ' '))
cat ${STREAM_TPL} >> $NGCONF
for stmap in "${STMAP[@]}"
do
options=($(echo $stmap |tr ',' ' '))
IFS=',' read -ra options <<< "$stmap"
for option in "${options[@]}"
do
kv=($(echo $option |tr '=' ' '))
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
sni)
sni="${kv[1]}"
@@ -103,6 +104,7 @@ options=($(echo $STSVR |tr ',' ' '))
;;
esac
done
unset IFS
# Naming the upstream as yahoo_com_jp for SNI yahoo.com.jp
upsname="${sni//\./_}"
echo " $sni $upsname;" >>/tmp/stmap.conf
@@ -132,10 +134,10 @@ do
unset certhome NGPROTOCOL
# removing site default config file if any.
rm -rf /etc/nginx/conf.d/00_default_*.conf
options=($(echo $ngsvr |tr ',' ' '))
IFS=',' read -ra options <<< "$ngsvr"
for option in "${options[@]}"
do
kv=($(echo $option |tr '=' ' '))
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -153,6 +155,7 @@ do
;;
esac
done
unset IFS
if [ -z "${certhome}" ]; then echo -e "Error: Nginx certhome undefined.\n"; usage; exit 1; fi
if [ "${#SITEDOMAINS[@]}" -eq 0 ]; then echo -e "Error: Nginx site domain undefined.\n"; usage; exit 1; fi
@@ -199,10 +202,10 @@ done
for ngproxy in "${NGPROXY[@]}"
do
unset XDOMAINS xhost xport xlocation xnetwork
options=($(echo $ngproxy |tr ',' ' '))
IFS=',' read -ra options <<< "$ngproxy"
for option in "${options[@]}"
do
kv=($(echo $option |tr '=' ' '))
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
d|domain)
XDOMAINS+=("${kv[1]}")
@@ -221,6 +224,7 @@ do
;;
esac
done
unset IFS
if [ -z "${xhost}" ]; then xhost="127.0.0.1"; fi
if [ "${#XDOMAINS[@]}" -eq 0 ]; then XDOMAINS=("${ALLDOMAINS[@]}"); fi

View File

@@ -7,10 +7,10 @@ usage() {
>&2 echo -e "User format: user|u=<uid>[:level:email]"
}
IFS=',' read -a options <<< "$1"
IFS=',' read -ra options <<< "$1"
for option in "${options[@]}"
do
IFS='=' read -a kv <<< "$option"
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -73,7 +73,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"troj
# User settings
for user in "${xuser[@]}"
do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}")
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi

View File

@@ -7,10 +7,10 @@ usage() {
>&2 echo -e "User format: user=<uid>[:level:email]"
}
IFS=',' read -a options <<< "$1"
IFS=',' read -ra options <<< "$1"
for option in "${options[@]}"
do
IFS='=' read -a kv <<< "$option"
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
d|domain)
domain="${kv[1]}"
@@ -65,7 +65,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"troj
# User settings
for user in "${xuser[@]}"
do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}")
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi
@@ -102,5 +102,5 @@ do
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound
echo "$inbound"
exit 0

View File

@@ -7,10 +7,10 @@ usage() {
>&2 echo -e "User format: user=<uid>[:level:email]"
}
IFS=',' read -a options <<< "$1"
IFS=',' read -ra options <<< "$1"
for option in "${options[@]}"
do
IFS='=' read -a kv <<< "$option"
IFS='=' read -ra kv <<< "$option"
case "${kv[0]}" in
c|certhome)
certhome="${kv[1]}"
@@ -81,7 +81,7 @@ inbound=$(jq -nc --arg port "${port}" '{"port":($port|tonumber),"protocol":"troj
# User settings
for user in "${xuser[@]}"
do
IFS=':'; uopt=(${user}); uopt=(${uopt[@]})
IFS=':'; uopt=("${user}"); uopt=("${uopt[@]}")
uid="${uopt[0]}"; level="${uopt[1]}"; email="${uopt[2]}"
unset IFS
if [ -z "${uid}" ]; then >&2 echo -e "Incorrect user format: $user\n"; usage; exit 1; fi
@@ -120,5 +120,5 @@ do
inbound=$(echo $inbound| jq -c --argjson Jfb "${Jfb}" '.settings.fallbacks += [$Jfb]')
done
echo $inbound
echo "$inbound"
exit 0