Skip to content

Commit 8bc6532

Browse files
committed
chore: added pre-commit hook for sourcecode sample files execution permissions
1 parent a9d736d commit 8bc6532

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,18 @@ repos:
203203
always_run: true
204204
pass_filenames: false
205205

206+
# Checks that tests/malware_analyzer/pypi/resources/sourcecode_samples files do not have executable permissions
207+
# This is another measure to make sure the files can't be accidentally executed
208+
- repo: local
209+
hooks:
210+
- id: sourcecode-sample-permissions
211+
name: Sourcecode sample executable permissions checker
212+
entry: scripts/dev_scripts/samples_permissions_checker.sh
213+
language: system
214+
always_run: true
215+
pass_filenames: false
216+
217+
206218
# A linter for Golang
207219
- repo: https://github.com/golangci/golangci-lint
208220
rev: v1.61.0
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2022 - 2025, Oracle and/or its affiliates. All rights reserved.
4+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
5+
6+
#
7+
# Checks if the files in tests/malware_analyzer/pypi/resources/sourcecode_samples have executable permissions,
8+
# failing if any do.
9+
#
10+
11+
MACARON_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd ../.. && pwd)"
12+
SAMPLES_PATH="${MACARON_DIR}/tests/malware_analyzer/pypi/resources/sourcecode_samples"
13+
14+
# any files have any of the executable bits set
15+
executables=$(find "$SAMPLES_PATH" -type f -perm -u+x -o -type f -perm -g+x -o -type f -perm -o+x)
16+
if [ -n "$executables" ]; then
17+
echo "The following files should not have any executable permissions:"
18+
echo "$executables"
19+
exit 1
20+
fi

0 commit comments

Comments
 (0)