Skip to content

Commit 68fd85c

Browse files
Apply security best practicesSigned-off-by: StepSecurity Bot <bot@stepsecurity.io>
1 parent 8664d85 commit 68fd85c

File tree

7 files changed

+433
-0
lines changed

7 files changed

+433
-0
lines changed

.github/workflows/automatePR.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Automate PR
2+
on:
3+
issues:
4+
types:
5+
- labeled
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
Automate:
12+
if: github.event.label.name == 'Automate'
13+
runs-on: ubuntu-latest
14+
permissions:
15+
issues: write
16+
actions: write
17+
18+
steps:
19+
- name: Harden Runner
20+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0
21+
with:
22+
egress-policy: audit
23+
24+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
25+
with:
26+
repository: step-security/secure-repo
27+
28+
- name: Automate PR
29+
uses: step-security/secure-repo/Automate-PR@98ff385ea512d8ac7a1445f95e199f6864f439e1
30+
with:
31+
github-token: ${{secrets.PAT }}
32+
issue-id: ${{ github.event.issue.number}}

.github/workflows/codeql.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: ["main"]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: ["main"]
20+
schedule:
21+
- cron: "35 17 * * 4"
22+
23+
permissions: # added using https://github.com/step-security/secure-repo
24+
contents: read
25+
26+
jobs:
27+
analyze:
28+
name: Analyze
29+
runs-on: ubuntu-latest
30+
permissions:
31+
actions: read
32+
contents: read
33+
security-events: write
34+
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
language: ["go"]
39+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
40+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
41+
42+
steps:
43+
- name: Harden Runner
44+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0
45+
with:
46+
egress-policy: audit
47+
48+
- name: Checkout repository
49+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
50+
51+
# Initializes the CodeQL tools for scanning.
52+
- name: Initialize CodeQL
53+
uses: github/codeql-action/init@bc02a25f6449997c5e9d5a368879b28f56ae19a1
54+
with:
55+
languages: ${{ matrix.language }}
56+
# If you wish to specify custom queries, you can do so here or in a config file.
57+
# By default, queries listed here will override any specified in a config file.
58+
# Prefix the list here with "+" to use these queries and those in the config file.
59+
60+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
61+
# queries: security-extended,security-and-quality
62+
63+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
64+
# If this step fails, then you should remove it and run the build manually (see below)
65+
- name: Autobuild
66+
uses: github/codeql-action/autobuild@bc02a25f6449997c5e9d5a368879b28f56ae19a1
67+
68+
# ℹ️ Command-line programs to run using the OS shell.
69+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
70+
71+
# If the Autobuild fails above, remove it and uncomment the following three lines.
72+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
73+
74+
# - run: |
75+
# echo "Run, Build Application using script"
76+
# ./location_of_script_within_repo/buildscript.sh
77+
78+
- name: Perform CodeQL Analysis
79+
uses: github/codeql-action/analyze@bc02a25f6449997c5e9d5a368879b28f56ae19a1
80+
with:
81+
category: "/language:${{matrix.language}}"

