Skip to content

Commit ae5b5a1

Browse files
Apply security best practicesSigned-off-by: StepSecurity Bot <[email protected]>
1 parent 842d114 commit ae5b5a1

File tree

7 files changed

+370
-0
lines changed

7 files changed

+370
-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/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"

.github/workflows/test.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Test
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
push:
7+
branches:
8+
- main # to update code coverage
9+
10+
permissions: # added using https://github.com/step-security/secure-repo
11+
contents: read
12+
13+
jobs:
14+
test:
15+
permissions:
16+
contents: read
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0
20+
with:
21+
egress-policy: audit
22+
allowed-endpoints: >
23+
api.github.com:443
24+
cli.codecov.io:443
25+
codecov.io:443
26+
uploader.codecov.io:443
27+
github.com:443
28+
proxy.golang.org:443
29+
sum.golang.org:443
30+
storage.googleapis.com:443
31+
objects.githubusercontent.com:443
32+
golang.org:443
33+
- name: Checkout
34+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
35+
with:
36+
ref: ${{ github.event.pull_request.head.sha }}
37+
- name: Set up Go
38+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
39+
with:
40+
go-version: 1.17
41+
- name: Run coverage
42+
run: go test ./... -coverpkg=./... -race -coverprofile=coverage.txt -covermode=atomic
43+
env:
44+
PAT: ${{ secrets.GITHUB_TOKEN }}
45+
- uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24
46+
with:
47+
token: ${{ secrets.CODECOV_TOKEN }}

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
repos:
2+
- repo: https://github.com/gitleaks/gitleaks
3+
rev: v8.16.3
4+
hooks:
5+
- id: gitleaks
6+
- repo: https://github.com/jumanjihouse/pre-commit-hooks
7+
rev: 3.0.0
8+
hooks:
9+
- id: shellcheck
10+
- repo: https://github.com/pre-commit/mirrors-eslint
11+
rev: v8.38.0
12+
hooks:
13+
- id: eslint
14+
- repo: https://github.com/pre-commit/pre-commit-hooks
15+
rev: v4.4.0
16+
hooks:
17+
- id: end-of-file-fixer
18+
- id: trailing-whitespace

0 commit comments

Comments
 (0)