Skip to content

Commit d790b0f

Browse files
authored
Merge branch 'master' into arduino-esp32
2 parents 587dbb1 + a7cec02 commit d790b0f

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

.github/workflows/tests_results.yml

+22-4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,24 @@ jobs:
4141
original_sha=$(cat ./artifacts/parent-artifacts/sha.txt)
4242
original_ref=$(cat ./artifacts/parent-artifacts/ref.txt)
4343
original_conclusion=$(cat ./artifacts/parent-artifacts/conclusion.txt)
44+
45+
# Sanitize the values to avoid security issues
46+
47+
# Event: Allow alphabetical characters and underscores
48+
original_event=$(echo "$original_event" | tr -cd '[:alpha:]_')
49+
50+
# Action: Allow alphabetical characters and underscores
51+
original_action=$(echo "$original_action" | tr -cd '[:alpha:]_')
52+
53+
# SHA: Allow alphanumeric characters
54+
original_sha=$(echo "$original_sha" | tr -cd '[:alnum:]')
55+
56+
# Ref: Allow alphanumeric characters, slashes, underscores, dots, and dashes
57+
original_ref=$(echo "$original_ref" | tr -cd '[:alnum:]/_.-')
58+
59+
# Conclusion: Allow alphabetical characters and underscores
60+
original_conclusion=$(echo "$original_conclusion" | tr -cd '[:alpha:]_')
61+
4462
echo "original_event=$original_event" >> $GITHUB_ENV
4563
echo "original_action=$original_action" >> $GITHUB_ENV
4664
echo "original_sha=$original_sha" >> $GITHUB_ENV
@@ -71,10 +89,10 @@ jobs:
7189
uses: actions/github-script@v7
7290
with:
7391
script: |
74-
const ref = '${{ env.original_ref }}';
92+
const ref = process.env.original_ref;
7593
const key_prefix = 'tests-' + ref + '-';
7694
77-
if ('${{ env.original_event }}' == 'pull_request' && '${{ env.original_action }}' != 'closed') {
95+
if (process.env.original_event == 'pull_request' && process.env.original_action != 'closed') {
7896
console.log('Skipping cache cleanup for open PR');
7997
return;
8098
}
@@ -104,12 +122,12 @@ jobs:
104122
script: |
105123
const owner = '${{ github.repository_owner }}';
106124
const repo = '${{ github.repository }}'.split('/')[1];
107-
const sha = '${{ env.original_sha }}';
125+
const sha = process.env.original_sha;
108126
core.debug(`owner: ${owner}`);
109127
core.debug(`repo: ${repo}`);
110128
core.debug(`sha: ${sha}`);
111129
const { context: name, state } = (await github.rest.repos.createCommitStatus({
112-
context: 'Runtime Tests / Report results (${{ env.original_event }} -> workflow_run -> workflow_run)',
130+
context: `Runtime Tests / Report results (${process.env.original_event} -> workflow_run -> workflow_run)`,
113131
owner: owner,
114132
repo: repo,
115133
sha: sha,

.github/workflows/upload-idf-component.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,25 @@ on:
66
types:
77
- completed
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
upload_components:
1114
runs-on: ubuntu-latest
1215
steps:
1316
- name: Get the release tag
17+
env:
18+
head_branch: ${{ github.event.workflow_run.head_branch }}
1419
run: |
1520
if [ "${{ github.event.workflow_run.conclusion }}" != "success" ]; then
1621
echo "Release workflow failed. Exiting..."
1722
exit 1
1823
fi
1924
20-
branch=${{ github.event.workflow_run.head_branch }}
25+
# Read and sanitize the branch/tag name
26+
branch=$(echo "$head_branch" | tr -cd '[:alnum:]/_.-')
27+
2128
if [[ $branch == refs/tags/* ]]; then
2229
tag="${branch#refs/tags/}"
2330
elif [[ $branch =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then

0 commit comments

Comments
 (0)