-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scram hash to table for pgbouncer on cloud instance create
- Loading branch information
1 parent
d6939fe
commit 4627592
Showing
9 changed files
with
117 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
name: Trivy Artifact Scanning | ||
on: | ||
# push: | ||
# branches: [ master ] | ||
# paths: | ||
# - "plural/**" | ||
# - ".github/workflows/trivy-artifact-scan.yaml" | ||
# pull_request: | ||
# branches: [ master ] | ||
# paths: | ||
# - "plural/**" | ||
# - ".github/workflows/trivy-artifact-scan.yaml" | ||
# schedule: | ||
# - cron: '0 0 * * 1' | ||
workflow_dispatch: | ||
jobs: | ||
trivy-scan: | ||
name: Trivy IaC scan | ||
runs-on: ubuntu-20.04 | ||
permissions: | ||
contents: read # for actions/checkout to fetch code | ||
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: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Run Trivy vulnerability scanner in IaC mode | ||
uses: aquasecurity/trivy-action@master | ||
with: | ||
scan-type: 'fs' | ||
scan-ref: 'plural' | ||
hide-progress: false | ||
format: 'sarif' | ||
output: 'trivy-results.sarif' | ||
security-checks: 'vuln,secret,config' | ||
ignore-unfixed: true | ||
#severity: 'CRITICAL,HIGH' | ||
env: | ||
TRIVY_SKIP_DB_UPDATE: true | ||
TRIVY_SKIP_JAVA_DB_UPDATE: true | ||
- name: Upload Trivy scan results to GitHub Security tab | ||
uses: github/codeql-action/upload-sarif@v2 | ||
with: | ||
sarif_file: 'trivy-results.sarif' | ||
# name: Trivy Artifact Scanning | ||
# on: | ||
# # push: | ||
# # branches: [ master ] | ||
# # paths: | ||
# # - "plural/**" | ||
# # - ".github/workflows/trivy-artifact-scan.yaml" | ||
# # pull_request: | ||
# # branches: [ master ] | ||
# # paths: | ||
# # - "plural/**" | ||
# # - ".github/workflows/trivy-artifact-scan.yaml" | ||
# # schedule: | ||
# # - cron: '0 0 * * 1' | ||
# workflow_dispatch: | ||
# jobs: | ||
# trivy-scan: | ||
# name: Trivy IaC scan | ||
# runs-on: ubuntu-20.04 | ||
# permissions: | ||
# contents: read # for actions/checkout to fetch code | ||
# 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: Checkout code | ||
# uses: actions/checkout@v3 | ||
# - name: Run Trivy vulnerability scanner in IaC mode | ||
# uses: aquasecurity/trivy-action@master | ||
# with: | ||
# scan-type: 'fs' | ||
# scan-ref: 'plural' | ||
# hide-progress: false | ||
# format: 'sarif' | ||
# output: 'trivy-results.sarif' | ||
# security-checks: 'vuln,secret,config' | ||
# ignore-unfixed: true | ||
# #severity: 'CRITICAL,HIGH' | ||
# env: | ||
# TRIVY_SKIP_DB_UPDATE: true | ||
# TRIVY_SKIP_JAVA_DB_UPDATE: true | ||
# - name: Upload Trivy scan results to GitHub Security tab | ||
# uses: github/codeql-action/upload-sarif@v2 | ||
# with: | ||
# sarif_file: 'trivy-results.sarif' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
name: Update Trivy Cache | ||
# name: Update Trivy Cache | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
workflow_dispatch: | ||
# on: | ||
# schedule: | ||
# - cron: '0 0 * * *' | ||
# workflow_dispatch: | ||
|
||
jobs: | ||
update-trivy-db: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get current date | ||
id: date | ||
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | ||
# jobs: | ||
# update-trivy-db: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Get current date | ||
# id: date | ||
# run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | ||
|
||
- name: Download and extract the vulnerability DB | ||
run: | | ||
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/db | ||
oras pull ghcr.io/aquasecurity/trivy-db:2 | ||
tar -xzf db.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/db | ||
rm db.tar.gz | ||
# - name: Download and extract the vulnerability DB | ||
# run: | | ||
# mkdir -p $GITHUB_WORKSPACE/.cache/trivy/db | ||
# oras pull ghcr.io/aquasecurity/trivy-db:2 | ||
# tar -xzf db.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/db | ||
# rm db.tar.gz | ||
|
||
- name: Download and extract the Java DB | ||
run: | | ||
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/java-db | ||
oras pull ghcr.io/aquasecurity/trivy-java-db:1 | ||
tar -xzf javadb.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/java-db | ||
rm javadb.tar.gz | ||
# - name: Download and extract the Java DB | ||
# run: | | ||
# mkdir -p $GITHUB_WORKSPACE/.cache/trivy/java-db | ||
# oras pull ghcr.io/aquasecurity/trivy-java-db:1 | ||
# tar -xzf javadb.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/java-db | ||
# rm javadb.tar.gz | ||
|
||
- name: Cache DBs | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: ${{ github.workspace }}/.cache/trivy | ||
key: cache-trivy-${{ steps.date.outputs.date }} | ||
# - name: Cache DBs | ||
# uses: actions/cache/save@v4 | ||
# with: | ||
# path: ${{ github.workspace }}/.cache/trivy | ||
# key: cache-trivy-${{ steps.date.outputs.date }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
defmodule Core.Services.Cloud.Scram do | ||
alias Plug.Crypto.KeyGenerator | ||
@salt_size 16 | ||
@digest_len 32 | ||
@iterations 4096 | ||
|
||
def encrypt(pwd) do | ||
salt = :crypto.strong_rand_bytes(@salt_size) | ||
pbkdf = KeyGenerator.generate(pwd, salt, iterations: @iterations, length: @digest_len) | ||
client = :crypto.mac(:hmac, :sha256, pbkdf, "Client Key") | ||
stored = :crypto.hash(:sha256, client) | ||
server = :crypto.mac(:hmac, :sha256, pbkdf, "Server Key") | ||
"SCRAM-SHA-256$#{@iterations}:#{Base.encode64(salt)}$#{Base.encode64(stored)}:#{Base.encode64(server)}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters