Skip to content

Commit 872fd3d

Browse files
security: fix command injection vulnerabilities in GitHub Actions workflows
- Move user-controlled inputs to env variables instead of direct interpolation - Fixes SonarCloud rule S7630 (BLOCKER severity) - Affects docs-stage-5-publish.yaml (14 issues) and docs-cicd-3-deploy.yaml (1 issue) - Prevents potential command injection attacks via workflow inputs - All ${{ inputs.* }} references now passed through environment variables
1 parent ab0ab8e commit 872fd3d

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

.github/workflows/docs-cicd-3-deploy.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,14 @@ jobs:
9292
shell: bash
9393
env:
9494
GH_TOKEN: ${{ github.token }}
95+
INPUTS_VERSION: ${{ inputs.version }}
96+
INPUTS_INCLUDE_PRERELEASES: ${{ inputs.include_prereleases }}
9597
run: |
96-
INPUTS_INCLUDE_PRERELEASES="${{ inputs.include_prereleases }}"
97-
INPUTS_INCLUDE_PRERELEASES=${INPUTS_INCLUDE_PRERELEASES:-"true"}
98+
INCLUDE_PRERELEASES=${INPUTS_INCLUDE_PRERELEASES:-"true"}
99+
VERSION=${INPUTS_VERSION:-"latest"}
98100
99-
INPUTS_VERSION="${{ inputs.version }}"
100-
INPUTS_VERSION=${INPUTS_VERSION:-"latest"}
101101
102-
103-
if [[ $INPUTS_INCLUDE_PRERELEASES == true ]]; then
102+
if [[ $INCLUDE_PRERELEASES == true ]]; then
104103
json=$(gh release list --json tagName --limit 1 --exclude-drafts)
105104
else
106105
json=$(gh release list --json tagName --limit 1 --exclude-drafts --exclude-pre-releases)

.github/workflows/docs-stage-5-publish.yaml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,38 +62,47 @@ jobs:
6262
env:
6363
GH_TOKEN: ${{ github.token }}
6464
GH_REPO: ${{ github.repository }}
65+
VERSION: ${{ inputs.version }}
66+
IS_PRERELEASE: ${{ inputs.is_version_prerelease }}
6567
run: |
68+
PRERELEASE_FLAG=""
69+
if [ "$IS_PRERELEASE" = "true" ]; then
70+
PRERELEASE_FLAG="--prerelease"
71+
fi
6672
gh release create \
67-
"${{ inputs.version }}" \
73+
"$VERSION" \
6874
--draft \
6975
--latest \
70-
--title "${{ inputs.version }}" \
71-
--notes "Release of ${{ inputs.version }}" \
72-
${{ inputs.is_version_prerelease == 'true' && '--prerelease' || '' }}
76+
--title "$VERSION" \
77+
--notes "Release of $VERSION" \
78+
$PRERELEASE_FLAG
7379
7480
- name: "Upload jeykll docs release asset"
7581
env:
7682
GH_TOKEN: ${{ github.token }}
7783
GH_REPO: ${{ github.repository }}
84+
VERSION: ${{ inputs.version }}
7885
run: |
79-
cp ./artifacts/jekyll-docs-${{ inputs.version }}/artifact.tar $RUNNER_TEMP/jekyll-docs-${{ inputs.version }}.tar
86+
cp ./artifacts/jekyll-docs-$VERSION/artifact.tar $RUNNER_TEMP/jekyll-docs-$VERSION.tar
8087
gh release upload \
81-
"${{ inputs.version }}" \
82-
$RUNNER_TEMP/jekyll-docs-${{ inputs.version }}.tar#jekyll-docs-${{ inputs.version }}
88+
"$VERSION" \
89+
$RUNNER_TEMP/jekyll-docs-$VERSION.tar#jekyll-docs-$VERSION
8390
8491
- name: "Upload schema release asset"
8592
env:
8693
GH_TOKEN: ${{ github.token }}
8794
GH_REPO: ${{ github.repository }}
95+
VERSION: ${{ inputs.version }}
8896
run: |
89-
cp ./artifacts/schemas-${{ inputs.version }}/artifact.tar $RUNNER_TEMP/schemas-${{ inputs.version }}.tar
97+
cp ./artifacts/schemas-$VERSION/artifact.tar $RUNNER_TEMP/schemas-$VERSION.tar
9098
gh release upload \
91-
"${{ inputs.version }}" \
92-
$RUNNER_TEMP/schemas-${{ inputs.version }}.tar#schemas-${{ inputs.version }}
99+
"$VERSION" \
100+
$RUNNER_TEMP/schemas-$VERSION.tar#schemas-$VERSION
93101
94102
95103
- name: Publish Release
96104
env:
97105
GH_TOKEN: ${{ github.token }}
98106
GH_REPO: ${{ github.repository }}
99-
run: gh release edit "${{ inputs.version }}" --draft=false
107+
VERSION: ${{ inputs.version }}
108+
run: gh release edit "$VERSION" --draft=false

docs/_layouts/event.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ <h2>Consumed by</h2>
5353
</ul>
5454

5555
<h2>Envelope Schema</h2>
56-
<iframe title="Envelope Schema {{page.title}}" src="{{ page.schema_envelope }}" width="100%" height="600px"></iframe>
56+
<iframe title="Envelope Schema {{page.title}}" src="{{ page.schema_envelope | replace: 'https://notify.nhs.uk/cloudevents', '' | replace: '.schema.json', '.bundle.schema.json' }}" width="100%" height="600px"></iframe>
5757

5858
<h2>Data Schema</h2>
59-
<iframe title="Data Schema {{page.title}}" src="{{ page.schema_data }}" width="100%" height="600px"></iframe>
59+
<iframe title="Data Schema {{page.title}}" src="{{ page.schema_data | replace: 'https://notify.nhs.uk/cloudevents', '' }}" width="100%" height="600px"></iframe>
6060

6161
{{ content }}

0 commit comments

Comments
 (0)