.github/workflows/int.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Cfnrelease-int
2+
3+
on:
4+
push:
5+
branches:
6+
- int
7+
8+
permissions: # added using https://github.com/step-security/secure-repo
9+
contents: read
10+
11+
jobs:
12+
publish-test:
13+
permissions:
14+
contents: read
15+
id-token: write
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Harden Runner
19+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0
20+
with:
21+
egress-policy: audit
22+
- name: Checkout
23+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
24+
with:
25+
fetch-depth: 0
26+
- name: Set up Go
27+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
28+
with:
29+
go-version: 1.17
30+
31+
- run: go test ./... -coverpkg=./...
32+
env:
33+
PAT: ${{ secrets.PAT }}
34+
35+
- uses: step-security/wait-for-secrets@084b3ae774c0e0003a9307ae4f487c10f1f998fe
36+
id: wait-for-secrets
37+
with:
38+
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
39+
secrets: |
40+
AWS_ACCESS_KEY_ID_INT:
41+
name: 'AWS access key id'
42+
description: 'Access key id for secure-repo int'
43+
AWS_SECRET_ACCESS_KEY_INT:
44+
name: 'AWS secret access key'
45+
description: 'Secret access key for secure-repo int'
46+
AWS_SESSION_TOKEN_INT:
47+
name: 'AWS session token'
48+
description: 'Session token for secure-repo int'
49+
50+
- name: Configure AWS Credentials
51+
uses: aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df
52+
with:
53+
aws-access-key-id: ${{ steps.wait-for-secrets.outputs.AWS_ACCESS_KEY_ID_INT }}
54+
aws-secret-access-key: ${{ steps.wait-for-secrets.outputs.AWS_SECRET_ACCESS_KEY_INT }}
55+
aws-session-token: ${{ steps.wait-for-secrets.outputs.AWS_SESSION_TOKEN_INT }}
56+
aws-region: us-west-2
57+
58+
- name: Deploy to AWS CloudFormation
59+
uses: aws-actions/aws-cloudformation-github-deploy@33527b83bddcf6b3f0b135d9550bde8475325c73
60+
with:
61+
name: secure-workflow-api-ecr
62+
template: cloudformation/ecr.yml
63+
parameter-overrides: "ResourceName=secure-workflow-api"
64+
no-fail-on-empty-changeset: "1"
65+
66+
- name: Login to Amazon ECR
67+
id: login-ecr
68+
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076
69+
70+
- name: Build, tag, and push image to Amazon ECR
71+
env:
72+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
73+
ECR_REPOSITORY: secure-workflow-api
74+
IMAGE_TAG: ${{ github.sha }}
75+
run: |
76+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
77+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
78+
79+
- name: Deploy to AWS CloudFormation
80+
uses: aws-actions/aws-cloudformation-github-deploy@33527b83bddcf6b3f0b135d9550bde8475325c73
81+
with:
82+
name: secure-workflow-api
83+
template: cloudformation/resources.yml
84+
parameter-overrides: >-
85+
ResourceName=secure-workflow-api,
86+
ImageTag=${{ github.sha }},
87+
PAT=${{ secrets.PAT }}
88+
no-fail-on-empty-changeset: "1"
89+
90+

.github/workflows/kb-test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Knowledge-base Test
2+
on:
3+
push:
4+
branches:
5+
- knowledge-base # to test new KBs
6+
7+
permissions: # added using https://github.com/step-security/secure-workflows
8+
contents: read
9+
concurrency:
10+
group: ${{ github.workflow }}
11+
jobs:
12+
test:
13+
permissions:
14+
contents: read
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0
18+
with:
19+
allowed-endpoints: >
20+
api.github.com:443
21+
github.com:443
22+
proxy.golang.org:443
23+
sum.golang.org:443
24+
storage.googleapis.com:443
25+
objects.githubusercontent.com:443
26+
golang.org:443
27+
- name: Checkout
28+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
29+
with:
30+
ref: ${{ github.event.pull_request.head.sha }}
31+
- name: Set up Go
32+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
33+
with:
34+
go-version: 1.17
35+
- name: Run coverage
36+
run: go test ./... -coverpkg=./... -race -coverprofile=coverage.txt -covermode=atomic
37+
env:
38+
PAT: ${{ secrets.PAT }}

