Skip to content

Commit b5ef489

Browse files
security: fix GitHub Actions command injection vulnerabilities and security hotspots
- Move all GitHub Actions inputs to environment variables to prevent command injection (S7630) - Add non-root user to Docker test image (S6471) - Pin peter-evans/create-pull-request to full commit SHA (S7637) Fixed 27 BLOCKER vulnerabilities and 2 security hotspots identified by SonarCloud. All inputs from GitHub Actions are now passed via env variables and properly quoted in shell commands to prevent potential command injection attacks.
1 parent e6f3c09 commit b5ef489

File tree

7 files changed

+48
-24
lines changed

7 files changed

+48
-24
lines changed

.github/actions/create-lines-of-code-report/action.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ runs:
2424
steps:
2525
- name: "Create CLOC report"
2626
shell: bash
27+
env:
28+
BUILD_DATETIME: ${{ inputs.build_datetime }}
2729
run: |
28-
export BUILD_DATETIME=${{ inputs.build_datetime }}
2930
./scripts/reports/create-lines-of-code-report.sh
3031
- name: "Compress CLOC report"
3132
shell: bash
@@ -51,7 +52,10 @@ runs:
5152
- name: "Send the CLOC report to the central location"
5253
shell: bash
5354
if: steps.check.outputs.secrets_exist == 'true'
55+
env:
56+
BUCKET_ENDPOINT: ${{ inputs.idp_aws_report_upload_bucket_endpoint }}
57+
BUILD_TIMESTAMP: ${{ inputs.build_timestamp }}
5458
run: |
5559
aws s3 cp \
5660
./lines-of-code-report.json.zip \
57-
${{ inputs.idp_aws_report_upload_bucket_endpoint }}/${{ inputs.build_timestamp }}-lines-of-code-report.json.zip
61+
"$BUCKET_ENDPOINT/$BUILD_TIMESTAMP-lines-of-code-report.json.zip"

.github/actions/perform-static-analysis/action.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ runs:
3232
shell: bash
3333
if: steps.check.outputs.secret_exist == 'true'
3434
continue-on-error: ${{ fromJSON(inputs.ignore_sonar_failure) }}
35+
env:
36+
SONAR_ORGANISATION_KEY: ${{ inputs.sonar_organisation_key }}
37+
SONAR_PROJECT_KEY: ${{ inputs.sonar_project_key }}
38+
SONAR_TOKEN: ${{ inputs.sonar_token }}
3539
run: |
3640
export BRANCH_NAME=${GITHUB_HEAD_REF:-$(echo $GITHUB_REF | sed 's#refs/heads/##')}
37-
export SONAR_ORGANISATION_KEY=${{ inputs.sonar_organisation_key }}
38-
export SONAR_PROJECT_KEY=${{ inputs.sonar_project_key }}
39-
export SONAR_TOKEN=${{ inputs.sonar_token }}
4041
./scripts/reports/perform-static-analysis.sh

.github/actions/publish-docs/action.yml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,41 +33,50 @@ runs:
3333
env:
3434
GH_TOKEN: ${{ github.token }}
3535
GH_REPO: ${{ github.repository }}
36+
VERSION: ${{ inputs.version }}
37+
IS_PRERELEASE: ${{ inputs.is_version_prerelease }}
3638
run: |
39+
PRERELEASE_FLAG=""
40+
if [ "$IS_PRERELEASE" = "true" ]; then
41+
PRERELEASE_FLAG="--prerelease"
42+
fi
3743
gh release create \
38-
"${{ inputs.version }}" \
44+
"$VERSION" \
3945
--draft \
4046
--latest \
41-
--title "${{ inputs.version }}" \
42-
--notes "Release of ${{ inputs.version }}" \
43-
${{ inputs.is_version_prerelease == 'true' && '--prerelease' || '' }}
47+
--title "$VERSION" \
48+
--notes "Release of $VERSION" \
49+
$PRERELEASE_FLAG
4450
4551
- name: "Upload jeykll docs release asset"
4652
shell: bash
4753
env:
4854
GH_TOKEN: ${{ github.token }}
4955
GH_REPO: ${{ github.repository }}
56+
VERSION: ${{ inputs.version }}
5057
run: |
51-
cp ./artifacts/jekyll-docs-${{ inputs.version }}/artifact.tar $RUNNER_TEMP/jekyll-docs-${{ inputs.version }}.tar
58+
cp "./artifacts/jekyll-docs-$VERSION/artifact.tar" "$RUNNER_TEMP/jekyll-docs-$VERSION.tar"
5259
gh release upload \
53-
"${{ inputs.version }}" \
54-
$RUNNER_TEMP/jekyll-docs-${{ inputs.version }}.tar#jekyll-docs-${{ inputs.version }}
60+
"$VERSION" \
61+
"$RUNNER_TEMP/jekyll-docs-$VERSION.tar#jekyll-docs-$VERSION"
5562
5663
- name: "Upload schema release asset"
5764
shell: bash
5865
env:
5966
GH_TOKEN: ${{ github.token }}
6067
GH_REPO: ${{ github.repository }}
68+
VERSION: ${{ inputs.version }}
6169
run: |
62-
cp ./artifacts/schemas-${{ inputs.version }}/artifact.tar $RUNNER_TEMP/schemas-${{ inputs.version }}.tar
70+
cp "./artifacts/schemas-$VERSION/artifact.tar" "$RUNNER_TEMP/schemas-$VERSION.tar"
6371
gh release upload \
64-
"${{ inputs.version }}" \
65-
$RUNNER_TEMP/schemas-${{ inputs.version }}.tar#schemas-${{ inputs.version }}
72+
"$VERSION" \
73+
"$RUNNER_TEMP/schemas-$VERSION.tar#schemas-$VERSION"
6674
6775
6876
- name: Publish Release
6977
shell: bash
7078
env:
7179
GH_TOKEN: ${{ github.token }}
7280
GH_REPO: ${{ github.repository }}
73-
run: gh release edit "${{ inputs.version }}" --draft=false
81+
VERSION: ${{ inputs.version }}
82+
run: gh release edit "$VERSION" --draft=false

