Skip to content

Commit 9b618ed

Browse files
authored
Bump pre-commit/pre-commit-hooks from 4.5.0 to 4.6.0 (#45)
### Description - Bump pre-commit/pre-commit-hooks from 4.5.0 to 4.6.0 - Transform some scripts from bash to sh
1 parent 69d2bed commit 9b618ed

9 files changed

Lines changed: 94 additions & 48 deletions

File tree

.github/workflows/functional-tests.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
name: Functional Tests
33

44
on: # yamllint disable-line rule:truthy
5+
pull_request: {}
56
push:
67
branches:
78
- "main"
8-
pull_request:
9+
10+
defaults:
11+
run:
12+
shell: sh
913

1014
jobs:
1115
package-manager:
@@ -27,20 +31,19 @@ jobs:
2731
type: scoop
2832
runs-on: ${{ matrix.os }}-latest
2933
steps:
30-
- uses: actions/checkout@v4
34+
- name: Checkout ${{ github.repository }}
35+
uses: actions/checkout@v4
3136
- name: Setup scoop
32-
if: ${{ runner.os == 'Windows' && matrix.type == 'scoop' }}
37+
if: ${{ matrix.type == 'scoop' }}
3338
uses: MinoruSekine/setup-scoop@main
3439
- name: Configure yarn
3540
if: ${{ runner.os == 'Windows' && matrix.type == 'yarn' }}
3641
run: yarn global bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
3742
shell: pwsh
3843
- name: Install snyk
3944
run: ./hooks/installation/install-${{ matrix.type }}.sh
40-
shell: bash
4145
- name: Print version
4246
run: snyk --version
43-
shell: sh
4447
standalone:
4548
name: Standalone
4649
timeout-minutes: 5
@@ -50,13 +53,12 @@ jobs:
5053
os: ["macos", "ubuntu", "windows"]
5154
runs-on: ${{ matrix.os }}-latest
5255
steps:
53-
- uses: actions/checkout@v4
56+
- name: Checkout ${{ github.repository }}
57+
uses: actions/checkout@v4
5458
- name: Install snyk
5559
run: ./hooks/installation/install-standalone.sh
56-
shell: bash
5760
- name: Print version
5861
run: snyk --version
59-
shell: sh
6062
standalone-alpine:
6163
name: Standalone
6264
timeout-minutes: 5
@@ -68,13 +70,11 @@ jobs:
6870
container:
6971
image: ${{ matrix.image }}:latest
7072
steps:
71-
- uses: actions/checkout@v4
73+
- name: Checkout ${{ github.repository }}
74+
uses: actions/checkout@v4
7275
- name: Install tools
73-
run: apk add bash curl
74-
shell: sh
76+
run: apk add curl
7577
- name: Install snyk
7678
run: ./hooks/installation/install-standalone.sh
77-
shell: bash
7879
- name: Print version
7980
run: snyk --version
80-
shell: sh

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ repos:
4343
- id: prettier
4444
stages: ["commit"]
4545
- repo: https://github.com/pre-commit/pre-commit-hooks
46-
rev: v4.5.0
46+
rev: v4.6.0
4747
hooks:
4848
- id: check-executables-have-shebangs
4949
- id: check-shebang-scripts-are-executable

hooks/installation/install-standalone.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22
set -eu
33

4-
if [[ -f "/etc/alpine-release" ]]; then
4+
if [ -f "/etc/alpine-release" ]; then
55
binary="snyk-alpine"
66
path="/usr/local/bin/"
77
else
@@ -19,7 +19,7 @@ else
1919
path="C:\Windows\System32"
2020
;;
2121
*)
22-
if [[ "$(uname -m)" == "arm64" ]]; then
22+
if [ "$(uname -m)" = "arm64" ]; then
2323
binary="snyk-linux-arm64"
2424
else
2525
binary="snyk-linux"
@@ -31,6 +31,6 @@ fi
3131

3232
url="https://static.snyk.io/cli/latest/$binary"
3333
echo "[pre-commit-snyk] GET $url"
34-
curl $url -o snyk
34+
curl "$url" -o snyk
3535
chmod +x ./snyk
36-
mv ./snyk $path
36+
mv ./snyk "$path"

hooks/installation/main.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
2+
# shellcheck disable=SC2039,SC3020
23
set -eu
34

4-
if ! command -v snyk &> /dev/null
5-
then
6-
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
5+
SCRIPT_PATH=$(realpath "$0")
6+
INSTALLATION_FOLDER_PATH=$(dirname "${SCRIPT_PATH}")
7+
8+
if ! command -v snyk &> /dev/null; then
79
if command -v brew &> /dev/null; then
8-
bash "${SCRIPT_DIR}"/install-brew.sh
10+
sh "${INSTALLATION_FOLDER_PATH}/install-brew.sh"
911
elif command -v scoop &> /dev/null; then
10-
bash "${SCRIPT_DIR}"/install-scoop.sh
12+
sh "${INSTALLATION_FOLDER_PATH}/install-scoop.sh"
1113
elif command -v npm &> /dev/null; then
12-
bash "${SCRIPT_DIR}"/install-npm.sh
14+
sh "${INSTALLATION_FOLDER_PATH}/install-npm.sh"
1315
elif command -v yarn &> /dev/null; then
14-
bash "${SCRIPT_DIR}"/install-yarn.sh
16+
sh "${INSTALLATION_FOLDER_PATH}/install-yarn.sh"
1517
else
16-
bash "${SCRIPT_DIR}"/install-standalone.sh
18+
sh "${INSTALLATION_FOLDER_PATH}/install-standalone.sh"
1719
fi
1820
fi

