Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
49915c0
feat(security): add CodeQL analysis and pre-release version gate to P…
bedatty Apr 9, 2026
aad6ec3
fix(security): configure private Go module access for CodeQL autobuild
bedatty Apr 9, 2026
046ef64
fix(security): add actions:read permission for CodeQL status reporting
bedatty Apr 9, 2026
537771d
fix(security): disable SARIF upload by default in codeql-analyze comp…
bedatty Apr 9, 2026
f89fd13
feat(security): add codeql_upload_sarif input for Security tab integr…
bedatty Apr 9, 2026
927fb87
feat(security): make prerelease gate branch-aware (block on rc/main, …
bedatty Apr 9, 2026
2edd134
feat(security): broaden prerelease check to block all unstable versio…
bedatty Apr 9, 2026
e4c9a7d
chore(deps): bump docker/build-push-action in the docker group
dependabot[bot] Apr 13, 2026
fafd2f9
chore(deps): bump actions/create-github-app-token in the release group
dependabot[bot] Apr 13, 2026
b0ff96d
fix(prerelease-check): also scan repo root for monorepos with shared …
bedatty Apr 13, 2026
2e7960b
feat(prerelease-check): post PR comment with unstable version findings
bedatty Apr 13, 2026
279a4bc
fix(prerelease-check): consolidate PR comments with shared marker + c…
bedatty Apr 13, 2026
9cf654b
Merge pull request #209 from LerianStudio/dependabot/github_actions/d…
bedatty Apr 14, 2026
a32a9ea
Merge pull request #210 from LerianStudio/dependabot/github_actions/d…
bedatty Apr 14, 2026
c320241
refactor(security): integrate prerelease findings into consolidated s…
bedatty Apr 14, 2026
dfea6f2
fix(security): point pr-security-reporter to feature branch with prer…
bedatty Apr 14, 2026
864a8a5
fix(prerelease-check): expose artifact-file output for reporter consu…
bedatty Apr 14, 2026
c5fd5ce
fix(ci): pin codeql actions by SHA, fix yaml lint errors
bedatty Apr 14, 2026
3409b28
fix(security): address CodeRabbit review findings
bedatty Apr 14, 2026
5abeb48
fix(ci): enable CodeQL SARIF upload in self-pr-validation
bedatty Apr 14, 2026
d947c6b
fix(ci): pin actions/checkout to SHA in self-pr-validation
bedatty Apr 14, 2026
596d0f5
fix(security): treat prerelease artifact contract violations as scan …
bedatty Apr 14, 2026
617b198
fix(security): bound prerelease table rows and truncate content
bedatty Apr 14, 2026
bccc175
Merge pull request #208 from LerianStudio/feat/pr-security-scan-codeq…
bedatty Apr 14, 2026
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/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ jobs:

- name: Build and push Docker image
id: build-push
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
with:
context: ${{ inputs.build_context_from_working_dir == true && matrix.app.working_dir || inputs.build_context }}
file: ${{ matrix.app.working_dir }}/${{ inputs.dockerfile_name }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ jobs:

- name: Build and push
id: build-push
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
with:
context: .
platforms: ${{ inputs.docker_platforms }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gptchangelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ jobs:

steps:
- name: Create GitHub App Token
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3
id: app-token
with:
app-id: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_APP_ID }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/helm-update-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
steps:
- name: Generate GitHub App Token
id: app-token
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
Expand Down
168 changes: 143 additions & 25 deletions .github/workflows/pr-security-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,44 @@ on:
type: boolean
default: true
docker_build_args:
description: 'Newline-separated Docker build arguments (e.g., "APP_NAME=spi\nCOMPONENT_NAME=api"). For sensitive values (tokens, keys, passwords), use BuildKit secrets instead — build arguments are visible in image history.'
description: >-
Newline-separated Docker build arguments (e.g., "APP_NAME=spi\nCOMPONENT_NAME=api").
For sensitive values, use BuildKit secrets — build arguments are visible in image history.
type: string
required: false
default: ''
build_context_from_working_dir:
description: 'Use the component working_dir as Docker build context instead of repo root. Useful for independent modules (e.g., tools with their own go.mod).'
type: boolean
default: false
enable_codeql:
description: 'Enable CodeQL static analysis. Requires codeql_languages to be set.'
type: boolean
default: false
codeql_languages:
description: 'Languages to analyze with CodeQL (comma-separated, e.g., "go", "javascript-typescript", "actions")'
type: string
required: false
default: ''
codeql_fail_on_findings:
description: 'Fail the workflow when CodeQL detects security issues'
type: boolean
default: true
codeql_upload_sarif:
description: 'Upload CodeQL SARIF results to the GitHub Security tab. Requires Code Security (GHAS) enabled on the repo.'
type: boolean
default: false
enable_prerelease_check:
description: 'Block dependencies pinned to pre-release versions (-beta, -rc)'
type: boolean
default: true
prerelease_block_branches:
description: 'Comma-separated list of PR target branches where pre-release versions cause a hard failure. On other branches, findings are reported as warnings only.'
type: string
default: 'release-candidate,main'

permissions:
actions: read # Required for CodeQL status reporting
id-token: write # Required for OIDC authentication
contents: read # Required to checkout the repository
pull-requests: write # Allows commenting on PRs
Expand All @@ -100,7 +128,7 @@ jobs:
# ----------------- Detect Changes & Build Matrix -----------------
- name: Get changed paths
id: changed-paths
uses: LerianStudio/github-actions-shared-workflows/src/config/changed-paths@v1.18.0
uses: LerianStudio/github-actions-shared-workflows/src/config/changed-paths@v1.23.1
with:
filter-paths: ${{ inputs.filter_paths }}
shared-paths: ${{ inputs.shared_paths }}
Expand Down Expand Up @@ -150,16 +178,17 @@ jobs:
- name: Trivy Filesystem Scan
id: fs-scan
if: always()
uses: LerianStudio/github-actions-shared-workflows/src/security/trivy-fs-scan@v1.18.0
uses: LerianStudio/github-actions-shared-workflows/src/security/trivy-fs-scan@v1.23.1
with:
scan-ref: ${{ matrix.working_dir }}
app-name: ${{ env.APP_NAME }}

# ----------------- Docker Build -----------------
- name: Build Docker Image for Scanning
if: always() && inputs.enable_docker_scan
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
with:
# yamllint disable-line rule:line-length
context: ${{ inputs.build_context_from_working_dir == true && matrix.working_dir || (inputs.monorepo_type == 'type2' && matrix.working_dir == inputs.frontend_folder && inputs.frontend_folder || '.') }}
file: ${{ env.DOCKERFILE_PATH }}
platforms: linux/amd64
Expand All @@ -175,7 +204,7 @@ jobs:
- name: Trivy Image Scan
id: image-scan
if: always() && inputs.enable_docker_scan
uses: LerianStudio/github-actions-shared-workflows/src/security/trivy-image-scan@v1.18.0
uses: LerianStudio/github-actions-shared-workflows/src/security/trivy-image-scan@v1.23.1
with:
image-ref: '${{ env.DOCKERHUB_ORG }}/${{ env.APP_NAME }}:pr-scan-${{ github.sha }}'
app-name: ${{ env.APP_NAME }}
Expand All @@ -185,49 +214,138 @@ jobs:
- name: Dockerfile Compliance Checks
id: dockerfile-checks
if: always() && inputs.enable_docker_scan && inputs.enable_health_score
uses: LerianStudio/github-actions-shared-workflows/src/security/dockerfile-checks@v1.18.0
uses: LerianStudio/github-actions-shared-workflows/src/security/dockerfile-checks@v1.23.1
with:
dockerfile-path: ${{ env.DOCKERFILE_PATH }}

# ----------------- Pre-release Version Gate -----------------
- name: Pre-release Version Check
id: prerelease-check
if: always() && inputs.enable_prerelease_check
uses: LerianStudio/github-actions-shared-workflows/src/security/prerelease-check@feat/pr-security-scan-codeql-prerelease
with:
scan-ref: ${{ matrix.working_dir }}
app-name: ${{ env.APP_NAME }}

# ----------------- Results & Security Gate -----------------
- name: Post Security Scan Results to PR
id: post-results
if: always() && github.event_name == 'pull_request'
uses: LerianStudio/github-actions-shared-workflows/src/security/pr-security-reporter@v1.18.0
uses: LerianStudio/github-actions-shared-workflows/src/security/pr-security-reporter@feat/pr-security-scan-codeql-prerelease
with:
github-token: ${{ secrets.MANAGE_TOKEN || secrets.GITHUB_TOKEN }}
app-name: ${{ env.APP_NAME }}
enable-docker-scan: ${{ inputs.enable_docker_scan }}
enable-health-score: ${{ inputs.enable_health_score && inputs.enable_docker_scan }}
dockerfile-has-non-root-user: ${{ steps.dockerfile-checks.outputs.has-non-root-user || 'false' }}
prerelease-findings-file: ${{ steps.prerelease-check.outputs.artifact-file }}
fail-on-findings: 'true'

## To be fixed
# - name: Upload Secret Scan Results - Repository (SARIF) to GitHub Security Tab
# uses: github/codeql-action/upload-sarif@v3
# if: always()
# continue-on-error: true
# with:
# sarif_file: 'trivy-secret-scan-repo-${{ env.APP_NAME }}.sarif'

# - name: Upload Vulnerability Scan Results - Docker Image (SARIF) to GitHub Security Tab
# uses: github/codeql-action/upload-sarif@v3
# if: always()
# continue-on-error: true
# with:
# sarif_file: 'trivy-vulnerability-scan-docker-${{ env.APP_NAME }}.sarif'
- name: Gate - Fail on Pre-release Versions
if: always() && inputs.enable_prerelease_check && steps.prerelease-check.outputs.has-findings == 'true'
env:
BLOCK_BRANCHES: ${{ inputs.prerelease_block_branches }}
TARGET_BRANCH: ${{ github.base_ref }}
FINDINGS_COUNT: ${{ steps.prerelease-check.outputs.findings-count }}
run: |
SHOULD_BLOCK=false
IFS=',' read -ra BRANCHES <<< "$BLOCK_BRANCHES"
for branch in "${BRANCHES[@]}"; do
branch=$(echo "$branch" | xargs)
if [ "$TARGET_BRANCH" = "$branch" ]; then
SHOULD_BLOCK=true
break
fi
done

if [ "$SHOULD_BLOCK" = "true" ]; then
echo "::error::Pre-release version pins detected ($FINDINGS_COUNT finding(s)). Target branch '$TARGET_BRANCH' does not allow beta or release candidate dependencies."
exit 1
else
echo "::warning::Pre-release version pins detected ($FINDINGS_COUNT finding(s)). Allowed on '$TARGET_BRANCH' — will be blocked on: $BLOCK_BRANCHES."
fi

# ----------------- CodeQL Analysis -----------------
codeql_scan:
needs: prepare_matrix
if: inputs.enable_codeql && inputs.codeql_languages != '' && needs.prepare_matrix.outputs.matrix != '[]'
runs-on: ${{ inputs.runner_type }}
steps:
# ----------------- Setup -----------------
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Extract changed paths from matrix
id: extract-paths
env:
MATRIX: ${{ needs.prepare_matrix.outputs.matrix }}
run: |
PATHS=$(echo "$MATRIX" | jq -r '.[].working_dir' | paste -sd ',' -)
echo "paths=$PATHS" >> "$GITHUB_OUTPUT"

# ----------------- CodeQL Config -----------------
- name: Generate CodeQL Config
id: codeql-config
uses: LerianStudio/github-actions-shared-workflows/src/security/codeql-config@feat/pr-security-scan-codeql-prerelease
with:
changed-paths: ${{ steps.extract-paths.outputs.paths }}

# ----------------- CodeQL Analysis -----------------
- name: Initialize CodeQL
if: steps.codeql-config.outputs.skip != 'true'
uses: LerianStudio/github-actions-shared-workflows/src/security/codeql-init@feat/pr-security-scan-codeql-prerelease
with:
languages: ${{ inputs.codeql_languages }}
config-file: ${{ steps.codeql-config.outputs.config-file }}

- name: Configure private Go modules access
if: steps.codeql-config.outputs.skip != 'true'
env:
TOKEN: ${{ secrets.MANAGE_TOKEN || secrets.GITHUB_TOKEN }}
run: |
git config --global url."https://x-access-token:${TOKEN}@github.com/".insteadOf "https://github.com/"
echo "GOPRIVATE=github.com/LerianStudio/*" >> "$GITHUB_ENV"

- name: Autobuild
if: steps.codeql-config.outputs.skip != 'true'
uses: github/codeql-action/autobuild@c10b8064de6f491fea524254123dbe5e09572f13 # v4

- name: Perform CodeQL Analysis
if: steps.codeql-config.outputs.skip != 'true'
uses: LerianStudio/github-actions-shared-workflows/src/security/codeql-analyze@feat/pr-security-scan-codeql-prerelease
with:
category: '/language:${{ inputs.codeql_languages }}'
upload: ${{ inputs.codeql_upload_sarif }}

# ----------------- Results & Security Gate -----------------
- name: Post CodeQL Results to PR
if: always() && github.event_name == 'pull_request' && steps.codeql-config.outputs.skip != 'true'
uses: LerianStudio/github-actions-shared-workflows/src/security/codeql-reporter@feat/pr-security-scan-codeql-prerelease
with:
github-token: ${{ secrets.MANAGE_TOKEN || secrets.GITHUB_TOKEN }}
languages: ${{ inputs.codeql_languages }}
fail-on-findings: ${{ inputs.codeql_fail_on_findings }}

# ----------------- Slack Notification -----------------
notify:
name: Notify
needs: [prepare_matrix, security_scan]
needs: [prepare_matrix, security_scan, codeql_scan]
if: always() && needs.prepare_matrix.outputs.matrix != '[]'
runs-on: ${{ inputs.runner_type }}
steps:
- name: Slack Notification
uses: LerianStudio/github-actions-shared-workflows/src/notify/slack-notify@v1.18.0
uses: LerianStudio/github-actions-shared-workflows/src/notify/slack-notify@v1.23.1
with:
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
status: ${{ needs.security_scan.result }}
# yamllint disable-line rule:line-length
status: ${{ (needs.security_scan.result == 'failure' || needs.codeql_scan.result == 'failure') && 'failure' || needs.security_scan.result }}
workflow-name: "PR Security Scan"
failed-jobs: ${{ needs.security_scan.result == 'failure' && 'Security Scan' || '' }}
# yamllint disable-line rule:line-length
failed-jobs: >-
${{
needs.security_scan.result == 'failure' && needs.codeql_scan.result == 'failure'
&& 'Security Scan, CodeQL Scan'
|| needs.security_scan.result == 'failure' && 'Security Scan'
|| needs.codeql_scan.result == 'failure' && 'CodeQL Scan'
|| ''
}}
2 changes: 1 addition & 1 deletion .github/workflows/release-notification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- name: Create GitHub App token
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
gpg_fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}

steps:
- uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
- uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
id: app-token
with:
app-id: ${{ secrets.LERIAN_STUDIO_MIDAZ_PUSH_BOT_APP_ID }}
Expand Down
Loading