.github/actions/scan-dependencies/action.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ runs:
2424
steps:
2525
- name: "Generate SBOM"
2626
shell: bash
27+
env:
28+
BUILD_DATETIME: ${{ inputs.build_datetime }}
2729
run: |
28-
export BUILD_DATETIME=${{ inputs.build_datetime }}
2930
./scripts/reports/create-sbom-report.sh
3031
- name: "Compress SBOM report"
3132
shell: bash
@@ -39,8 +40,9 @@ runs:
3940
retention-days: 21
4041
- name: "Scan vulnerabilities"
4142
shell: bash
43+
env:
44+
BUILD_DATETIME: ${{ inputs.build_datetime }}
4245
run: |
43-
export BUILD_DATETIME=${{ inputs.build_datetime }}
4446
./scripts/reports/scan-vulnerabilities.sh
4547
- name: "Compress vulnerabilities report"
4648
shell: bash
@@ -65,10 +67,13 @@ runs:
6567
- name: "Send the SBOM and vulnerabilities reports to the central location"
6668
shell: bash
6769
if: steps.check.outputs.secrets_exist == 'true'
70+
env:
71+
BUCKET_ENDPOINT: ${{ inputs.idp_aws_report_upload_bucket_endpoint }}
72+
BUILD_TIMESTAMP: ${{ inputs.build_timestamp }}
6873
run: |
6974
aws s3 cp \
7075
./sbom-repository-report.json.zip \
71-
${{ inputs.idp_aws_report_upload_bucket_endpoint }}/${{ inputs.build_timestamp }}-sbom-repository-report.json.zip
76+
"$BUCKET_ENDPOINT/$BUILD_TIMESTAMP-sbom-repository-report.json.zip"
7277
aws s3 cp \
7378
./vulnerabilities-repository-report.json.zip \
74-
${{ inputs.idp_aws_report_upload_bucket_endpoint }}/${{ inputs.build_timestamp }}-vulnerabilities-repository-report.json.zip
79+
"$BUCKET_ENDPOINT/$BUILD_TIMESTAMP-vulnerabilities-repository-report.json.zip"

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,10 @@ jobs:
8787
shell: bash
8888
env:
8989
GH_TOKEN: ${{ github.token }}
90+
INPUTS_INCLUDE_PRERELEASES: ${{ inputs.include_prereleases }}
91+
INPUTS_VERSION: ${{ inputs.version }}
9092
run: |
91-
INPUTS_INCLUDE_PRERELEASES="${{ inputs.include_prereleases }}"
9293
INPUTS_INCLUDE_PRERELEASES=${INPUTS_INCLUDE_PRERELEASES:-"true"}
93-
94-
INPUTS_VERSION="${{ inputs.version }}"
9594
INPUTS_VERSION=${INPUTS_VERSION:-"latest"}
9695
9796

.github/workflows/scheduled-repository-template-sync.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
3333
- name: Create Pull Request
3434
if: ${{ !env.ACT }}
35-
uses: peter-evans/[email protected]
35+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
3636
with:
3737
token: ${{ secrets.GITHUB_TOKEN }}
3838
commit-message: Drift from template

scripts/docker/tests/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# `*:latest` will be replaced with a corresponding version stored in the '.tool-versions' file
22
# hadolint ignore=DL3007
33
FROM python:latest
4+
5+
# Create a non-root user for running the application
6+
RUN groupadd -r appuser && useradd -r -g appuser appuser
7+
8+
# Switch to non-root user
9+
USER appuser

0 commit comments

Comments
 (0)