.github/workflows/kbanalysis.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: KBAnalysis
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
owner:
6+
type: string
7+
description: owner of the missing KB
8+
repo:
9+
type: string
10+
description: repo of the missing KB
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
Analysis:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
issues: write
20+
contents: write
21+
pull-requests: write
22+
23+
steps:
24+
- name: Harden Runner
25+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0
26+
with:
27+
egress-policy: audit
28+
29+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
30+
with:
31+
repository: step-security/secure-repo
32+
33+
- name: KBAnalysis
34+
uses: step-security/secure-workflows/kbanalysis@main
35+
with:
36+
github-token: ${{secrets.PAT}}
37+
owner: ${{inputs.owner}}
38+
repo : ${{inputs.repo}}
39+
40+
- id: get-action
41+
uses: actions/github-script@5d03ada4b0a753e9460b312e61cc4f8fdeacf163
42+
with:
43+
script: |
44+
var id = "${{github.event.issue.title}}".split(' ')[6]
45+
core.setOutput('id', id)
46+
47+
- name: Create Pull Request
48+
uses: peter-evans/create-pull-request@18f7dc018cc2cd597073088f7c7591b9d1c02672
49+
with:
50+
token: ${{secrets.PAT}} # need to use PAT since GITHUB_TOKEN does not initiate workflows
51+
commit-message: "added action-security.yml for ${{inputs.owner}}/${{inputs.repo}}"
52+
title: "[KB] Add GitHub token permissions for ${{inputs.owner}}/${{inputs.repo}}"
53+
branch: "kb-${{inputs.owner}}-${{inputs.repo}}"
54+
base: "knowledge-base"
55+
body: "PR added by kb-analysis workflow"
56+
labels: "knowledge-base"

.github/workflows/release.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Cfnrelease
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions: # added using https://github.com/step-security/secure-repo
10+
contents: read
11+
12+
jobs:
13+
publish-test:
14+
permissions:
15+
contents: read
16+
id-token: write
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Harden Runner
20+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0
21+
with:
22+
egress-policy: audit
23+
- name: Checkout
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
25+
with:
26+
fetch-depth: 0
27+
- name: Set up Go
28+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
29+
with:
30+
go-version: 1.17
31+
32+
- run: go test ./... -coverpkg=./...
33+
env:
34+
PAT: ${{ secrets.PAT }}
35+
36+
- uses: step-security/wait-for-secrets@084b3ae774c0e0003a9307ae4f487c10f1f998fe
37+
id: wait-for-secrets
38+
with:
39+
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
40+
secrets: |
41+
AWS_ACCESS_KEY_ID:
42+
name: 'AWS access key id'
43+
description: 'Access key id for secure-repo prod'
44+
AWS_SECRET_ACCESS_KEY:
45+
name: 'AWS secret access key'
46+
description: 'Secret access key for secure-repo prod'
47+
AWS_SESSION_TOKEN:
48+
name: 'AWS session token'
49+
description: 'Session token for secure-repo prod'
50+
51+
- name: Configure AWS Credentials
52+
uses: aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df
53+
with:
54+
aws-access-key-id: ${{ steps.wait-for-secrets.outputs.AWS_ACCESS_KEY_ID }}
55+
aws-secret-access-key: ${{ steps.wait-for-secrets.outputs.AWS_SECRET_ACCESS_KEY }}
56+
aws-session-token: ${{ steps.wait-for-secrets.outputs.AWS_SESSION_TOKEN }}
57+
aws-region: us-west-2
58+
59+
- name: Deploy to AWS CloudFormation
60+
uses: aws-actions/aws-cloudformation-github-deploy@33527b83bddcf6b3f0b135d9550bde8475325c73
61+
with:
62+
name: secure-workflow-api-ecr
63+
template: cloudformation/ecr.yml
64+
parameter-overrides: "ResourceName=secure-workflow-api"
65+
no-fail-on-empty-changeset: "1"
66+
67+
- name: Login to Amazon ECR
68+
id: login-ecr
69+
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076
70+
71+
- name: Build, tag, and push image to Amazon ECR
72+
env:
73+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
74+
ECR_REPOSITORY: secure-workflow-api
75+
IMAGE_TAG: ${{ github.sha }}
76+
run: |
77+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
78+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
79+
80+
- name: Deploy to AWS CloudFormation
81+
uses: aws-actions/aws-cloudformation-github-deploy@33527b83bddcf6b3f0b135d9550bde8475325c73
82+
with:
83+
name: secure-workflow-api
84+
template: cloudformation/resources.yml
85+
parameter-overrides: >-
86+
ResourceName=secure-workflow-api,
87+
ImageTag=${{ github.sha }},
88+
PAT=${{ secrets.PAT }}
89+
no-fail-on-empty-changeset: "1"

0 commit comments

Comments
 (0)