hooks/snyk-code.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22
set -eu
3-
SCRIPT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
4-
bash "${SCRIPT_DIR}"/installation/main.sh
3+
4+
SCRIPT_PATH=$(realpath "$0")
5+
HOOKS_FOLDER_PATH=$(dirname "${SCRIPT_PATH}")
6+
INSTALLATION_FOLDER_PATH="${HOOKS_FOLDER_PATH}/installation"
7+
8+
sh "${INSTALLATION_FOLDER_PATH}/main.sh"
59

610
snyk code test "$@"

hooks/snyk-container.sh

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
11
#!/usr/bin/env bash
22
set -eu
3-
SCRIPT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
4-
bash "${SCRIPT_DIR}"/installation/main.sh
3+
4+
SCRIPT_PATH=$(realpath "$0")
5+
HOOKS_FOLDER_PATH=$(dirname "${SCRIPT_PATH}")
6+
INSTALLATION_FOLDER_PATH="${HOOKS_FOLDER_PATH}/installation"
7+
8+
sh "${INSTALLATION_FOLDER_PATH}/main.sh"
9+
10+
prefix="[pre-commit-snyk]"
11+
12+
container_build() {
13+
tag="$1"
14+
path="$2"
15+
if command -v docker &> /dev/null; then
16+
docker build -t "$tag" "$path"
17+
elif command -v podman &> /dev/null; then
18+
podman build -t "$tag" "$path"
19+
else
20+
echo "$prefix docker or podman are not found. Please install one of these tools and try again"
21+
exit 1
22+
fi
23+
}
24+
25+
container_rmi() {
26+
image="$1"
27+
if command -v docker &> /dev/null; then
28+
docker rmi "$(docker images "$image" -q)" || printf "\n%s Unable to remove %s" "$prefix" "$image"
29+
elif command -v podman &> /dev/null; then
30+
podman rmi "$(podman images "$image" -q)" || printf "\n%s Unable to remove %s" "$prefix" "$image"
31+
else
32+
echo "$prefix docker or podman are not found. Please install one of these tools and try again"
33+
exit 1
34+
fi
35+
}
536

637
snyk_args=()
738
dockerfiles=()
@@ -13,22 +44,19 @@ for arg in "$@"; do
1344
fi
1445
done
1546

16-
prefix="[pre-commit-snyk]"
17-
1847
tag=$(date +%s)
1948
i=1
2049

2150
for file_path in "${dockerfiles[@]}"; do
2251
image="pre-commit-snyk:$tag-$i"
23-
if [[ $i -gt 1 ]]
24-
then
52+
if [ $i -gt 1 ]; then
2553
echo ""
2654
fi
2755
printf "%s Building %s from %s\n\n" "$prefix" "$image" "$file_path"
28-
docker build -t "$image" "$(echo "$file_path" | rev | cut -d'/' -f2- | rev)"
56+
container_build "$image" "$(echo "$file_path" | rev | cut -d'/' -f2- | rev)"
2957
printf "\n%s Testing %s\n" "$prefix" "$image"
3058
snyk container test "$image" "--file=$file_path" "${snyk_args[*]}"
3159
printf "\n%s Removing %s" "$prefix" "$image"
32-
docker rmi "$(docker images "$image" -q)" || printf "\n%s Unable to remove %s" "$prefix" "$image"
60+
container_rmi "$image"
3361
i=$((i + 1))
3462
done

hooks/snyk-iac.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22
set -eu
3-
SCRIPT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
4-
bash "${SCRIPT_DIR}"/installation/main.sh
3+
4+
SCRIPT_PATH=$(realpath "$0")
5+
HOOKS_FOLDER_PATH=$(dirname "${SCRIPT_PATH}")
6+
INSTALLATION_FOLDER_PATH="${HOOKS_FOLDER_PATH}/installation"
7+
8+
sh "${INSTALLATION_FOLDER_PATH}/main.sh"
59

610
snyk iac test "$@"

hooks/snyk-log4shell.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22
set -eu
3-
SCRIPT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
4-
bash "${SCRIPT_DIR}"/installation/main.sh
3+
4+
SCRIPT_PATH=$(realpath "$0")
5+
HOOKS_FOLDER_PATH=$(dirname "${SCRIPT_PATH}")
6+
INSTALLATION_FOLDER_PATH="${HOOKS_FOLDER_PATH}/installation"
7+
8+
sh "${INSTALLATION_FOLDER_PATH}/main.sh"
59

610
snyk log4shell "$@"

hooks/snyk-test.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
22
set -eu
3-
SCRIPT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
4-
bash "${SCRIPT_DIR}"/installation/main.sh
3+
4+
SCRIPT_PATH=$(realpath "$0")
5+
HOOKS_FOLDER_PATH=$(dirname "${SCRIPT_PATH}")
6+
INSTALLATION_FOLDER_PATH="${HOOKS_FOLDER_PATH}/installation"
7+
8+
sh "${INSTALLATION_FOLDER_PATH}/main.sh"
59

610
snyk test "$@"

0 commit comments

Comments
 (0)