-
Couldn't load subscription status.
- Fork 8
feat: Add GitHub Actions CI/CD workflow #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Add GitHub Actions CI/CD workflow #189
Conversation
Kusari Analysis Results:Caution Flagged Issues Detected While dependency analysis found no security issues, code analysis identified 16 high severity security vulnerabilities that pose critical risks. The most concerning issues include dangerous template injection vulnerabilities in GitHub workflows that could enable code injection attacks, overly broad workflow permissions violating least privilege principles, and unpinned GitHub actions creating supply chain risks. These template injection vulnerabilities are particularly severe as they can compromise the entire CI/CD pipeline. The identified security flaws must be remediated before merging to prevent potential code execution attacks and maintain secure deployment practices. Note View full detailed analysis result for more information on the output and the checks that were run. Required Code MitigationsMove permissions to job level instead of workflow level to follow least privilege principle. Remove workflow-level permissions block.
Template injection vulnerability - avoid direct interpolation of GitHub context variables in shell commands
Template injection vulnerability - avoid direct interpolation of repository context in shell commands
Add persist-credentials: false to prevent credential persistence
Found this helpful? Give it a 👍 or 👎 reaction! |
.github/workflows/ci-cd.yml
Outdated
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: Move permissions to job level instead of workflow level to follow least privilege principle. Remove workflow-level permissions block.
Recommended Code Changes:
Remove the entire permissions block at workflow level (lines 14-19) and add specific permissions to individual jobs that need them.
| GOOS: ${{ matrix.os }} | ||
| GOARCH: ${{ matrix.arch }} | ||
| CGO_ENABLED: 0 | ||
| run: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: Template injection vulnerability - avoid direct interpolation of GitHub context variables in shell commands
Recommended Code Changes:
env:
VERSION: ${{ github.ref_name }}
COMMIT_HASH: ${{ github.sha }}
run: |
go build -ldflags="-s -w -X 'main.Version=${VERSION}' -X 'main.GitCommitHash=${COMMIT_HASH}' -X 'main.BuiltAt=$(date -u +%Y-%m-%dT%H:%M:%SZ)'" -o ${{ matrix.output }}
.github/workflows/ci-cd.yml
Outdated
| applicability: | ||
| - Maturity Level 1 | ||
| vars: | ||
| owner: ${{ github.repository_owner }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: Template injection vulnerability - avoid direct interpolation of repository context in shell commands
Recommended Code Changes:
env:
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
run: |
cat > test-config.yml << EOF
loglevel: info
write-directory: evaluation_results
write: true
output: yaml
services:
self-test:
plugin: github-repo
policy:
catalogs:
- OSPS_B
applicability:
- Maturity Level 1
vars:
owner: ${REPO_OWNER}
repo: ${REPO_NAME}
token: \${{ secrets.GITHUB_TOKEN }}
EOF
| needs: [docker-build-push] | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| steps: | ||
| - name: Checkout code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: Add persist-credentials: false to prevent credential persistence
Recommended Code Changes:
- name: Checkout code
uses: actions/checkout@v5
with:
persist-credentials: false
- Add ci-cd.yml workflow with automated build, test, and deployment - Implement security scanning with Trivy and Gosec - Add multi-platform binary builds (Linux, macOS, Windows - amd64/arm64) - Add Docker multi-arch builds with GHCR and Docker Hub support - Include integration testing and artifact uploads - Update README with CI/CD information
Security Fixes (Kusari Inspector findings):
- Move permissions from workflow level to individual jobs (least privilege)
- Fix template injection vulnerabilities using environment variables
- Add persist-credentials: false to integration-test checkout
- Add proper permissions to all jobs
Optimizations (ChatGPT suggestions):
- Add id: build to Docker step for attestation digest reference
- Pin action versions: trivy@0.28.0, gosec@v2.21.4 (prevent breaking changes)
- Add concurrency control to cancel old runs on new push
- Add explicit permissions: {} at workflow level for clarity
All 16 high severity Kusari issues resolved.
f62feac to
479166b
Compare
Adds GitHub Actions CI/CD workflow with automated build, test, security scanning, and multi-platform Docker image publishing.
Workflow runs automatically on push/PR to
mainordevelop.