Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
-Dsonar.organization=tyktechnologies
-Dsonar.projectKey=TykTechnologies_${{ github.event.repository.name }}
-Dsonar.sources=.
-Dsonar.exclusions=${{ github.event.inputs.exclusions }}
-Dsonar.exclusions=${{ inputs.exclusions }}
-Dsonar.coverage.exclusions=**/*_test.go

Check failure on line 37 in .github/workflows/sonarcloud.yaml

View check run for this annotation

probelabs / Visor: security

security Issue

The workflow input `inputs.exclusions` is directly substituted into the `args` for the SonarCloud action. The SonarSource action executes these arguments in a shell context without proper quoting, which can allow an attacker to inject arbitrary shell commands. If this reusable workflow is triggered by a pull request from a fork, a malicious actor could provide a crafted `exclusions` value to execute code on the runner, potentially leading to secret exfiltration (e.g., GITHUB_TOKEN, SONAR_TOKEN).
Raw output
Add a step before the 'SonarCloud Scan' step to validate and sanitize the `inputs.exclusions`. The validation should ensure that the input only contains characters that are safe for file paths and patterns, and disallow shell metacharacters like ';', '$', '(', ')', '`', '|', '&'.

Example validation step:
```yaml
      - name: Validate exclusions input
        run: |
          if [[ "${{ inputs.exclusions }}" =~ [^a-zA-Z0-9,.*/_-] ]]; then
            echo "Error: Invalid characters found in 'exclusions' input."
            exit 1
          fi
```
This step should be placed before the 'SonarCloud Scan' step.
-Dsonar.test.inclusions=**/*_test.go
-Dsonar.tests=.
-Dsonar.go.coverage.reportPaths=*.cov
Expand Down
Loading