|
| 1 | +permissions: |
| 2 | + id-token: write # This is required for requesting the JWT |
| 3 | + contents: read # This is required for actions/checkout |
| 4 | + |
| 5 | +name: pipeline |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - '*' |
| 11 | + pull_request: |
| 12 | + branches: |
| 13 | + - '*' |
| 14 | + |
| 15 | +jobs: |
| 16 | + lint: |
| 17 | + uses: ./.github/workflows/witness.yml |
| 18 | + with: |
| 19 | + pull_request: ${{ github.event_name == 'pull_request' }} |
| 20 | + step: lint |
| 21 | + pre-command-attestations: "git github environment" |
| 22 | + attestations: "git github environment" |
| 23 | + pre-command: | |
| 24 | + curl -sSfL https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64 -o /usr/local/bin/hadolint && \ |
| 25 | + chmod +x /usr/local/bin/hadolint |
| 26 | + command: hadolint -f sarif Dockerfile > hadolint.sarif |
| 27 | + artifact-upload-name: hadolint.sarif |
| 28 | + artifact-upload-path: hadolint.sarif |
| 29 | + |
| 30 | + sast: |
| 31 | + uses: ./.github/workflows/witness.yml |
| 32 | + with: |
| 33 | + pull_request: ${{ github.event_name == 'pull_request' }} |
| 34 | + step: sast |
| 35 | + pre-command-attestations: "git github environment" |
| 36 | + attestations: "git github environment" |
| 37 | + pre-command: python3 -m pip install semgrep==1.45.0 |
| 38 | + command: semgrep scan --config auto ./ --sarif -o semgrep.sarif |
| 39 | + artifact-upload-name: semgrep.sarif |
| 40 | + artifact-upload-path: semgrep.sarif |
| 41 | + |
| 42 | + build-image: |
| 43 | + needs: [ lint, sast ] |
| 44 | + runs-on: ubuntu-latest |
| 45 | + |
| 46 | + permissions: |
| 47 | + packages: write |
| 48 | + id-token: write # This is required for requesting the JWT |
| 49 | + contents: read # This is required for actions/checkout |
| 50 | + |
| 51 | + steps: |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + - name: Docker meta |
| 56 | + id: meta |
| 57 | + uses: docker/metadata-action@v5 |
| 58 | + with: |
| 59 | + images: ghcr.io/testifysec/swf/software |
| 60 | + |
| 61 | + - name: Docker Login |
| 62 | + uses: docker/login-action@v3 |
| 63 | + with: |
| 64 | + registry: ghcr.io |
| 65 | + username: ${{ github.actor }} |
| 66 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + |
| 68 | + - name: Setup Buildx |
| 69 | + uses: docker/setup-buildx-action@v3 |
| 70 | + with: |
| 71 | + platforms: linux/amd64 |
| 72 | + install: true |
| 73 | + use: true |
| 74 | + |
| 75 | + - name: Build Image |
| 76 | + uses: testifysec/witness-run-action@reusable-workflow # v0.2.0 |
| 77 | + with: |
| 78 | + version: 0.6.0 |
| 79 | + step: build-image |
| 80 | + archivista-server: "https://archivista.aws-sandbox-staging.testifysec.dev/" |
| 81 | + attestations: "git github environment oci slsa" |
| 82 | + command: | |
| 83 | + /bin/sh -c "docker buildx build -t ${{ steps.meta.outputs.tags }} -o type=docker,dest=image.tar --push ." |
| 84 | + |
| 85 | + - name: Upload Artifact |
| 86 | + uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0 |
| 87 | + with: |
| 88 | + name: image.tar |
| 89 | + path: image.tar |
| 90 | + |
| 91 | + outputs: |
| 92 | + tags: ${{ steps.meta.outputs.tags }} |
| 93 | + |
| 94 | + generate-sbom: |
| 95 | + needs: build-image |
| 96 | + uses: ./.github/workflows/witness.yml |
| 97 | + with: |
| 98 | + pull_request: ${{ github.event_name == 'pull_request' }} |
| 99 | + step: generate-sbom |
| 100 | + pre-command-attestations: "git github environment" |
| 101 | + attestations: "git github environment sbom" |
| 102 | + artifact-download: image.tar |
| 103 | + pre-command: | |
| 104 | + curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin |
| 105 | + command: | |
| 106 | + syft packages docker-archive:/tmp/image.tar --source-name=pkg:oci/testifysec/swf -o cyclonedx-json --file sbom.cdx.json |
| 107 | + artifact-upload-name: sbom.cdx.json |
| 108 | + artifact-upload-path: sbom.cdx.json |
| 109 | + |
| 110 | + secret-scan: |
| 111 | + needs: build-image |
| 112 | + uses: ./.github/workflows/witness.yml |
| 113 | + with: |
| 114 | + pull_request: ${{ github.event_name == 'pull_request' }} |
| 115 | + step: secret-scan |
| 116 | + pre-command-attestations: "git github environment" |
| 117 | + attestations: "git github environment" |
| 118 | + artifact-download: image.tar |
| 119 | + pre-command: | |
| 120 | + curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -b /usr/local/bin |
| 121 | + command: | |
| 122 | + trufflehog docker --image=file:///tmp/image.tar -j > trufflehog.json |
| 123 | + artifact-upload-name: trufflehog.json |
| 124 | + artifact-upload-path: trufflehog.json |
0 commit comments