Skip to content

Commit

Permalink
[StepSecurity] Apply security best practices
Browse files Browse the repository at this point in the history
Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
  • Loading branch information
step-security-bot committed Nov 20, 2024
1 parent 2c89a2a commit 2cf64ff
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 29 deletions.
35 changes: 35 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,38 @@ updates:
directory: "/" # Localização do workflow YAML
schedule:
interval: "daily"

- package-ecosystem: pip
directory: /chainguard/environments/dev
schedule:
interval: daily

- package-ecosystem: pip
directory: /chainguard/environments/prd
schedule:
interval: daily

- package-ecosystem: pip
directory: /chainguard/environments/staging
schedule:
interval: daily

- package-ecosystem: pip
directory: /chainguard
schedule:
interval: daily

- package-ecosystem: docker
directory: /redis
schedule:
interval: daily

- package-ecosystem: docker
directory: /src
schedule:
interval: daily

- package-ecosystem: pip
directory: /src
schedule:
interval: daily
22 changes: 15 additions & 7 deletions .github/workflows/chainguard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches:
- 'main'

permissions:
contents: read

jobs:
build:
name: Build e Distribuição de Pacotes
Expand All @@ -16,12 +19,17 @@ jobs:

steps:
# Checkout do código
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

# Configurar Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1

# Instalar Melange
- name: Install Melange
Expand All @@ -43,7 +51,7 @@ jobs:
# Instalar Cosign
- name: Instalar Cosign
uses: sigstore/cosign-installer@v3.7.0
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0

# Gerar chaves com Melange
- name: Generate keys with Melange
Expand All @@ -65,7 +73,7 @@ jobs:
# Login no DockerHub
- name: Login to DockerHub
uses: docker/login-action@v3
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
Expand All @@ -80,7 +88,7 @@ jobs:
# Extrair metadados (tags, labels) para Docker
- name: Extrair metadados (tags, labels) para Docker
id: meta
uses: docker/metadata-action@v5
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
with:
images: nataliagranato/senhas

Expand All @@ -103,7 +111,7 @@ jobs:
# Scan de segurança com Aqua Security Trivy
- name: Aqua Security Trivy
uses: aquasecurity/trivy-action@0.28.0
uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # 0.28.0
with:
image-ref: nataliagranato/senhas:${{ steps.generate-tag.outputs.tag }}
format: 'sarif'
Expand All @@ -112,7 +120,7 @@ jobs:

# Envio dos resultados do Trivy para a aba de Segurança do GitHub
- name: Fazer upload dos resultados do Trivy para a aba de Segurança do GitHub
uses: github/codeql-action/upload-sarif@v3
uses: github/codeql-action/upload-sarif@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4
if: always()
with:
sarif_file: 'trivy-results.sarif'
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: ["main"]
pull_request:
# The branches below must be a subset of the branches above
branches: ["main"]
schedule:
- cron: "0 0 * * 1"

permissions:
contents: read

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: ["javascript", "python"]
# CodeQL supports [ $supported-codeql-languages ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4
with:
category: "/language:${{matrix.language}}"
27 changes: 27 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Dependency Review Action
#
# This Action will scan dependency manifest files that change as part of a Pull Request,
# surfacing known-vulnerable versions of the packages declared or updated in the PR.
# Once installed, if the workflow run is marked as required,
# PRs introducing known-vulnerable packages will be blocked from merging.
#
# Source repository: https://github.com/actions/dependency-review-action
name: 'Dependency Review'
on: [pull_request]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: 'Checkout Repository'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 'Dependency Review'
uses: actions/dependency-review-action@4081bf99e2866ebe428fc0477b69eb4fcda7220a # v4.4.0
12 changes: 10 additions & 2 deletions .github/workflows/digestabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches:
- main

permissions:
contents: read

jobs:
image-update:
name: Image digest update
Expand All @@ -16,8 +19,13 @@ jobs:
id-token: write # Necessário para solicitar o JWT (JSON Web Token)

steps:
- uses: actions/checkout@v4
- uses: chainguard-dev/digestabot@v1.2.1
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: chainguard-dev/digestabot@cee67ce333549107c469dbe7656afda5a1e1f287 # v1.2.1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
signoff: true
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/generator-generic-ossf-slsa3-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,22 @@ on:
release:
types: [created]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
outputs:
digests: ${{ steps.hash.outputs.digests }}

steps:
- uses: actions/checkout@v4
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

# ========================================================
#
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches:
- 'main'

permissions:
contents: read

jobs:
build:
name: Melange, APKO e GitHub Container Registry
Expand All @@ -16,12 +19,17 @@ jobs:

steps:
# Checkout do código
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

# Configurar Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1

# Instalar Melange
- name: Install Melange
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/giropops-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches:
- 'main'

permissions:
contents: read

jobs:
build:
name: Build da Imagem giropops-senhas
Expand All @@ -15,17 +18,22 @@ jobs:
security-events: write

steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Fazer checkout do código
uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc

- name: Configurar QEMU
uses: docker/setup-qemu-action@v3.2.0
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0

- name: Instalar Cosign
uses: sigstore/cosign-installer@v3.7.0
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0

- name: Configurar Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1

- name: Fazer login no Docker Hub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
Expand All @@ -35,7 +43,7 @@ jobs:

- name: Extrair metadados (tags, labels) para Docker
id: meta
uses: docker/metadata-action@v5
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
with:
images: nataliagranato/linuxtips-giropops-senhas

Expand All @@ -49,7 +57,7 @@ jobs:
echo "::set-output name=tag::${SHORT_HASH}-${TIMESTAMP}"
- name: Construir e enviar a imagem Docker
uses: docker/build-push-action@v6
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
id: build-and-push
with:
context: ./src
Expand All @@ -60,15 +68,15 @@ jobs:
platforms: linux/amd64,linux/arm64

- name: Aqua Security Trivy
uses: aquasecurity/trivy-action@0.28.0
uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # 0.28.0
with:
image-ref: nataliagranato/linuxtips-giropops-senhas:${{ steps.generate-tag.outputs.tag }}
format: 'sarif'
severity: 'UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL'
output: 'trivy-results.sarif'

- name: Fazer upload dos resultados do Trivy para a aba de Segurança do GitHub
uses: github/codeql-action/upload-sarif@v3
uses: github/codeql-action/upload-sarif@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4
if: always()
with:
sarif_file: 'trivy-results.sarif'
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/hadolint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ jobs:
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Run hadolint Giropops-Senhas
uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf
Expand All @@ -48,7 +53,7 @@ jobs:
no-fail: true

- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
uses: github/codeql-action/upload-sarif@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4
with:
sarif_file: hadolint-results.sarif
wait-for-processing: true
Loading

0 comments on commit 2cf64ff

Please sign in to comment.