Skip to content

Commit a18e2f6

Browse files
authored
fix: pass file to check as first bash-exec param (#7471)
When launching bash-exec, pass the file to check as the first parameter. Add a test for BASH_EXEC_IGNORE_LIBRARIES=true that was missing. Fix #7467
1 parent c285101 commit a18e2f6

17 files changed

Lines changed: 144 additions & 13 deletions

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,11 @@ jobs:
272272
env:
273273
LOG_LEVEL: DEBUG
274274
CREATE_LOG_FILE: true
275+
REMOVE_ANSI_COLOR_CODES_FROM_OUTPUT: true
275276
VALIDATE_ALL_CODEBASE: false
276277
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
277278
GITLEAKS_CONFIG_FILE: .gitleaks-ignore-tests.toml
278-
FILTER_REGEX_EXCLUDE: ".*(/test/linters/|CHANGELOG.md|/test/data/test-repository-contents/).*"
279+
FILTER_REGEX_EXCLUDE: ".*(/test/linters/|CHANGELOG.md|/test/data/detect-files-scripts/|/test/data/test-repository-contents/).*"
279280
RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES: "default.json,hoge.json"
280281

281282
- name: Get the contents of the log file
@@ -286,10 +287,11 @@ jobs:
286287
- name: Test Local Action (default log)
287288
uses: ./
288289
env:
290+
REMOVE_ANSI_COLOR_CODES_FROM_OUTPUT: true
289291
VALIDATE_ALL_CODEBASE: false
290292
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
291293
GITLEAKS_CONFIG_FILE: .gitleaks-ignore-tests.toml
292-
FILTER_REGEX_EXCLUDE: ".*(/test/linters/|CHANGELOG.md|/test/data/test-repository-contents/).*"
294+
FILTER_REGEX_EXCLUDE: ".*(/test/linters/|CHANGELOG.md|/test/data/detect-files-scripts/|/test/data/test-repository-contents/).*"
293295

294296
build-test-suite-matrix:
295297
name: Build test suite matrix

Makefile

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ test: \
3838
test-github-event-push-force-push \
3939
test-github-event-push-force-push-multiple-commits \
4040
test-runtime-dependencies-installation \
41+
test-linters-bash-exec-ignore-libraries-expect-failure \
42+
test-linters-bash-exec-ignore-libraries-expect-success \
4143
test-linters-expect-failure \
4244
test-linters-expect-failure-log-level-notice \
4345
test-linters-expect-failure-suppress-output-on-success \
@@ -137,10 +139,24 @@ info: ## Gather information about the runtime environment
137139
$(SUPER_LINTER_TEST_CONTAINER_URL) \
138140
| sort --human
139141

140-
.PHONY: check-github-token
141-
check-github-token:
142+
.PHONY: check-github-token-file
143+
check-github-token-file:
142144
@if [ ! -f "${GITHUB_TOKEN_PATH}" ]; then echo "Cannot find the file to load the GitHub access token: $(GITHUB_TOKEN_PATH). Create a readable file there, and populate it with a GitHub personal access token."; exit 1; fi
143145

146+
.PHONY: check-github-token
147+
check-github-token: check-github-token-file
148+
@if ! curl \
149+
--fail \
150+
-o /dev/null \
151+
--silent \
152+
-H "Authorization: Bearer $(shell cat "${GITHUB_TOKEN_PATH}")" \
153+
https://api.github.com/rate_limit; then \
154+
echo "GitHub token not valid or might be expired"; \
155+
exit 1; \
156+
else \
157+
echo "GitHub token successfully validated"; \
158+
fi
159+
144160
.PHONY: inspec
145161
inspec: inspec-check ## Run InSpec tests
146162
DOCKER_CONTAINER_STATE="$$(docker inspect --format "{{.State.Running}}" $(SUPER_LINTER_TEST_CONTAINER_NAME) 2>/dev/null || echo "")"; \
@@ -476,6 +492,20 @@ test-linters-expect-success: ## Run the linters test suite expecting successes
476492
"run_test_cases_expect_success" \
477493
"$(IMAGE)"
478494

495+
.PHONY: test-linters-bash-exec-ignore-libraries-expect-failure
496+
test-linters-bash-exec-ignore-libraries-expect-failure: ## Run the bash-exec linter test expecting failures
497+
$(CURDIR)/test/run-super-linter-tests.sh \
498+
$(SUPER_LINTER_TEST_CONTAINER_URL) \
499+
"run_test_cases_bash_exec_ignore_libraries_expect_failure" \
500+
"$(IMAGE)"
501+
502+
.PHONY: test-linters-bash-exec-ignore-libraries-expect-success
503+
test-linters-bash-exec-ignore-libraries-expect-success: ## Run the bash-exec linter test expecting successes
504+
$(CURDIR)/test/run-super-linter-tests.sh \
505+
$(SUPER_LINTER_TEST_CONTAINER_URL) \
506+
"run_test_cases_bash_exec_ignore_libraries_expect_success" \
507+
"$(IMAGE)"
508+
479509
.PHONY: test-linters-expect-failure
480510
test-linters-expect-failure: ## Run the linters test suite expecting failures
481511
$(CURDIR)/test/run-super-linter-tests.sh \

lib/functions/linterCommands.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ if [ -n "${BASH_SEVERITY:-}" ]; then
103103
export BASH_SEVERITY
104104
LINTER_COMMANDS_ARRAY_BASH+=(--severity="${BASH_SEVERITY}")
105105
fi
106-
LINTER_COMMANDS_ARRAY_BASH_EXEC=(bash-exec)
106+
LINTER_COMMANDS_ARRAY_BASH_EXEC=(bash-exec '{}')
107107
if [ "${BASH_EXEC_IGNORE_LIBRARIES:-}" == 'true' ]; then
108108
debug "Enabling bash-exec option to ignore shell library files."
109109
LINTER_COMMANDS_ARRAY_BASH_EXEC+=('true')
File renamed without changes.

test/linters/bash_exec/libraries/indentedShebang_bad.sh renamed to test/data/detect-files-scripts/indentedShebang_bad.sh

File renamed without changes.
File renamed without changes.

test/linters/bash_exec/libraries/secondLineShebang_bad.sh renamed to test/data/detect-files-scripts/secondLineShebang_bad.sh

File renamed without changes.

test/linters/bash_exec/libraries/shebangWithBlank_bad.sh renamed to test/data/detect-files-scripts/shebangWithBlank_bad.sh

File renamed without changes.
File renamed without changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Super-linter summary
2+
3+
<!-- textlint-disable terminology -->
4+
<!-- Disable MD060 to avoid false positives because of emojis -->
5+
<!-- markdownlint-disable MD060 -->
6+
7+
| Language | Validation result |
8+
| --------- | ----------------- |
9+
| BASH_EXEC | Fail ❌ |
10+
| JSON | Pass ✅ |
11+
12+
<!-- markdownlint-enable MD060 -->
13+
<!-- textlint-enable terminology -->
14+
15+
Super-linter detected linting errors
16+
17+
For more information, see the Super-linter summary
18+
(super-linter-output/super-linter-summary.md) and the Super-linter log
19+
(super-linter.log)
20+
21+
Powered by [Super-linter](https://github.com/super-linter/super-linter)

0 commit comments

Comments
 (0)